org.elasticsearch.index.search.geo
Class GeoUtils

java.lang.Object
  extended by org.elasticsearch.index.search.geo.GeoUtils

public class GeoUtils
extends Object


Constructor Summary
GeoUtils()
           
 
Method Summary
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(Point point)
          Normalize the geo Point for its coordinates to lie within their respective normalized ranges.
static void normalizePoint(Point point, boolean normLat, boolean normLon)
          Normalize the geo Point for the given coordinates to lie within their respective normalized ranges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeoUtils

public GeoUtils()
Method Detail

normalizeLon

public static double normalizeLon(double lon)
Normalize longitude to lie within the -180 (exclusive) to 180 (inclusive) range.

Parameters:
lon - Longitude to normalize
Returns:
The normalized longitude.
See Also:
normalizePoint(Point)

normalizeLat

public static double normalizeLat(double lat)
Normalize latitude to lie within the -90 to 90 (both inclusive) range.

Note: You should not normalize longitude and latitude separately, because when normalizing latitude it may be necessary to add a shift of 180° in the longitude. For this purpose, you should call the normalizePoint(Point) function.

Parameters:
lat - Latitude to normalize
Returns:
The normalized latitude.
See Also:
normalizePoint(Point)

normalizePoint

public static void normalizePoint(Point point)
Normalize the geo 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.

Parameters:
point - The point to normalize in-place.

normalizePoint

public static void normalizePoint(Point point,
                                  boolean normLat,
                                  boolean normLon)
Normalize the geo 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.

Parameters:
point - The point to normalize in-place.
normLat - Whether to normalize latitude or leave it as is.
normLon - Whether to normalize longitude.


Copyright © 2009-2012. All Rights Reserved.