org.tridas.spatial
Class SpatialUtils

java.lang.Object
  extended by org.tridas.spatial.SpatialUtils

public class SpatialUtils
extends Object

Various static helper functions for working with coordinates

Author:
peterbrewer

Field Summary
static String WGS84
           
 
Constructor Summary
SpatialUtils()
           
 
Method Summary
static Point2D.Double BNGLetterReftoBNGNumberRef(String gridref)
          Converts British National Grid reference with letter prefix to full numeric reference style.
static String BNGNumRefToBNGLetRef(Double e, Double n, Integer digits)
          Convert a British National Grid number reference to standard letter+number reference.
static Projection getBritishNationalGrid()
          Helper function for getting the JMapProjLib Projection for the British National Grid using PROJ4 specification
static Double getDecimalCoords(Double degrees, Double minutes, Double seconds)
          Convert DMS format coordinate into decimal degrees, where W and S are indicated by negative degrees.
static Double getDecimalCoords(Integer degrees, Integer minutes, Integer seconds)
          Convert DMS format coordinate into decimal degrees, where W and S are indicated by negative degrees.
static Double getDecimalCoords(String sign, Double degrees, Double minutes, Double seconds)
          Convert DMS with NSEW sign into decimal coordinates
static Double getDecimalCoords(String sign, Integer degrees, Integer minutes, Integer seconds)
          Convert DMS with NSEW sign into decimal coordinates
static org.tridas.schema.TridasLocationGeometry getLocationGeometry(Double latitude, Double longitude)
          Create a TridasLocationGeometry from decimal latitude and longitudes
static org.tridas.schema.TridasLocationGeometry getLocationGeometry(net.opengis.gml.schema.Pos pos)
          Create a TridasLocationGeoemtry from a GML Pos.
static org.tridas.schema.TridasLocation getLocationGeometryFromBNG(String bngStr)
          Converts a SN****** style British National Grid coordinate into EPSG:4326 lat long coordinates.
static Double parseLatLonFromHalfLatLongString(String str)
          Attempt to convert a string to a decimal lat or lon value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WGS84

public static String WGS84
Constructor Detail

SpatialUtils

public SpatialUtils()
Method Detail

getDecimalCoords

public static Double getDecimalCoords(Integer degrees,
                                      Integer minutes,
                                      Integer seconds)
                               throws NumberFormatException
Convert DMS format coordinate into decimal degrees, where W and S are indicated by negative degrees.

Parameters:
degrees -
minutes -
seconds -
Returns:
Throws:
NumberFormatException

getDecimalCoords

public static Double getDecimalCoords(Double degrees,
                                      Double minutes,
                                      Double seconds)
                               throws NumberFormatException
Convert DMS format coordinate into decimal degrees, where W and S are indicated by negative degrees.

Parameters:
degrees -
minutes -
seconds -
Returns:
Throws:
NumberFormatException

getDecimalCoords

public static Double getDecimalCoords(String sign,
                                      Integer degrees,
                                      Integer minutes,
                                      Integer seconds)
                               throws NumberFormatException
Convert DMS with NSEW sign into decimal coordinates

Parameters:
sign -
degrees -
minutes -
seconds -
Returns:
Throws:
NumberFormatException

getDecimalCoords

public static Double getDecimalCoords(String sign,
                                      Double degrees,
                                      Double minutes,
                                      Double seconds)
                               throws NumberFormatException
Convert DMS with NSEW sign into decimal coordinates

Parameters:
sign -
degrees -
minutes -
seconds -
Returns:
Throws:
NumberFormatException

getLocationGeometry

public static org.tridas.schema.TridasLocationGeometry getLocationGeometry(Double latitude,
                                                                           Double longitude)
Create a TridasLocationGeometry from decimal latitude and longitudes

Parameters:
latitude -
longitude -
Returns:

getBritishNationalGrid

public static Projection getBritishNationalGrid()
Helper function for getting the JMapProjLib Projection for the British National Grid using PROJ4 specification

Returns:

getLocationGeometryFromBNG

public static org.tridas.schema.TridasLocation getLocationGeometryFromBNG(String bngStr)
Converts a SN****** style British National Grid coordinate into EPSG:4326 lat long coordinates. As BNG refs refer to tiles, this function also sets the precision of the reference depending on the size of the tile referred to. For instance 12 character reference refers to 1m tiles, therefore precision is set to 1m.

Parameters:
bngStr -
Returns:

BNGNumRefToBNGLetRef

public static String BNGNumRefToBNGLetRef(Double e,
                                          Double n,
                                          Integer digits)
Convert a British National Grid number reference to standard letter+number reference.

Parameters:
e - - easting
n - - nothing
digits - - number of digits to use
Returns:

BNGLetterReftoBNGNumberRef

public static Point2D.Double BNGLetterReftoBNGNumberRef(String gridref)
Converts British National Grid reference with letter prefix to full numeric reference style. As standard SN****** style codes refer to tiles, this function returns the coordinate as the centre of the referenced tile. Works on references up to 12 characters long (=1m grid tiles)

Parameters:
gridref -
Returns:

getLocationGeometry

public static org.tridas.schema.TridasLocationGeometry getLocationGeometry(net.opengis.gml.schema.Pos pos)
Create a TridasLocationGeoemtry from a GML Pos. Assumes coordinates are WGS84.

Parameters:
pos -
Returns:

parseLatLonFromHalfLatLongString

public static Double parseLatLonFromHalfLatLongString(String str)
                                               throws NumberFormatException
Attempt to convert a string to a decimal lat or lon value.

Parameters:
str -
Returns:
Throws:
NumberFormatException


Copyright © 2011. All Rights Reserved.