Location

smuet.lecture.ub.ac.id

Location

Faculty Summit

September 28 th ,

Bandung

rayrizaldy@gits.co.id


Network and

Location


Location, Maps

Bluetooth


› Traditional ”location” APIs

use GPS

Location

› Network-­‐based location is

faster to give a result, but

the result is less precise

› There are several variants

available. The phone will pick

the most precise among the

options you consider

acceptable.


Network-­‐based Positioning Accuracy Estimates

Cell-­‐id precision offered across Asha range of phones

Only on WLAN phones

500 m 2000 m 4000 m

100 m

Urban:

50% within 250 m

80% within 500 m

100 % hit rate

Sub – Urban:

50% within 600 m

80% within 1.5 km

80-­‐90 % hit rate

Rural:

50% within 1500 m

80% within 3 km

60-­‐90 % hit rate

WLAN:

Up to 30m precision in

urban areas


Cell ID Positioning

* Series 40 5th Edition FP1 +: Manufacturer & Operator Domains. Java Runtime 1.0.0+: all domains

Example: mapExample

» Specify the location methods which are acceptable

» Get a LocationProvier, the best the phone can offer on current

network

//Specify the retrieval method to Online/Cell-­‐ID

int[] methods = {(Location.MTA_ASSISTED | Location.MTE_CELLID | Location.MTE_SHORTRANGE | Location.MTY_NETWORKBASED)};

// Retrieve the location provider

LocationProvider provider = LocationUtil.getLocationProvider(methods, null);

// 50 seconds time-­‐out

Location loc = provider.getLocation(50000);

// Get longitude and latitude

QualifiedCoordinates coordinates = loc.getQualifiedCoordinates();


LocationUtil

» The com.nokia.mid.location.LocationUtil class provides an extra mechanism for creating

a LocationProvider

» This is an extension to the JSR-­‐179 Location API, which provides the LocationProvider class

» It just makes it easier and more logical to request your location

}

class LocationUtils {

static LocationProvider LocationUtil.getLocationProvider(int[] preferedMethods,

String parameters );

» The parameters is for additional platform parameters, for now use null


LocationUtil

» The preferedMethods can be a combination of the following definitions of

the JSR-­‐179 Location class

› Offline CellID

› MTA_UNASSISTED | MTE_CELLID | MTY_TERMINALBASED

› Online CellID and/or WLAN

› MTA_ASSISTED | MTE_CELLID | MTE_SHORTRANGE | MTY_NETWORKBASED

› Assisted GPS

› MTA_ASSISTED | MTE_SATELLTITE | MTY_TERMINALBASED

› Standalone GPS

› MTA_UNASSISTED | MTE_SATELLITE | MTY_TERMINALBASED


Cell-­‐ID Based Location

» A MIDlet can obtain approximate location by using the Cell-­‐ID based

method

» This method will send to a network based server the cell-­‐id that the

phone is connected to. This server will return the known location of

that cell-­‐id

» This enabled phones without built in GPS to obtain an approximate

Location without requiring a separate Bluetooth GPS device

» Note using Cell-­‐ID based location, the coordinates can vary from a few

meters to hundreds of kilometers, depending on the local network

deployment and on how much information the backend database has

been able to collect for that area


Cell-­‐ID Example Code

» Example code:

int[] methods = {(Location.MTA_ASSISTED |

Location.MTE_CELLID |

Location.MTY_NETWORKBASED)};

LocationProvider lp = LocationUtil.getLocationProvider(methods,

null);

Location loc = lp.getLocation(-1);

Coordinates coords = loc.getQualifiedCoordinates();

double lat = coords.getLatitude();

double lng = coords.getLongitude();


Maps


Maps API for Java ME

Now included in Nokia Java SDK 2.0

(previously separate plug-in package)


Nokia Maps API – Services Available

http://www.developer.nokia.com/Develop/Maps/Maps_API_for_Java_ME/

Supports local

search and places

look-­‐up by

category

Geo-­‐coding &

Reverse Geo-­coding


Routing between

any start and end

point, taking into

consideration

transport and

traffic

preferences

Location Sharing

into your app.

Lets users send

images or URL in

SMS Message

Integrated

KML to show

the content on

the map

without having

to recreate it

manually


Pricing Models for Nokia Maps APIs

Product Offering

Section Standard Premium

NLP Standard API Access ✓ ✓

Throughput

Maps – Unlimited

Routes – 20,000 trans/day

Search – 20,000 trans/day

Maps – Unlimited

Routes – Up to 10 trans/sec

Search – Up to 10 trans/sec

Service Level Targeted 99.9% Guaranteed 99.9%

Support X ✓

Pricing Model

Transaction Bundles

Free usage within following

limits:

Maps 1,000,000 per month

Routes 500,000 per month

Search 500,000 per month

Excess Transaction Fee €0.0050 €0.0025

No limits , bundles valid for 24

months:

1 million -­‐ €1,750

5 million -­‐ €7,500

25 million -­‐ €31,250

50 million -­‐ €50,000

100 million -­‐ €75,000

200 million -­‐ €100,000


Developer Offering Overview

Section Standard Premium

Product Offering

Nokia Developer Site API Access ✓ ✓

Support and Service Level Agreement X ✓

Pricing Model

Take It or Leave It Terms ✓ ✓

Transactions Fees ✓ ✓

Terms & Conditions

Platform Registration ✓ ✓

Nokia Branding ✓ ✓

Advertising Required ✓ ✓/ Opt Out

Commercial Applications ✓ ✓

Monetization Allowed ✓ ✓

Unlimited Transactions & Requests X SLA


Using Maps API

1. Register as a developer free at www.developer.nokia.com

2. Obtain a free set of authentication credentials (App Id and Token) from:

1. https://api.developer.nokia.com/ovi-­‐api/ui/registration

2. A unique App ID and Token, are required for each application

3. Create the app with Maps API. Add the Maps plug-­‐in binary as a reference to the project.

4. Test & Publish app

5. In case the quota is exceeded, Nokia would contact you with further details!

6. Write in to locationapi@nokia.com if you would directly like to go for Premium Model


Series 40 & Cell ID positioning support

JSR-­‐179 with cell-­‐id positioning

• Nokia Asha 202

• Nokia Asha 302

• Nokia Asha 203

• Nokia X2-­‐02

• Nokia Asha 300

• Nokia Asha 201

• Nokia Asha 200

• Nokia Asha 303

• Nokia C3-­‐01 Gold Edition

• Nokia C2-­‐05

• Nokia X2-­‐05

• Nokia C2-­‐03

• Nokia C2-­‐06

• Nokia C2-­‐02

• Nokia C2-­‐01

• Nokia X2-­‐01

• Nokia X2-­‐00

• Nokia X3-­‐02

• Nokia C3-­‐00

• Nokia C3-­‐01

• Nokia 6750 Mural

• Nokia 6303i classic

• Nokia X3-­‐02

• Nokia C3-­‐00

• Nokia X2-­‐00

• Nokia 2710 Navigation Edition

• Nokia 3720 classic

• Nokia 7230

• Nokia 3710 fold

• Nokia 6350

• Nokia X3-­‐00

• Nokia 7020

• Nokia 6700 classic

• Nokia 6303 classic

• Nokia 7510 Supernova

• Nokia 6275i

• Nokia 6260 slide

• Nokia 5330 Mobile TV Edition

• Nokia 6165

• Asha 306

JSR-­‐179 with cell-­‐id + WLAN positioning

• Asha 305

• Asha 311


Supported Features

» Maps

» Search

» (Reverse) Geocoding

» Routing

» Sharing: convert to URL

» Note: now always requires AppID and Token


Map View

Features

» Multiple map types – conventional street

map, satellite and terrain

» Touch support – use touch to pan and zoom

the map

» Customizable markers – set color, labels and

images

» Polygons, polylines – set colors and

transparency levels

» Overlay support – set color/labels or use

custom images

» Download indicator – provided as a standard

UI component


Using: Maps

Example: mapExample

public class MapMidlet extends MIDlet {

public void startApp() {

// Set registered application ID and token

ApplicationContext.getInstance().setAppID("xxx");

ApplicationContext.getInstance().setToken("xxx");

// Create new Nokia Maps canvas

Display display = Display.getDisplay(this);

MapCanvas mapCanvas = new MapCanvas(display);

}

}

// Show map on the screen

display.setCurrent(mapCanvas);

// Geocode an address

SearchManager searchManager = SearchManager.getInstance();

searchManager.geocode("Vienna, Austria", null);

Location[] locations = searchManager.getLocations();

// Center map on the latitude and longitude

mapCanvas.getMapDisplay().setCenter(locations[0].getDisplayPosition());

mapCanvas.getMapDisplay().setZoomLevel(11, 0, 0);


Maps Package Overview

» The API is divided into four packages.

Package

com.nokia.maps.common

Description

Common classes needed by other packages including Address,

ApplicationContext, GeoBoundingBox and GeoCoordinate.

com.nokia.maps.map

com.nokia.maps.routing

com.nokia.maps.search

Map package contains classes needed to show and interact with map

content and place objects on map.

Routing package contains classes to calculate route and access route data.

PositioningManager provides an easy to get current location information

based on GPS device or device cell information.

Search package contains SearchManager for geocoding and reverse

geocoding.


The Minimal LBSP App

» Displaying interactive map to the user is simple as creating

MapCanvas instance and setting it as a current displayable:

import com.nokia.maps.map.MapCanvas;

/**

* Minimal MIDP application to show map content to the user.

*/

public class MapMIDlet extends MIDlet {

/**

* This method is called when the application is started and sets

* MapCanvas as a current Displayable.

*/

protected void startApp() throws MIDletStateChangeException {

Display display = Display.getDisplay(this);

MapCanvas mapCanvas = new MapCanvas( display );

display.setCurrent(mapCanvas);

}

}


Map


Map Markers

» A Marker can be added to a map with the following code:

double lat = 51.3;

double lng = 0.8;

int size = 10;

String s = “You are here!”;

GeoCoordinate coord = new GeoCoordinate(lat, lng, 0 );

MapFactory mapFactory = mapCanvas.getMapFactory();

MapStandardMarker marker =

mapFactory.createStandardMarker(coord, size, s);

mapCanvas.getMapDisplay().addMapObject( marker );


Map Marker


Other Map Markers

» The MapFactory class defines other types of Map Markers:

MapMarker createMapMarker( GeoCoordinate coordinate, Image image );

MapCircle createMapCircle( double radius, GeoCoordinate centre );

MapRectangle createMapRectangle( GeoBoundingBox boundingBox );

MapPolygon createMapPolygon( GeoCoordinate[] coordinates );

MapPolyline createMapOptPolyline( GeoCoordinate[] coordinates );


Search Manager

» Places can be searched for with the SearchManager

» You can also look up locations near a specified GeoCoordinate

// Get instance of SearchManager

SearchManager searchManager = SearchManager.getInstance();

searchManager.setListener(this);

// Look up locations based on a search string

searchManager.geocode( “Germany,Berlin", null );

// Or, get locations at specified GeoCoordinate

GeoCoordinate coord = new GeoCoordinate(51.3, 0.8, 0 );

searchManager.reverseGeocode( coord );


Search Listener

» The SearchListener allows a MIDlet to get notification when a search

request is completed

public class MySearchListener implements SearchListener {

}

public void searchRequestError(SearchManager source, Throwable error)

{

// Handle search error

}

public void searchRequestFinished(SearchManager source) {

// Can now get the search results

Location[] locations = source.getLocations();

}

public void searchResponseCleared(SearchManager source) {

}


Routing

» RouteManager provides access to Ovi routing service

» Calculating route requires at least two waypoints and wanted modes

» Modes are used to control route calculation features

// Create the waypoints

GeoCoordinate start = new GeoCoordinate(51.3, 0.8, 0);

GeoCoordinate end = new GeoCoordinate(55.0, 0.0, 0);

WaypointParameterList waypoints = new WaypointParameterList();

waypoints.addCoordinate(start);

waypoints.addCoordinate(end);

RouteManager rm = RouteManager.getInstance();

rm.setListener(this);

// Use default routing mode

RoutingMode[] modes = { new RoutingMode() };

rm.calculateRoute(waypoints, modes );


Route Listener

public void calculateRouteRequestFinished(RouteManager rm) {

Route[] routes = rm.getRoutes();

Maneuver m = route[0].getFirstManeuver();

while( m != null ) {

String s = m.getInstruction();


m = m.getNextManeuver();

}

}

public void routeRequestError(RouteManager rm, Throwable error) {

// handle error condition

}

public void routeResponseCleared(RouteManager rm) {

// route cleared

}


Routing Mode

» A RoutingMode consists of:

› A routing type

› A list of transport modes

› A list of routing options

public RoutingMode(int routingType,

int[] transportModes,

java.lang.String

[] routingOptions);


Routing Types

» The Routing Type must be one of the types defined in

RoutingType

RoutingType.DIRECT_DRIVE » These are static ints

RoutingType.ECONOMIC

RoutingType.FASTEST

RoutingType.FASTEST_NOW

RoutingType.SCENIC

RoutingType.SHORTEST


Transport Modes

» The following transport Modes are available

TransportMode.BICYCLE

TransportMode.CAR

TransportMode.PEDESTRIAN

TransportMode.PUBLICTRANSPORT

TransportMode.TRUCK


Routing Options

» These are string constants defines in RoutingOptions

RoutingOptions.AVOID_BOATFERRY

RoutingOptions.AVOID_DIRTROAD

RoutingOptions.AVOID_MOTORWAY

RoutingOptions.AVOID_PARK

RoutingOptions.AVOID_PUBLICTRANSPORT

RoutingOptions.AVOID_RAILFERRY

RoutingOptions.AVOID_STAIRS

RoutingOptions.AVOID_TOLLROAD

RoutingOptions.AVOID_TUNNEL

RoutingOptions.PREFER_HOVLANE

NOTE: HOVLANE = High occupancy vehicle lane


Custom Display

» So far the example used a MapCanvas which performs all the Map rendering

» The LBSP API also allows you to use the MapDisplay directly, to provide a greater

control on how the Maps are rendered to the canvas

MapFactory mapFactory = MapFactory.createMapFactory(MapDisplayType.TILE_MAP,

MapResolutionEnum.MAP_RESOLUTION_128_x_128, getWidth(), getHeight());

MapDisplay map = mapFactory.createMapDisplay();

» Display Type can be either: TILE_MAP or VECTOR_MAP

» Resolution can be either: 128 x 128 or 256 x 256


Using MapDisplay

» You can then render the map on your own Canvas with

renderMap(Graphics)

protected void paint(Graphics g) {

map.renderMap(g);

}

» Alternatively, you can render the map to an Image instead and

then use that Image wherever you like

Image image = Image.createImage( width, height );

Graphics g = image.getGraphics();

map.renderMap(g);


Custom Display Screenshot


Bluetooth

› You can use push-­‐registry to

wake the application when

other phones connect to a

port

› If you register the port when

the app is running,

connections will work but

the app will not start when

someone else connects

› SPP (serial port profile) is the

most useful for exchanging

your own, proprietary data


Network and

Location :

Key Points

1) Network-­‐based location is

fast, low power,

approximate (better

accuracy in 3G), and works

indoors

2) Customized Maps with

cloud routing and search

are fast to add to your app

More magazines by this user
Similar magazines