-
Notifications
You must be signed in to change notification settings - Fork 10
Embedding resources into GeoJSON features
The Geospatial Resource types in this repository have mostly been created without containing their spatial representation - the polygon, line, multi-line, or points that define the object. You may be wondering why this is.
These resources are designed for use within GeoJSON, and RFC-7946 which defines this specification is quite specific about how GeoJSON Features and FeatureCollections should work. In order to support this, it is better that our resources can be embedded within GeoJSON Features rather than the other way around.
There are two commonly used approaches to extend GEOJSON:
- Embed additional properties into the
propertiesmember of a GeoJSON Feature. This is the recommended approach and is supported by most parsers and tools that read and write GeoJSON collections. - Embed the properties at a slightly higher level in the GeoJSON Feature, so that they form top-level constructs along with the
geometryandtypemembers. These are called "foreign members" in the GeoJSON specification. Many GIS tools do just this with their attribute data. However, a number of tools, libraries, and parsers ignore foreign members, or only handle specific foreign members that they explicitly support.
On this basis we decided that we would use the properties member. We add two properties to each GeoJSON Feature:
-
contentTypeis a string containing the JSON resource name (file name without the .json extension). For instance, a holding would be"contentType": "HoldingResource". -
contentis an object that is the chosen resource type.
You can see an example of this in the code section, under \resources\geojson-AgriculturalContentResource.json.