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

project Method is missing #50

Closed
kviolka opened this issue Aug 9, 2012 · 5 comments
Closed

project Method is missing #50

kviolka opened this issue Aug 9, 2012 · 5 comments

Comments

@kviolka
Copy link

kviolka commented Aug 9, 2012

Hi,

i would like to calculate some distances in meters with the GEOS extension. In the standard WGS84 projection the distance function returns no meters, but degrees. So I learned I have to project to a different SRID.

The project method is not implemented, any reason for this? Maybe I can supply a patch.

best,

Karsten

@phayes
Copy link
Owner

phayes commented Aug 9, 2012

Hi Karsten,

Oh you are correct. We have the "project" method in the API documentation, but it's not implemented in code! Whoops! A pull request would be great.

@phayes
Copy link
Owner

phayes commented Aug 27, 2012

OK, this is now fixed

@phayes phayes closed this as completed Aug 27, 2012
@TheCelavi
Copy link

TheCelavi commented Mar 9, 2017

@kviolka Dude, how do you project? Could you give me some sample code, I am obviously dumb...

I have something like:

$point1 = new \Point(10, 12);
$point2 = new \Point(12, 10);

How to get distance in meters? How to invoke properly project() method? Thanks!

@BathoryPeter
Copy link

If you are using geographical coordinates (lat, lon) then greatCircleLength() is your friend:

$line = new LineString([new Point(10, 12), new Point(12, 10)]);
echo $line->greatCircleLength();    // 311971.11435993 meters
echo $line->length();               // 2.828427 degree

@TheCelavi
Copy link

@BathoryPeter DUDE! You are awesome! Thanks!

How about calculating shortest distance between two, per example, polygons? Is that possible? How to do that?

BTW, your recipe, as well as my second question -> I think that it should be part of the documentation, it is quite common...

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

4 participants