2

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)?

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.