Endpoint Structure: GeoJSON or JSON #11
Replies: 4 comments 7 replies
-
Agree with the folks suggesting using GeoJSON. Regarding the thread on separating regulation from location, could we consider using GeoJSON for spatial-related endpoints, and JSON for non-spatial endpoints? |
Beta Was this translation helpful? Give feedback.
-
I'm with @interline-io where we're watching the development of CDS and considering aggregating public sources in the future. For our use-cases there is no material difference between JSON and GeoJSON. However, based on past experience with open transportation and geo tooling and datasets, I would recommend GeoJSON in this case. As others mentioned above, there is value in being able to point a novice to geojson.io or the equivalent to do basic debugging or editing of a data payload, with no transformation required. It's true that feature properties can turn into dumping grounds in GeoJSON files, so if you all do go with GeoJSON, do consider also having a complete JSON Schema for validating and to serve as precise documentation for advanced producers/consumers. |
Beta Was this translation helpful? Give feedback.
-
From Mpls team: as it relates to GeoJSON vs JSON is that I think it would be good to try and be consistent with MDS standards where possible. I would imagine that many agencies or companies might be using both APIs, and from a development perspective it makes sense to not have discrepancies like that for pushing and pulling data. So if GeoJSON is the preferred approach, it might be good to migrate MDS to that as well eventually (or vice versa). |
Beta Was this translation helpful? Give feedback.
-
A little late to the party (sorry!), but I think there are pros and cons with both. From a tooling perspective, I think that GeoJSON is the fairly obvious winner (note: all of the discussion above!). That being said, I think that from a design perspective (and also implementation perspective), having GeoJSON be the only data format is a bit limiting. In my experience, in order to maintain high performance, most of those properties need to be pulled out at the persistence layer and added as additional columns; this means that in order to serve this data back to clients, an implementation will almost always have to be doing a healthy amount of transforms before returning data to the client. This is fine some of the time (when you have humans pulling data to put in a GIS tool), but what if you have machine consumers that are pulling from the API, and need to do the exact same thing when they persist data from CDS? I think that it adds a lot of overhead round-trip for almost any cases where you're not pulling CDS data in order to jam it into a GIS tool. I almost want to propose that we have both: a not-embedded-in-GeoJSON version (the main source-of-truth in the spec), as well as the option to query for the GeoJSON-ified version (where we just jam everything into properties). Though there would be some added complexity, I think this would allow CDS to provide the best of both worlds; performance when serving machine-to-machine clients, as well as users fetching data to use in a GIS tool. TLDR; instead of just having:
We could have:
Thinking even a bit further, I could totally imagine a library being maintained by the OMF purely to do these transforms to make adoption easier! Do a little survey to see what languages people are using, and then rally together some folks to make transformers for the top 3 :) |
Beta Was this translation helpful? Give feedback.
-
Should endpoints be GeoJSON format with CDS details in the ‘properties’, or more freely structured JSON to align with MDS's design language with GeoJSON objects in them when needed?
Discussion from doc:
Michael Schnuerle
I wonder if GeoJSON is too limiting for what we want may out of an API? Object hierarchy, metadata, flexible structure. Is the only benefit that it's easily visualize using out of the box tools?
Marie Maxham
That's a pretty big benefit :)
Michael Schnuerle
Well another way it can be done is have the geoJSON be a value within the larger JSON structure. So you can still get to the valid GeoJSON easily, but it’s not the entire file structure.
Jacob Malleau
I agree with using JSON structure - get the flexibility but can still extract geoJSON.
Eric Mai
I think a strictly typed JSON object (with a GeoJSON property) would be easier and clearer to define than a special kind of GeoJSON object (because it would be GeoJSON but with specific expected metadata properties).
Jacob Baskin
GeoJSON is pretty permissive -- what we are doing below is defining all of the objects to be GeoJSON features, but then putting the "meat" of the object inside "properties" which is 100% permitted within the GeoJSON spec. I don't find this so constraining and doing it any other way means that you can't load the API responses into GeoJSON-supporting tools without some coding/ETL which seems pretty undesirable.
Beta Was this translation helpful? Give feedback.
All reactions