Class BufferedLine
java.lang.Object
org.locationtech.spatial4j.shape.BaseShape<SpatialContext>
org.locationtech.spatial4j.shape.impl.BufferedLine
- All Implemented Interfaces:
Shape
INTERNAL: A line between two points with a buffer distance extending in every direction. By
contrast, an un-buffered line covers no area and as such is extremely unlikely to intersect with
a point. BufferedLine isn't yet aware of geodesics (e.g. the anti-meridian); it operates in Euclidean
space.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Rectangleprivate final doubleprivate final InfBufLineperpendicular to the primary line, centered between pA invalid input: '&' pBprivate final InfBufLinethe primary line; passes through pA invalid input: '&' pBprivate final Pointprivate final Point -
Constructor Summary
ConstructorsConstructorDescriptionBufferedLine(Point pA, Point pB, double buf, SpatialContext ctx) Creates a buffered line from pA to pB. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanThe sub-classes of Shape generally implement the same contract forObject.equals(Object)andObject.hashCode()amongst the same sub-interface type.static doubleexpandBufForLongitudeSkew(Point pA, Point pB, double buf) CallsDistanceUtils.calcLonDegreesAtLat(double, double)given pA or pB's latitude; whichever is farthest.getA()doublegetArea(SpatialContext ctx) Calculates the area of the shape, in square-degrees.getB()Get the bounding box for this Shape.doublegetBuf()getBuffered(double distance, SpatialContext ctx) Returns a buffered version of this shape.Returns the center point of this shape.INTERNALINTERNALbooleanhasArea()Does the shape have area? This will be false for points and lines.inthashCode()booleanisEmpty()Shapes can be "empty", which is to say it exists nowhere.Describe the relationship between the two objects.toString()Methods inherited from class org.locationtech.spatial4j.shape.BaseShape
getContext
-
Field Details
-
pA
-
pB
-
buf
private final double buf -
bbox
-
linePrimary
the primary line; passes through pA invalid input: '&' pB -
linePerp
perpendicular to the primary line, centered between pA invalid input: '&' pB
-
-
Constructor Details
-
BufferedLine
Creates a buffered line from pA to pB. The buffer extends on both sides of the line, making the width 2x the buffer. The buffer extends out from pA & pB, making the line in effect 2x the buffer longer than pA to pB.- Parameters:
pA- start pointpB- end pointbuf- the buffer distance in degrees
-
-
Method Details
-
isEmpty
public boolean isEmpty()Description copied from interface:ShapeShapes can be "empty", which is to say it exists nowhere. The underlying coordinates are typically NaN. -
getBuffered
Description copied from interface:ShapeReturns a buffered version of this shape. The buffer is usually a rounded-corner buffer, although some shapes might buffer differently. This is an optional operation.- Returns:
- Not null, and the returned shape should contain the current shape.
-
expandBufForLongitudeSkew
CallsDistanceUtils.calcLonDegreesAtLat(double, double)given pA or pB's latitude; whichever is farthest. It's useful to expand a buffer of a line segment when used in a geospatial context to cover the desired area. -
relate
Description copied from interface:ShapeDescribe the relationship between the two objects. For example- this is WITHIN other
- this CONTAINS other
- this is DISJOINT other
- this INTERSECTS other
If the shapes are equal then the result is CONTAINS (preferred) or WITHIN.
-
relate
-
contains
-
getBoundingBox
Description copied from interface:ShapeGet the bounding box for this Shape. This means the shape is within the bounding box and that it touches each side of the rectangle.Postcondition:
this.getBoundingBox().relate(this) == CONTAINS -
hasArea
public boolean hasArea()Description copied from interface:ShapeDoes the shape have area? This will be false for points and lines. It will also be false for shapes that normally have area but are constructed in a degenerate case as to not have area (e.g. a circle with 0 radius or rectangle with no height or no width). -
getArea
Description copied from interface:ShapeCalculates the area of the shape, in square-degrees. If ctx is null then simple Euclidean calculations will be used. This figure can be an estimate. -
getCenter
Description copied from interface:ShapeReturns the center point of this shape. This is usually the same asgetBoundingBox().getCenter()but it doesn't have to be.Postcondition:
this.relate(this.getCenter()) == CONTAINS -
getA
-
getB
-
getBuf
public double getBuf() -
getLinePrimary
INTERNAL -
getLinePerp
INTERNAL -
toString
-
equals
Description copied from interface:ShapeThe sub-classes of Shape generally implement the same contract forObject.equals(Object)andObject.hashCode()amongst the same sub-interface type. This means, for example, that multiple Point implementations of different classes are equal if they share the same x & y. -
hashCode
public int hashCode()
-