Skip to content

Commit

Permalink
projinfo: document PROJJSON output, and add single-line output capabi…
Browse files Browse the repository at this point in the history
…lity
  • Loading branch information
rouault committed Aug 9, 2019
1 parent f0d766e commit 124eb22
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 6 deletions.
63 changes: 59 additions & 4 deletions docs/source/apps/projinfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +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*)

{object_reference} is a filename preceded by the '@' character. The
file referenced by the {object_reference} must contain a valid
Expand All @@ -54,7 +55,8 @@ Description

:program:`projinfo` is a program that can query information on a geodetic object,
coordinate reference system (CRS) or coordinate operation, when the ``-s`` and ``-t``
options are specified, and display it under different formats (PROJ string, WKT string).
options are specified, and display it under different formats (PROJ string, WKT string
or PROJJSON string).

It can also be used to query coordinate operations available between two CRS.

Expand All @@ -69,7 +71,7 @@ The following control parameters can appear in any order:
.. option:: -o formats

formats is a comma separated combination of:
``all``, ``default``, ``PROJ``, ``WKT_ALL``, ``WKT2_2015``, ``WKT2_2018``, ``WKT1_GDAL``, ``WKT1_ESRI``.
``all``, ``default``, ``PROJ``, ``WKT_ALL``, ``WKT2_2015``, ``WKT2_2018``, ``WKT1_GDAL``, ``WKT1_ESRI``, ``PROJJSON``.

Except ``all`` and ``default``, other formats can be preceded by ``-`` to disable them.

Expand All @@ -90,7 +92,7 @@ The following control parameters can appear in any order:
.. option:: -q

Turn on quiet mode. Quiet mode is only available for queries on single objects,
and only one output format is selected. In that mode, only the PROJ or WKT
and only one output format is selected. In that mode, only the PROJ, WKT or PROJJSON
string is displayed, without other introduction output. The output is then
potentially compatible of being piped in other utilities.

Expand Down Expand Up @@ -223,7 +225,7 @@ The following control parameters can appear in any order:

.. option:: --single-line

Output WKT strings on a single line, instead of multiple intended lines by
Output WKT or PROJJSON strings on a single line, instead of multiple intended lines by
default.

Examples
Expand Down Expand Up @@ -320,6 +322,59 @@ Output:
BBOX[23.81,-129.17,49.38,-65.69]],
ID["DERIVED_FROM(EPSG)",1241]]

3. Export an object as a PROJJSON string

.. code-block:: console
projinfo GDA94 -o PROJJSON -q
Output:

.. code-block:: json
{
"type": "GeographicCRS",
"name": "GDA94",
"datum": {
"type": "GeodeticReferenceFrame",
"name": "Geocentric Datum of Australia 1994",
"ellipsoid": {
"name": "GRS 1980",
"semi_major_axis": 6378137,
"inverse_flattening": 298.257222101
}
},
"coordinate_system": {
"subtype": "ellipsoidal",
"axis": [
{
"name": "Geodetic latitude",
"abbreviation": "Lat",
"direction": "north",
"unit": "degree"
},
{
"name": "Geodetic longitude",
"abbreviation": "Lon",
"direction": "east",
"unit": "degree"
}
]
},
"area": "Australia - GDA",
"bbox": {
"south_latitude": -60.56,
"west_longitude": 93.41,
"north_latitude": -8.47,
"east_longitude": 173.35
},
"id": {
"authority": "EPSG",
"code": 4283
}
}
.. only:: man

See also
Expand Down
7 changes: 5 additions & 2 deletions src/apps/projinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,11 @@ static void outputObject(
if (!outputOpt.quiet) {
std::cout << "PROJJSON:" << std::endl;
}
auto jsonString(JSONExportable->exportToJSON(
JSONFormatter::create(dbContext).get()));
auto formatter(JSONFormatter::create(dbContext));
if (outputOpt.singleLine) {
formatter->setMultiLine(false);
}
auto jsonString(JSONExportable->exportToJSON(formatter.get()));
if (outputOpt.c_ify) {
jsonString = c_ify_string(jsonString);
}
Expand Down

0 comments on commit 124eb22

Please sign in to comment.