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

GeometryCollection operations (+ added fromArray fn) #10

Open
iredmedia opened this issue Feb 8, 2018 · 0 comments
Open

GeometryCollection operations (+ added fromArray fn) #10

iredmedia opened this issue Feb 8, 2018 · 0 comments

Comments

@iredmedia
Copy link

I'm trying to implement the fromArray functionality for GeometryCollection, but with this function

public static function fromArray(array $items) {
    $parsed = array_map(function($p){
        if( !is_array($p) or sizeof($p) != 2)
            throw new GeoSpatialException('Error: array of array containing lat, lon expected.');

        if ($p['type'] == 'POLYGON') {
            $points = array_map(function ($p) {
                if( !is_array($p) or sizeof($p) != 2)
                    throw new GeoSpatialException('Error: array of array containing lat, lon expected.');

                return new Point($p[0], $p[1]);
            }, $p['value'][0]);
        }

        return new Polygon([new LineString($points)]);
    }, $items);

    return new static(new GeometryCollection([$parsed]));
}```

I'm getting this error:

`ElevenLab\PHPOGC\Exceptions\GeoSpatialException with message 'A GeometryCollection must be constructed with an array of OGCObject objects'`

It works fine with this `return new static($parsed));` however, I every whereX query fails, intersection, touches, etc.

I have a few contribs for this library in the pipeline, hoping to gain a deeper understanding here so I can push forward.

Cheers!
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

1 participant