The Location API for Java™ 2 Platform, Micro Edition (J2ME™) (JSR-179), first introduced in Series 40 3rd Edition, is an optional package that can be used with many Java ME profiles. The minimum platform for JSR-179 use is Connected Limited Device Configuration (CLDC) 1.1, because the API requires floating point math support
Devices with integrated GPS modules were introduced on Series 40 6th Edition, while network based location retrieval became available in Java Runtime 1.0.0 for Series 40 or later. For devices without integrated GPS capabilities, an external Bluetooth GPS module can be used.
The purpose of the Location API is to enable the development of location-based mobile applications. Considering the nature of mobile devices, the Location API provides a natural way to utilize location-based information. Moreover, the Location API is a compact package of classes and interfaces that are easy to use. The main features that the Location API brings to the mobile programming are:
Obtaining information about the location of a device
The possibility to create, edit, store, and retrieve landmarks
The Location API needs a connection to a location-providing method, which generates the locations. Location-providing methods differ from each other in many ways. For example, the use of some methods may cost more than others, and the accuracies supported by individual location-providing methods vary. The most common methods are device-based (for example, GPS module - a method based on a Global Positioning System's satellites), network-based (for example, cell of origin - a method in which the network determines a user's place), or hybrid methods (for example, A-GPS - a GPS method which also uses network-based information to speed up location determination).
Location API-based applications can be developed and tested in a simulated environment.
The figure below shows a generalized structure of a Location API MIDlet that uses a GPS module as a location-providing method.
Figure: General Location API MIDlet model
Location-Based Services (LBS) are applications that utilize a user’s current physical location to provide enhanced services. You can use location information for a variety of purposes. The use cases include:
Mapping, navigation, and directions applications, which can also be combined with directory services
Workforce-tracking and management applications
Interactive gaming and services that complement sporting events, concerts, and more
“Finder” applications can apply users’ location to help them locate people or places nearby
Weather applications can provide local forecasts and warnings about bad weather
A basic knowledge of geographic coordinates is required before starting to code with JSR-179. The Location API uses coordinates that are given using the World Geodetic System (WGS 84) datum. It is also currently used as a reference system by the Global Positioning System (GPS).
The coordinates in the API are constructed from latitude, longitude, and altitude values. (In this case, altitude is the elevation above the sea level.) In the below Figure the horizontal lines measure latitude. These lines represent the north-south position between the poles. The North Pole is 90 degrees North (+90 degrees) and the South Pole is 90 degrees South (-90 degrees). The largest circle is called the Equator and is defined as 0 degrees. Locations above the Equator have positive latitudes (0 to +90 degrees) and locations below the Equator have negative ones (0 to -90 degrees).
However, the definition of the North Pole is not unambiguous. Location API implementations may use either the Magnetic North Pole or the True North Pole (also known as Geographical North Pole). In practice, any application using a compass should check how the API defines the North Pole.
Magnetic North Pole is the point to which magnetic compasses point. The position of the Magnetic North Pole is not static, since its position moves several kilometers a year. Poles are not at directly opposite positions of the globe, because they move independently of each other. The definition of the True North Pole defines latitude as +90 degrees. The distance from the North Pole to the Equator is approximately equal to the distance from the South Pole to the Equator.
The lines drawn from north to south in the below Figure are meridians, which are constant longitudinal values. There is no natural starting position for longitude, which is why a reference meridian had to be chosen. Traditionally the Prime Meridian is the meridian that passes through the Greenwich Observatory (located in Greenwich, England). The value of the Prime Meridian (Greenwich Meridian) is 0 degrees. WGS84, which the Location API uses, defines its zero meridian about 100 meters east of the traditional one. Locations east of the prime meridian have positive longitudinal values (0 to +180 degrees). Locations west of the prime meridian have negative longitudinal values (0 to -180 degrees).
Figure: A globe showing longitudinal and latitudinal lines. The Zero Meridian and Equator are drawn in bold.
As seen in the figure below, the latitude lines become smaller and smaller near the poles. At the equator, one degree of longitude is roughly 111.3 km, whereas at 60 degrees of latitude one degree of longitude is only 55.8 km. That makes it difficult to see the lengths of latitudinal lines.
Figure: Length difference between latitude lines on the equator and at 60 degrees of latitude