pretty_persistable_reference

geodetic_engine.persistablereference.pretty_persistable_reference(payload, *, indent=2, wkt=False)[source]

Lay a persistableReference out for reading.

By default the result is the reference’s JSON, indented, with its members in the order the payload states them and each WKT a single string, so it is still JSON. With wkt each embedded ESRI WKT is laid out over indented lines beneath its key as well. Only whitespace changes either way, but the second is no longer JSON: it is for reading, and the verbatim payload is what to store or send.

Parameters:
  • payload (str) – The reference, plain or URL-encoded JSON.

  • indent (int, default: 2) – Spaces per level of nesting, of the JSON and the WKT alike.

  • wkt (bool, default: False) – Lay the embedded WKT out over indented lines. A WKT that does not parse is left as the string it is.

Return type:

str

Returns:

The laid-out text.

Raises:

MalformedReferenceError – If the payload is not a JSON object.

Example

>>> print(pretty_persistable_reference(
...     '{"type":"LBC","wkt":"GEOGCS[\\"a\\",DATUM[\\"b\\",'
...     'SPHEROID[\\"c\\",1.0,2.0]]]"}',
...     wkt=True,
... ))
{
  "type": "LBC",
  "wkt":
    GEOGCS["a",
      DATUM["b",
        SPHEROID["c",1.0,2.0]]]
}