ngx-openlayers icon indicating copy to clipboard operation
ngx-openlayers copied to clipboard

Coordinates collection - polygon, multi-polygon

Open samuel-girard opened this issue 7 years ago • 2 comments

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?

samuel-girard avatar Dec 27 '17 15:12 samuel-girard

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

samuel-girard avatar Jan 02 '18 16:01 samuel-girard

Mutli-geometries are implemented in https://github.com/quentin-ol/ngx-openlayers/pull/213

samuel-girard avatar Nov 30 '18 10:11 samuel-girard