Class GeomBuilder

java.lang.Object
org.oscim.utils.geom.GeomBuilder

public class GeomBuilder extends Object
Builder for geometry objects.

Example usage:

 
 GeometryBuilder gb = new GeometryBuilder();

 // create array two 2d points and turn into a line string
 gb.points(1,2,3,4,5,6).toLineString();

 // build a polygon with holes
 gb.points(0,0,10,0,10,10,0,10,0,0).ring()
   .points(4,4,6,4,6,6,4,6,4,4).ring()
   .toPolygon();

 
 

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a builder with the default geometry factory.
    GeomBuilder(int srid)
    Constructs a builder with a specific srid for geometry objects.
    GeomBuilder(org.locationtech.jts.geom.GeometryFactory factory)
    Constructs a builder with an explicit geometry factory.
  • Method Summary

    Modifier and Type
    Method
    Description
    buffer(double amt)
    Buffers the geometry at the top of the geometry stack, and places the result back on the geometry stack.
    Creates a GeometryCollection from all Geometries on the geometry stack and places the result back on the geometry stack.
    org.locationtech.jts.geom.Geometry
    get()
    Consumes the top of the geometry stack.
    Creates a LineString from all points on the coordinate stack, and places the result on the geometry stack.
    Creates a MultiLineString from all LineStrings on the geometry stack and places the result back on the geometry stack.
    Creates a MultiPoint from all coordinates on the coordinate stack, plaching the result back on the geometry stack.
    Creates a MultiPolygon from all Polygons on the geometry stack and places the result back on the geometry stack.
    Creates a Point from the last point on the coordinate stack, and places the result on the geometry stack.
    point(double x, double y)
    Adds a 2d point to the coordinate stack.
    points(double... ord)
    Adds an array of 2d points to the coordinate stack.
    pointsz(double... ord)
    Adds an array of 3d points to the coordinate stack.
    pointz(double x, double y, double z)
    Adds a 3d point to the coordinate stack.
    Creates a Polygon from all LinearRings on the geometry stack and places the result back on the geometry stack.
    Creates a LinearRing from all points on the coordinate stack, and places the result on the geometry stack.
    org.locationtech.jts.geom.GeometryCollection
    Builds and returns a GEometryCollection.
    org.locationtech.jts.geom.LinearRing
    Builds and returns a LineString.
    org.locationtech.jts.geom.LineString
    Builds and returns a LineString.
    org.locationtech.jts.geom.MultiLineString
    Builds and returns a MultiLineString.
    org.locationtech.jts.geom.MultiPoint
    Builds and returns a MultiPoint.
    org.locationtech.jts.geom.MultiPolygon
    Builds and returns a MultiPolygon.
    org.locationtech.jts.geom.Point
    Builds and returns a Point.
    org.locationtech.jts.geom.Polygon
    Builds and returns a Polygon.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GeomBuilder

      public GeomBuilder()
      Constructs a builder with the default geometry factory.
    • GeomBuilder

      public GeomBuilder(org.locationtech.jts.geom.GeometryFactory factory)
      Constructs a builder with an explicit geometry factory.
    • GeomBuilder

      public GeomBuilder(int srid)
      Constructs a builder with a specific srid for geometry objects.
  • Method Details

    • point

      public GeomBuilder point(double x, double y)
      Adds a 2d point to the coordinate stack.
    • pointz

      public GeomBuilder pointz(double x, double y, double z)
      Adds a 3d point to the coordinate stack.
    • points

      public GeomBuilder points(double... ord)
      Adds an array of 2d points to the coordinate stack.
    • pointsz

      public GeomBuilder pointsz(double... ord)
      Adds an array of 3d points to the coordinate stack.
    • point

      public GeomBuilder point()
      Creates a Point from the last point on the coordinate stack, and places the result on the geometry stack.
    • lineString

      public GeomBuilder lineString()
      Creates a LineString from all points on the coordinate stack, and places the result on the geometry stack.
    • ring

      public GeomBuilder ring()
      Creates a LinearRing from all points on the coordinate stack, and places the result on the geometry stack.

      If the first and last coordinate on the point stack are not equal an additional point will be added.

    • polygon

      public GeomBuilder polygon()
      Creates a Polygon from all LinearRings on the geometry stack and places the result back on the geometry stack.
    • multiPoint

      public GeomBuilder multiPoint()
      Creates a MultiPoint from all coordinates on the coordinate stack, plaching the result back on the geometry stack.

      If the coordinate stack is empty this method will consume all Point geometries on the geometry stack.

    • multiLineString

      public GeomBuilder multiLineString()
      Creates a MultiLineString from all LineStrings on the geometry stack and places the result back on the geometry stack.
    • multiPolygon

      public GeomBuilder multiPolygon()
      Creates a MultiPolygon from all Polygons on the geometry stack and places the result back on the geometry stack.
    • collection

      public GeomBuilder collection()
      Creates a GeometryCollection from all Geometries on the geometry stack and places the result back on the geometry stack.
    • buffer

      public GeomBuilder buffer(double amt)
      Buffers the geometry at the top of the geometry stack, and places the result back on the geometry stack.
    • get

      public org.locationtech.jts.geom.Geometry get()
      Consumes the top of the geometry stack.
    • toPoint

      public org.locationtech.jts.geom.Point toPoint()
      Builds and returns a Point.

      This method is equivalent to:

         (Point) point().get();
       

    • toLineString

      public org.locationtech.jts.geom.LineString toLineString()
      Builds and returns a LineString.

      This method is equivalent to:

         (LineString) lineString().get();
       

    • toLinearRing

      public org.locationtech.jts.geom.LinearRing toLinearRing()
      Builds and returns a LineString.

      This method is equivalent to:

         (LinearRing) ring().get();
       

    • toPolygon

      public org.locationtech.jts.geom.Polygon toPolygon()
      Builds and returns a Polygon.

      This method is equivalent to:

         (Polygon) polygon().get();
       

    • toMultiPoint

      public org.locationtech.jts.geom.MultiPoint toMultiPoint()
      Builds and returns a MultiPoint.

      This method is equivalent to:

         (MultiPoint) multiPoint().get();
       

    • toMultiLineString

      public org.locationtech.jts.geom.MultiLineString toMultiLineString()
      Builds and returns a MultiLineString.

      This method is equivalent to:

         (MultiLineString) multiLineString().get();
       

    • toMultiPolygon

      public org.locationtech.jts.geom.MultiPolygon toMultiPolygon()
      Builds and returns a MultiPolygon.

      This method is equivalent to:

         (MultiPolygon) multiPolygon().get();
       

    • toCollection

      public org.locationtech.jts.geom.GeometryCollection toCollection()
      Builds and returns a GEometryCollection.

      This method is equivalent to:

         (GeometryCollection) collection().get();