You are on page 1of 41

Lecture 5

Location-based Services
GE2338 Internet Applications and Security
Global Positioning System (GPS)

 The Global Positioning System (GPS) that includes 24 satellites in circular


orbits around the earth provides location and time information in all
weather, anywhere on or near the earth, where there is an unobstructed
line of sight to four or more GPS satellites.

 GPS is maintained by the United States


government and is freely accessible
by anyone with a GPS receiver.

GPS receivers.
Differential GPS (1/2)

 Differential GPS (DGPS) is an enhancement to GPS that provides


improved location accuracy, from the 15-meter nominal GPS accuracy to
about 10 cm in case of the best implementations.
 DGPS uses a network of fixed, ground-based reference stations to
broadcast the difference
between the positions indicated by
the satellite systems and the
known fixed positions.

DGPS receiver.
Differential GPS (2/2)

 Hong Kong Survey and Mapping Office / Lands Department provides


DGPS correctional signal

Website: http://www.geodetic.gov.hk/smo/gsi/programs/en/GSK/FAQ/faq_NetworkRTK.htm
GLONASS
 GLONASS (Global Navigation Satellite System) is a radio-based satellite navigation
system operated for the Russian government. It both complements and provides an
alternative to the United States' GPS.
 Its accuracy is about 3m by 2011. With more ground stations being built, hopefully the
accuracy will improve to 0.6m by year 2020.

GLONASS – 3 orbital panes and 8 evenly GPS – 6 orbital panes and 4 unevenly
spaced satellites per plane spaced satellites per plane
Other Navigation Systems

 Galileo is a satellite navigation system currently


being built by the European Union (EU).
 3 orbital planes and 10 satellites per plane

 The BeiDou (北斗) Navigation System is an


independent satellite navigation system
developed by China.
 It became operational with coverage of China
in December 2011 with 10 satellites in use. It is
planned to offer services to customers in Asia-
Pacific region by 2012, and the global system should be finished by 2020.
7

Cellular Positioning

 One of the cellular positioning methods is


Time of Arrival (ToA).
 ToA uses the travel time of a radio signal
from a single transmitter to a remote single
receiver as a measure for their distance.
 ToA data from two base stations will narrow
a position to a circle; data from a third base
station is required to resolve the precise
position to a single point.
 Accuracy: 100 to 200 meters
8

Smartphones

 Most of all current smartphones support Assisted GPS

 More smartphones will support GLONASS (e.g., iPhone and Samsung


GALAXY Note)
9

Wi-Fi Positioning System (WPS)

 WPS is used where GPS is inadequate, including indoors, taking


advantage of the rapid growth of wireless access points in urban areas.

 There are several commercial providers of this type of service, including


Google, Navizon, and Skyhook.

 The localization technique


used for positioning with
wireless access points is
based on measuring the
received signal strength
(RSS) and the method of
“fingerprinting”.
iPhone supports Wi-Fi location positioning
10

Wi-Fi Fingerprinting

 A reference database stores an access point’s MAC address (i.e., a unique


identifier assigned to network interfaces) associated with its location.

 When a user enters into an area, the reference database is searched for
nearby access points and then the exact position of the user is calculated
by selecting and comparing
them in the reference database.

 The accuracy depends on the


number of positions that have
been entered into the database.
11

How is Google Collecting Wi-Fi Data?

 Mobile users who use Google applications to get their position or share
their location with friends are helping Google build out a database of Wi-Fi
hot-spot locations.

 Whenever you make a request, a list of nearby wireless hotspot address is


sent along the request.

 Google applications turn your mobile phone into a Google Wi-Fi sensor!

 Laptop owners using browsers that take advantage of HTML5 geolocation


technologies are also contributing to the database when they upload their
location to services like Twitter or Foursquare or use Firefox geolocation
services.
Source: http://news.cnet.com/8301-30684_3-20009223-265.html
Intelligent Transport System in HK (1/5)

 Journey Time Indication System (JTIS)


monitors 22 major routes, including 9 routes
from Kowloon Peninsula (KL) to Hong Kong
Island (HK) and 13 routes from HK to KL via
the three cross-harbour tunnels (i.e., Cross
Habour Tunnel, Eastern Harbour Crossing,
and Western Harbour Crossing).
 10 sets of journey time indicators are installed
to display average journey time, on a 24-hour
basis and refreshed every two minutes, in
three colours for different traffic conditions:
Red represents congested traffic, Amber
represents slow traffic and Green represents
smooth traffic.

Reference: https://www.td.gov.hk/en/transport_in_hong_kong/its/its_achievements/journey_time_indication_system_/index.html
Intelligent Transport System in HK (2/5)

 Speed Map Panels (SMPs) monitors 13


major routes from New Territories (NT) to
Kowloon Peninsula (KL).
 Each set of Speed Map Panel consists of a
series of speed map display and journey
time indicators. Three sets of the Panels are
installed at New Territories East and two
sets are installed at New Territories West to
provide real-time traffic information.

Reference: https://www.td.gov.hk/en/transport_in_hong_kong/its/its_achievements/speed_map_panels/index.html
Intelligent Transport System in HK (3/5)

 ITS mainly requires road-side


sensors
 Video detectors collect data on
traffic speed and volume and
automatically detect traffic incidents
on roads through video analytics
 Automatic licence plate recognition
detectors collect traffic volume of
different vehicle classes on roads
through matching of licence plate
numbers captured by the detectors
and Transport Department’s vehicle
licensing system
Intelligent Transport System in HK (4/5)

 The (1) current journey time


refreshed every two minutes and (2)
historical journey times of the 22
routes of JTIS and 13 routes of
SMPs can be accessed online.

Reference: http://resource.data.one.gov.hk/td/journeytime.xml
Intelligent Transport System in HK (5/5)

 The ITS provides free traffic information on some major routes, but it
has some limitations.
 Although HK Transport Department plans to install about 400 sets of
traffic detectors to increase their coverage on strategic routes to about
80% by late 2020, the overall coverage is still relatively very small
compared to the entire road network in HK.
 The road-side hardware installation and operation costs are expensive.
 The ITS does not provide a platform for building location-based services
on the collected traffic information.
Google Maps Platform

 Google Maps was launched in February 2005 and its API was launched
in June 2005.
 Google Maps API supports three main platforms: Web, Android and
iOS, and provides two types of journey time estimation methods: the
typical journey time obtained from historical data and the real-time
journey time based on live traffic conditions and historical data.
 Google: “When we combine your speed with the speed of other phones
on the road, across thousands of phones moving around a city at any
given time, we can get a pretty good picture of live traffic conditions.”

Reference: Dave Barth. "The bright side of sitting in traffic: Crowdsourcing road congestion data", Google Official Blog, August 25, 2009.
[Online: https://googleblog.blogspot.com/2009/08/bright-side-of-sitting-in-traffic.html]
Google Geocoding API

 The Geocoding API is a service that provides geocoding and reverse


geocoding of addresses.
 Geocoding is the process of converting addresses (like a street address)
into geographic coordinates (like latitude and longitude), which you can
use to place markers on a map, or position the map.
 Reverse geocoding is the process of converting geographic coordinates
into a human-readable address.

Reference: https://developers.google.com/maps/documentation/geocoding/start
Google Geocoding API

 For example, find out the latitude and


longitude of City University of Hong
Kong.
 The geocoding request is
https://maps.googleapis.com/maps/api/ge
ocode/json?address=Tat+Chee+Ave,+Ko
wloon+Tong,+Hong+Kong&key=YOUR_
API_KEY
Google Geocoding API

 For example, find out the address of


City University of Hong Kong based
on its latitude and longitude
 The reverse-geocoding request is
https://maps.googleapis.com/maps/ap
i/geocode/json?latlng=22.332693,114.
175444&key=YOUR_API_KEY
Google Directions API

 The Directions API is a service that calculates directions between


locations using an HTTP request.
 Given user-specified origin and destination, the API returns the most
efficient routes in terms of many factors, e.g., travel time (the primary
factor), distance and number of turns, when calculating directions. (This
optimization is an application of the shortest path problem.)
 Specify origins, destinations, and waypoints as text strings (e.g., “City
University of Hong Kong, Hong Kong”), latitude/longitude coordinates, or
as place IDs.
 The API can calculate directions for several modes of transportation,
including driving (default), transit, walking or cycling.
Google Directions API

 For example, the API calculates the


direction from City University of Hong
Kong, Hong Kong to Mong Kok, Hong
Kong.
 The URL request is
https://maps.googleapis.com/maps/api/d
irections/json?origin=City+Univeristy+of
+Hong+Kong,+Hong+Kong&destination
=Mong+Kok,+Hong+Kong&key=Your_A
PI_Key
 The output format is json.
Google Directions API

 For a directions API request, you can specify an array of waypoints to


alert a route by routing it through the specified location(s) from an origin
to a destination. The maximum allowed number of waypoints is 23, but
requests using 10 or more waypoints are billed at a higher rate.
 A waypoint is specified a latitude/longitude coordinate, an encoded
polyline, a place ID, or an address which will be geocoded.
 By default, the API calculates a route through the provided waypoints in
their given order. Optionally, you may set a parameter to request the API
to optimize the provided route by rearranging the waypoints in a more
efficient order. (This optimization is an application of the traveling
salesperson problem: “Given a list of cities and the distances between
each pair of cities, what is the shortest possible route that visits each city
and returns to the origin city?”.)

Reference: https://developers.google.com/maps/documentation/directions/intro
Google Directions API

 For example, the API calculates the


direction from City University of Hong
Kong, Hong Kong to Mong Kok, Hong
Kong via Hong Kong Baptist University,
Hong Kong as a waypoint
 The URL request is
https://maps.googleapis.com/maps/api/
directions/json?origin=City+Univeristy+
of+Hong+Kong,+Hong+Kong&destinati
on=Mong+Kok,+Hong+Kong&waypoint
s=Hong+Kong+Baptist+University,+Hon
g+Kong&key=YOUR_API_KEY
Google Maps API (1/2)

 The coverage of real-time traffic monitoring of Google Maps API is much


higher than that of the ITS in Hong Kong.
 No hardware installation and setup costs for using Google Maps API
 Google Maps API increased prices in July 2018. For example, the number
of free API calls per day was reduced from 25,000 per day to 28,000 API
calls per month (i.e., 2,578%). The price for an additional 1,000 API calls
was increased from $0.5 USD to $7 USD (i.e., 1,300%).
 You may want to look for alternatives if your application requires a large
number of API calls.

Reference: https://www.mapsmarker.com/docs/misc/google-maps-tos-changes/
Google Maps API (2/2)

Reference: https://cloud.google.com/maps-platform/pricing/sheet/
A Comparative Analysis of Journey Time
from Google Maps and ITS in Hong Kong
 Experiments were conducted to compare the journey time data crawled
from the ITS in Hong Kong and Google Maps during two weeks from
May 24, 2018 to June 6, 2018 (i.e., 10 weekends and 4 weekends).
 The journey time data crawled from Google Maps every 10 minutes,
while the journey time data crawled from the ITS every 2 minutes.
 Experimental results indicate that the distributions of the journey time
data from the ITS and Google Maps are consistent with each other for
most routes throughout the entire day; and the differences are
acceptable.
Experiment Results (1/3)

 ITS at Island Eastern Corridor westbound near City Garden to Western


Harbour Crossing (May 30, 2018, Wednesday)
Experiment Results (2/3)

 ITS at Island Eastern Corridor westbound near City Garden to Western


Harbour Crossing (June 03, 2018, Sunday)
Experiment Results (3/3)

Route Set (Weekdays) MAD MRD (%) Route Set (Weekends) MAD MRD (%)
(minutes) (minutes)
HK-KL 2.00 15.03 HK-KL 1.25 11.40

KL-HK 2.12 18.71 KL-HK 1.97 20.42


NT-KL (general routes) 1.04 9.23 NT-KL (general routes) 0.73 7.73
NT-KL (highway routes) 1.02 7.59 NT-KL (highway routes) 0.70 5.83
All 1.69 14.00 All 1.32 13.12
Shortest Path Problem

 Dijkstra’s shortest path algorithm: Given a graph and a source vertex in


the graph, find shortest path from the source to all vertices in the graph.
 Initialization: label all the vertices as “new”; set the distance from the
source to other vertices to infinity and the distance of the source as zero.
 Step 1: Select a “new” vertex with the shortest distance
 Step 2: For each adjacent vertex, calculate the distance from the source to
it, keep the shortest distance and keep the incoming edge with the
shortest distance (i.e., remember the previous node in the shortest path)
 Step 3: Repeat Steps 1 and 2 until no vertex is still labelled as “new”

Reference: https://en.wikipedia.org/wiki/Dijkstra's_algorithm
Dijkstra’s Shortest Path Algorithm (1/10)

 Given a graph of 8 vertices (i.e., a, b, …, h), each edge with its distance
between its connected vertices. Vertex a is the source.
8 7
b d f
4 9

a 11 8 3 h

8 15
c e g
1 2
Dijkstra’s Shortest Path Algorithm (2/10)

 Initialization: Each “new” vertex is underlined, the distance of a is set to 0


and the distance of other vertices is set to ∞
8 7
b d f
4 ∞ ∞ ∞ 9

0 a 11 8 3 h ∞

8 ∞ ∞ ∞ 15
c e g
1 2
Dijkstra’s Shortest Path Algorithm (3/10)

 Select vertex a, and update the distance of b and c.

8 7
b d f
4 4 ∞ ∞ 9

0 a 11 8 3 h ∞

8 8 ∞ ∞ 15
c e g
1 2
Dijkstra’s Shortest Path Algorithm (4/10)

 Select vertex b and update the distance of d

8 7
b d f
4 4 12 ∞ 9

0 a 11 8 3 h ∞

8 8 ∞ ∞ 15
c e g
1 2
Dijkstra’s Shortest Path Algorithm (5/10)

 Select vertex c and update the distance of e

8 7
b d f
4 4 12 ∞ 9

0 a 11 8 3 h ∞

8 8 9 ∞ 15
c e g
1 2
Dijkstra’s Shortest Path Algorithm (6/10)

 Select vertex e and update the distance of g

8 7
b d f
4 4 12 ∞ 9

0 a 11 8 3 h ∞

8 8 9 11 15
c e g
1 2
Dijkstra’s Shortest Path Algorithm (7/10)

 Select vertex g and update the distance of f and h

8 7
b d f
4 4 12 14 9

0 a 11 8 3 h 26

8 8 9 11 15
c e g
1 2
Dijkstra’s Shortest Path Algorithm (8/10)

 Select vertex d

8 7
b d f
4 4 12 14 9

0 a 11 8 3 h 26

8 8 9 11 15
c e g
1 2
Dijkstra’s Shortest Path Algorithm (9/10)

 Select vertex f, update the distance of h, and update the incoming edge

8 7
b d f
4 4 12 14 9

0 a 11 8 3 h 23

8 8 9 11 15
c e g
1 2
Dijkstra’s Shortest Path Algorithm (10/10)

 Select vertex h
The shortest path from
a to h is a->c->e->g->f-
8 7 >h.
b d f
4 4 12 14 9

0 a 11 8 3 h 23

8 8 9 11 15
c e g
1 2

You might also like