com.gisgraphy.helper
Class GeolocHelper

java.lang.Object
  extended by com.gisgraphy.helper.GeolocHelper

public class GeolocHelper
extends java.lang.Object

Provides useful methods for geolocalisation

Author:
David Masclet

Constructor Summary
GeolocHelper()
           
 
Method Summary
static com.vividsolutions.jts.geom.Point createPoint(java.lang.Float longitude, java.lang.Float latitude)
          Create a JTS point from the specified longitude and latitude for the SRID (aka : Spatial Reference IDentifier) 4326 (WGS84)
static double distance(com.vividsolutions.jts.geom.Point point1, com.vividsolutions.jts.geom.Point point2)
          Calculate the distance between the specified point.
static java.lang.Class<? extends GisFeature> getClassEntityFromString(java.lang.String classNameWithoutPackage)
          Return the class corresponding to the specified String or null if not found.
static float parseInternationalDouble(java.lang.String number)
          parse a string and return the corresponding double value, it accepts comma or point as decimal separator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeolocHelper

public GeolocHelper()
Method Detail

createPoint

public static com.vividsolutions.jts.geom.Point createPoint(java.lang.Float longitude,
                                                            java.lang.Float latitude)
Create a JTS point from the specified longitude and latitude for the SRID (aka : Spatial Reference IDentifier) 4326 (WGS84)

Parameters:
longitude - The longitude for the point
latitude - The latitude for the point
Returns:
A jts point from the specified longitude and latitude
Throws:
java.lang.IllegalArgumentException - if latitude is not between -90 and 90, or longitude is not between -180 and 180
See Also:
SRID, SRID

distance

public static double distance(com.vividsolutions.jts.geom.Point point1,
                              com.vividsolutions.jts.geom.Point point2)
Calculate the distance between the specified point.

Parameters:
point1 - The first JTS point
point2 - The second JTS point
Returns:
The calculated distance

getClassEntityFromString

public static java.lang.Class<? extends GisFeature> getClassEntityFromString(java.lang.String classNameWithoutPackage)
Return the class corresponding to the specified String or null if not found. The Class will be searched in the 'entity' package. The search is not case sensitive. This method is mainly used to determine an entity Class from a web parameter

Parameters:
classNameWithoutPackage - the simple name of the Class we want to retrieve
Returns:
The class corresponding to the specified String or null if not found.

parseInternationalDouble

public static float parseInternationalDouble(java.lang.String number)
                                      throws java.text.ParseException
parse a string and return the corresponding double value, it accepts comma or point as decimal separator

Parameters:
number - the number with a point or a comma as decimal separator
Returns:
the float value corresponding to the parsed string
Throws:
java.text.ParseException - in case of errors


Copyright © 2009. All Rights Reserved.