phayes / geoPHP

Advanced geometry operations in PHP
https://geophp.net
Other
861 stars 262 forks source link

union return null #172

Open Boka opened 4 years ago

Boka commented 4 years ago

Hi, I ran the following code example and I keep having null in $combined_poly var... is there something that I'm doing wrong? sorry to bother ciao GL

            $poly1 = \geoPHP::load('POLYGON((30 10,10 20,20 40,40 40,30 10))','wkt');
            $poly2 = \geoPHP::load('POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30, 35 35, 30 20, 20 30))','wkt');
            $combined_poly = $poly1->union($poly2);
            $kml = $combined_poly->out('kml');
mprins commented 3 years ago

union requires the native Geos module with PHP bindings compiled

MurzNN commented 2 years ago

Thanks for the tip! Will be good to throw an exception of missing Geos module, instead of silently returning null.

BathoryPeter commented 2 years ago

You may give a try to my fork. It also throws exception if Geos is missing.

See the union method: https://github.com/funiq/geoPHP/blob/master/src/Geometry/Geometry.php#L672

MurzNN commented 2 years ago

Wow, cool, thanks @BathoryPeter! Maybe create a PR to main repo with this your exception enhancement?

BathoryPeter commented 2 years ago

I had a pull request: #125.

Unfortunately, this repo hasn't been maintained for years.