Class ShapeBuilder<T extends org.locationtech.spatial4j.shape.Shape,​E extends ShapeBuilder<T,​E>>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static boolean AUTO_INDEX_JTS_GEOMETRY  
      protected static boolean AUTO_VALIDATE_JTS_GEOMETRY  
      protected java.util.List<org.locationtech.jts.geom.Coordinate> coordinates  
      static double DATELINE  
      static org.locationtech.jts.geom.GeometryFactory FACTORY  
      protected static org.elasticsearch.common.geo.builders.ShapeBuilder.IntersectionOrder INTERSECTION_ORDER  
      protected static org.apache.logging.log4j.Logger LOGGER  
      protected static boolean MULTI_POLYGON_MAY_OVERLAP
      It's possible that some geometries in a MULTI* shape might overlap.
      static org.locationtech.spatial4j.context.jts.JtsSpatialContext SPATIAL_CONTEXT  
      protected boolean wrapdateline
      We're expecting some geometries might cross the dateline.
      static org.locationtech.jts.geom.Coordinate ZERO_ZERO
      coordinate at [0.0, 0.0]
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ShapeBuilder()
      default ctor
      protected ShapeBuilder​(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates)
      ctor from list of coordinates
      protected ShapeBuilder​(StreamInput in)
      ctor from serialized stream input
    • Method Summary

      Modifier and Type Method Description
      abstract java.lang.Object buildLucene()
      build lucene geometry.
      abstract T buildS4J()
      Create a new Shape from this builder.
      protected java.lang.StringBuilder contentToWKT()  
      E coordinate​(double longitude, double latitude)
      Add a new coordinate to the collection
      E coordinate​(org.locationtech.jts.geom.Coordinate coordinate)
      Add a new coordinate to the collection
      protected static java.lang.StringBuilder coordinateListToWKT​(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates)  
      protected org.locationtech.jts.geom.Coordinate[] coordinates​(boolean closed)
      Copy all coordinate to a new Array
      E coordinates​(java.util.Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)
      Add a collection of coordinates to the collection
      E coordinates​(org.locationtech.jts.geom.Coordinate... coordinates)
      Add a array of coordinates to the collection
      protected XContentBuilder coordinatesToXcontent​(XContentBuilder builder, boolean closed)
      builds an array of coordinates to a XContentBuilder
      protected static boolean debugEnabled()  
      boolean equals​(java.lang.Object o)  
      java.lang.String getWriteableName()
      Returns the name of the writeable object
      int hashCode()  
      protected static double intersection​(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2, double dateline)
      Calculate the intersection of a line segment and a vertical dateline.
      protected static int intersections​(double dateline, ShapeBuilder.Edge[] edges)
      Calculate all intersections of line segments and a vertical line.
      protected org.locationtech.spatial4j.shape.jts.JtsGeometry jtsGeometry​(org.locationtech.jts.geom.Geometry geom)  
      abstract int numDimensions()
      tracks number of dimensions for this shape
      static ShapeBuilder parse​(XContentParser parser)
      Deprecated.
      this method will be removed in a future version; use ShapeParser.parse instead
      protected static org.locationtech.jts.geom.Coordinate readFromStream​(StreamInput in)  
      protected static org.locationtech.jts.geom.Coordinate shift​(org.locationtech.jts.geom.Coordinate coordinate, double dateline)  
      java.lang.String toString()  
      java.lang.String toWKT()  
      protected static XContentBuilder toXContent​(XContentBuilder builder, org.locationtech.jts.geom.Coordinate coordinate)  
      abstract GeoShapeType type()
      get the shapes type
      protected static void writeCoordinateTo​(org.locationtech.jts.geom.Coordinate coordinate, StreamOutput out)  
      void writeTo​(StreamOutput out)
      Write this into the StreamOutput.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LOGGER

        protected static final org.apache.logging.log4j.Logger LOGGER
      • coordinates

        protected final java.util.List<org.locationtech.jts.geom.Coordinate> coordinates
      • ZERO_ZERO

        public static final org.locationtech.jts.geom.Coordinate ZERO_ZERO
        coordinate at [0.0, 0.0]
      • SPATIAL_CONTEXT

        public static final org.locationtech.spatial4j.context.jts.JtsSpatialContext SPATIAL_CONTEXT
      • FACTORY

        public static final org.locationtech.jts.geom.GeometryFactory FACTORY
      • wrapdateline

        protected final boolean wrapdateline
        We're expecting some geometries might cross the dateline.
      • MULTI_POLYGON_MAY_OVERLAP

        protected static final boolean MULTI_POLYGON_MAY_OVERLAP
        It's possible that some geometries in a MULTI* shape might overlap. With the possible exception of GeometryCollection, this normally isn't allowed.
        See Also:
        Constant Field Values
      • AUTO_VALIDATE_JTS_GEOMETRY

        protected static final boolean AUTO_VALIDATE_JTS_GEOMETRY
        See Also:
        JtsGeometry.validate(), Constant Field Values
      • AUTO_INDEX_JTS_GEOMETRY

        protected static final boolean AUTO_INDEX_JTS_GEOMETRY
        See Also:
        JtsGeometry.index(), Constant Field Values
      • INTERSECTION_ORDER

        protected static final org.elasticsearch.common.geo.builders.ShapeBuilder.IntersectionOrder INTERSECTION_ORDER
    • Constructor Detail

      • ShapeBuilder

        protected ShapeBuilder()
        default ctor
      • ShapeBuilder

        protected ShapeBuilder​(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates)
        ctor from list of coordinates
      • ShapeBuilder

        protected ShapeBuilder​(StreamInput in)
                        throws java.io.IOException
        ctor from serialized stream input
        Throws:
        java.io.IOException
    • Method Detail

      • readFromStream

        protected static org.locationtech.jts.geom.Coordinate readFromStream​(StreamInput in)
                                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCoordinateTo

        protected static void writeCoordinateTo​(org.locationtech.jts.geom.Coordinate coordinate,
                                                StreamOutput out)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • coordinate

        public E coordinate​(double longitude,
                            double latitude)
        Add a new coordinate to the collection
        Parameters:
        longitude - longitude of the coordinate
        latitude - latitude of the coordinate
        Returns:
        this
      • coordinate

        public E coordinate​(org.locationtech.jts.geom.Coordinate coordinate)
        Add a new coordinate to the collection
        Parameters:
        coordinate - coordinate of the point
        Returns:
        this
      • coordinates

        public E coordinates​(org.locationtech.jts.geom.Coordinate... coordinates)
        Add a array of coordinates to the collection
        Parameters:
        coordinates - array of Coordinates to add
        Returns:
        this
      • coordinates

        public E coordinates​(java.util.Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)
        Add a collection of coordinates to the collection
        Parameters:
        coordinates - array of Coordinates to add
        Returns:
        this
      • coordinates

        protected org.locationtech.jts.geom.Coordinate[] coordinates​(boolean closed)
        Copy all coordinate to a new Array
        Parameters:
        closed - if set to true the first point of the array is repeated as last element
        Returns:
        Array of coordinates
      • jtsGeometry

        protected org.locationtech.spatial4j.shape.jts.JtsGeometry jtsGeometry​(org.locationtech.jts.geom.Geometry geom)
      • buildS4J

        public abstract T buildS4J()
        Create a new Shape from this builder. Since calling this method could change the defined shape. (by inserting new coordinates or change the position of points) the builder looses its validity. So this method should only be called once on a builder
        Returns:
        new Shape defined by the builder
      • buildLucene

        public abstract java.lang.Object buildLucene()
        build lucene geometry.
        Returns:
        GeoPoint, double[][], Line, Line[], Polygon, Polygon[], Rectangle, Object[]
      • shift

        protected static org.locationtech.jts.geom.Coordinate shift​(org.locationtech.jts.geom.Coordinate coordinate,
                                                                    double dateline)
      • type

        public abstract GeoShapeType type()
        get the shapes type
        Returns:
        type of the shape
      • numDimensions

        public abstract int numDimensions()
        tracks number of dimensions for this shape
      • intersection

        protected static final double intersection​(org.locationtech.jts.geom.Coordinate p1,
                                                   org.locationtech.jts.geom.Coordinate p2,
                                                   double dateline)
        Calculate the intersection of a line segment and a vertical dateline.
        Parameters:
        p1 - start-point of the line segment
        p2 - end-point of the line segment
        dateline - x-coordinate of the vertical dateline
        Returns:
        position of the intersection in the open range (0..1] if the line segment intersects with the line segment. Otherwise this method returns Double.NaN
      • intersections

        protected static int intersections​(double dateline,
                                           ShapeBuilder.Edge[] edges)
        Calculate all intersections of line segments and a vertical line. The Array of edges will be ordered asc by the y-coordinate of the intersections of edges.
        Parameters:
        dateline - x-coordinate of the dateline
        edges - set of edges that may intersect with the dateline
        Returns:
        number of intersecting edges
      • contentToWKT

        protected java.lang.StringBuilder contentToWKT()
      • toWKT

        public java.lang.String toWKT()
      • coordinateListToWKT

        protected static java.lang.StringBuilder coordinateListToWKT​(java.util.List<org.locationtech.jts.geom.Coordinate> coordinates)
      • debugEnabled

        protected static final boolean debugEnabled()
      • parse

        @Deprecated
        public static ShapeBuilder parse​(XContentParser parser)
                                  throws java.io.IOException
        Deprecated.
        this method will be removed in a future version; use ShapeParser.parse instead
        Throws:
        java.io.IOException
      • toXContent

        protected static XContentBuilder toXContent​(XContentBuilder builder,
                                                    org.locationtech.jts.geom.Coordinate coordinate)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • coordinatesToXcontent

        protected XContentBuilder coordinatesToXcontent​(XContentBuilder builder,
                                                        boolean closed)
                                                 throws java.io.IOException
        builds an array of coordinates to a XContentBuilder
        Parameters:
        builder - builder to use
        closed - repeat the first point at the end of the array if it's not already defines as last element of the array
        Returns:
        the builder
        Throws:
        java.io.IOException
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object