Interface Geometry

All Superinterfaces:
Cloneable, Serializable
All Known Subinterfaces:
AnnotationTypeGeometry, Curve, EllipseTypeGeometry, LineTypeGeometry, PointTypeGeometry, PolygonTypeGeometry, Surface
All Known Implementing Classes:
Annotation, Complex, DefaultGeometry, Ellipse, GeometryCollection, Line, LinearRing, LineString, MultiAnnotation, MultiCurve, MultiLineString, MultiPoint, MultiPolygon, MultiSurface, OrientedRectangle, OrientedRectangle.Double, OrientedRectangle.Float, Point, Point.Double, Point.Float, PointM, Polygon, Rectangle, Rectangle.Double, Rectangle.Float

public interface Geometry extends Cloneable, Serializable
This interface is implemented by all geometry classes in JMap.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final short
    Constant for geometry id of type Annotation.
    static final short
    Constant for geometry id of type Complex.
    static final short
    Constant for geometry id of type Ellipse.
    static final short
    Constant for geometry id of type Line.
    static final short
    Constant for geometry id of type LinearRing.
    static final short
    Constant for geometry id of type LineString.
    static final short
    Constant for geometry id of type MultiAnnotation.
    static final short
    Constant for geometry id of type MultiLineString.
    static final short
    Constant for geometry id of type MultiPoint.
    static final short
    Constant for geometry id of type MultiPolygon.
    static final short
    Constant for geometry id of type Point.
    static final short
    Constant for geometry id of type Polygon.
    static final short
    Constant for geometry id of type Rectangle.
  • Method Summary

    Modifier and Type
    Method
    Description
    default double
    Returns the geometry area.
     
    Returns the boundary of this geometry as a line string.
    Clones this geometry.
    void
    Updates the geometry bounds from the current geometry.
    Returns the minimum bounding rectangle of this geometry.
    This method returns a point that is typically centered on the geometry.
    short
    Returns the geometry class id.
    int
    Returns the geometry type for this geometry.
    default double
    Returns the geometry length.
    Returns this geometry as an array of Point.
    int
    Returns an approximation in bytes of the memory used by this geometry.
    boolean
    Tests if this geometry is equal to the argument, on a topological point of view
    it means that they represent the same geometry, even if it is described differently (direction of the rings, order of the rings)
    it does not remove additional points on lineString (3 points aligned), one must use smoother.removeExtraPoints() before in order to achieve that.
    boolean
    spatiallyEquals(Geometry geometry, PrecisionModel precisionModel)
    Tests if this geometry is equal to the argument, on a topological point of view.
    Returns information about the current geometry.
    Creates a clone of the current geometry and returns the new instance transformed with the specified geometry transformation.
    The returned geometry can be of any geometry types after the transformation.
    void
    translate(double dx, double dy)
    Translate this geometry with the specified values.
  • Field Details

  • Method Details

    • getBounds

      Rectangle getBounds()
      Returns the minimum bounding rectangle of this geometry.
      Returns:
      the bounding box of this geometry.
    • serialize

      Point[] serialize()
      Returns this geometry as an array of Point.
      Returns:
      this geometry as an array of Point.
    • clone

      Geometry clone()
      Clones this geometry.
      Returns:
      a deep copy of the current geometry.
    • spatiallyEquals

      boolean spatiallyEquals(Geometry geometry)
      Tests if this geometry is equal to the argument, on a topological point of view
      it means that they represent the same geometry, even if it is described differently (direction of the rings, order of the rings)
      it does not remove additional points on lineString (3 points aligned), one must use smoother.removeExtraPoints() before in order to achieve that.
      Parameters:
      geometry - the geometry to be tested.
      Returns:
      whether both geometries are spatial equals.
    • spatiallyEquals

      boolean spatiallyEquals(Geometry geometry, PrecisionModel precisionModel)
      Tests if this geometry is equal to the argument, on a topological point of view.
      Parameters:
      geometry - the geometry to be tested.
      precisionModel - the precision model to use while comparing geometries.
      Returns:
      whether both geometries are spatially equals.
    • boundary

      Geometry boundary()
      Returns the boundary of this geometry as a line string.
      Returns:
      a line string which defines the boundary of the current geometry.
    • toString

      String toString()
      Returns information about the current geometry.
      Overrides:
      toString in class Object
      Returns:
      information about the current geometry.
    • translate

      void translate(double dx, double dy)
      Translate this geometry with the specified values.
      Parameters:
      dx - translation on the X-axis.
      dy - translation on the Y-axis.
    • sizeOf

      int sizeOf()
      Returns an approximation in bytes of the memory used by this geometry.
      Returns:
      the memory used by this geometry.
    • getGeometryId

      short getGeometryId()
      Returns the geometry class id. This method is useful for geometry serialization.
      Returns:
      the geometry id.
    • getGeometryType

      int getGeometryType()
      Returns the geometry type for this geometry.
      Returns:
      the geometry type.
      See Also:
    • transform

      Geometry transform(Transformation tr)
      Creates a clone of the current geometry and returns the new instance transformed with the specified geometry transformation.
      The returned geometry can be of any geometry types after the transformation.
      Parameters:
      tr - the transformation to apply.
      Returns:
      the newly created and transformed geometry instance.
    • createBounds

      void createBounds()
      Updates the geometry bounds from the current geometry.
    • getCenteredPoint

      Point getCenteredPoint()
      This method returns a point that is typically centered on the geometry. If the geometry is a point, the point is returned. If it is a line, a point on the curve interpolated at 50% is returned. If the geometry is a surface, the centroid is returned if it is inside the polygon, if not, a point inside the polygon (but likely not exactly in the center) will be returned. If the geometry is a collection, the method is called on the first part of the collection.
      Returns:
      a point likely at the center of the geometry
    • asText

      String asText()
    • area

      default double area()
      Returns the geometry area. If the geometry is not a surface, then 0 shall be returned.
      Returns:
      the geometry area.
    • length

      default double length()
      Returns the geometry length. If the geometry is a surface, then the geometry perimeter shall be returned.
      Returns:
      the geometry length.