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

pointOnSurface() for a valid polygon always returns null #124

Open
david-faith opened this issue Mar 7, 2016 · 3 comments
Open

pointOnSurface() for a valid polygon always returns null #124

david-faith opened this issue Mar 7, 2016 · 3 comments

Comments

@david-faith
Copy link

Using geoPHP with geos installed. pointOnSurface() for a valid polygon always returns null. While other functions such as centroid() work fine.

Example:

geoPHP::geosInstalled();          //true

$geo->geometryType();             //Polygon

$point = $geo->centroid();        //Point {coords: [-73.931519444925, 40.85512387767]}

$geo->covers($point);             //true

$geo->pointOnSurface();           //null

I'm wondering if anyone else has this problem (or I'm missing something)?

@david-faith
Copy link
Author

Edit: This workaround seems to do the trick:

$geos_geometry = $geo->geos();                    //GEOSGeometry

$geos_POS = $geos_geometry->pointOnSurface();     //GEOSGeometry

$geos_POS->isEmpty();                             //false

$geos_POS->getX();                                //-73.932666589981

$geos_POS->getY();                                //40.85405746088

@cvaida
Copy link

cvaida commented Mar 22, 2016

That is because it seems the function is overriden in the Collection class. Had the same issue, and I commented line 310 in lib/geometry/Collection.php:
public function pointOnSurface() { return NULL; }
and it works fine now.

@jafar690
Copy link

jafar690 commented May 5, 2018

@david-faith where does the $geo variable come form

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

3 participants