opengeospatial / 2D-Tile-Matrix-Set

OGC 2D Tile Matrix Set & TileSet Metadata standard
https://www.ogc.org/standards/tms
Apache License 2.0
8 stars 10 forks source link

Clarification for CRS wkt type #89

Open vincentsarago opened 8 months ago

vincentsarago commented 8 months ago

in the schema it says the the wkt should be an object of type PROJJSON

https://github.com/opengeospatial/2D-Tile-Matrix-Set/blob/7cee2f8cd03b07bf457683321747be41d10abe66/schemas/tms/2.0/json/crs.json#L26-L38

but in https://docs.ogc.org/is/17-083r4/17-083r4.html#toc13 it says that the datatype is Any

Screenshot 2024-01-18 at 4 28 38 PM

In the OGC Tiles API the schema says it should be an object (no PROJJSON type mentioned)

https://github.com/opengeospatial/ogcapi-tiles/blob/2961beeaca21e5db5f3f558dcd48c8e775061a45/openapi/schemas/common-geodata/crs.yaml#L15-L20

IMO using wkt attribute to expect a PROJJSON object is pretty confusing because in wkt there is the word text 🤷.

in epsg.io or spatialreference.org the representation for PROJJSON is defined with json while the ogc wkt (2) use text. In Proj if you use to_wkt you get a string and to get a PROJJSON you use to_json


pyproj.CRS.from_epsg(3857).to_wkt()
>> 'PROJCRS["WGS 84 / Pseudo-Mercator",BASEGEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]],CONVERSION["Popular Visualisation Pseudo-Mercator",METHOD["Popular Visualisation Pseudo Mercator",ID["EPSG",1024]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["Web mapping and visualisation."],AREA["World between 85.06°S and 85.06°N."],BBOX[-85.06,-180,85.06,180]],ID["EPSG",3857]]'

pyproj.CRS.from_epsg(3857).to_json()
>> '{"$schema":"https://proj.org/schemas/v0.6/projjson.schema.json","type":"ProjectedCRS","name":"WGS 84 / Pseudo-Mercator","base_crs":{"name":"WGS 84","datum_ensemble":{"name":"World Geodetic System 1984 ensemble","members":[{"name":"World Geodetic System 1984 (Transit)","id":{"authority":"EPSG","code":1166}},{"name":"World Geodetic System 1984 (G730)","id":{"authority":"EPSG","code":1152}},{"name":"World Geodetic System 1984 (G873)","id":{"authority":"EPSG","code":1153}},{"name":"World Geodetic System 1984 (G1150)","id":{"authority":"EPSG","code":1154}},{"name":"World Geodetic System 1984 (G1674)","id":{"authority":"EPSG","code":1155}},{"name":"World Geodetic System 1984 (G1762)","id":{"authority":"EPSG","code":1156}},{"name":"World Geodetic System 1984 (G2139)","id":{"authority":"EPSG","code":1309}}],"ellipsoid":{"name":"WGS 84","semi_major_axis":6378137,"inverse_flattening":298.257223563},"accuracy":"2.0","id":{"authority":"EPSG","code":6326}},"coordinate_system":{"subtype":"ellipsoidal","axis":[{"name":"Geodetic latitude","abbreviation":"Lat","direction":"north","unit":"degree"},{"name":"Geodetic longitude","abbreviation":"Lon","direction":"east","unit":"degree"}]},"id":{"authority":"EPSG","code":4326}},"conversion":{"name":"Popular Visualisation Pseudo-Mercator","method":{"name":"Popular Visualisation Pseudo Mercator","id":{"authority":"EPSG","code":1024}},"parameters":[{"name":"Latitude of natural origin","value":0,"unit":"degree","id":{"authority":"EPSG","code":8801}},{"name":"Longitude of natural origin","value":0,"unit":"degree","id":{"authority":"EPSG","code":8802}},{"name":"False easting","value":0,"unit":"metre","id":{"authority":"EPSG","code":8806}},{"name":"False northing","value":0,"unit":"metre","id":{"authority":"EPSG","code":8807}}]},"coordinate_system":{"subtype":"Cartesian","axis":[{"name":"Easting","abbreviation":"X","direction":"east","unit":"metre"},{"name":"Northing","abbreviation":"Y","direction":"north","unit":"metre"}]},"scope":"Web mapping and visualisation.","area":"World between 85.06°S and 85.06°N.","bbox":{"south_latitude":-85.06,"west_longitude":-180,"north_latitude":85.06,"east_longitude":180},"id":{"authority":"EPSG","code":3857}}'
jerstlouis commented 8 months ago

Bonjour Vincent,

IMO using wkt attribute to expect a PROJJSON object is pretty confusing because in wkt there is the word text

I strongly agree with this. However, unfortunately, I believe the WKT-CRS standard, as it is referred to ( https://docs.ogc.org/is/18-010r11/18-010r11.pdf ) currently acts as both a logical & conceptual model as well specifically the WKT encoding for the CRS.

The intent in 2DTMS was that this would be a JSON object, as defined once the OGC CRS SWG approves a proper JSON encoding for the WKT-CRS conceptual & logical model. In the meantime, the recommendation is to use PROJJSON in a provisional manner.

There is a note to that effect in 7.1:

NOTE This Standard adopts the https://proj.org/specifications/projjson.html encoding, pending a resolution in the CRS group for adopting a possible future JSON encoding for WKT for CRS 2.0

and the table above says:

WKT object The WKT encoding for JSON is an object representing a JSON encoding of the WKT for CRS 2.0 defined by https://proj.org/specifications/projjson.html

Again, I fully agree and dislike that something not text is called WKT, but this is how things have been defined so far by the CRS group.

There is even confusion between the WKT encoding for simple features vs. the WKT CRS.

EDIT: Probably we could have used something else than wkt as the attribute name, but changing it at this point would be a breaking change that would require a major version bump.

vincentsarago commented 8 months ago

😬 well I just realized that PROJJSON is of type text (because json is of type text) 🤦

It's just confusing about wkt/projjson. Maybe it would be nice to really mention that it's should be PROJJSON string.

jerstlouis commented 8 months ago

@vincentsarago To be clear, it should be a PROJJSON object, not some JSON inside a "" string.

vincentsarago commented 8 months ago

ok ok 🙏

I'll update my libraries accordingly, thanks @jerstlouis

jerstlouis commented 8 months ago

@vincentsarago And in general, if a registered URI exists, the uri approach should be used, which avoids having to parse the CRS definition when it can easily be recognized by string-comparing the URI, which is likely to be more widely supported by clients.

vincentsarago commented 8 months ago

@jerstlouis sure I'm just trying to follow the specification to the letter to win the OGC TMS2.0 badge 😄