public class GeoUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static double |
EARTH_AXIS_RATIO
Earth axis ratio defined by WGS 84 (0.996647189335)
|
static double |
EARTH_EQUATOR
Earth ellipsoid equator length in meters
|
static double |
EARTH_MEAN_RADIUS
Earth mean radius defined by WGS 84 in meters
|
static double |
EARTH_POLAR_DISTANCE
Earth ellipsoid polar distance in meters
|
static double |
EARTH_SEMI_MAJOR_AXIS
Earth ellipsoid major axis defined by WGS 84 in meters
|
static double |
EARTH_SEMI_MINOR_AXIS
Earth ellipsoid minor axis defined by WGS 84 in meters
|
static String |
GEOHASH
|
static String |
LATITUDE
|
static String |
LONGITUDE
|
| Modifier and Type | Method and Description |
|---|---|
static double |
earthDiameter(double latitude)
Return an approximate value of the diameter of the earth (in meters) at the given latitude (in radians).
|
static double |
geoHashCellHeight(int level)
Calculate the height (in meters) of geohash cells at a specific level
|
static double |
geoHashCellSize(int level)
Calculate the size (in meters) of geohash cells at a specific level
|
static double |
geoHashCellWidth(int level)
Calculate the width (in meters) of geohash cells at a specific level
|
static int |
geoHashLevelsForPrecision(double meters)
Calculate the number of levels needed for a specific precision.
|
static int |
geoHashLevelsForPrecision(String
Calculate the number of levels needed for a specific precision.
|
static double |
normalizeLat(double lat)
Normalize latitude to lie within the -90 to 90 (both inclusive) range.
|
static double |
normalizeLon(double lon)
Normalize longitude to lie within the -180 (exclusive) to 180 (inclusive) range.
|
static void |
normalizePoint(GeoPoint
Normalize the geo
Point for its coordinates to lie within their respective normalized ranges.
|
static void |
normalizePoint(GeoPoint
Normalize the geo
Point for the given coordinates to lie within their respective normalized ranges.
|
static GeoPoint |
parseGeoPoint(XContentParser
Parse a
GeoPoint with a
XContentParser:
|
static GeoPoint |
parseGeoPoint(XContentParser
Parse a
GeoPoint with a
XContentParser.
|
static double |
quadTreeCellHeight(int level)
Calculate the height (in meters) of quadtree cells at a specific level
|
static double |
quadTreeCellSize(int level)
Calculate the size (in meters) of quadtree cells at a specific level
|
static double |
quadTreeCellWidth(int level)
Calculate the width (in meters) of quadtree cells at a specific level
|
static int |
quadTreeLevelsForPrecision(double meters)
Calculate the number of levels needed for a specific precision.
|
static int |
quadTreeLevelsForPrecision(String
Calculate the number of levels needed for a specific precision.
|
public static final StringLATITUDE
public static final StringLONGITUDE
public static final StringGEOHASH
public static final double EARTH_SEMI_MAJOR_AXIS
public static final double EARTH_SEMI_MINOR_AXIS
public static final double EARTH_MEAN_RADIUS
public static final double EARTH_AXIS_RATIO
public static final double EARTH_EQUATOR
public static final double EARTH_POLAR_DISTANCE
public static double earthDiameter(double latitude)
public static double geoHashCellWidth(int level)
level - geohash level must be greater or equal to zero
public static double quadTreeCellWidth(int level)
level - quadtree level must be greater or equal to zero
public static double geoHashCellHeight(int level)
level - geohash level must be greater or equal to zero
public static double quadTreeCellHeight(int level)
level - quadtree level must be greater or equal to zero
public static double geoHashCellSize(int level)
level - geohash level must be greater or equal to zero
public static double quadTreeCellSize(int level)
level - quadtree level must be greater or equal to zero
public static int quadTreeLevelsForPrecision(double meters)
meters - Maximum size of cells in meters (must greater than zero)
public static int quadTreeLevelsForPrecision(Stringdistance)
distance - Maximum size of cells as unit string (must greater or equal to zero)
public static int geoHashLevelsForPrecision(double meters)
meters - Maximum size of cells in meters (must greater or equal to zero)
public static int geoHashLevelsForPrecision(Stringdistance)
distance - Maximum size of cells as unit string (must greater or equal to zero)
public static double normalizeLon(double lon)
lon - Longitude to normalize
public static double normalizeLat(double lat)
normalizePoint(GeoPoint) function.
lat - Latitude to normalize
normalizePoint(GeoPoint)
public static void normalizePoint(GeoPointpoint)
Point for its coordinates to lie within their respective normalized ranges.
Note: A shift of 180° is applied in the longitude if necessary, in order to normalize properly the latitude.
point - The point to normalize in-place.
public static void normalizePoint(GeoPointpoint, boolean normLat, boolean normLon)
Point for the given coordinates to lie within their respective normalized ranges.
You can control which coordinate gets normalized with the two flags.
Note: A shift of 180° is applied in the longitude if necessary, in order to normalize properly the latitude. If normalizing latitude but not longitude, it is assumed that the longitude is in the form x+k*360, with x in ]-180;180], and k is meaningful to the application. Therefore x will be adjusted while keeping k preserved.
point - The point to normalize in-place.
normLat - Whether to normalize latitude or leave it as is.
normLon - Whether to normalize longitude.
public static GeoPointparseGeoPoint(XContentParser parser) throws IOException , ElasticsearchParseException
GeoPoint with a
XContentParser:
parser -
XContentParser to parse the value from
GeoPoint parsed from the parse
IOException -
ElasticsearchParseException -
public static GeoPointparseGeoPoint(XContentParser parser, GeoPoint point) throws IOException , ElasticsearchParseException
GeoPoint with a
XContentParser. A geopoint has one of the following forms:
{"lat": <latitude>, "lon": <longitude>}"<latitude>,<longitude>"
"<geohash>"
[<longitude>,<latitude>]
parser -
XContentParser to parse the value from
point - A
GeoPoint that will be reset by the values parsed
GeoPoint parsed from the parse
IOException -
ElasticsearchParseException -