Skip to content

Instantly share code, notes, and snippets.

@sgillies
Created October 8, 2012 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgillies/3853624 to your computer and use it in GitHub Desktop.
Save sgillies/3853624 to your computer and use it in GitHub Desktop.
A GeoJSON profile of the application/json media type

A GeoJSON profile of the application/json media type (Strawman)

Motivation

There are at least two different dialects of geospatial JSON1 data on the internet today and we're doing very little to explain to clients or servers which one is being used in a particular interaction. A web API may return data using the application/json media type if given a f=json parameter (or not) but a client doesn't necessarily know whether it is getting GeoJSON2 or ArcGIS JSON3, two different ways of structuring information about the same kinds of entities.

Profiles

What's a 'profile'? I'll quote from draft-wilde-profile-link-034:

The concept of a profile has no strict definition on the Internet or on the Web. For the purpose of this specification, a profile can be described as additional semantics that can be used to process a resource representation, such as constraints, conventions, extensions, or any other aspects that do not alter the basic media type semantics. A profile MUST NOT change the semantics of the resource representation when processed without profile knowledge, so that clients both with and without knowledge of a profiled resource can safely use the same representation. While this specification associates profiles with resource representations, creators and users of profiles MAY define and manage them in a way that they can be used across media types and thus could be associated with a resource, independent of its representations (i.e., using the same profile URI for in different media types). However, such a design is outside of the scope of this specification, and clients SHOULD treat profiles as being associated with a resource representation.

The 'profile' Link Relation Type I-D5 drafted by Erik Wilde can help us serve GeoJSON along with all the special semantics entailed in that spec (default coordinate system, meaning of the 'properties' object, etc) with less ambiguity. As discussed in Mark Nottingham's blog6, it may also provide a way to formalize extension of GeoJSON. If the GeoJSON profile were http://example.com/profiles/geojson-org, an extension that layered, for example, data series semantics7 over GeoJSON might say that the http://example.com/profiles/data-series profile extended http://example.com/profiles/geojson-org.

(I've deliberately not used a profile URI under http://geojson.org in the examples above and proposal below so as to not trigger premature implementation.)

Proposal

A single profile identified by http://example.com/geojson.org-profile will signal the presence of all the extra semantics that the GeoJSON adds to the application/json media type defined in RFC 46278. Servers that want to provide this signal to distinguish GeoJSON from other JSON dialects can add a link header to response like so:

HTTP/1.1 200 OK
Content-Type: application/json
Link: <http://example.com/profiles/geojson-org>; rel="profile"
Connection: close

{
  "type": "FeatureCollection",
  "features": [...]
}

Implications

It's possible that a JSON document returning just a GeoJSON feature outside of a collection, or just a geometry outside of a feature, might be said to be using a different profile of GeoJSON.

References


  1. http://www.ietf.org/rfc/rfc4627.txt

  2. http://geojson.org

  3. http://www.esri.com/industries/landing-pages/geoservices/geoservices.html

  4. http://tools.ietf.org/html/draft-wilde-profile-link-03

  5. http://tools.ietf.org/html/draft-wilde-profile-link-03

  6. http://www.mnot.net/blog/2012/04/17/profiles

  7. https://github.com/GeoJSONWG/geojson-spec/wiki/Data-Series-Proposal

  8. http://www.ietf.org/rfc/rfc4627.txt

@dret
Copy link

dret commented May 7, 2014

just as an update, the "The 'profile' Link Relation Type" draft now has been published as RFC 6906.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment