diff options
| -rw-r--r-- | data/Makefile.am | 4 | ||||
| -rw-r--r-- | data/projjson.schema.json (renamed from data/crsjson.schema.json) | 41 | ||||
| -rw-r--r-- | docs/Makefile | 1 | ||||
| -rw-r--r-- | docs/source/apps/projinfo.rst | 2 | ||||
| -rw-r--r-- | include/proj/io.hpp | 1 | ||||
| -rw-r--r-- | schemas/v0.1/projjson.schema.json | 972 | ||||
| -rw-r--r-- | scripts/reference_exported_symbols.txt | 1 | ||||
| -rw-r--r-- | src/iso19111/c_api.cpp | 4 | ||||
| -rw-r--r-- | src/iso19111/io.cpp | 21 | ||||
| -rw-r--r-- | test/cli/testprojinfo_out.dist | 1 | ||||
| -rw-r--r-- | test/unit/test_c_api.cpp | 7 | ||||
| -rw-r--r-- | test/unit/test_datum.cpp | 27 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 153 | ||||
| -rwxr-xr-x | travis/install.sh | 8 |
14 files changed, 1180 insertions, 63 deletions
diff --git a/data/Makefile.am b/data/Makefile.am index 096ba7c3..d686270d 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -3,7 +3,7 @@ DATAPATH = $(top_srcdir)/data pkgdata_DATA = GL27 nad.lst nad27 nad83 world other.extra \ CH null \ ITRF2000 ITRF2008 ITRF2014 proj.db \ - crsjson.schema.json + projjson.schema.json SQL_ORDERED_LIST = sql/begin.sql \ sql/proj_db_table_defs.sql \ @@ -41,7 +41,7 @@ EXTRA_DIST = GL27 nad.lst nad27 nad83 \ world other.extra \ CH \ ITRF2000 ITRF2008 ITRF2014 \ - crsjson.schema.json \ + projjson.schema.json \ CMakeLists.txt tests/test_nodata.gtx null \ generate_all_sql_in.cmake sql_filelist.cmake \ $(SQL_ORDERED_LIST) diff --git a/data/crsjson.schema.json b/data/projjson.schema.json index 726d8ece..60fca6df 100644 --- a/data/crsjson.schema.json +++ b/data/projjson.schema.json @@ -1,7 +1,8 @@ { - "$id": "https://proj.org/crsjson.schema.json", + "$id": "https://proj.org/schemas/v0.1/projjson.schema.json", "$schema": "http://json-schema.org/draft-07/schema#", - "description": "Schema for CRS JSON", + "description": "Schema for PROJJSON", + "$comment": "This file exists both in data/ and in schemas/vXXX/. Keep both in sync. And if changing the value of $id, change PROJJSON_CURRENT_VERSION accordingly in io.cpp", "oneOf": [ { "$ref": "#/definitions/crs" }, @@ -18,6 +19,7 @@ "abridged_transformation": { "type": "object", "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["AbridgedTransformation"] }, "name": { "type": "string" }, "method": { "$ref": "#/definitions/method" }, @@ -38,6 +40,7 @@ "axis": { "type": "object", "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["Axis"] }, "name": { "type": "string" }, "abbreviation": { "type": "string" }, @@ -109,6 +112,7 @@ "bound_crs": { "type": "object", "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["BoundCRS"] }, "source_crs": { "$ref": "#/definitions/crs" }, "target_crs": { "$ref": "#/definitions/crs" }, @@ -128,6 +132,7 @@ "type": "array", "items": { "$ref": "#/definitions/crs" } }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -151,6 +156,7 @@ "type": "array", "items": { "$ref": "#/definitions/single_operation" } }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -165,6 +171,7 @@ "conversion": { "type": "object", "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["Conversion"] }, "name": { "type": "string" }, "method": { "$ref": "#/definitions/method" }, @@ -185,6 +192,7 @@ "coordinate_system": { "type": "object", "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["CoordinateSystem"] }, "name": { "type": "string" }, "subtype": { "type": "string", @@ -245,6 +253,7 @@ "datum_ensemble": { "type": "object", "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["DatumEnsemble"] }, "name": { "type": "string" }, "members": { @@ -285,6 +294,7 @@ "base_crs": { "$ref": "#/definitions/engineering_crs" }, "conversion": { "$ref": "#/definitions/conversion" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -307,6 +317,7 @@ "base_crs": { "$ref": "#/definitions/geodetic_crs" }, "conversion": { "$ref": "#/definitions/conversion" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -328,6 +339,7 @@ "base_crs": { "$ref": "#/definitions/parametric_crs" }, "conversion": { "$ref": "#/definitions/conversion" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -349,6 +361,7 @@ "base_crs": { "$ref": "#/definitions/projected_crs" }, "conversion": { "$ref": "#/definitions/conversion" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -370,6 +383,7 @@ "base_crs": { "$ref": "#/definitions/temporal_crs" }, "conversion": { "$ref": "#/definitions/conversion" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -391,6 +405,7 @@ "base_crs": { "$ref": "#/definitions/vertical_crs" }, "conversion": { "$ref": "#/definitions/conversion" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -413,6 +428,7 @@ "prime_meridian": {}, "frame_reference_epoch": { "type": "number" }, "deformation_model": { "type": "string" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -433,6 +449,7 @@ "anchor": {}, "frame_reference_epoch": { "type": "number" }, "deformation_model": { "type": "string" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -449,6 +466,7 @@ "oneOf":[ { "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["Ellipsoid"] }, "name": { "type": "string" }, "semi_major_axis": { "$ref": "#/definitions/value_in_metre_or_value_and_unit" }, @@ -461,6 +479,7 @@ }, { "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["Ellipsoid"] }, "name": { "type": "string" }, "semi_major_axis": { "$ref": "#/definitions/value_in_metre_or_value_and_unit" }, @@ -473,6 +492,7 @@ }, { "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["Ellipsoid"] }, "name": { "type": "string" }, "radius": { "$ref": "#/definitions/value_in_metre_or_value_and_unit" }, @@ -496,6 +516,7 @@ "name": { "type": "string" }, "datum": { "$ref": "#/definitions/engineering_datum" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -514,6 +535,7 @@ "type": { "type": "string", "enum": ["EngineeringDatum"] }, "name": { "type": "string" }, "anchor": { "type": "string" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -538,6 +560,7 @@ }, "datum_ensemble": { "$ref": "#/definitions/datum_ensemble" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -563,6 +586,7 @@ "anchor": { "type": "string" }, "ellipsoid": { "$ref": "#/definitions/ellipsoid" }, "prime_meridian": { "$ref": "#/definitions/prime_meridian" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -594,6 +618,7 @@ "method": { "type": "object", "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["OperationMethod"]}, "name": { "type": "string" }, "id": { "$ref": "#/definitions/id" }, @@ -635,6 +660,7 @@ { "type": "object", "properties": { + "$schema" : { "type": "string" }, "scope": { "type": "string" }, "area": { "type": "string" }, "bbox": { "$ref": "#/definitions/bbox" }, @@ -649,6 +675,7 @@ { "type": "object", "properties": { + "$schema" : { "type": "string" }, "usages": { "$ref": "#/definitions/usages" }, "remarks": { "type": "string" }, "id": { "$ref": "#/definitions/id" }, @@ -664,6 +691,7 @@ "parameter_value": { "type": "object", "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["ParameterValue"] }, "name": { "type": "string" }, "value": { @@ -691,6 +719,7 @@ "name": { "type": "string" }, "datum": { "$ref": "#/definitions/parametric_datum" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -709,6 +738,7 @@ "type": { "type": "string", "enum": ["ParametricDatum"] }, "name": { "type": "string" }, "anchor": { "type": "string" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -723,6 +753,7 @@ "prime_meridian": { "type": "object", "properties": { + "$schema" : { "type": "string" }, "type": { "type": "string", "enum": ["PrimeMeridian"] }, "name": { "type": "string" }, "longitude": { "$ref": "#/definitions/value_and_unit" }, @@ -753,6 +784,7 @@ "base_crs": { "$ref": "#/definitions/geodetic_crs" }, "conversion": { "$ref": "#/definitions/conversion" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -772,6 +804,7 @@ "name": { "type": "string" }, "datum": { "$ref": "#/definitions/temporal_datum" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -791,6 +824,7 @@ "name": { "type": "string" }, "calendar": { "type": "string" }, "time_origin": { "type": "string" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -817,6 +851,7 @@ "items": { "$ref": "#/definitions/parameter_value" } }, "accuracy": { "type": "string" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -897,6 +932,7 @@ }, "datum_ensemble": { "$ref": "#/definitions/datum_ensemble" }, "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, @@ -920,6 +956,7 @@ "type": { "type": "string", "enum": ["VerticalReferenceFrame"] }, "name": { "type": "string" }, "anchor": { "type": "string" }, + "$schema" : {}, "scope": {}, "area": {}, "bbox": {}, diff --git a/docs/Makefile b/docs/Makefile index 4e1e88aa..c0801a9b 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -65,6 +65,7 @@ html: .doxygen_up_to_date # Undoes the hacks of scripts/generate_breathe_friendly_general_doc.py @sed "s/<em class=\"property\">namespace <\/em>//g" < $(BUILDDIR)/html/development/reference/cpp/cpp_general.html > $(BUILDDIR)/html/development/reference/cpp/cpp_general.html.tmp @mv $(BUILDDIR)/html/development/reference/cpp/cpp_general.html.tmp $(BUILDDIR)/html/development/reference/cpp/cpp_general.html + @cp -r ../schemas $(BUILDDIR)/html/schemas @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." diff --git a/docs/source/apps/projinfo.rst b/docs/source/apps/projinfo.rst index efbc3948..8018f300 100644 --- a/docs/source/apps/projinfo.rst +++ b/docs/source/apps/projinfo.rst @@ -44,7 +44,7 @@ Synopsis (*added in 6.2*) - a OGC URN combining references for concatenated operations (e.g. "urn:ogc:def:coordinateOperation,coordinateOperation:EPSG::3895,coordinateOperation:EPSG::1618") - - a PROJJSON string. The jsonschema is at https://github.com/OSGeo/proj/blob/master/data/crsjson.schema.json (*added in 6.2*) + - a PROJJSON string. The jsonschema is at https://proj.org/schemas/v0.1/projjson.schema.json (*added in 6.2*) {object_reference} is a filename preceded by the '@' character. The file referenced by the {object_reference} must contain a valid diff --git a/include/proj/io.hpp b/include/proj/io.hpp index 66c1a4cd..9c99fc0e 100644 --- a/include/proj/io.hpp +++ b/include/proj/io.hpp @@ -477,6 +477,7 @@ class PROJ_GCC_DLL JSONFormatter { PROJ_DLL JSONFormatter &setMultiLine(bool multiLine) noexcept; PROJ_DLL JSONFormatter &setIndentationWidth(int width) noexcept; + PROJ_DLL JSONFormatter &setSchema(const std::string &schema) noexcept; PROJ_DLL const std::string &toString() const; diff --git a/schemas/v0.1/projjson.schema.json b/schemas/v0.1/projjson.schema.json new file mode 100644 index 00000000..60fca6df --- /dev/null +++ b/schemas/v0.1/projjson.schema.json @@ -0,0 +1,972 @@ +{ + "$id": "https://proj.org/schemas/v0.1/projjson.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Schema for PROJJSON", + "$comment": "This file exists both in data/ and in schemas/vXXX/. Keep both in sync. And if changing the value of $id, change PROJJSON_CURRENT_VERSION accordingly in io.cpp", + + "oneOf": [ + { "$ref": "#/definitions/crs" }, + { "$ref": "#/definitions/datum" }, + { "$ref": "#/definitions/datum_ensemble" }, + { "$ref": "#/definitions/ellipsoid" }, + { "$ref": "#/definitions/prime_meridian" }, + { "$ref": "#/definitions/single_operation" }, + { "$ref": "#/definitions/concatenated_operation" } + ], + + "definitions": { + + "abridged_transformation": { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["AbridgedTransformation"] }, + "name": { "type": "string" }, + "method": { "$ref": "#/definitions/method" }, + "parameters": { + "type": "array", + "items": { "$ref": "#/definitions/parameter_value" } + }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name", "method", "parameters" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + }, + + "axis": { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["Axis"] }, + "name": { "type": "string" }, + "abbreviation": { "type": "string" }, + "direction": { "type": "string", + "enum": [ "north", + "northNorthEast", + "northEast", + "eastNorthEast", + "east", + "eastSouthEast", + "southEast", + "southSouthEast", + "south", + "southSouthWest", + "southWest", + "westSouthWest", + "west", + "westNorthWest", + "northWest", + "northNorthWest", + "up", + "down", + "geocentricX", + "geocentricY", + "geocentricZ", + "columnPositive", + "columnNegative", + "rowPositive", + "rowNegative", + "displayRight", + "displayLeft", + "displayUp", + "displayDown", + "forward", + "aft", + "port", + "starboard", + "clockwise", + "counterClockwise", + "towards", + "awayFrom", + "future", + "past", + "unspecified" ] }, + "unit": { "$ref": "#/definitions/unit" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name", "abbreviation", "direction" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + }, + + "bbox": { + "type": "object", + "properties": { + "east_longitude": { "type": "number" }, + "west_longitude": { "type": "number" }, + "south_latitude": { "type": "number" }, + "north_latitude": { "type": "number" } + }, + "required" : [ "east_longitude", "west_longitude", + "south_latitude", "north_latitude" ], + "additionalProperties": false + }, + + "bound_crs": { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["BoundCRS"] }, + "source_crs": { "$ref": "#/definitions/crs" }, + "target_crs": { "$ref": "#/definitions/crs" }, + "transformation": { "$ref": "#/definitions/abridged_transformation" } + }, + "required" : [ "source_crs", "target_crs", "transformation" ], + "additionalProperties": false + }, + + "compound_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["CompoundCRS"] }, + "name": { "type": "string" }, + "components": { + "type": "array", + "items": { "$ref": "#/definitions/crs" } + }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "components" ], + "additionalProperties": false + }, + + "concatenated_operation": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["ConcatenatedOperation"] }, + "name": { "type": "string" }, + "source_crs": { "$ref": "#/definitions/crs" }, + "target_crs": { "$ref": "#/definitions/crs" }, + "steps": { + "type": "array", + "items": { "$ref": "#/definitions/single_operation" } + }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "source_crs", "target_crs", "steps" ], + "additionalProperties": false + }, + + "conversion": { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["Conversion"] }, + "name": { "type": "string" }, + "method": { "$ref": "#/definitions/method" }, + "parameters": { + "type": "array", + "items": { "$ref": "#/definitions/parameter_value" } + }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name", "method" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + }, + + "coordinate_system": { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["CoordinateSystem"] }, + "name": { "type": "string" }, + "subtype": { "type": "string", + "enum": ["Cartesian", + "spherical", + "ellipsoidal", + "vertical", + "ordinal", + "parametric", + "TemporalDateTime", + "TemporalCount", + "TemporalMeasure"] }, + "axis": { + "type": "array", + "items": { "$ref": "#/definitions/axis" } + }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "subtype", "axis" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + }, + + "crs": { + "oneOf": [ + { "$ref": "#/definitions/bound_crs" }, + { "$ref": "#/definitions/compound_crs" }, + { "$ref": "#/definitions/derived_engineering_crs" }, + { "$ref": "#/definitions/derived_geodetic_crs" }, + { "$ref": "#/definitions/derived_parametric_crs" }, + { "$ref": "#/definitions/derived_projected_crs" }, + { "$ref": "#/definitions/derived_temporal_crs" }, + { "$ref": "#/definitions/derived_vertical_crs" }, + { "$ref": "#/definitions/engineering_crs" }, + { "$ref": "#/definitions/geodetic_crs" }, + { "$ref": "#/definitions/parametric_crs" }, + { "$ref": "#/definitions/projected_crs" }, + { "$ref": "#/definitions/temporal_crs" }, + { "$ref": "#/definitions/vertical_crs" } + ] + }, + + "datum": { + "oneOf": [ + { "$ref": "#/definitions/geodetic_reference_frame" }, + { "$ref": "#/definitions/vertical_reference_frame" }, + { "$ref": "#/definitions/dynamic_geodetic_reference_frame" }, + { "$ref": "#/definitions/dynamic_vertical_reference_frame" }, + { "$ref": "#/definitions/temporal_datum" }, + { "$ref": "#/definitions/parametric_datum" }, + { "$ref": "#/definitions/engineering_datum" } + ] + }, + + "datum_ensemble": { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["DatumEnsemble"] }, + "name": { "type": "string" }, + "members": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + } + }, + "ellipsoid": { "$ref": "#/definitions/ellipsoid" }, + "accuracy": { "type": "string" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name", "members", "accuracy" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + }, + + "derived_engineering_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", + "enum": ["DerivedEngineeringCRS"] }, + "name": { "type": "string" }, + "base_crs": { "$ref": "#/definitions/engineering_crs" }, + "conversion": { "$ref": "#/definitions/conversion" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "base_crs", "conversion", "coordinate_system" ], + "additionalProperties": false + }, + + "derived_geodetic_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", + "enum": ["DerivedGeodeticCRS", + "DerivedGeographicCRS"] }, + "name": { "type": "string" }, + "base_crs": { "$ref": "#/definitions/geodetic_crs" }, + "conversion": { "$ref": "#/definitions/conversion" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "base_crs", "conversion", "coordinate_system" ], + "additionalProperties": false + }, + + "derived_parametric_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", + "enum": ["DerivedParametricCRS"] }, + "name": { "type": "string" }, + "base_crs": { "$ref": "#/definitions/parametric_crs" }, + "conversion": { "$ref": "#/definitions/conversion" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "base_crs", "conversion", "coordinate_system" ], + "additionalProperties": false + }, + + "derived_projected_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", + "enum": ["DerivedProjectedCRS"] }, + "name": { "type": "string" }, + "base_crs": { "$ref": "#/definitions/projected_crs" }, + "conversion": { "$ref": "#/definitions/conversion" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "base_crs", "conversion", "coordinate_system" ], + "additionalProperties": false + }, + + "derived_temporal_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", + "enum": ["DerivedTemporalCRS"] }, + "name": { "type": "string" }, + "base_crs": { "$ref": "#/definitions/temporal_crs" }, + "conversion": { "$ref": "#/definitions/conversion" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "base_crs", "conversion", "coordinate_system" ], + "additionalProperties": false + }, + + "derived_vertical_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", + "enum": ["DerivedVerticalCRS"] }, + "name": { "type": "string" }, + "base_crs": { "$ref": "#/definitions/vertical_crs" }, + "conversion": { "$ref": "#/definitions/conversion" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "base_crs", "conversion", "coordinate_system" ], + "additionalProperties": false + }, + + "dynamic_geodetic_reference_frame": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/geodetic_reference_frame" }], + "properties": { + "type": { "type": "string", "enum": ["DynamicGeodeticReferenceFrame"] }, + "name": {}, + "anchor": {}, + "ellipsoid": {}, + "prime_meridian": {}, + "frame_reference_epoch": { "type": "number" }, + "deformation_model": { "type": "string" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "ellipsoid", "frame_reference_epoch" ], + "additionalProperties": false + }, + + "dynamic_vertical_reference_frame": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/vertical_reference_frame" }], + "properties": { + "type": { "type": "string", "enum": ["DynamicVerticalReferenceFrame"] }, + "name": {}, + "anchor": {}, + "frame_reference_epoch": { "type": "number" }, + "deformation_model": { "type": "string" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "frame_reference_epoch" ], + "additionalProperties": false + }, + + "ellipsoid": { + "type": "object", + "oneOf":[ + { + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["Ellipsoid"] }, + "name": { "type": "string" }, + "semi_major_axis": { "$ref": "#/definitions/value_in_metre_or_value_and_unit" }, + "semi_minor_axis": { "$ref": "#/definitions/value_in_metre_or_value_and_unit" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name", "semi_major_axis", "semi_minor_axis" ], + "additionalProperties": false + }, + { + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["Ellipsoid"] }, + "name": { "type": "string" }, + "semi_major_axis": { "$ref": "#/definitions/value_in_metre_or_value_and_unit" }, + "inverse_flattening": { "type": "number" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name", "semi_major_axis", "inverse_flattening" ], + "additionalProperties": false + }, + { + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["Ellipsoid"] }, + "name": { "type": "string" }, + "radius": { "$ref": "#/definitions/value_in_metre_or_value_and_unit" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name", "radius" ], + "additionalProperties": false + } + ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ] + }, + + "engineering_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["EngineeringCRS"] }, + "name": { "type": "string" }, + "datum": { "$ref": "#/definitions/engineering_datum" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "datum" ], + "additionalProperties": false + }, + + "engineering_datum": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["EngineeringDatum"] }, + "name": { "type": "string" }, + "anchor": { "type": "string" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name" ], + "additionalProperties": false + }, + + "geodetic_crs": { + "type": "object", + "properties": { + "type": { "type": "string", "enum": ["GeodeticCRS", "GeographicCRS"] }, + "name": { "type": "string" }, + "datum": { + "oneOf": [ + { "$ref": "#/definitions/geodetic_reference_frame" }, + { "$ref": "#/definitions/dynamic_geodetic_reference_frame" } + ] + }, + "datum_ensemble": { "$ref": "#/definitions/datum_ensemble" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name" ], + "description": "One and only one of datum and datum_ensemble must be provided", + "allOf": [ + { "$ref": "#/definitions/object_usage" }, + { "$ref": "#/definitions/one_and_only_one_of_datum_or_datum_ensemble" } + ], + "additionalProperties": false + }, + + "geodetic_reference_frame": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["GeodeticReferenceFrame"] }, + "name": { "type": "string" }, + "anchor": { "type": "string" }, + "ellipsoid": { "$ref": "#/definitions/ellipsoid" }, + "prime_meridian": { "$ref": "#/definitions/prime_meridian" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "ellipsoid" ], + "additionalProperties": false + }, + + "id": { + "type": "object", + "properties": { + "authority": { "type": "string" }, + "code": { + "oneOf": [ { "type": "string" }, { "type": "integer" } ] + } + }, + "required" : [ "authority", "code" ], + "additionalProperties": false + }, + + "ids": { + "type": "array", + "items": { "$ref": "#/definitions/id" } + }, + + "method": { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["OperationMethod"]}, + "name": { "type": "string" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + }, + + "id_ids_mutually_exclusive": { + "not": { + "type": "object", + "required": [ "id", "ids" ] + } + }, + + "one_and_only_one_of_datum_or_datum_ensemble": { + "allOf": [ + { + "not": { + "type": "object", + "required": [ "datum", "datum_ensemble" ] + } + }, + { + "oneOf": [ + { "type": "object", "required": ["datum"] }, + { "type": "object", "required": ["datum_ensemble"] } + ] + } + ] + }, + + "object_usage": { + "anyOf": [ + { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "scope": { "type": "string" }, + "area": { "type": "string" }, + "bbox": { "$ref": "#/definitions/bbox" }, + "remarks": { "type": "string" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ] + }, + { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "usages": { "$ref": "#/definitions/usages" }, + "remarks": { "type": "string" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ] + } + ] + }, + + "parameter_value": { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["ParameterValue"] }, + "name": { "type": "string" }, + "value": { + "oneOf": [ + { "type": "string" }, + { "type": "number" } + ] + }, + "unit": { "$ref": "#/definitions/unit" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name", "value" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + }, + + "parametric_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["ParametricCRS"] }, + "name": { "type": "string" }, + "datum": { "$ref": "#/definitions/parametric_datum" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "datum" ], + "additionalProperties": false + }, + + "parametric_datum": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["ParametricDatum"] }, + "name": { "type": "string" }, + "anchor": { "type": "string" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name" ], + "additionalProperties": false + }, + + "prime_meridian": { + "type": "object", + "properties": { + "$schema" : { "type": "string" }, + "type": { "type": "string", "enum": ["PrimeMeridian"] }, + "name": { "type": "string" }, + "longitude": { "$ref": "#/definitions/value_and_unit" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "name" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + }, + + "single_operation": { + "oneOf": [ + { "$ref": "#/definitions/conversion" }, + { "$ref": "#/definitions/transformation" } + ] + }, + + "projected_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", + "enum": ["ProjectedCRS"] }, + "name": { "type": "string" }, + "base_crs": { "$ref": "#/definitions/geodetic_crs" }, + "conversion": { "$ref": "#/definitions/conversion" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "base_crs", "conversion", "coordinate_system" ], + "additionalProperties": false + }, + + "temporal_crs": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["TemporalCRS"] }, + "name": { "type": "string" }, + "datum": { "$ref": "#/definitions/temporal_datum" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "datum" ], + "additionalProperties": false + }, + + "temporal_datum": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["TemporalDatum"] }, + "name": { "type": "string" }, + "calendar": { "type": "string" }, + "time_origin": { "type": "string" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "calendar" ], + "additionalProperties": false + }, + + "transformation": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["Transformation"] }, + "name": { "type": "string" }, + "source_crs": { "$ref": "#/definitions/crs" }, + "target_crs": { "$ref": "#/definitions/crs" }, + "interpolation_crs": { "$ref": "#/definitions/crs" }, + "method": { "$ref": "#/definitions/method" }, + "parameters": { + "type": "array", + "items": { "$ref": "#/definitions/parameter_value" } + }, + "accuracy": { "type": "string" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name", "source_crs", "target_crs", "method", "parameters" ], + "additionalProperties": false + }, + + "unit": { + "oneOf": [ + { + "type": "string", + "enum": ["metre", "degree", "unity"] + }, + { + "type": "object", + "properties": { + "type": { "type": "string", + "enum": ["LinearUnit", "AngularUnit", "ScaleUnit", + "TimeUnit", "ParametricUnit", "Unit"] }, + "name": { "type": "string" }, + "conversion_factor": { "type": "number" }, + "id": { "$ref": "#/definitions/id" }, + "ids": { "$ref": "#/definitions/ids" } + }, + "required" : [ "type", "name" ], + "allOf": [ + { "$ref": "#/definitions/id_ids_mutually_exclusive" } + ], + "additionalProperties": false + } + ] + }, + + "usages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "scope": { "type": "string" }, + "area": { "type": "string" }, + "bbox": { "$ref": "#/definitions/bbox" } + }, + "additionalProperties": false + } + }, + + "value_and_unit": { + "type": "object", + "properties": { + "value": { "type": "number" }, + "unit": { "$ref": "#/definitions/unit" } + }, + "required" : [ "value", "unit" ], + "additionalProperties": false + }, + + "value_in_metre_or_value_and_unit": { + "oneOf": [ + { "type": "number" }, + { "$ref": "#/definitions/value_and_unit" } + ] + }, + + "vertical_crs": { + "type": "object", + "properties": { + "type": { "type": "string", "enum": ["VerticalCRS"] }, + "name": { "type": "string" }, + "datum": { + "oneOf": [ + { "$ref": "#/definitions/vertical_reference_frame" }, + { "$ref": "#/definitions/dynamic_vertical_reference_frame" } + ] + }, + "datum_ensemble": { "$ref": "#/definitions/datum_ensemble" }, + "coordinate_system": { "$ref": "#/definitions/coordinate_system" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name"], + "description": "One and only one of datum and datum_ensemble must be provided", + "allOf": [ + { "$ref": "#/definitions/object_usage" }, + { "$ref": "#/definitions/one_and_only_one_of_datum_or_datum_ensemble" } + ], + "additionalProperties": false + }, + + "vertical_reference_frame": { + "type": "object", + "allOf": [{ "$ref": "#/definitions/object_usage" }], + "properties": { + "type": { "type": "string", "enum": ["VerticalReferenceFrame"] }, + "name": { "type": "string" }, + "anchor": { "type": "string" }, + "$schema" : {}, + "scope": {}, + "area": {}, + "bbox": {}, + "usages": {}, + "remarks": {}, + "id": {}, "ids": {} + }, + "required" : [ "name" ], + "additionalProperties": false + } + + } +} diff --git a/scripts/reference_exported_symbols.txt b/scripts/reference_exported_symbols.txt index a372d163..a453bb2d 100644 --- a/scripts/reference_exported_symbols.txt +++ b/scripts/reference_exported_symbols.txt @@ -344,6 +344,7 @@ osgeo::proj::io::JSONFormatter::ObjectContext::~ObjectContext() osgeo::proj::io::JSONFormatter::ObjectContext::ObjectContext(osgeo::proj::io::JSONFormatter&, char const*, bool) osgeo::proj::io::JSONFormatter::setIndentationWidth(int) osgeo::proj::io::JSONFormatter::setMultiLine(bool) +osgeo::proj::io::JSONFormatter::setSchema(std::string const&) osgeo::proj::io::JSONFormatter::toString() const osgeo::proj::io::NoSuchAuthorityCodeException::getAuthorityCode() const osgeo::proj::io::NoSuchAuthorityCodeException::getAuthority() const diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index d4813091..d27b8800 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -1335,6 +1335,8 @@ const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj, * <li>MULTILINE=YES/NO. Defaults to YES</li> * <li>INDENTATION_WIDTH=number. Defauls to 2 (when multiline output is * on).</li> + * <li>SCHEMA=string. URL to PROJJSON schema. Can be set to empty string to + * disable it.</li> * </ul> * @return a string, or NULL in case of error. * @@ -1359,6 +1361,8 @@ const char *proj_as_projjson(PJ_CONTEXT *ctx, const PJ *obj, formatter->setMultiLine(ci_equal(value, "YES")); } else if ((value = getOptionValue(*iter, "INDENTATION_WIDTH="))) { formatter->setIndentationWidth(std::atoi(value)); + } else if ((value = getOptionValue(*iter, "SCHEMA="))) { + formatter->setSchema(value); } else { std::string msg("Unknown option :"); msg += *iter; diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 9f4f6061..5ccd9642 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -86,6 +86,10 @@ using json = nlohmann::json; //! @cond Doxygen_Suppress static const std::string emptyString{}; + +// If changing that value, change it in data/projjson.schema.json as well +#define PROJJSON_CURRENT_VERSION \ + "https://proj.org/schemas/v0.1/projjson.schema.json" //! @endcond #if 0 @@ -9103,6 +9107,7 @@ struct JSONFormatter::Private { bool allowIDInImmediateChild_ = false; bool omitTypeInImmediateChild_ = false; bool abridgedTransformation_ = false; + std::string schema_ = PROJJSON_CURRENT_VERSION; std::string result_{}; @@ -9148,6 +9153,17 @@ JSONFormatter &JSONFormatter::setIndentationWidth(int width) noexcept { // --------------------------------------------------------------------------- +/** \brief Set the value of the "$schema" key in the top level object. + * + * If set to empty string, it will not be written. + */ +JSONFormatter &JSONFormatter::setSchema(const std::string &schema) noexcept { + d->schema_ = schema; + return *this; +} + +// --------------------------------------------------------------------------- + //! @cond Doxygen_Suppress JSONFormatter::JSONFormatter() : d(internal::make_unique<Private>()) {} @@ -9188,6 +9204,11 @@ JSONFormatter::ObjectContext::ObjectContext(JSONFormatter &formatter, const char *objectType, bool hasId) : m_formatter(formatter) { m_formatter.d->writer_.StartObj(); + if (m_formatter.d->outputIdStack_.size() == 1 && + !m_formatter.d->schema_.empty()) { + m_formatter.d->writer_.AddObjKey("$schema"); + m_formatter.d->writer_.Add(m_formatter.d->schema_); + } if (objectType && !m_formatter.d->omitTypeInImmediateChild_) { m_formatter.d->writer_.AddObjKey("type"); m_formatter.d->writer_.Add(objectType); diff --git a/test/cli/testprojinfo_out.dist b/test/cli/testprojinfo_out.dist index 73751b99..97c1138c 100644 --- a/test/cli/testprojinfo_out.dist +++ b/test/cli/testprojinfo_out.dist @@ -137,6 +137,7 @@ GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.25722 PROJJSON: { + "$schema": "https://proj.org/schemas/v0.1/projjson.schema.json", "type": "GeographicCRS", "name": "WGS 84", "datum": { diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 5649ca9f..97440796 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -3503,6 +3503,8 @@ TEST_F(CApi, proj_as_projjson) { ASSERT_NE(projjson, nullptr); EXPECT_EQ(std::string(projjson), "{\n" + " \"$schema\": " + "\"https://proj.org/schemas/v0.1/projjson.schema.json\",\n" " \"type\": \"Ellipsoid\",\n" " \"name\": \"WGS 84\",\n" " \"semi_major_axis\": 6378137,\n" @@ -3514,7 +3516,8 @@ TEST_F(CApi, proj_as_projjson) { "}"); } { - const char *const options[] = {"INDENTATION_WIDTH=4", nullptr}; + const char *const options[] = {"INDENTATION_WIDTH=4", "SCHEMA=", + nullptr}; auto projjson = proj_as_projjson(m_ctxt, obj, options); ASSERT_NE(projjson, nullptr); EXPECT_EQ(std::string(projjson), @@ -3530,7 +3533,7 @@ TEST_F(CApi, proj_as_projjson) { "}"); } { - const char *const options[] = {"MULTILINE=NO", nullptr}; + const char *const options[] = {"MULTILINE=NO", "SCHEMA=", nullptr}; auto projjson = proj_as_projjson(m_ctxt, obj, options); ASSERT_NE(projjson, nullptr); EXPECT_EQ(std::string(projjson), diff --git a/test/unit/test_datum.cpp b/test/unit/test_datum.cpp index d8fab1f0..fbd1f79d 100644 --- a/test/unit/test_datum.cpp +++ b/test/unit/test_datum.cpp @@ -207,19 +207,20 @@ TEST(datum, prime_meridian_to_PROJString) { TEST(datum, prime_meridian_to_JSON) { - EXPECT_EQ( - PrimeMeridian::GREENWICH->exportToJSON(JSONFormatter::create().get()), - "{\n" - " \"type\": \"PrimeMeridian\",\n" - " \"name\": \"Greenwich\",\n" - " \"longitude\": 0,\n" - " \"id\": {\n" - " \"authority\": \"EPSG\",\n" - " \"code\": 8901\n" - " }\n" - "}"); - - EXPECT_EQ(PrimeMeridian::PARIS->exportToJSON(JSONFormatter::create().get()), + EXPECT_EQ(PrimeMeridian::GREENWICH->exportToJSON( + &(JSONFormatter::create()->setSchema(""))), + "{\n" + " \"type\": \"PrimeMeridian\",\n" + " \"name\": \"Greenwich\",\n" + " \"longitude\": 0,\n" + " \"id\": {\n" + " \"authority\": \"EPSG\",\n" + " \"code\": 8901\n" + " }\n" + "}"); + + EXPECT_EQ(PrimeMeridian::PARIS->exportToJSON( + &(JSONFormatter::create()->setSchema(""))), "{\n" " \"type\": \"PrimeMeridian\",\n" " \"name\": \"Paris\",\n" diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index e1d424e9..7a3e6729 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -9137,6 +9137,7 @@ TEST(wkt_export, invalid_angular_unit) { TEST(json_import, ellipsoid_flattened_sphere) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"Ellipsoid\",\n" " \"name\": \"WGS 84\",\n" " \"semi_major_axis\": 6378137,\n" @@ -9149,13 +9150,15 @@ TEST(json_import, ellipsoid_flattened_sphere) { auto obj = createFromUserInput(json, nullptr); auto ellps = nn_dynamic_pointer_cast<Ellipsoid>(obj); ASSERT_TRUE(ellps != nullptr); - EXPECT_EQ(ellps->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(ellps->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, ellipsoid_major_minor_custom_unit) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"Ellipsoid\",\n" " \"name\": \"foo\",\n" " \"semi_major_axis\": 6378137,\n" @@ -9171,13 +9174,15 @@ TEST(json_import, ellipsoid_major_minor_custom_unit) { auto obj = createFromUserInput(json, nullptr); auto ellps = nn_dynamic_pointer_cast<Ellipsoid>(obj); ASSERT_TRUE(ellps != nullptr); - EXPECT_EQ(ellps->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(ellps->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, ellipsoid_sphere) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"Ellipsoid\",\n" " \"name\": \"Sphere\",\n" " \"radius\": 6371000,\n" @@ -9189,7 +9194,8 @@ TEST(json_import, ellipsoid_sphere) { auto obj = createFromUserInput(json, nullptr); auto ellps = nn_dynamic_pointer_cast<Ellipsoid>(obj); ASSERT_TRUE(ellps != nullptr); - EXPECT_EQ(ellps->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(ellps->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- @@ -9217,6 +9223,7 @@ TEST(json_import, ellipsoid_errors) { TEST(json_import, prime_meridian) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"PrimeMeridian\",\n" " \"name\": \"Paris\",\n" " \"longitude\": {\n" @@ -9231,7 +9238,8 @@ TEST(json_import, prime_meridian) { auto obj = createFromUserInput(json, nullptr); auto pm = nn_dynamic_pointer_cast<PrimeMeridian>(obj); ASSERT_TRUE(pm != nullptr); - EXPECT_EQ(pm->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(pm->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- @@ -9251,6 +9259,7 @@ TEST(json_import, prime_meridian_errors) { TEST(json_import, geodetic_reference_frame_with_implicit_prime_meridian) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"GeodeticReferenceFrame\",\n" " \"name\": \"World Geodetic System 1984\",\n" " \"ellipsoid\": {\n" @@ -9262,13 +9271,15 @@ TEST(json_import, geodetic_reference_frame_with_implicit_prime_meridian) { auto obj = createFromUserInput(json, nullptr); auto grf = nn_dynamic_pointer_cast<GeodeticReferenceFrame>(obj); ASSERT_TRUE(grf != nullptr); - EXPECT_EQ(grf->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(grf->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, geodetic_reference_frame_with_explicit_prime_meridian) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"GeodeticReferenceFrame\",\n" " \"name\": \"Nouvelle Triangulation Francaise (Paris)\",\n" " \"ellipsoid\": {\n" @@ -9291,7 +9302,8 @@ TEST(json_import, geodetic_reference_frame_with_explicit_prime_meridian) { auto obj = createFromUserInput(json, nullptr); auto grf = nn_dynamic_pointer_cast<GeodeticReferenceFrame>(obj); ASSERT_TRUE(grf != nullptr); - EXPECT_EQ(grf->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(grf->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- @@ -9299,6 +9311,7 @@ TEST(json_import, geodetic_reference_frame_with_explicit_prime_meridian) { TEST(json_import, dynamic_geodetic_reference_frame_with_implicit_prime_meridian) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DynamicGeodeticReferenceFrame\",\n" " \"name\": \"World Geodetic System 1984\",\n" " \"frame_reference_epoch\": 1,\n" @@ -9312,7 +9325,8 @@ TEST(json_import, auto obj = createFromUserInput(json, nullptr); auto dgrf = nn_dynamic_pointer_cast<DynamicGeodeticReferenceFrame>(obj); ASSERT_TRUE(dgrf != nullptr); - EXPECT_EQ(dgrf->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(dgrf->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- @@ -9329,6 +9343,7 @@ TEST(json_import, geodetic_reference_frame_errors) { TEST(json_import, dynamic_vertical_reference_frame) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DynamicVerticalReferenceFrame\",\n" " \"name\": \"bar\",\n" " \"frame_reference_epoch\": 1,\n" @@ -9337,13 +9352,15 @@ TEST(json_import, dynamic_vertical_reference_frame) { auto obj = createFromUserInput(json, nullptr); auto dvrf = nn_dynamic_pointer_cast<DynamicVerticalReferenceFrame>(obj); ASSERT_TRUE(dvrf != nullptr); - EXPECT_EQ(dvrf->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(dvrf->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, several_usages) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"GeodeticReferenceFrame\",\n" " \"name\": \"World Geodetic System 1984\",\n" " \"ellipsoid\": {\n" @@ -9370,13 +9387,15 @@ TEST(json_import, several_usages) { auto obj = createFromUserInput(json, nullptr); auto gdr = nn_dynamic_pointer_cast<GeodeticReferenceFrame>(obj); ASSERT_TRUE(gdr != nullptr); - EXPECT_EQ(gdr->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(gdr->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, geographic_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"GeographicCRS\",\n" " \"name\": \"WGS 84\",\n" " \"datum\": {\n" @@ -9421,7 +9440,8 @@ TEST(json_import, geographic_crs) { auto obj = createFromUserInput(json, nullptr); auto gcrs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(gcrs != nullptr); - EXPECT_EQ(gcrs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(gcrs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- @@ -9486,6 +9506,7 @@ TEST(json_import, geographic_crs_errors) { TEST(json_import, geocentric_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"GeodeticCRS\",\n" " \"name\": \"WGS 84\",\n" " \"datum\": {\n" @@ -9524,13 +9545,15 @@ TEST(json_import, geocentric_crs) { auto obj = createFromUserInput(json, nullptr); auto gdcrs = nn_dynamic_pointer_cast<GeodeticCRS>(obj); ASSERT_TRUE(gdcrs != nullptr); - EXPECT_EQ(gdcrs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(gdcrs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, projected_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"ProjectedCRS\",\n" " \"name\": \"WGS 84 / UTM zone 31N\",\n" " \"base_crs\": {\n" @@ -9644,13 +9667,15 @@ TEST(json_import, projected_crs) { auto obj = createFromUserInput(json, nullptr); auto pcrs = nn_dynamic_pointer_cast<ProjectedCRS>(obj); ASSERT_TRUE(pcrs != nullptr); - EXPECT_EQ(pcrs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(pcrs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, compound_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"CompoundCRS\",\n" " \"name\": \"WGS 84 + EGM2008 height\",\n" " \"components\": [\n" @@ -9716,7 +9741,9 @@ TEST(json_import, compound_crs) { auto obj = createFromUserInput(json, nullptr); auto compoundCRS = nn_dynamic_pointer_cast<CompoundCRS>(obj); ASSERT_TRUE(compoundCRS != nullptr); - EXPECT_EQ(compoundCRS->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ( + compoundCRS->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- @@ -9724,6 +9751,7 @@ TEST(json_import, compound_crs) { TEST(json_import, bound_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"BoundCRS\",\n" " \"source_crs\": {\n" " \"type\": \"GeographicCRS\",\n" @@ -9817,13 +9845,16 @@ TEST(json_import, bound_crs) { auto obj = createFromUserInput(json, nullptr); auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(obj); ASSERT_TRUE(boundCRS != nullptr); - EXPECT_EQ(boundCRS->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ( + boundCRS->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, transformation) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"Transformation\",\n" " \"name\": \"GDA94 to GDA2020 (1)\",\n" " \"source_crs\": {\n" @@ -10004,7 +10035,9 @@ TEST(json_import, transformation) { auto obj = createFromUserInput(json, nullptr); auto transf = nn_dynamic_pointer_cast<Transformation>(obj); ASSERT_TRUE(transf != nullptr); - EXPECT_EQ(transf->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ( + transf->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- @@ -10012,6 +10045,7 @@ TEST(json_import, transformation) { TEST(json_import, concatenated_operation) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"ConcatenatedOperation\",\n" " \"name\": \"Inverse of Vicgrid + GDA94 to GDA2020 (1)\",\n" " \"source_crs\": {\n" @@ -10434,13 +10468,16 @@ TEST(json_import, concatenated_operation) { auto obj = createFromUserInput(json, nullptr); auto concat = nn_dynamic_pointer_cast<ConcatenatedOperation>(obj); ASSERT_TRUE(concat != nullptr); - EXPECT_EQ(concat->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ( + concat->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, geographic_crs_with_datum_ensemble) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"GeographicCRS\",\n" " \"name\": \"WGS 84\",\n" " \"datum_ensemble\": {\n" @@ -10481,6 +10518,7 @@ TEST(json_import, geographic_crs_with_datum_ensemble) { auto expected_json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"GeographicCRS\",\n" " \"name\": \"WGS 84\",\n" " \"datum_ensemble\": {\n" @@ -10536,22 +10574,26 @@ TEST(json_import, geographic_crs_with_datum_ensemble) { auto obj = createFromUserInput(json, nullptr); auto gcrs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(gcrs != nullptr); - EXPECT_EQ(gcrs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ( + gcrs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } { auto obj = createFromUserInput(json, DatabaseContext::create()); auto gcrs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(gcrs != nullptr); - EXPECT_EQ(gcrs->exportToJSON((JSONFormatter::create().get())), - expected_json); + EXPECT_EQ( + gcrs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + expected_json); } { auto obj = createFromUserInput(expected_json, DatabaseContext::create()); auto gcrs = nn_dynamic_pointer_cast<GeographicCRS>(obj); ASSERT_TRUE(gcrs != nullptr); - EXPECT_EQ(gcrs->exportToJSON((JSONFormatter::create().get())), - expected_json); + EXPECT_EQ( + gcrs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + expected_json); } } @@ -10559,6 +10601,7 @@ TEST(json_import, geographic_crs_with_datum_ensemble) { TEST(json_import, datum_ensemble_without_ellipsoid) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DatumEnsemble\",\n" " \"name\": \"ensemble\",\n" " \"members\": [\n" @@ -10576,13 +10619,16 @@ TEST(json_import, datum_ensemble_without_ellipsoid) { auto obj = createFromUserInput(json, nullptr); auto ensemble = nn_dynamic_pointer_cast<DatumEnsemble>(obj); ASSERT_TRUE(ensemble != nullptr); - EXPECT_EQ(ensemble->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ( + ensemble->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, vertical_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"VerticalCRS\",\n" " \"name\": \"EGM2008 height\",\n" " \"datum\": {\n" @@ -10605,10 +10651,12 @@ TEST(json_import, vertical_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<VerticalCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); auto datum = crs->datum(); - auto datum_json = datum->exportToJSON((JSONFormatter::create().get())); + auto datum_json = + datum->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))); auto datum_obj = createFromUserInput(datum_json, nullptr); auto datum_got = nn_dynamic_pointer_cast<VerticalReferenceFrame>(datum_obj); ASSERT_TRUE(datum_got != nullptr); @@ -10618,6 +10666,7 @@ TEST(json_import, vertical_crs) { TEST(json_import, vertical_crs_with_datum_ensemble) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"VerticalCRS\",\n" " \"name\": \"foo\",\n" " \"datum_ensemble\": {\n" @@ -10649,13 +10698,15 @@ TEST(json_import, vertical_crs_with_datum_ensemble) { auto obj = createFromUserInput(json, nullptr); auto vcrs = nn_dynamic_pointer_cast<VerticalCRS>(obj); ASSERT_TRUE(vcrs != nullptr); - EXPECT_EQ(vcrs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(vcrs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, parametric_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"ParametricCRS\",\n" " \"name\": \"WMO standard atmosphere layer 0\",\n" " \"datum\": {\n" @@ -10682,10 +10733,12 @@ TEST(json_import, parametric_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<ParametricCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); auto datum = crs->datum(); - auto datum_json = datum->exportToJSON((JSONFormatter::create().get())); + auto datum_json = + datum->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))); auto datum_obj = createFromUserInput(datum_json, nullptr); auto datum_got = nn_dynamic_pointer_cast<ParametricDatum>(datum_obj); ASSERT_TRUE(datum_got != nullptr); @@ -10695,6 +10748,7 @@ TEST(json_import, parametric_crs) { TEST(json_import, engineering_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"EngineeringCRS\",\n" " \"name\": \"Engineering CRS\",\n" " \"datum\": {\n" @@ -10722,10 +10776,12 @@ TEST(json_import, engineering_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<EngineeringCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); auto datum = crs->datum(); - auto datum_json = datum->exportToJSON((JSONFormatter::create().get())); + auto datum_json = + datum->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))); auto datum_obj = createFromUserInput(datum_json, nullptr); auto datum_got = nn_dynamic_pointer_cast<EngineeringDatum>(datum_obj); ASSERT_TRUE(datum_got != nullptr); @@ -10735,6 +10791,7 @@ TEST(json_import, engineering_crs) { TEST(json_import, temporal_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"TemporalCRS\",\n" " \"name\": \"Temporal CRS\",\n" " \"datum\": {\n" @@ -10757,10 +10814,12 @@ TEST(json_import, temporal_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<TemporalCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); auto datum = crs->datum(); - auto datum_json = datum->exportToJSON((JSONFormatter::create().get())); + auto datum_json = + datum->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))); auto datum_obj = createFromUserInput(datum_json, nullptr); auto datum_got = nn_dynamic_pointer_cast<TemporalDatum>(datum_obj); ASSERT_TRUE(datum_got != nullptr); @@ -10770,6 +10829,7 @@ TEST(json_import, temporal_crs) { TEST(json_import, derived_geodetic_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DerivedGeodeticCRS\",\n" " \"name\": \"Derived geodetic CRS\",\n" " \"base_crs\": {\n" @@ -10842,13 +10902,15 @@ TEST(json_import, derived_geodetic_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<DerivedGeodeticCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, derived_geographic_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DerivedGeographicCRS\",\n" " \"name\": \"WMO Atlantic Pole\",\n" " \"base_crs\": {\n" @@ -10925,13 +10987,15 @@ TEST(json_import, derived_geographic_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<DerivedGeographicCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, derived_projected_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DerivedProjectedCRS\",\n" " \"name\": \"derived projectedCRS\",\n" " \"base_crs\": {\n" @@ -11075,13 +11139,15 @@ TEST(json_import, derived_projected_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<DerivedProjectedCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, derived_vertical_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DerivedVerticalCRS\",\n" " \"name\": \"Derived vertCRS\",\n" " \"base_crs\": {\n" @@ -11131,13 +11197,15 @@ TEST(json_import, derived_vertical_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<DerivedVerticalCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, derived_engineering_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DerivedEngineeringCRS\",\n" " \"name\": \"Derived EngineeringCRS\",\n" " \"base_crs\": {\n" @@ -11198,13 +11266,15 @@ TEST(json_import, derived_engineering_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<DerivedEngineeringCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, derived_parametric_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DerivedParametricCRS\",\n" " \"name\": \"Derived ParametricCRS\",\n" " \"base_crs\": {\n" @@ -11261,13 +11331,15 @@ TEST(json_import, derived_parametric_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<DerivedParametricCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, derived_temporal_crs) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"DerivedTemporalCRS\",\n" " \"name\": \"Derived TemporalCRS\",\n" " \"base_crs\": {\n" @@ -11321,13 +11393,15 @@ TEST(json_import, derived_temporal_crs) { auto obj = createFromUserInput(json, nullptr); auto crs = nn_dynamic_pointer_cast<DerivedTemporalCRS>(obj); ASSERT_TRUE(crs != nullptr); - EXPECT_EQ(crs->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(crs->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } // --------------------------------------------------------------------------- TEST(json_import, multiple_ids) { auto json = "{\n" + " \"$schema\": \"foo\",\n" " \"type\": \"Ellipsoid\",\n" " \"name\": \"WGS 84\",\n" " \"semi_major_axis\": 6378137,\n" @@ -11346,5 +11420,6 @@ TEST(json_import, multiple_ids) { auto obj = createFromUserInput(json, nullptr); auto ellps = nn_dynamic_pointer_cast<Ellipsoid>(obj); ASSERT_TRUE(ellps != nullptr); - EXPECT_EQ(ellps->exportToJSON((JSONFormatter::create().get())), json); + EXPECT_EQ(ellps->exportToJSON(&(JSONFormatter::create()->setSchema("foo"))), + json); } diff --git a/travis/install.sh b/travis/install.sh index 249e0f2c..b2e13c12 100755 --- a/travis/install.sh +++ b/travis/install.sh @@ -55,24 +55,24 @@ find /tmp/proj_autoconf_install_from_dist_all /tmp/proj_autoconf_install_from_dist_all/bin/projinfo EPSG:32631 -o PROJJSON -q > out.json cat out.json echo "Validating JSON" -jsonschema -i out.json /tmp/proj_autoconf_install_from_dist_all/share/proj/crsjson.schema.json && echo "Valid !" +jsonschema -i out.json /tmp/proj_autoconf_install_from_dist_all/share/proj/projjson.schema.json && echo "Valid !" /tmp/proj_autoconf_install_from_dist_all/bin/projinfo EPSG:4326+3855 -o PROJJSON -q > out.json cat out.json echo "Validating JSON" -jsonschema -i out.json /tmp/proj_autoconf_install_from_dist_all/share/proj/crsjson.schema.json && echo "Valid !" +jsonschema -i out.json /tmp/proj_autoconf_install_from_dist_all/share/proj/projjson.schema.json && echo "Valid !" /tmp/proj_autoconf_install_from_dist_all/bin/projinfo "+proj=longlat +ellps=GRS80 +nadgrids=@foo +type=crs" -o PROJJSON -q > out.json cat out.json echo "Validating JSON" -jsonschema -i out.json /tmp/proj_autoconf_install_from_dist_all/share/proj/crsjson.schema.json && echo "Valid !" +jsonschema -i out.json /tmp/proj_autoconf_install_from_dist_all/share/proj/projjson.schema.json && echo "Valid !" /tmp/proj_autoconf_install_from_dist_all/bin/projinfo @out.json -o PROJJSON -q > out2.json diff -u out.json out2.json /tmp/proj_autoconf_install_from_dist_all/bin/projinfo -s EPSG:3111 -t GDA2020 -o PROJJSON -o PROJJSON -q > out.json cat out.json echo "Validating JSON" -jsonschema -i out.json /tmp/proj_autoconf_install_from_dist_all/share/proj/crsjson.schema.json && echo "Valid !" +jsonschema -i out.json /tmp/proj_autoconf_install_from_dist_all/share/proj/projjson.schema.json && echo "Valid !" /tmp/proj_autoconf_install_from_dist_all/bin/projinfo @out.json -o PROJJSON -q > out2.json diff -u out.json out2.json |
