
Tests that addional members are allowed in any level of GeoJSON
===============================================================

A dictionary can satisfy the protocol
-------------------------------------

  >>> f = {
  ...     "type": "Feature",
  ...     "geometry": {
  ...                  "type": "LineString",
  ...                  "coordinates": [[100.0, 0.0], [101.0, 1.0]]
  ...     },
  ...     "properties": {
  ...                  "prop0": "value0",
  ...                  "prop1": "value1"
  ...     },
  ...     "foo": "bar"
  ... }

  >>> import geojson

  Encoding

  >>> json = geojson.dumps(f, sort_keys=True)
  
  >>> json # doctest: +ELLIPSIS
  '{"foo": "bar", "geometry": {"coordinates": [[100..., 0...], [101..., 1...]], "type": "LineString"}, "properties": {"prop0": "value0", "prop1": "value1"}, "type": "Feature"}'

  Decoding

  >>> o = geojson.loads(json)
  >>> type(o)
  <class 'geojson.feature.Feature'>

  >>> o # doctest: +ELLIPSIS
  {"foo": "bar", "geometry": {"coordinates": [[100..., 0...], [101..., 1...]], "type": "LineString"}, "id": null, "properties": {"prop0": "value0", "prop1": "value1"}, "type": "Feature"}

Custom objects can be decoded into a json structure containing valid geojson
----------------------------------------------------------------------------

  >>> class Route(object):
  ...    def __init__(self, title, description, waypoints):
  ...        self.title = title
  ...        self.descrpition = description
  ...        self.waypoints = waypoints
  ...    @property
  ...    def __geo_interface__(self):
  ...        return dict(type="Feature", geometry=dict(type="LineString", coordinates=self.waypoints),
  ...                    title=self.title, description=self.descrpition)
  ...

  >>> r = Route("Snowdonia circular", "A nice bike ride around some mountains", ((1.0, 2.0), (2.0, 3.2)))
  
  >>> json = geojson.dumps(r, sort_keys=True)
  
  >>> json  # doctest: +ELLIPSIS
  '{"description": "A nice bike ride around some mountains", "geometry": {"coordinates": [[1..., 2...], [2..., 3...]], "type": "LineString"}, "title": "Snowdonia circular", "type": "Feature"}'

  >>> r = geojson.loads(json) 
  >>> print(r["description"])
  A nice bike ride around some mountains

  >>> print(r["title"])
  Snowdonia circular

  >>> print(r["type"])
  Feature

  >>> r["geometry"]["coordinates"]# doctest: +ELLIPSIS
  [[1..., 2...], [2..., 3...]]

  >>> print(r["id"])
  None

  >>> print(r["geometry"]["type"])
  LineString

  >>> r["properties"]
  {}

