ezvcard.util
Class GeoUri

java.lang.Object
  extended by ezvcard.util.GeoUri

public final class GeoUri
extends Object

Represents a URI for encoding a geographical position.

Example geo URI: geo:40.714623,-74.006605

This class is immutable. Use the GeoUri.Builder object to construct a new instance, or the parse(java.lang.String) method to parse a geo URI string.

Examples:

 GeoUri uri = new GeoUri.Builder(40.714623, -74.006605).coordC(1.1).build();
 GeoUri uri = GeoUri.parse("geo:40.714623,-74.006605,1.1");
 GeoUri copy = new GeoUri.Builder(original).coordC(2.1).build();
 

Author:
Michael Angstadt
See Also:
RFC 5870

Nested Class Summary
static class GeoUri.Builder
          Builder class for GeoUri.
 
Field Summary
static String CRS_WGS84
          The coordinate reference system used by GPS (the default).
 
Method Summary
 Double getCoordA()
          Gets the first coordinate (latitude).
 Double getCoordB()
          Gets the second coordinate (longitude).
 Double getCoordC()
          Gets the third coordinate (altitude).
 String getCrs()
          Gets the coordinate reference system.
 String getParameter(String name)
          Gets a parameter value.
 Map<String,String> getParameters()
          Gets all the parameters.
 Double getUncertainty()
          Gets the uncertainty (how accurate the coordinates are).
static GeoUri parse(String uri)
          Parses a geo URI string.
 String toString()
          Converts this geo URI to its string representation.
 String toString(int decimals)
          Converts this geo URI to its string representation.
 URI toUri()
          Creates a URI object from this geo URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CRS_WGS84

public static final String CRS_WGS84
The coordinate reference system used by GPS (the default).

See Also:
Constant Field Values
Method Detail

parse

public static GeoUri parse(String uri)
Parses a geo URI string.

Parameters:
uri - the URI string (e.g. "geo:40.714623,-74.006605")
Returns:
the parsed geo URI
Throws:
IllegalArgumentException - if the string is not a valid geo URI

getCoordA

public Double getCoordA()
Gets the first coordinate (latitude).

Returns:
the first coordinate or null if there is none

getCoordB

public Double getCoordB()
Gets the second coordinate (longitude).

Returns:
the second coordinate or null if there is none

getCoordC

public Double getCoordC()
Gets the third coordinate (altitude).

Returns:
the third coordinate or null if there is none

getCrs

public String getCrs()
Gets the coordinate reference system.

Returns:
the coordinate reference system or null if using the default (WGS-84)

getUncertainty

public Double getUncertainty()
Gets the uncertainty (how accurate the coordinates are).

Returns:
the uncertainty (in meters) or null if not set

getParameter

public String getParameter(String name)
Gets a parameter value.

Parameters:
name - the parameter name
Returns:
the parameter value or null if not found

getParameters

public Map<String,String> getParameters()
Gets all the parameters.

Returns:
all the parameters

toUri

public URI toUri()
Creates a URI object from this geo URI.

Returns:
the URI object

toString

public String toString()
Converts this geo URI to its string representation.

Overrides:
toString in class Object
Returns:
the geo URI's string representation

toString

public String toString(int decimals)
Converts this geo URI to its string representation.

Parameters:
decimals - the number of decimals to display for floating point values
Returns:
the geo URI's string representation


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.