Package org.h2gis.utilities
Class GeographyUtilities
- java.lang.Object
-
- org.h2gis.utilities.GeographyUtilities
-
public class GeographyUtilities extends Object
Some utilities for geographic data- Author:
- Erwan Bocher
-
-
Field Summary
Fields Modifier and Type Field Description static doubleRADIUS_OF_EARTH_IN_METERS
-
Constructor Summary
Constructors Constructor Description GeographyUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublecomputeLatitudeDistance(double meters)Computes the amount of degrees of latitude for a given distance in meters.static doublecomputeLongitudeDistance(double meters, double latitude)Computes the amount of degrees of longitude for a given distance in meters.static org.locationtech.jts.geom.EnvelopecreateEnvelope(org.locationtech.jts.geom.Coordinate point, double dx, double dy)This method is used to create a JTS envelope by a given point coordinates in degrees and spatial increments in meters.static org.locationtech.jts.geom.EnvelopecreateEnvelope(org.locationtech.jts.geom.Coordinate point, double dx, double dy, int quadrant)This method is used to create a JTS envelope by a given point coordinates in degrees and spatial increments in meters.static org.locationtech.jts.geom.EnvelopeexpandEnvelopeByMeters(org.locationtech.jts.geom.Envelope envelope, double distance)This method is used to expand a JTS envelope by a given distance in degrees in all directions.static doublegetHaversineDistanceInMeters(org.locationtech.jts.geom.Coordinate coordA, org.locationtech.jts.geom.Coordinate coordB)Calculate the spherical distance between two coordinates in meters using the Haversine formula.static intgetSRID(Connection connection, float latitude, float longitude)Return a SRID code from latitude and longitude coordinates
-
-
-
Field Detail
-
RADIUS_OF_EARTH_IN_METERS
public static final double RADIUS_OF_EARTH_IN_METERS
- See Also:
- Constant Field Values
-
-
Method Detail
-
createEnvelope
public static org.locationtech.jts.geom.Envelope createEnvelope(org.locationtech.jts.geom.Coordinate point, double dx, double dy)This method is used to create a JTS envelope by a given point coordinates in degrees and spatial increments in meters.- Parameters:
point- Coordinates of a point used to build an envelope.dx- Spatial horizontal increment expressed in metersdy- Spatial vertical increment expressed in meters.- Returns:
- an envelope
-
createEnvelope
public static org.locationtech.jts.geom.Envelope createEnvelope(org.locationtech.jts.geom.Coordinate point, double dx, double dy, int quadrant)This method is used to create a JTS envelope by a given point coordinates in degrees and spatial increments in meters.- Parameters:
point- Coordinates of a point used to build an envelope in degrees.dx- Spatial horizontal increment expressed in meters.dy- Spatial vertical increment expressed in meters.quadrant- One of the four quadrants delimiting the plane (counter-clockwise and starting from the upper right)- Returns:
- an envelope
-
expandEnvelopeByMeters
public static org.locationtech.jts.geom.Envelope expandEnvelopeByMeters(org.locationtech.jts.geom.Envelope envelope, double distance)This method is used to expand a JTS envelope by a given distance in degrees in all directions. see : https://www.mkompf.com/gps/distcalc.html- Parameters:
envelope- to expanddistance- expressed in degrees- Returns:
- a new envelope
-
computeLatitudeDistance
public static double computeLatitudeDistance(double meters)
Computes the amount of degrees of latitude for a given distance in meters.- Parameters:
meters- distance in meters- Returns:
- latitude degrees
-
computeLongitudeDistance
public static double computeLongitudeDistance(double meters, double latitude)Computes the amount of degrees of longitude for a given distance in meters.- Parameters:
meters- distance in meterslatitude- the latitude at which the calculation should be performed- Returns:
- longitude degrees
-
getHaversineDistanceInMeters
public static double getHaversineDistanceInMeters(org.locationtech.jts.geom.Coordinate coordA, org.locationtech.jts.geom.Coordinate coordB)Calculate the spherical distance between two coordinates in meters using the Haversine formula. See https://fr.wikipedia.org/wiki/Formule_de_haversine This calculation is done using the approximate earth radius- Parameters:
coordA-coordB-- Returns:
- distance in meters
-
getSRID
public static int getSRID(Connection connection, float latitude, float longitude) throws SQLException
Return a SRID code from latitude and longitude coordinates- Parameters:
connection- to the databaselatitude-longitude-- Returns:
- a SRID code
- Throws:
SQLException
-
-