-
Notifications
You must be signed in to change notification settings - Fork 2
Description
PROJJSON has been derived from Well Known Text (WKT) 2. However, WKT 2 was constrained by WKT 1 compatibility, which followed a model that predated ISO 19111. Consequently, PROJJSON diverges from what would be a CRS JSON derived from ISO 19111 abstract model. Examples of incompatible divergences are:
- In the names of elements.
- In the way that coordinate system types are identified (Should coordinate system subtypes be defined? #63).
- In the structure where scope and geographic/vertical/temporal extents are stored.
- In the structure of identifiers.
Between following the abstract model or preserving compatibility with PROJJSON, what should prevail?
Arguments in favor of PROJJSON compatibility
The main argument against following the OGC Topic 2 / ISO 19111 model is that it would be incompatible changes compared to PROJJSON, and the later is already used for 5 years.
We have two communities in the balance: the galaxy of projects around PROJ (admittedly large), and the rest of the geospatial community. Making life easier for one creates complications for the others. Some impacts of PROJJSON compatibility are discussed in the next sections. Whether they should be considered important or not has not been discussed yet.
Arguments in favor of CRS-JSON following the abstract model
Reduce the conceptual weight
Following closely the abstract model would make the specification simpler. The specification could give the general rules, keep the list of departures (special cases or exceptions to the rules) shorter, and provides some examples of CRS and coordinate operation definitions. By contrast, an encoding that diverges from the abstract model would need more explanations about how to map JSON elements to the abstract model. It would also require that users keep two models in mind: the abstract model and its encoding.
Reduce the dissemination of deviations from abstract model
If the encoding diverges from the abstract model, users will likely not look at the abstract specification and rather think that the encoding is the model. This confusion, where WKT 2 is interpreted as the model, is already observed on GitHub issues and mailing lists, and in PROJJSON itself (while the latter was maybe a conscious choice). The consequences are more limited with WKT 2 than it would be with JSON, because WKT 2 requires specialized libraries to be read and those libraries have a smaller scope than JSON or XML tools. But if OGC publishes CRS schema in JSON, because there is tools for generating automatically codes in various programming languages from XML and JSON schema, it is very likely that some users will use those tools for generating their codes and take the output as the state-of-the-art OGC model, as it happened 10 years ago with XML. The risk is larger for JavaScript developers, since they can read JSON documents directly as JavaScript objects (JSON is derived from JavaScript). If the JSON encoding is made closer to the abstract model (even if not identical, as some departures may be unavoidable), the divergences between those automatically generated codes and the abstract model will be smaller. Reducing those divergences is less cosmetic than it seems, because we have observed users attributing to Topic 2 / ISO 19111 issues that were actually WKT 2 shortcomings, without realizing that the encoding is not the model.
Convenience for developers using dynamic programming languages
Java and C# are semi-static and semi-dynamic programming languages. Their dynamic aspect makes possible to parse an XML or JSON document easily if the document structure matches the objects in the programming language. For example, a Java class could be defined as below (ignoring the complexity of GML particularities in this first example):
@XmlAccessorType(XmlAccessType.FIELD)
class CoordinateSystemAxis {
String axisAbbrev;
AxisDirection axisDirection;
double minimumValue;
// etc.
}The @XmlAccessorType(XmlAccessType.FIELD) annotation instructs JAXB (a Java tool for parsing XML, but equivalent technologies exist for JSON) to automatically assign the values of axisAbbrev, axisDirection, minimumValue, etc. XML elements to the fields of the same names. It makes easy to read those documents with very few codes. In the simplest cases, nothing more than the above is needed. Even if there is some divergences between the XML/JSON encoding and the programmatic model, those divergences can still be handled if they are not too large. For example, if the names are different and if GML particularities must be supported:
@XmlRootElement(name = "CoordinateSystemAxis")
class Foo {
@XmlJavaTypeAdapter(CS_AxisDirection.class) // For handling the GML-way to encode XML
@XmlElement(name = "axisDirection")
AxisDirection bar;
// etc.
}However, above approach does not work anymore, or become complicated, if the encoding diverges too much from the programmatic model. This argument may apply to all dynamic or semi-dynamic programming languages. This argument is less relevant to fully static programming languages such as C/C++ since they need to write or generate codes for explicit assignments to those fields anyway.