Class GeoJsonUtils.GeoJsonTarget

java.lang.Object
org.h2.util.geometry.GeometryUtils.Target
org.h2.util.geometry.GeoJsonUtils.GeoJsonTarget
Enclosing class:
GeoJsonUtils

public static final class GeoJsonUtils.GeoJsonTarget extends GeometryUtils.Target
Converter output target that writes a GeoJson.
  • Field Details

    • output

      private final JSONByteArrayTarget output
    • dimensionSystem

      private final int dimensionSystem
    • type

      private int type
    • inMulti

      private boolean inMulti
    • inMultiLine

      private boolean inMultiLine
    • wasEmpty

      private boolean wasEmpty
  • Constructor Details

    • GeoJsonTarget

      public GeoJsonTarget(JSONByteArrayTarget output, int dimensionSystem)
      Creates new GeoJson output target.
      Parameters:
      output - output JSON target
      dimensionSystem - dimension system to use
  • Method Details

    • startPoint

      protected void startPoint()
      Description copied from class: GeometryUtils.Target
      Invoked before writing a POINT.
      Overrides:
      startPoint in class GeometryUtils.Target
    • startLineString

      protected void startLineString(int numPoints)
      Description copied from class: GeometryUtils.Target
      Invoked before writing a LINESTRING.
      Overrides:
      startLineString in class GeometryUtils.Target
      Parameters:
      numPoints - number of points in line string
    • startPolygon

      protected void startPolygon(int numInner, int numPoints)
      Description copied from class: GeometryUtils.Target
      Invoked before writing a POLYGON. If polygon is empty, both parameters are 0.
      Overrides:
      startPolygon in class GeometryUtils.Target
      Parameters:
      numInner - number of inner polygons
      numPoints - number of points in outer polygon
    • startPolygonInner

      protected void startPolygonInner(int numInner)
      Description copied from class: GeometryUtils.Target
      Invoked before writing an inner polygon in POLYGON.
      Overrides:
      startPolygonInner in class GeometryUtils.Target
      Parameters:
      numInner - number of points in inner polygon
    • endNonEmptyPolygon

      protected void endNonEmptyPolygon()
      Description copied from class: GeometryUtils.Target
      Invoked after writing of non-empty POLYGON.
      Overrides:
      endNonEmptyPolygon in class GeometryUtils.Target
    • startCollection

      protected void startCollection(int type, int numItems)
      Description copied from class: GeometryUtils.Target
      Invoked before writing of a collection.
      Overrides:
      startCollection in class GeometryUtils.Target
      Parameters:
      type - type of collection, one of GeometryUtils.MULTI_POINT, GeometryUtils.MULTI_LINE_STRING, GeometryUtils.MULTI_POLYGON, GeometryUtils.GEOMETRY_COLLECTION
      numItems - number of items in this collection
    • startCollectionItem

      protected GeometryUtils.Target startCollectionItem(int index, int total)
      Description copied from class: GeometryUtils.Target
      Invoked before writing of a collection item.
      Overrides:
      startCollectionItem in class GeometryUtils.Target
      Parameters:
      index - 0-based index of this item in the collection
      total - total number of items in the collection
      Returns:
      output target that should be used for processing of this collection item. May return this target or an custom sub-target.
    • endObject

      protected void endObject(int type)
      Description copied from class: GeometryUtils.Target
      Invoked after writing of the object.
      Overrides:
      endObject in class GeometryUtils.Target
      Parameters:
      type - type of the object
    • writeHeader

      private void writeHeader(int type)
    • addCoordinate

      protected void addCoordinate(double x, double y, double z, double m, int index, int total)
      Description copied from class: GeometryUtils.Target
      Invoked to add a coordinate to a geometry.
      Specified by:
      addCoordinate in class GeometryUtils.Target
      Parameters:
      x - X coordinate
      y - Y coordinate
      z - Z coordinate (NaN if not used)
      m - M coordinate (NaN if not used)
      index - 0-based index of coordinate in the current sequence
      total - total number of coordinates in the current sequence
    • writeStartObject

      private void writeStartObject(int type)
    • writeDouble

      private void writeDouble(double v)