Class CartesianDistCalc
java.lang.Object
org.locationtech.spatial4j.distance.AbstractDistanceCalculator
org.locationtech.spatial4j.distance.CartesianDistCalc
- All Implemented Interfaces:
DistanceCalculator
Calculates based on Euclidean / Cartesian 2d plane.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CartesianDistCalcstatic final CartesianDistCalcprivate final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubledoublecalcBoxByDistFromPt(Point from, double distDEG, SpatialContext ctx, Rectangle reuse) Calculates the bounding box of a circle, as specified by its center point and distance.doublecalcBoxByDistFromPt_yHorizAxisDEG(Point from, double distDEG, SpatialContext ctx) TheYcoordinate of the horizontal axis of a circle that has maximum width.doubleThe distance betweenfromandPoint(toX,toY).private static doubledistanceSquared(double fromX, double fromY, double toX, double toY) doubledistanceToLineSegment(Point point, double vX, double vY, double wX, double wY) Distance from point to a line segment formed between points 'v' and 'w'.booleaninthashCode()pointOnBearing(Point from, double distDEG, double bearingDEG, SpatialContext ctx, Point reuse) Calculates where a destination point is given an origin (from) distance, and bearing (given in degrees -- 0-360).booleanReturns true if the distance between from and to is <= distance.Methods inherited from class AbstractDistanceCalculator
distance, toString
-
Field Details
-
INSTANCE
-
INSTANCE_SQUARED
-
squared
private final boolean squared
-
-
Constructor Details
-
CartesianDistCalc
public CartesianDistCalc() -
CartesianDistCalc
public CartesianDistCalc(boolean squared) - Parameters:
squared- Set to true to haveAbstractDistanceCalculator.distance(org.locationtech.spatial4j.shape.Point, org.locationtech.spatial4j.shape.Point)return the square of the correct answer. This is a performance optimization used when sorting in which the actual distance doesn't matter so long as the sort order is consistent.
-
-
Method Details
-
distance
Description copied from interface:DistanceCalculatorThe distance betweenfromandPoint(toX,toY). -
distanceSquared
private static double distanceSquared(double fromX, double fromY, double toX, double toY) -
distanceToLineSegment
Distance from point to a line segment formed between points 'v' and 'w'. It respects the "squared" option. -
within
Description copied from interface:DistanceCalculatorReturns true if the distance between from and to is <= distance.- Specified by:
withinin interfaceDistanceCalculator- Overrides:
withinin classAbstractDistanceCalculator
-
pointOnBearing
public Point pointOnBearing(Point from, double distDEG, double bearingDEG, SpatialContext ctx, Point reuse) Description copied from interface:DistanceCalculatorCalculates where a destination point is given an origin (from) distance, and bearing (given in degrees -- 0-360). If reuse is given, then this method may reset() it and return it. -
calcBoxByDistFromPt
public Rectangle calcBoxByDistFromPt(Point from, double distDEG, SpatialContext ctx, Rectangle reuse) Description copied from interface:DistanceCalculatorCalculates the bounding box of a circle, as specified by its center point and distance. -
calcBoxByDistFromPt_yHorizAxisDEG
Description copied from interface:DistanceCalculatorTheYcoordinate of the horizontal axis of a circle that has maximum width. On a 2D plane, this result is alwaysfrom.getY()but, perhaps surprisingly, on a sphere it is going to be slightly different. -
area
-
area
-
equals
-
hashCode
-