com.gisgraphy.helper
Class GeolocHelper

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

public class GeolocHelper
extends Object

Provides useful methods for geolocalisation

Author:
David Masclet

Field Summary
protected static org.slf4j.Logger logger
          The logger
 
Constructor Summary
GeolocHelper()
           
 
Method Summary
static com.vividsolutions.jts.geom.Geometry convertFromHEXEWKBToGeometry(String hewewkbt)
           
static com.vividsolutions.jts.geom.LineString createLineString(String wktLineString)
          Create a JTS LineString from the specified String for the SRID (aka : Spatial Reference IDentifier) 4326 (WGS84)
example : {"LINESTRING (0 0, 10 10, 20 20)"}
static com.vividsolutions.jts.geom.MultiLineString createMultiLineString(String[] wktLineStrings)
          Create a JTS MultiLineString from the specified array of linestring for the SRID (aka : Spatial Reference IDentifier) 4326 (WGS84)
example : {"LINESTRING (0 0, 10 10, 20 20)","LINESTRING (30 30, 40 40, 50 50)"}
static com.vividsolutions.jts.geom.Point createPoint(Float longitude, Float latitude)
          Create a JTS point from the specified longitude and latitude for the SRID (aka : Spatial Reference IDentifier) 4326 (WGS84)
static com.vividsolutions.jts.geom.Polygon createPolygonBox(double lng, double lat, double distance)
           
static double distance(com.vividsolutions.jts.geom.Point point1, com.vividsolutions.jts.geom.Point point2)
          Calculate the distance between the specified point.
static String getBoundingBox(String alias, double latInDegree, double longInDegree, double distance)
           
static Class<? extends GisFeature> getClassEntityFromString(String classNameWithoutPackage)
          Return the class corresponding to the specified String or null if not found.
static byte getFromChar(char c)
          Turns a char that encodes four bits in hexadecimal notation into a byte
static Float parseInternationalDouble(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
 

Field Detail

logger

protected static final org.slf4j.Logger logger
The logger

Constructor Detail

GeolocHelper

public GeolocHelper()
Method Detail

createPoint

public static com.vividsolutions.jts.geom.Point createPoint(Float longitude,
                                                            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:
IllegalArgumentException - if latitude is not between -90 and 90, or longitude is not between -180 and 180
See Also:
SRID, SRID

createMultiLineString

public static com.vividsolutions.jts.geom.MultiLineString createMultiLineString(String[] wktLineStrings)
Create a JTS MultiLineString from the specified array of linestring for the SRID (aka : Spatial Reference IDentifier) 4326 (WGS84)
example : {"LINESTRING (0 0, 10 10, 20 20)","LINESTRING (30 30, 40 40, 50 50)"}

Parameters:
wktLineStrings - The array that contains all the linestrings
Returns:
A MultilineStringObject from the specified array of linestring
Throws:
IllegalArgumentException - if the string are not correct
See Also:
SRID, SRID

createLineString

public static com.vividsolutions.jts.geom.LineString createLineString(String wktLineString)
Create a JTS LineString from the specified String for the SRID (aka : Spatial Reference IDentifier) 4326 (WGS84)
example : {"LINESTRING (0 0, 10 10, 20 20)"}

Parameters:
wktLineString - a String that represent the lineString
Returns:
A LineStringObject from the specified linestring
Throws:
IllegalArgumentException - if the string are not correct
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 Class<? extends GisFeature> getClassEntityFromString(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(String number)
                                      throws 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:
ParseException - in case of errors

createPolygonBox

public static com.vividsolutions.jts.geom.Polygon createPolygonBox(double lng,
                                                                   double lat,
                                                                   double distance)
Parameters:
lat - the central latitude for the Polygon
lng - the central longitude for the polygon
distance - the distance in meters from the point to create the polygon
Returns:
a polygon / square with a side of distance , with the point (long,lat) as centroid throws RuntimeException if an error occured thros IllegalArgumentException if lat, long or distance is not correct

getBoundingBox

public static String getBoundingBox(String alias,
                                    double latInDegree,
                                    double longInDegree,
                                    double distance)
Parameters:
alias - the sql alias
latInDegree - the latitude in degree
longInDegree - the longitude in degree
distance - the boundingbox distance
Returns:
a sql String that represents the bounding box

convertFromHEXEWKBToGeometry

public static com.vividsolutions.jts.geom.Geometry convertFromHEXEWKBToGeometry(String hewewkbt)
Parameters:
hewewkbt - the string in hexa well know text
Returns:
the geometry type, or throw an exception if the string can not be convert.the SRID will be SRID.WGS84_SRID

getFromChar

public static byte getFromChar(char c)
Turns a char that encodes four bits in hexadecimal notation into a byte

Parameters:
c - the char to convert


Copyright © 2012. All Rights Reserved.