- java.lang.Object
-
- org.arakhne.afc.gis.location.GeoLocationUtil
-
public class GeoLocationUtil extends Object
Some geo-location functions.- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:53
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- giscore
-
-
Field Summary
Fields Modifier and Type Field Description static doubleGIS_POINT_DEMI_SIZEDemo-size of the area covered by a GIS point when computing its bounds (in meters).static doubleGIS_POINT_SIZESize of the area covered by a GIS point when computing its bounds (in meters).
-
Constructor Summary
Constructors Modifier Constructor Description protectedGeoLocationUtil()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static floatcastDistance(double distance)Cast the specified geo-distance to the nearest distance according to the current supported precision.static intcompare(GeoLocation l1, GeoLocation l2)Compares its two arguments for order.static intepsilonCompareToDistance(double value)Replies if the specified distance value is approximatively equal to zero, less or greater than zero.static intepsilonCompareToDistance(double distance1, double distance2)Replies if the specified distances are approximatively equal, less or greater than.static booleanepsilonEqualsDistance(double value)Replies if the specified distance value is approximatively equal to zero.static booleanepsilonEqualsDistance(double value1, double value2)Replies if the specified distances are approximatively equal.static booleanepsilonEqualsDistance(Point2D<?,?> p1, Point2D<?,?> p2)Replies if the specified points are approximatively equal.static booleanepsilonEqualsDistance(Point3D<?,?> p1, Point3D<?,?> p2)Replies if the specified points are approximatively equal.static doublegetDistanceEpsilon()Replies the precision used to test a distance value (in meters).static StringmakeInternalId(float[] coordinates, Rectangle2d bounds)Compute and replies the internal identifier that may be used to create a GeoId from the given point coordinates.static StringmakeInternalId(float x, float y)Compute and replies the internal identifier that may be used to create a GeoId from the given point.static StringmakeInternalId(float minx, float miny, float maxx, float maxy)Compute and replies the internal identifier that may be used to create a GeoId from the given rectangle.static StringmakeInternalId(UUID uid)Compute and replies the internal identifier that may be used to create a GeoId from the given identifier.static doublesetDistanceEpsilon(double newPrecisionValue)Replies the precision used to test a distance value.static voidsetGISCoordinateSystemAsDefault()Force the GIS coordinate systems to be the default coordinates systems.
-
-
-
Field Detail
-
GIS_POINT_SIZE
public static final double GIS_POINT_SIZE
Size of the area covered by a GIS point when computing its bounds (in meters).- See Also:
- Constant Field Values
-
GIS_POINT_DEMI_SIZE
public static final double GIS_POINT_DEMI_SIZE
Demo-size of the area covered by a GIS point when computing its bounds (in meters).- See Also:
- Constant Field Values
-
-
Method Detail
-
getDistanceEpsilon
@Pure public static double getDistanceEpsilon()
Replies the precision used to test a distance value (in meters).- Returns:
- the epsilon
-
setDistanceEpsilon
public static double setDistanceEpsilon(double newPrecisionValue)
Replies the precision used to test a distance value.- Parameters:
newPrecisionValue- the new precision value (in meters).- Returns:
- the old precision value.
-
castDistance
@Pure public static float castDistance(double distance)
Cast the specified geo-distance to the nearest distance according to the current supported precision.- Parameters:
distance- the distance to cast.- Returns:
- the casted distance.
-
epsilonEqualsDistance
@Pure public static boolean epsilonEqualsDistance(Point3D<?,?> p1, Point3D<?,?> p2)
Replies if the specified points are approximatively equal. This function uses the distance precision.- Parameters:
p1- the first point.p2- the second point.- Returns:
trueif both points are equal, otherwisefalse
-
epsilonEqualsDistance
@Pure public static boolean epsilonEqualsDistance(Point2D<?,?> p1, Point2D<?,?> p2)
Replies if the specified points are approximatively equal. This function uses the distance precision.- Parameters:
p1- the first point.p2- the second point.- Returns:
trueif both points are equal, otherwisefalse
-
epsilonEqualsDistance
@Pure public static boolean epsilonEqualsDistance(double value)
Replies if the specified distance value is approximatively equal to zero.- Parameters:
value- the value to test.- Returns:
trueif the given distance is near zero, otherwisefalse
-
epsilonEqualsDistance
@Pure public static boolean epsilonEqualsDistance(double value1, double value2)Replies if the specified distances are approximatively equal.- Parameters:
value1- the first value.value2- the second value.- Returns:
trueif both values are equal, otherwisefalse
-
epsilonCompareToDistance
@Pure public static int epsilonCompareToDistance(double value)
Replies if the specified distance value is approximatively equal to zero, less or greater than zero.- Parameters:
value- the value.- Returns:
- a negative value if the parameter is negative, a positive value of the parameter is positive, or zero if the parameter is approximatively equal to zero.
-
epsilonCompareToDistance
@Pure public static int epsilonCompareToDistance(double distance1, double distance2)Replies if the specified distances are approximatively equal, less or greater than.- Parameters:
distance1- the first distance.distance2- the second distance.- Returns:
- a negative value if the parameter distance1 is lower than distance2, a positive if distance1 is greater than distance2, zero if the two parameters are approximatively equal.
-
compare
@Pure public static int compare(GeoLocation l1, GeoLocation l2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.In the foregoing description, the notation sgn(expression) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive.
The implementor must ensure that sgn(compare(x, y)) == -sgn(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)
The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.
Finally, the implementor must ensure that compare(x, y)==0 implies that sgn(compare(x, z))==sgn(compare(y, z)) for all z.
It is generally the case, but not strictly required that (compare(x, y)==0) == (x.equals(y)). Generally speaking, any comparator that violates this condition should clearly indicate this fact. The recommended language is "Note: this comparator imposes orderings that are inconsistent with equals."
- Parameters:
l1- the first object to be compared.l2- the second object to be compared.- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
- Throws:
ClassCastException- if the arguments' types prevent them from being compared by this comparator.
-
makeInternalId
@Pure public static String makeInternalId(float[] coordinates, Rectangle2d bounds)
Compute and replies the internal identifier that may be used to create a GeoId from the given point coordinates. The coordinates are the (x;y) pairs of the points. X coordinates are at even indexes, and Y coordinates at odd indexes.- Parameters:
coordinates- are the point pairs.bounds- are the bounds of the points.- Returns:
- the internal identifier.
-
makeInternalId
@Pure public static String makeInternalId(float x, float y)
Compute and replies the internal identifier that may be used to create a GeoId from the given point.- Parameters:
x- x coordinate.y- y coordinate- Returns:
- the internal identifier.
-
makeInternalId
@Pure public static String makeInternalId(UUID uid)
Compute and replies the internal identifier that may be used to create a GeoId from the given identifier. The replied identifier is not geolocalized.- Parameters:
uid- the identifier- Returns:
- the internal identifier.
-
makeInternalId
@Pure public static String makeInternalId(float minx, float miny, float maxx, float maxy)
Compute and replies the internal identifier that may be used to create a GeoId from the given rectangle.- Parameters:
minx- minimum x coordinate of the bounding rectangle.miny- minimum y coordinate of the bounding rectangle.maxx- maximum x coordinate of the bounding rectangle.maxy- maximum y coordinate of the bounding rectangle.- Returns:
- the internal identifier.
-
setGISCoordinateSystemAsDefault
public static void setGISCoordinateSystemAsDefault()
Force the GIS coordinate systems to be the default coordinates systems. This function sets the default coordinate systems to the value specified in the system properties "fr.utbm.set.math.defaultCoordinateSystem2D" and "fr.utbm.set.math.defaultCoordinateSystem3D", or if not set toCoordinateSystemConstants.GIS_2DandCoordinateSystemConstants.GIS_3D.- Since:
- 15.0
-
-