Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from...

49
Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet

Transcript of Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from...

Page 1: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Location for Mobiles

Mobile Computing

Some slides from MobEduNet

Page 2: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Where… is the question answered by location

How do I get there?

How do I get there?

What’s around me?

What’s around me?

Where am I?

Where am I?

Page 3: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Location needs context

Where am I going, and how am I travelling there?

Car/WalkCar/WalkBikeBike

??????

Page 4: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

LBS can be pulled by the client

Pull based scenarios let the user determine the interaction: get directions, find a shop, etc

Page 5: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

LBS push and pull the client

Push based scenarios let the service prompt the user: proximity based sending of adverts and coupons

Special voucher for startbucks

Page 6: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Location can be determined a number of ways for mobiles

http://www.flickr.com/photos/timothymorgan/75699268/

Cell tower IDCell tower ID

Satellite GPSSatellite GPS

A- GPSA- GPS

Enhanced 911Enhanced 911

Local proximity for Bluetooth

Local proximity for Bluetooth

Page 7: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Location methods all offer different features

• Real-time positioning methods

• Accuracy depends on the method used

• Different level of accuracy

• Warm-up time

Page 8: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

The output of the location also differs

• Location types:– Spatial term– Text description

• Text description is usually expressed as a street address, including city, postal code, etc.

Page 9: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Spatial terms provide latitude-longitude-altitude

• Latitude: 0-90 degrees north or south of the equator

• Longitude: 0-180 degrees east or west of the prime meridian, which passes through Greenwich, England

• Altitude: meters above sea level

Page 10: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Go the ‘long way round’ to remember lat/long

• Latitude = north/south of the equator

• Longitude = east/west of Greenwich

Bruce Scharlau, University of Aberdeen, 2011

Page 11: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Location can be determined a number of ways for mobiles

http://www.flickr.com/photos/timothymorgan/75699268/

Cell tower IDCell tower ID

Satellite GPSSatellite GPS

A- GPSA- GPS

Enhanced 911Enhanced 911

Local proximity for Bluetooth

Local proximity for Bluetooth

Page 12: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Network based positioning uses Cell ID

• Device is communicating with a Base Transceiver Station (BTS)

• Current cell ID can be used to identify BTS

• Accuracy depends on the size of the cell:– A GSM cell may be anywhere from 2 to 20

kilometers in diameter– Other techniques used along with cell ID can

achieve accuracy within 150 meters

Page 13: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Satellite based positioning• GPS is controlled by the US Department of Defense, and

other systems are also coming online • Determines the device's position by calculating

differences in the times signals from different satellites take to reach the receiver

• Most accurate method, between 4 and 40 meters• Disadvantages:

– Extra hardware can be costly– Consumes battery while in use– Requires some warm-up – „Canyon effects” in cities, where satellite visibility is intermittent

Page 14: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Short-range positioning beacons use Bluetooth

• Small areas like single buildings

• Local area network can provide location

• Bluetooth for short-range positioning

Page 15: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Accuracy is dependent upon the application

• Some applications don't need high accuracy:– Position information from a larger area

• Others will be useless if the location isn't accurate enough:– Navigation applications

Page 16: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

There are also other issues to consider

Where were you at?, asks the boss.

Where is the shipment?, asks the delivery man.

What is the pattern of behaviour for this customer?, asks the network operator.

All can be answered with Location data, but should they be?All can be answered with Location data, but should they be?

Page 17: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Nokia and maps the dark horse?

• Believe still long way to go with maps: generic now, tailored per context in future

• Crosss-platform HERE Maps with API for developers

• Combine maps with AR for more information and content

Bruce Scharlau, University of Aberdeen, 2011http://www.guardian.co.uk/technology/appsblog/2012/nov/14/nokia-here-maps-location

Page 18: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Foursquare is like a loyalty card• Analytics and Yield management: some 500,000 registered

merchants with dashboard allows merchants to claim their venue, run specials, and access a host of other data about how 15mn customers interact with their business in real-time.

• Customer loyalty: Foursquare wants to be "a digital version of a stamp card." This is where check-in specials come in: Free drinks for the mayor or for the nth check-in. 

• Search and Discovery: Foursquare added the Explore feature a year ago to let users search neighborhoods and garner recommendations for nearby businesses. 

• Deals: Foursquare has partnered with a number of daily deal sites over the past year to provide real-time location-based deals

http://www.businessinsider.com/bii-report-heres-how-location-based-services-like-foursquare-are-trying-to-become-big-businesses-2012-9

Bruce Scharlau, University of Aberdeen, 2011

Page 19: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Location apps not easy

• Facebook places is little-used by business; possibly as not mobile based app

• Google Latitude not done much and more of a bolt-on to maps

• Yelp both desktop (search for places to eat/drink/etc) and mobile with reviews etc, but mainly US

Bruce Scharlau, University of Aberdeen, 2011

Page 20: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Location based services aren’t corporate enough

• Security and privacy policies fine for individuals, but not at business level.

• People want more control over who sees where they are

• Location is really another form of social media

Bruce Scharlau, University of Aberdeen, 2011http://www.computerworld.com/s/article/9226785/Location_based_services_Are_they_there_yet_

Page 21: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

LBS in iOS uses location + maps

• Core location provides ‘where’ someone is

• Maps handled by Map Kit Framework

• Geocoding to move from lat/long to place objects (address, building, etc) on map

• Reverse geocoding also possible

• Issue with maps at moment…

Bruce Scharlau, University of Aberdeen, 2011

Page 22: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

And where is Aberdeen?

What’s the latitude and longitude of Aberdeen?

Bruce Scharlau, University of Aberdeen, 2011

Page 23: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Aberdeen is west of London

Bruce Scharlau, University of Aberdeen, 2011

http://www.earthtools.org/

57.1467°N 2.0901°W

Page 24: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Use Google API for location

• Select Google APIs for new projects using maps and location

• Otherwise your app won’t run

Bruce Scharlau, University of Aberdeen, 2011

Page 25: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Also put permissions in manifest

• Need to add permissions for

• INTERNET

• ACCESS_COURSE_LOCATION

• ACCESS_FINE_LOCATION

Bruce Scharlau, University of Aberdeen, 2011

Page 26: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Manifest also needs to specify map library

Apps with maps need to specify need as ‘true’ for com.google.android.maps library in manifest

Bruce Scharlau, University of Aberdeen, 2011

Page 27: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Map layouts need API key

• Need to get Google MAPs API key to use maps in your apps – referenced in layout

Bruce Scharlau, University of Aberdeen, 2011

http://code.google.com/android/add-ons/google-apis/mapkey.html

This allows map tiles to be downloaded to your application

Page 28: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Direction API for routes included

Bruce Scharlau, University of Aberdeen, 2011

Can use direction API within maps API for routes

http://www.anddev.org/google_driving_directions_-_mapview_overlayed-t826.html

Page 29: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

LocationListener updates map

Bruce Scharlau, University of Aberdeen, 2011

This is about as simple as it gets for map display

http://www.vogella.de/articles/Android/article.html#locationapi

Page 30: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Use DDMS tool to set location

Bruce Scharlau, University of Aberdeen, 2011

Page 31: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Geocoder library to look up location

Bruce Scharlau, University of Aberdeen, 2011

Page 32: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Summary

• Maps need API key to be displayed

• Maps needs permissions set in manifest

• Maps need API enabled

• Lots of work done over network

Bruce Scharlau, University of Aberdeen, 2011

Page 33: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Location API for Java ME is JSR 179

• JSR 179: javax.microedition.location package

• Physical location

• Orientation (compass direction)

• Support the creation and use of databases of known landmarks, stored in the device

Page 34: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

The Location API has only a few components

Source: Nokia Location Guide

Page 35: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

JSR 179 requires CLDC 1.1

• Connected Device Configuration (CDC) or Connected Limited Device Configuration 1.1 (CLDC) for floating-point numbers

• CLDC 1.0 does not support floating-point numbers

• No requirements for MIDP

Page 36: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Hardware determines the other requirements, ie BT, GPS, orientataion

• Hardware platform determines which location methods are supported

• At least one is needed for using LBS

• Request providers with particular characteristics, such as a minimum degree of accuracy

• Some location methods may be free; others may entail service fees

Page 37: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Using Java ME the Location API starts with a Criteria

Need a LocationProvider, but can only call that once you know the criteria for choosing one: cost, accuracy, etc

Criteria c = new Criteria();LocationProvider lp = LocationProvider.getInstance(c);

Page 38: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Don’t need to write any extra code to get coordinates from Bluetooth GPS

API checks for ‘best’ LocationProvider given the Criteria requirements

If it finds an ‘on-board’ device, then it uses that.

If not, then it checks the Bluetooth list of devices for a suitable one, and uses this.

Page 39: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

With a LocationProvider you can call getLocation() to find your location

No matching LocationProvider returns null, and a LocationException if no LocationProviders are available

Location location = lp.getLocation(10); // timeout in seconds

QualifiedCoordinates qc = location.getQualifiedCoordinates();double lat = qc.getLatitude();double lon = qc.getLongitude();

Page 40: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Get period updates on your position with LocationListener

// method added by LocationListenerpublic void locationUpdated(LocationProvider provider, Location location) {

QualifiedCoordinates qc = location.getQualifiedCoordinates();double lat = qc.getLatitude();double lon = qc.getLongitude();String latString = Double.toString(lat);String lonString = Double.toString(lon);log("locationUpdated(): " + latString + " " + lonString);

}

// method added by LocationListenerpublic void providerStateChanged(LocationProvider provider, int newState) {

log("providerStateChanged()");}

Page 41: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Use ProximityListener to find out when you’re close to a location

These only work on supported devices

Page 42: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

The LandmarkStore provides a location database

LandmarkStore.createLandmarkStore("Auction");

String[] stores = LandmarkStore.listLandmarkStores();

Easy to create a LandmarkStore

All LandmarkStores available to ALL Java ME apps

Page 43: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Find your LandmarkStore and then add landmark

LandmarkStore ls = LandmarkStore.getInstance("Auction");

qc = new QualifiedCoordinates(35.977876, -78.514786, Float.NaN, Float.NaN, Float.NaN);

Landmark landmark = new Landmark("Baseball park","Forest Park", qc, null);ls.addCategory("Sports");ls.addLandmark(landmark, "Sports");

Page 44: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Find landmarks meeting set criteria using Enumeration

Enumeration ge = ls.getLandmarks(null, 35.963280, 36.010783, -78.555336, -78.483582);

while (ge.hasMoreElements()) {Landmark found = (Landmark) ge.nextElement();log(" " + found.getName());

}

ls.getLandmarks(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude);

Page 45: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

You may also be able to determine the Orientation of the device

Orientation provides an understanding of ‘North’ either as magnetic, or ‘true North’ as ‘magnetic north’ moves over time

This can be used in some devices such as the N95 as a type of ‘accelerometer’ similar to what is used in the Wii controls

Page 46: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Nokia’s TouristRoute example provides a LBS and MVC study

Source: Nokia Location Guide

Page 47: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

TouristRoute startup follows criteria requirements

Source: Nokia Location Guide

Page 48: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

TouristRoute is ‘blueprint’ of sorts, but raises questions too

• Uses many classes – decomposses objects and views

• Might be better to use fewer, test if need performance, or other issues resolved

Bruce Scharlau, University of Aberdeen, 2011

Page 49: Bruce Scharlau, University of Aberdeen, 2011 Location for Mobiles Mobile Computing Some slides from MobEduNet.

Bruce Scharlau, University of Aberdeen, 2011

Further references for Location API

• http://www.ibm.com/developerworks/edu/wi-dw-wi-mobilesa-i.html IBM example that shows how to use external event tool in WTK (registration required)

• http://www.forum.nokia.com/main/resources/technologies/location_based_services/java.html Nokia tutorial also good on using its tools, and on MVC design for larger app