ngx-openlayers
ngx-openlayers copied to clipboard
Coordinates collection - polygon, multi-polygon
Hello,
I just saw that ngx-openlayers does not manage well coordinates collection / geometries.
For example, GeometryPolygon can only contain an array of Coordinates (so no holes), and we cannot create MultiLineString, MultiPoint and MultiPolygon.
To implement these geometries, I'm afraid CoordinateComponent will get less maintainable as it is now if we have to add a lot of if (someGeometry !== null) { ... }
as it is now.
I suggest to update the way Coordinate/Geometries are managed in ngx-openlayers:
- The coordinates for a geometry are passed in an
@Input
of the component.<aol-geometry-polygon [coordinates]="[[[0,0], [0,1], [1,1], [1,0], [0,0]], [[0.5,0.5], [0,0.5], [0,0], [0.5,0.5]]]"></aol-geometry-polygon>
- In this case, we lose the re-projection feature that is included in the CoordinateComponent, but well it's better than not having those other geometries
- This will make the CoordinateComponent only used for View and OverlayHost
Anybody can see some disadvantages that I couldn't see with this method?
I implemented the change in https://github.com/quentin-ol/ngx-openlayers/pull/143 The reprojection feature is still working, but on the Geometry instead of the Coordinate component. I could easily add MultiPolygon geometry with a bit of code refactoring (move geometries to their own directory).
Mutli-geometries are implemented in https://github.com/quentin-ol/ngx-openlayers/pull/213