UCamGeoJSON

From University Map Wiki
Revision as of 12:36, 13 December 2012 by dje39 (talk | contribs) (new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This is work in progress. Do not rely on this document just yet.
We expect to finalize this by the end of January 2013.

Introduction

In early 2013 we will be introducing a facility to annotate the University Map with your own information. Typically this will be done using a user interface, but for those who want to derive overlays programmatically from existing data or otherwise roll their own, this describes how.

GeoJSON

Overlays are specified using UCamGeoJSON, a file format based on GeoJSON (see specification). UcamGeoJSON differs in two respects from GeoJSON:

  • It does not implement Co-ordinate Reference Systems. All points are given as latitude and longitude using the WGS84 datum.
  • GeoJSON only provides geometry. UCamGeoJSON defines the recognized content of the properties element of Feature objects, used to define what the shapes are for: things like colour of shapes, what text and icons are to appear at points, and so on.

Using UCamGeoJSON

The map is told to overlay custom annotation by giving it some UCamGeoJSON data in the URL. This is done in the fragment part of the URL (that is, the bit after a '#'), like this:

 http://map.cam.ac.uk/...#data

One can still include other parts of the URL as normal, for example to search for a particular institution. The whole of such URLs can be shortened using any shortening service, such as [bit.ly].

The data can be included in one of three ways:

  • Directly including UCamGeoJSON in the URL. This is only appropriate for small amounts, as length of URLs that browsers and other software can handle is limited. In practice, restrict the total length of URLs to under 2,000 characters. In this case the first character after the hash will always be '{'. Remember that everything after the '#' needs to be properly URL encoded, and that this also makes the URL considerably longer.
  • Referencing the UCamGeoJSON via a URL. The content provided by the URL is the UCamGeoJSON data, and the response to the request will use content-type 'application/json'. The URL will usually be absolute, that is start with 'http://', but in a few cases it may be relative to the map itself, and therefore start with a '/' (see especially Adapters below). For example:
 http://map.cam.ac.uk/#http://www.example.com/my-ucamgeojson.json
 http://map.cam.ac.uk/#/annotate/adapters/osm.json?src=http://www.example.com/my-osmfile.osm
  • Giving one, two or three numbers after the '#'. These are abbreviations for default zoom level, default map centre, or both, respectively, thus:
 http://map.cam.ac.uk/#z
 http://map.cam.ac.uk/#lat,lon
 http://map.cam.ac.uk/#lat,lon,z

properties