Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distance calculation #22

Closed
markus-dark-green opened this issue Feb 16, 2017 · 2 comments
Closed

Distance calculation #22

markus-dark-green opened this issue Feb 16, 2017 · 2 comments

Comments

@markus-dark-green
Copy link

Sorry for the newbee question but when i am using the Distance calculation it provides me some false values. Went through the documentation but could not find some hint.

this is the function call:
$p1 = new \Location\Coordinate($point1_lat,$point1_long);
$p2 = new \Location\Coordinate($point2_lat,$point2_long);
$meters = $p1->getDistance($p2, new \Location\Distance\Vincenty());

and the result (sorry for the json encapsulation) is:

"distance": "4597208.7 Location\Coordinate Object\n(\n [lat:protected] => 16.1398995\n [lng:protected] => 48.0313793\n [ellipsoid:protected] => Location\Ellipsoid Object\n (\n [name:protected] => World Geodetic System 1984\n [a:protected] => 6378137\n [f:protected] => 298.257223563\n )\n\n)\n Location\Coordinate Object\n(\n [lat:protected] => 48.4664936\n [lng:protected] => 16.3988242\n [ellipsoid:protected] => Location\Ellipsoid Object\n (\n [name:protected] => World Geodetic System 1984\n [a:protected] => 6378137\n [f:protected] => 298.257223563\n )\n\n)\n"

is it a bug or is there a need to set unit system or is it just "stupid me"

@mjaschen
Copy link
Owner

Hi,

it seems that one of the two points has latitude and logitude values swapped.

From your example:

p1: lat=16.1398995, lng=48.0313793
p2: lat=48.4664936, lng=16.3988242

I think this issue will magically disappear if you swap the lat/lng values ;-)

Marcus

@markus-dark-green
Copy link
Author

ohhhh so option 3 "me stupid" sorry within the project i didnt see the forest cause of the many trees

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants