javax.microedition.location
Class Location

java.lang.Object
  |
  +--javax.microedition.location.Location

public class Location
extends Object

The Location class represents the standard set of basic location information. This includes the timestamped coordinates, accuracy, speed, heading, and information about the positioning method used for the location, plus an optional address.

The location method is indicated using a bit field. The individual bits are defined using constants in this class. This bit field is a bitwise combination of the location method technology bits (MTE_*), method type (MTY_*) and method assistance information (MTA_*). All other bits in the 32 bit integer than those that have defined constants in this class are reserved and MUST not be set by implementations (i.e. these bits must be 0).

A Location object may be either 'valid' or 'invalid'. The validity can be queried using the isValid method. A valid Location object represents a location with valid coordinates. An invalid Location object doesn't have valid coordinates, but the extra info that is obtained from the getExtraInfo method can provide information about the reason why it was not possible to provide a valid Location. The periodic location updates to the LocationListener may return invalid Location objects if it isn't possible to determine the location.

This class is only a container for the information. When the platform implementation returns Location objects, it MUST ensure that it only returns objects where the parameters have values set as described for their semantics in this class.

Since:
JDE 4.0.2

Field Summary
static int MTA_ASSISTED
          Location method is assisted by the other party (Terminal assisted for Network based, Network assisted for terminal based).
static int MTA_UNASSISTED
          Location method is unassisted.
static int MTE_ANGLEOFARRIVAL
          Location method Angle of Arrival for cellular / terrestrial RF system.
static int MTE_CELLID
          Location method Cell-ID for cellular (in GSM, this is the same as CGI, Cell Global Identity).
static int MTE_SATELLITE
          Location method using satellites (for example, Global Positioning System (GPS)).
static int MTE_SHORTRANGE
          Location method Short-range positioning system (for example, Bluetooth LP).
static int MTE_TIMEDIFFERENCE
          Location method Time Difference for cellular / terrestrial RF system (for example, Enhanced Observed Time Difference (E-OTD) for GSM).
static int MTE_TIMEOFARRIVAL
          Location method Time of Arrival (TOA) for cellular / terrestrial RF system.
static int MTY_NETWORKBASED
          Location method is of type network based.
static int MTY_TERMINALBASED
          Location method is of type terminal based.
 
Constructor Summary
protected Location()
           
 
Method Summary
 AddressInfo getAddressInfo()
          Returns the AddressInfo associated with this Location object.
 float getCourse()
          Returns the terminal's course made good in degrees relative to true north.
 String getExtraInfo(String mimetype)
          Returns extra information about the location.
 int getLocationMethod()
          Returns information about the location method used.
 QualifiedCoordinates getQualifiedCoordinates()
          Returns the coordinates of this location and their accuracy.
 float getSpeed()
          Returns the terminal's current ground speed in meters per second (m/s) at the time of measurement.
 long getTimestamp()
          Returns the time stamp at which the data was collected.
 boolean isValid()
          Returns whether this Location instance represents a valid location with coordinates or an invalid one where all the data, especially the latitude and longitude coordinates, may not be present.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MTA_ASSISTED

public static final int MTA_ASSISTED

Location method is assisted by the other party (Terminal assisted for Network based, Network assisted for terminal based). MTA_ASSISTED = 0x00040000

Since:
JDE 4.0.2

MTA_UNASSISTED

public static final int MTA_UNASSISTED

Location method is unassisted. This bit and MTA_ASSISTED bit MUST NOT both be set. Only one of these bits may be set or neither to indicate that the assistance information is not known. MTA_UNASSISTED = 0x00080000

Since:
JDE 4.0.2

MTE_ANGLEOFARRIVAL

public static final int MTE_ANGLEOFARRIVAL

Location method Angle of Arrival for cellular / terrestrial RF system. MTE_ANGLEOFARRIVAL = 0x00000020

Since:
JDE 4.0.2

MTE_CELLID

public static final int MTE_CELLID

Location method Cell-ID for cellular (in GSM, this is the same as CGI, Cell Global Identity). MTE_CELLID = 0x00000008

Since:
JDE 4.0.2

MTE_SATELLITE

public static final int MTE_SATELLITE

Location method using satellites (for example, Global Positioning System (GPS)). MTE_SATELLITE = 0x00000001

Since:
JDE 4.0.2

MTE_SHORTRANGE

public static final int MTE_SHORTRANGE

Location method Short-range positioning system (for example, Bluetooth LP). MTE_SHORTRANGE = 0x00000010

Since:
JDE 4.0.2

MTE_TIMEDIFFERENCE

public static final int MTE_TIMEDIFFERENCE

Location method Time Difference for cellular / terrestrial RF system (for example, Enhanced Observed Time Difference (E-OTD) for GSM). MTE_TIMEDIFFERENCE = 0x00000002

Since:
JDE 4.0.2

MTE_TIMEOFARRIVAL

public static final int MTE_TIMEOFARRIVAL

Location method Time of Arrival (TOA) for cellular / terrestrial RF system. MTE_TIMEOFARRIVAL = 0x00000004

Since:
JDE 4.0.2

MTY_NETWORKBASED

public static final int MTY_NETWORKBASED

Location method is of type network based. This means that the final location result is calculated in the network. This bit and MTY_TERMINALBASED bit MUST NOT both be set. Only one of these bits may be set or neither to indicate that it is not known where the result is calculated. MTY_NETWORKBASED = 0x00020000

Since:
JDE 4.0.2

MTY_TERMINALBASED

public static final int MTY_TERMINALBASED

Location method is of type terminal based. This means that the final location result is calculated in the terminal. MTY_TERMINALBASED = 0x00010000

Since:
JDE 4.0.2
Constructor Detail

Location

protected Location()
Since:
JDE 4.0.2
Method Detail

getAddressInfo

public AddressInfo getAddressInfo()

Returns the AddressInfo associated with this Location object. If no address is available, null is returned.

Returns:
an AddressInfo associated with this Location object

RIM Implementation Note

This method returns null because the RIM implementation does not support textual address.

Since:
JDE 4.0.2

getCourse

public float getCourse()

Returns the terminal's course made good in degrees relative to true north. The value is always in the range [0.0,360.0) degrees.

Returns:
the terminal's course made good in degrees relative to true north or Float.NaN if the course is not known
Since:
JDE 4.0.2

getExtraInfo

public String getExtraInfo(String mimetype)

Returns extra information about the location. This method is intended to provide location method specific extra information that applications that are aware of the used location method and information format are able to use.

A MIME type is used to identify the type of the extra information when requesting it. If the implementation supports this type, it returns the extra information as a String encoded according to format identified by the MIME type. If the implementation does not support this type, the method returns null.

This specification does not require implementations to support any extra information type.

The following MIME types are defined here together with their definitions in order to ensure interoperability of implementations wishing to use these types. The definition of these types here is not an indication that these formats are preferred over any other format not defined here.

When the MIME type is "application/X-jsr179-location-nmea", the returned string shall be a valid sequence of NMEA sentences formatted according to the syntax specified in the NMEA 0183 v3.1 specification. These sentences should represent the set of NMEA sentences that are related to this location at the time this location was created.

A sample returned string of getExtraInfo("application/X-jsr179-location-nmea"):
$GPGGA,140234,26:08.76784,N,-80:15.22240,W,1,6,,7.0,M,,
$GPGLL,26:08.76784,N,-80:15.22240,W,140234,A

When the MIME type is "application/X-jsr179-location-lif", the returned string shall contain an XML formatted document containing the "pd" element defined in the LIF Mobile Location Protocol TS 101 v3.0.0 as the root element of the document.

A sample returned string of getExtraInfo("application/X-jsr179-location-lif"):
lif:<pd><time>1105044947940</time><shape><Point><coord><X>-23.67</X><Y>34.45</Y></coord></Point></shape><alt>456.0</alt><alt_acc>23.0</alt_acc><speed>20</speed><direction>120</direction></pd>

When the MIME type is "text/plain", the returned string shall contain textual extra information that can be displayed to the end user.

Parameters:
mimetype - the MIME type of the requested extra information
Returns:
string encoded according to the format identified by the MIME type defined in the parameter. null if the information for the requested MIME type is not available or not supported by this implementation.
Since:
JDE 4.0.2

getLocationMethod

public int getLocationMethod()

Returns information about the location method used. The returned value is a bitwise combination (OR) of the method technology, method type and assistance information. The method technology values are defined as constant values named MTE_* in this class, the method type values are named MTY_* and assistance information values are named MTA_*.

For example, if the location method used is terminal based, network assisted E-OTD, the value 0x00050002 ( = MTY_TERMINALBASED | MTA_ASSISTED | MTE_TIMEDIFFERENCE) would be returned.

If the location is determined by combining several location technologies, the returned value may have several MTE_* bits set.

If the used location method is unknown, the returned value may have all the bits set to zero.

Only bits that have defined constants within this class are allowed to be used. Other bits are reserved and must be set to 0.

Returns:
a bitfield identifying the used the location method
Since:
JDE 4.0.2

getQualifiedCoordinates

public QualifiedCoordinates getQualifiedCoordinates()

Returns the coordinates of this location and their accuracy.

Returns:
a QualifiedCoordinates object. If the coordinates are not known, returns null.
Since:
JDE 4.0.2

getSpeed

public float getSpeed()

Returns the terminal's current ground speed in meters per second (m/s) at the time of measurement. The speed is always a non-negative value. Note that unlike the coordinates, speed does not have an associated accuracy because the methods used to determine the speed typically are not able to indicate the accuracy.

Returns:
the current ground speed in m/s for the terminal or Float.NaN if the speed is not known
Since:
JDE 4.0.2

getTimestamp

public long getTimestamp()

Returns the time stamp at which the data was collected. This timestamp should represent the point in time when the measurements were made. Implementations make best effort to set the timestamp as close to this point in time as possible. The time returned is the local device time in milliseconds using the same clock and same time representation as System.currentTimeMillis().

Returns:
a timestamp representing the time
Since:
JDE 4.0.2
See Also:
System.currentTimeMillis()

isValid

public boolean isValid()

Returns whether this Location instance represents a valid location with coordinates or an invalid one where all the data, especially the latitude and longitude coordinates, may not be present.

A valid Location object contains valid coordinates whereas an invalid Location object may not contain valid coordinates but may contain other information via the getExtraInfo() method to provide information on it was not possible to provide a valid Location object.

Returns:
a boolean value with true indicating that this Location instance is valid and false indicating an invalid Location instance
Since:
JDE 4.0.2
See Also:
getExtraInfo(String)



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.