Package com.kheops.jmap.spatial
Class Rectangle
java.lang.Object
com.kheops.jmap.spatial.DefaultGeometry
com.kheops.jmap.spatial.Rectangle
- All Implemented Interfaces:
Geometry,Surface,Serializable,Cloneable
- Direct Known Subclasses:
Rectangle.Double,Rectangle.Float
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final class -
Field Summary
FieldsFields inherited from interface com.kheops.jmap.spatial.Geometry
GEOMETRY_ANNOTATION, GEOMETRY_COMPLEX, GEOMETRY_ELLIPSE, GEOMETRY_LINE, GEOMETRY_LINEAR_RING, GEOMETRY_LINESTRING, GEOMETRY_MULTI_ANNOTATION, GEOMETRY_MULTI_LINESTRING, GEOMETRY_MULTI_POINT, GEOMETRY_MULTI_POLYGON, GEOMETRY_POINT, GEOMETRY_POLYGON, GEOMETRY_RECTANGLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionModifies this rectangle so that it is equal to the sum of the two rectangles.static RectangleAdds the second rectangle to the first rectangle specified.doublearea()Computes and returns the surface area.asText()Returns this geometry encoded using the Well-Known Text (WKT) standard.boundary()Returns the boundary of this geometry as a line string.centroid()Returns the centroid of the current surface.abstract Rectangleclone()Clones this geometry.booleancontains(double x, double y) booleancontains(double x, double y, double tolerance) booleanbooleancontains(Point coord, PrecisionModel precisionModel) static RectanglevoidUpdates the geometry bounds from the current geometry.booleanReturns the minimum bounding rectangle of this geometry.This method returns a point that is typically centered on the geometry.getCoord()shortReturns the geometry class id.intReturns the geometry type for this geometry.abstract doubleabstract doublegetMaxX()abstract doublegetMaxY()abstract doublegetMinX()abstract doublegetMinY()abstract doublegetWidth()inflate(double factor) static Geometryintersection(Geometry geo, Rectangle rect) static Geometryintersection(Geometry geo, Rectangle rect, PrecisionModel precisionModel) intersection(Rectangle rect) static booleanintersects(LineString l, Rectangle rect, PrecisionModel precisionModel) fast intersects test (faster than the one for geometries in general)static booleanintersects(Point p, Rectangle rect) fast intersects test (faster than the one for geometries in general)static booleanintersects(Point p, Rectangle rect, PrecisionModel precisionModel) fast intersects test (faster than the one for geometries in general)static booleanintersects(Polygon poly, Rectangle rect, PrecisionModel precisionModel) fast intersects test (faster than the one for geometries in general)booleanintersects(Rectangle rect) static booleanintersects(Rectangle rect, double x, double y, double width, double height) static booleanintersects(Rectangle rect, double x, double y, double width, double height, PrecisionModel precisionModel) booleanintersects(Rectangle rect, PrecisionModel precisionModel) doublelength()Returns the geometry length.Returns a point that is located in the interior of this surface geometry.Point[]Returns this geometry as an array of Point.voidSets the new bounds of this rectangle.voidsetCoord(double x, double y) voidabstract voidsetHeight(double height) abstract voidsetWidth(double width) booleanspatiallyEquals(Geometry geometry, PrecisionModel precisionModel) Tests if this geometry is equal to the argument, on a topological point of view.toPolygon(double maxNodeDistance) Creates a polygon from the rectangle, inserting nodes along the sides of the rectangle so that the maximum distance between 2 nodes is less than the specified distance.Creates a clone of the current rectangle and returns the new instance tranformed with the specified geometry transformation.
The returned geometry can be of any geometry types after the transformation.voidtranslate(double dx, double dy) Translate this geometry with the specified values.static RectangleCreates a clone of the specified rectangle et translates it by the specified values.Methods inherited from class com.kheops.jmap.spatial.DefaultGeometry
spatiallyEqualsMethods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.kheops.jmap.spatial.Geometry
sizeOf, spatiallyEquals, toString
-
Field Details
-
coord
-
-
Constructor Details
-
Rectangle
protected Rectangle()
-
-
Method Details
-
createBigRectangle
-
pointOnSurface
Description copied from interface:SurfaceReturns a point that is located in the interior of this surface geometry.- Specified by:
pointOnSurfacein interfaceSurface- Returns:
- a point on thge surface.
-
getCenteredPoint
Description copied from interface:GeometryThis 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.- Specified by:
getCenteredPointin interfaceGeometry- Returns:
- a point likely at the center of the geometry
- See Also:
-
getHeight
public abstract double getHeight()- Returns:
-
getCoord
- Returns:
- Bottom-left coordinates
-
getWidth
public abstract double getWidth()- Returns:
-
setHeight
public abstract void setHeight(double height) - Parameters:
height-
-
clone
Description copied from class:DefaultGeometryClones this geometry.- Specified by:
clonein interfaceGeometry- Specified by:
clonein classDefaultGeometry- Returns:
- a deep copy of the current geometry.
-
setCoord
public void setCoord(double x, double y) - Parameters:
x-y-
-
setCoord
- Parameters:
coord-
-
setWidth
public abstract void setWidth(double width) - Parameters:
width-
-
getMinX
public abstract double getMinX() -
getMinY
public abstract double getMinY() -
getMaxX
public abstract double getMaxX() -
getMaxY
public abstract double getMaxY() -
createBounds
public void createBounds()Description copied from interface:GeometryUpdates the geometry bounds from the current geometry.- Specified by:
createBoundsin interfaceGeometry
-
getBounds
Description copied from interface:GeometryReturns the minimum bounding rectangle of this geometry. -
setBounds
Sets the new bounds of this rectangle.- Parameters:
rect- the new bounds to set.
-
area
public double area()Description copied from interface:SurfaceComputes and returns the surface area. -
length
public double length()Description copied from interface:GeometryReturns the geometry length. If the geometry is a surface, then the geometry perimeter shall be returned. -
centroid
Description copied from interface:SurfaceReturns the centroid of the current surface. -
add
Modifies this rectangle so that it is equal to the sum of the two rectangles. The result contains the two rectangles entirely.- Parameters:
rect- the rectangle to add- Returns:
- the modified rectangle
-
intersects
-
intersects
-
intersects
-
intersects
public static boolean intersects(Rectangle rect, double x, double y, double width, double height, PrecisionModel precisionModel) -
intersection
-
equals
-
spatiallyEquals
Description copied from interface:GeometryTests if this geometry is equal to the argument, on a topological point of view.- Specified by:
spatiallyEqualsin interfaceGeometry- Parameters:
geometry- the geometry to be tested.precisionModel- the precision model to use while comparing geometries.- Returns:
- whether both geometries are spatially equals.
-
contains
-
contains
-
contains
public boolean contains(double x, double y) -
contains
public boolean contains(double x, double y, double tolerance) -
translate
public void translate(double dx, double dy) Description copied from interface:GeometryTranslate this geometry with the specified values. -
inflate
-
add
Adds the second rectangle to the first rectangle specified. If one of the rectangle is null, the other non-null rectangle is returned. If both rectangles are null, null is returned.- Parameters:
r1- the first rectangler2- the second rectangle- Returns:
- the addition of both rectangles.
-
translate
Creates a clone of the specified rectangle et translates it by the specified values.- Parameters:
rect- the rectangle to translate.dx- the value to add to the X coordinate.dy- the value to add to the Y coordinate.- Returns:
- a new rectangle initialized using the specified rectangle and translated by the specified values.
-
intersects
fast intersects test (faster than the one for geometries in general) -
intersects
fast intersects test (faster than the one for geometries in general)- Parameters:
p-rect-precisionModel-- Returns:
-
intersects
fast intersects test (faster than the one for geometries in general)- Parameters:
l-rect-precisionModel-- Returns:
-
intersects
fast intersects test (faster than the one for geometries in general)- Parameters:
poly-rect-precisionModel-- Returns:
-
intersection
-
intersection
-
toAwtRectangle
-
getGeometryId
public short getGeometryId()Description copied from interface:GeometryReturns the geometry class id. This method is useful for geometry serialization.- Specified by:
getGeometryIdin interfaceGeometry- Returns:
- a new Polygon
-
getGeometryType
public int getGeometryType()Description copied from interface:GeometryReturns the geometry type for this geometry.- Specified by:
getGeometryTypein interfaceGeometry- Returns:
- the geometry type.
- See Also:
-
transform
Creates a clone of the current rectangle and returns the new instance tranformed with the specified geometry transformation.
The returned geometry can be of any geometry types after the transformation. -
toPolygon
-
toPolygon
Creates a polygon from the rectangle, inserting nodes along the sides of the rectangle so that the maximum distance between 2 nodes is less than the specified distance.- Parameters:
maxNodeDistance- the maximum distance between 2 nodes of the polygon- Returns:
- the resulting polygon
-
boundary
Description copied from interface:GeometryReturns the boundary of this geometry as a line string. -
serialize
Description copied from interface:GeometryReturns this geometry as an array of Point. -
asText
Description copied from class:DefaultGeometryReturns this geometry encoded using the Well-Known Text (WKT) standard.- Specified by:
asTextin interfaceGeometry- Overrides:
asTextin classDefaultGeometry- Returns:
- a WKT geometry.
-