I'm modelling a bus route as a series of waypoints. Most of these waypoints have just a latitude and a longitude and represent points along a road. However, when the bus gets to a bus stop, the waypoint has an arrival and departure time associated with it. This information could potentially be relevant to plotting this route, for example, if I was to animate the progress of the bus.
Since I am going to be exposing these models through an API, I want to keep to standards by using the GeoJSON format. This will be my first time using GeoJSON. I know that the first three coordinates of a GeoJSON point are [longitude, latitude, elevation]. According to Tom Macwright, GeoJSON supports multi-dimensional coordinates. However, I couldn't find any information on any standards beyond those three.
I plan to represent the times in ticks (JavaScript ticks, i.e. number of milliseconds since midnight of January 1, 1970). I would like to use the following standard:
{
"type": "Point",
"coordinates": [longitude, latitude, null, arrivalTime, departureTime]
}
- Will this format collide with any GeoJSON standard?
- Elevation data is meaningless to me. Do I need the "null" in order to conform to GeoJSON?
Best Answer
The current GeoJSON specification is geojson.org/geojson-spec.html and it defines "positions" as
The new draft version https://datatracker.ietf.org/doc/html/draft-butler-geojson-06 is a bit more explicit:
It means that GeoJSON defines only that two first elements of position are X and Y and if there is a third element it must mean elevation. There may be further elements which can mean whatever. It is up to you to define what they mean and how they should be handled. A basic GeoJSON reader that does not know what to do with extra elements should just skip them without throwing an error.
However, if your data are points I think you could as well write the times as normal attributes like in this example https://github.com/kgeographer/catalhoyuk/blob/master/geotemporal_fig.json?short_path=b3b33df. Multidimensional coordinates will suit better if you plan to present you bus lines as linestrings because then one bus route would be only one geometric feature which can have just one arrival and departure time.