[Geojson] Need to know the type of a Feature

Riche, Antoine (GE Energy) antoine.riche at ge.com
Mon Nov 5 07:11:15 PST 2012


The GeoJSON format does not provide a way to describe the type of a
Feature. The "type" member of a Feature object just says it is a
Feature, so parsing GeoJSON data does not enable a web client to find
out whether a feature is a motorway or a footpath, whether it is a gas
pipe or a cable. This information however might be needed for the
response to a WMS GetFeatureInfo request, as there might be several
features of different types in the same position (where the user clicks
on a map). Generally speaking a FeatureCollection can be heterogeneous,
so providing a mean to distinguish the features it contains would be
useful.

I can think if a couple of ways to add this information to the GeoJSON
format :

1 - Add a member called "name" to Feature objects, e.g. 
    { "type": "Feature",
      "name": "Cable",
      "geometry": {"type": "LineString", "coordinates": [[102.0,
0.5],[108.5,12.0]]},
      "properties": {"depth": "1.5 metres"}
    }

2 - Allow the type value of a Feature to be any string, e.g.
    { "type": "Cable",
      "geometry": {"type": "LineString", "coordinates": [[102.0,
0.5],[108.5,12.0]]},
      "properties": {"depth": "1.5 metres"}
    }
Although this loosens the third rule for GeoJSON Objects
<http://www.geojson.org/geojson-spec.html> , this could be handled by
parsers as long as the value of the type member is relaxed for Feature
objects only - note the type "Feature" remains valid for anonymous
features. 

The benefit of the first solution is backward compatibility (as long as
parsers ignore members whose name is unknown). The benefit of the second
solution is that it is less verbose - which is one of the goals of JSON.

Regards,
Antoine Riche.




More information about the GeoJSON mailing list