Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9266757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:23:31+00:00 2026-06-18T14:23:31+00:00

I am trying to calculate a distance between two points in Oracle DB, Point

  • 0

I am trying to calculate a distance between two points in Oracle DB,

Point A is 40.716715, -74.033907
Point B is 40.716300, -74.033900

using this sql statement:

SELECT   sdo_geom.sdo_distance( sdo_geom.sdo_geometry(2001 ,8307 ,sdo_geom.sdo_point_type(40.716715, -74.033907 , NULL) ,NULL ,NULL)
                           ,sdo_geom.sdo_geometry(2001 ,8307 ,sdo_point_type(40.716300,-74.033901, NULL) ,NULL ,NULL) ,0.0001 ,'unit=M') distance_in_m
                           from DUAL;

Result is 12.7646185977151

While doing it using Apple’s CoreLocation api:

CLLocation* pa = [[CLLocation alloc] initWithLatitude:40.716715 longitude:-74.033907];
CLLocation* pa2 = [[CLLocation alloc] initWithLatitude:40.716300 longitude:-74.033900];
CLLocationDistance dist = [pa distanceFromLocation:pa2];

Result is 46.0888946842423

Own implementation

double dinstance_m(double lat1, double long1, double lat2, double long2){
 double dlong = (long2 - long1) * d2r;
 double dlat = (lat2 - lat1) * d2r;
 double a = pow(sin(dlat/2.0), 2) + cos(lat1*d2r) * cos(lat2*d2r) * pow(sin(dlong/2.0), 2);
 double c = 2 * atan2(sqrt(a), sqrt(1-a));
 double d = 6367 * c;

return d * 1000.;
}

Result is 46.120690774231

Oracle’s implementation is clearly off, but I don’t see why. Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:23:32+00:00Added an answer on June 18, 2026 at 2:23 pm

    Try reversing the order of the ordinates, as in:

    SELECT sdo_geom.sdo_distance(sdo_geom.sdo_geometry(2001, 8307, sdo_geom.sdo_point_type(-74.033907, 40.716715, NULL), NULL, NULL),
                               sdo_geom.sdo_geometry(2001, 8307, sdo_point_type(-74.033901, 40.716300, NULL), NULL, NULL), 0.0001, 'unit=M') distance_in_m
                               from DUAL;
    

    I get 46.087817955912.

    With SDO_GEOMETRY, ordinates are listed in X, Y (longitude, latitude) order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using xcode v. 4.5.1 and trying to calculate the distance between two points
I am trying to calculate the distance between two map point using Google Map
I'm trying to calculate the distance between two points. The two points I stored
I have a SQL function that calculates the distance between two points using their
I am trying to calculate distance between two corelocation objects like this: float meters
I am trying to calculate squared Euclidean distance between two 4d float vectors using
I am trying to calculate distance between two matrices.For eg. it goes like this.
I'm trying to calculate a distance between two sets of coordinate points in an
I am trying to calculate the distance between two points (Pins) on the iPhone
In the program below, I am trying to calculate the distance between two points.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.