Skip to content

geojson: consider configurable serialization #266

@sargunv

Description

@sargunv

The specification says:

The size of a GeoJSON text in bytes is a major interoperability
consideration, and precision of coordinate values has a large impact
on the size of texts. A GeoJSON text containing many detailed
Polygons can be inflated almost by a factor of two by increasing
coordinate precision from 6 to 15 decimal places. For geographic
coordinates with units of degrees, 6 decimal places (a default common
in, e.g., sprintf) amounts to about 10 centimeters, a precision well
within that of current GPS systems. Implementations should consider
the cost of using a greater precision than necessary.

Things to investigate:

  • Does kotlinx-serialization let us control the precision of Double serialization?
    • Yes, but only with a custom serializer for the field
  • Does it make sense to expose some configurable serialization (class GeoJson instead of object GeoJson)? Other than coordinate precision, I could see this being used to:
    • register additional default serializers for feature properties
    • configure strictness of coordinate validate (allow / disallow invalid latlon)
    • configure whether foreign keys are allowed, etc.
    • allow lenient json (comments, trailing comma, Infinity, NaN)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions