Subject: [Geojson] Definition of a GeoJSON object

From: Sean Gillies <[email-masked]>
Date: Tue, 1 Dec 2015 10:18:32 -0700

The definition of a GeoJSON object at
https://github.com/geojson/draft-geojson/blob/master/middle.mkd#geojson-object
needs some work. Currently, it reads:

GeoJSON always consists of a single object. This object (referred to as the
> GeoJSON object below) represents a geometry, feature, or collection of
> features.
>
>    -
>
>    The top level of GeoJSON text MUST be a JSON object.
>    -
>
>    The GeoJSON object MUST have a member with the name "type". The value
>    of the member MUST be one of the GeoJSON types.
>    -
>
>    A GeoJSON object MAY have a "bbox" member, the value of which MUST be
>    a bounding box array (see 4. Bounding Boxes).
>    -
>
>    The GeoJSON object MAY have any number of other members.
>    Implementations MUST ignore unrecognized members.
>
> The concepts of JSON object and JSON text are mixed up in this definition.
I'd like to separate them to clarify the spec, make it more clear what
semantics may not be changed (when we say "extensions may not change
semantics of GeoJSON" below), and to make the definition of GeoJSON object
usable within GeoJSON feature sequences (a different kind of text format).

What I propose is this:

GeoJSON Object:

- A GeoJSON object is a JSON object.
- A GeoJSON object MUST have a member with the name "type". The value of
the member MUST be one of the GeoJSON types.
- A GeoJSON object MAY have a "bbox" member, the value of which MUST be a
bounding box array (see 4. Bounding Boxes).
- A GeoJSON object MAY have any number of other members (see X. Extending
GeoJSON).

GeoJSON Text:

- A GeoJSON text is a JSON text.
- A GeoJSON text consists of a single GeoJSON object.

The last two points are not as self-evident as they seemed when the spec
originated. I have first hand experience with a parser that has not parsed
GeoJSON as JSON text and am a regular user of streams of LF and
RS-delimited GeoJSON feature objects. These streams are not exactly GeoJSON
and a GeoJSON text definition makes that more clear.

-- 
Sean Gillies