4

From a reading of the spec it seems that a GeometryCollection is a Geometry and can contain geometry objects? But I want to be sure that this is really allowed before I file a bug report.

Ian Turton
  • 81,417
  • 6
  • 84
  • 185

2 Answers2

5

Update: nested collections are specifically NOT RECOMMENDED in the latest GeoJSON specification.

To maximize interoperability implementations SHOULD avoid nested geometry collections. Furthermore, geometry collections composed of a single part or a number of parts of a single type SHOULD be avoided when that single part or a single object of multi-part type (MultiPoint, MultiLineString, or MultiPolygon) could be used instead.

https://datatracker.ietf.org/doc/html/draft-ietf-geojson-03#section-3.1.8

sgillies
  • 9,056
  • 1
  • 33
  • 41
2

Yes, it should be allowed. And I have tested it on OpenLayers at least, you can create a feature whose geometry is a GeometryCollection which contains another GeometryCollection by reading a geojson string (using OpenLayers.Format.GeoJSON object).

mfdev
  • 1,948
  • 1
  • 12
  • 19