mobile location-based apps · location-based services 1. location-based: 80% of data 2. service (or...

64
Mobile location-based apps University of Tartu Jaak Laineste, Oct. 2017

Upload: others

Post on 18-Jul-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Mobile location-based apps

University of TartuJaak Laineste, Oct. 2017

Page 2: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Location-based service

overview

Part 1

Page 3: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Jaak Laineste

• GIS/LBS experience

– 22 years in GIS/mapping, 17 years in LBS

– Regio/Reach-U, Mobile operator LBS globally

– Nutiteq: 2006-2016

– CARTO since 2016

• CARTO and mobile development

– CARTO Maps SDK – native maps API

– CARTO Builder and Engine – Location Intelligence

platform

Page 4: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Location-Based Services

1. Location-based: 80% of data

2. Service (or mobile application)

3. Mobile technologies (phones, networks)

4. Mobile positioning

• LBS is universial technology

– Can be aspect of any app type: info, game,

tool, social...

Page 5: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Android app with mapPart 2

Page 6: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

What can be done

• Display map

– MapView API – interactive map:

Google Maps, 2D/2.5D, online

– Add clickable points to map

(annotations, clusters)

– Add overlays (rasters)

– Show user GPS location

• Geocoding

– android.location.Geocoder API,

online

• Reverse-geocoding

– android.location.Geocoder

getFromLocation()

• Calculate distance between

objects

– Location.distanceTo() method

• Find Point in area (and other

georelations)

– Spatial-enabled GIS engine:

PostGIS in server or Spatialite in

phone

• Routing – find optimal path in

graph

– Google online API, other on-line

routing engines

– Spatialite routing, in small area

– Graphhopper offline – open

source

• Navigation

– Turn by turn – Telenav, HERE

SDK

• Offline

– Maps, Routing, Geocoding, Data

– CARTO SDK

Page 7: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Practical coding on Android

1. Adding MapView to app

2. Add layers and objects to map

– Make pin clickable

3. Manipulate with map view

4. Get and show user location

5. Using geo back-end service

– CARTO service

Page 8: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

If you get stuck

• Code snippets

– http://bit.do/ut-lbs

• Guides:

– https://carto.com/docs/carto-engine/mobile-

sdk

• Working sample

– https://github.com/CartoDB/mobile-android-

samples/

Page 9: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Add Maps SDK to your project

1. Create new project, with single view

– Minimum SDK : 15, Phone and Tablet

– Blank activity, with Compatibility

2. Automatic CARTO SDK dependency to

MyApplication project build.gradle , add to

existing lines

dependencies {

compile 'com.carto:carto-mobile-sdk:4.1.0-rc.3@aar'

}

3. Sync gradle

http://bit.do/ut-lbs

Page 10: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Add MapView to Layout

• Make sure your AndroidManifest.xml defines

INTERNET permission

• Modify Layout:

– Change TextView to com.carto.ui.MapView

http://bit.do/ut-lbs

Page 11: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Initial code into MainActivity

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

// 1. The initial step: register your license. This must be done before using MapView!

MapView.registerLicense("YOUR_LICENSE_KEY", getApplicationContext());

// Create map view

MapView mapView = (MapView) this.findViewById(R.id.mapView);

// Create base layer. Use vector style from assets

CartoOnlineVectorTileLayer baseLayer = new CartoOnlineVectorTileLayer(CartoBaseMapStyle.CARTO_BASEMAP_STYLE_VOYAGER);

// Add layer to map

mapView.getLayers().add(baseLayer);

}

http://bit.do/ut-lbs

Page 12: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Data models

• Raster

– PNG for maps, lossless

– JPG for aerials

– GeoTIFF, coverages

– Key parameters: bitmap resolution, size, channels

• Vector

– Base objects: points, lines, polygons

– Collections: multi-polygon, multi-line, multi-point

– Attributes (fields): text/boolean/numeric/binary etc

– Texts on map - labels from attributes

– Layer – same as „table“ in DB

– Special cases: topological models, graphs, 3D vectors

Page 13: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

GIS Layers

Page 14: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Other data models

• Elevation models

– DEM – Digital Elevation Model

– TIN - triangulated irregular network

• 3D worlds

– Collada, X3D, KMZ, 3D vector tiles

– CityGML, IndoorGML

• Point clouds

– Lidar – laser measurements

Page 15: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Hillshade from DEM

Page 16: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

TIN

Page 17: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Point cloud

Page 18: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

3D model

Page 19: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

GIS layers in a map

• One base layer

– Background map: Google, OpenStreetMap etc

– Raster or vector-based

• Overlay layer(s)

– Points of Interest, markers

– GPS location – dynamic info

– Lines, Polygons, Points

– Clustered points

– 3D objects

Page 20: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Add pin to map

// Initialize a local vector data source

Projection proj = mapView.getOptions().getBaseProjection(); LocalVectorDataSource vectorDataSource1 = new LocalVectorDataSource(proj);

// Create marker styleMarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder();markerStyleBuilder.setSize(30);MarkerStyle sharedMarkerStyle = markerStyleBuilder.buildStyle();// Add marker to the local data sourceMapPos mapPos = proj.fromWgs84(new MapPos(13.38933, 52.51704));Marker marker1 = new Marker(mapPos, sharedMarkerStyle);

vectorDataSource1.add(marker1);

// Create a vector layer with the previously created data sourceVectorLayer vectorLayer1 = new VectorLayer(vectorDataSource1);// Add the previous vector layer to the mapmapView.getLayers().add(vectorLayer1);

http://bit.do/ut-lbs

Page 21: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Make map pin interactive

1. Add metadata to object

marker1.setMetaDataElement("id","My PIN");

2. Add Listener

http://bit.do/ut-lbs

Page 22: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Projections

Page 23: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Coordinate systems

• Geographical – spherical

– Units: Latitude and Longitude

– Based on an ellipsoid, e.g. WGS-84

– Datums, also WGS84 for GPS

– DMS for display, decimal degrees for programming

• Projected - cartesian

– Units: usually meters

– 1000+ named projections, mostly for local regions

– Reduce distortions: keep angles, distances, areas

equal

Page 24: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Geographical coordinate space

Page 25: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Cartesian (projected) coordinate

space

Page 26: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Different projections

• Extreme examples

– http://www.jasondavies.com/maps/

• In real life

– Plate Carre, Latitude/Longitude, WGS84

(EPSG:4326)

– Web map Spherical Mercator (EPSG:3857)

– Mercator

– UTM with zones

– Robinson – equal-area world map

– Lambert Conformal Conic, L-EST (EPSG:3301)

Page 27: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Robinson

Page 28: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Mercator

Page 29: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Short and long projection

description

EPSG codes: 4-5 digit numbers

• EPSG:4326 – WGS84

• EPSG:3301 – Estonian system

• EPSG:3857 – „Google web Mercator“

– A.k.a EPSG:900913

<EPSG:3301>

PROJCS["Estonian Coordinate System of 1997",

GEOGCS["EST97",

DATUM["Estonia_1997",

SPHEROID["GRS 1980",6378137,298.257222101,

AUTHORITY["EPSG","7019"]],

TOWGS84[0,0,0,0,0,0,0],

AUTHORITY["EPSG","6180"]],

PRIMEM["Greenwich",0,

AUTHORITY["EPSG","8901"]],

UNIT["degree",0.01745329251994328,

AUTHORITY["EPSG","9122"]],

AUTHORITY["EPSG","4180"]],

UNIT["metre",1,

AUTHORITY["EPSG","9001"]],

PROJECTION["Lambert_Conformal_Conic_2SP"],

PARAMETER["standard_parallel_1",59.33333333333334],

PARAMETER["standard_parallel_2",58],

PARAMETER["latitude_of_origin",57.51755393055556],

PARAMETER["central_meridian",24],

PARAMETER["false_easting",500000],

PARAMETER["false_northing",6375000],

AUTHORITY["EPSG","3301"],

AXIS["Y",EAST],

AXIS["X",NORTH]]

Page 30: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

View manipulation and some

Options// Set view

mapView.setFocusPos(proj.fromWgs84(new MapPos(13.38933, 52.51704)), 0); mapView.setZoom(10, 0); // zoom 2, duration 0 seconds (no animation)mapView.setMapRotation(0, 0);mapView.setTilt(90, 0);

// Some options

mapView.getOptions().setRotatable(false); // make map not rotatable

mapView.getOptions().setTileThreadPoolSize(4); // faster tile downloading

mapView.getOptions().setZoomRange(new MapRange(0, 14));

// Use MapView coordinate system like this:

mapView.getOptions().setPanBounds(new MapBounds(new MapPos(2336596.00, 8398607.00), new MapPos(2561461.75, 8626954.00)));

http://bit.do/ut-lbs

Page 31: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

zoom = 0 zoom = 1 zoom = 2

X=0Y=0

X=0Y=0

X=0Y=1

X=1Y=1

X=1Y=0

y

x

X=0Y=0

X=0Y=1

X=1Y=1

X=1Y=0

X=0Y=2

X=0Y=3

X=1Y=3

X=1Y=2

X=2Y=0

X=2Y=1

X=3Y=1

X=3Y=0

X=2Y=2

X=2Y=3

X=3Y=3

X=3Y=2

Web map tiling system (OSM)

X=150524Y=78432Zoom=18

Page 32: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

User location on map

• Android Location API

– GNSS (GPS, GLONASS, Galileo) + wifi + mobile network cell

• Alternative positioning methods

– External GPS

– Mobile Positioning

– Indoor positioning

• Beacons

• Wifi

• Bluetooth

• Magnetic variations

Page 33: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Location API in Android

• Location Provider

– Selected automatically based on set requirements: Cell-id,WiFI or GNSS

• Features

– Listen for updates – most common

– Last known location (cached) – not suggested

– Proximity alerts – not guaranteed

• Best strategy depends on app

– http://developer.android.com/guide/topics/location/obtaining-user-location.html

Page 34: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Using Android location API code1. Define permission in AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

2. Ask runtime permissions

– Needed for Android 6.0+

3. Add a Polygon (circle) to map

– Can reuse Layer+DataSource of pins

– Make it a member, not local variable

4. Define LocationListener

– Get location updates, always async

– Get provider status updates

5. Define LocationManager with location Criteria

– Time and accuracy criteria

– Do not consume too much power

http://bit.do/ut-lbs

Page 35: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Add a circle to map

// style for GPS My Location circlePolygonStyleBuilder polygonStyleBuilder = new PolygonStyleBuilder();polygonStyleBuilder.setColor(new Color(0xAAFF0000));PolygonStyle gpsStyle = polygonStyleBuilder.buildStyle();

MapPosVector gpsCirclePoses = new MapPosVector();final Polygon locationCircle = new Polygon(gpsCirclePoses, gpsStyle);

// initially empty and invisiblelocationCircle.setVisible(false);

vectorDataSource.add(locationCircle);

http://bit.do/ut-lbs

Page 36: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Define locationlistener

final LocationListener locationListener = new LocationListener(){

@Overridepublic void onLocationChanged(Location location) {

Log.debug("GPS onLocationChanged "+location);if (locationCircle != null) {

locationCircle.setPoses(createLocationCircle(location, proj));locationCircle.setVisible(true);mapView.setFocusPos(proj.fromWgs84(

new MapPos(location.getLongitude(), location.getLatitude())), 0.5f);

}}

@Overridepublic void onStatusChanged(String s, int i, Bundle bundle) {}

@Overridepublic void onProviderEnabled(String s) {}

@Overridepublic void onProviderDisabled(String s) {}

};

http://bit.do/ut-lbs

Page 37: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Define LocationManagerLocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

// user has maybe disabled location services / GPSif(locationManager.getProviders(true).size() == 0){

Toast.makeText(this, "Cannot get location, no location providers enabled. Check device settings",Toast.LENGTH_LONG).show();}

// use all enabled device providers with same parametersfor(String provider : locationManager.getProviders(true)){

Log.debug("adding location provider " + provider);locationManager.requestLocationUpdates(provider, 1000, 50, locationListener);

}

http://bit.do/ut-lbs

Page 38: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Create circular polygonprivate MapPosVector createLocationCircle(Location location, Projection proj) {

// number of points of circleint N = 50;int EARTH_RADIUS = 6378137;

float radius = location.getAccuracy();double centerLat = location.getLatitude();double centerLon = location.getLongitude();

MapPosVector points = new MapPosVector();for (int i = 0; i <= N; i++){

double angle = Math.PI*2*i/N;double dx = radius*Math.cos(angle);double dy = radius*Math.sin(angle);double lat = centerLat + (180/Math.PI) * (dy/ EARTH_RADIUS);double lon = centerLon + (180/Math.PI) * (dx/ EARTH_RADIUS)/Math.cos(centerLat * Math.PI/180);points.add(proj.fromWgs84(new MapPos(lon, lat)));

}return points;

}

http://bit.do/ut-lbs

Page 39: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Indoor LBS

• 90% time people are indoors

– Retail, Safety

• Indoor maps

– Google Maps, project Tango

– HERE: 90K buildings, 71 countries in 2014

– Micello (15K), aisle411 (12K)

– 3D technologies R&D Tartu: Wayfinder

– Sanborn SPIN: https://www.youtube.com/watch?v=UX9nOh3XiJs

• Indoor Positioning

– IndoorAtlas, Indoor.rs etc

• Technologies

– iBeacon positioning – BT LE

– Standards: IndoorGML, OSM Simple 3D, i-locate.eu

Page 40: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Map data modelsAdding online (or offline) data to map

Page 41: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Common GIS file formats• Shapefile (ESRI) – most common

– 4+ files per layer: .shp, .dbf etc

– One geometry type per layer allowed

– No style information, pure geometry

– Optional: projection file .prj, spatial index, charset

• KML (Google, open standard)

– Vector data, includes styles

– Special data types: 3D data (Collada), linked data, visual coverages

– Can have only WGS84 coordinates

– Can be KMZ – zipped file

• Other formats

– GeoJSON and TopoJSON – web/Javascript-friendly

– GeoPackage: SQLite binary format, vector and raster

– SpatiaLite: vector and raster data, SQLite. Any projection, no styles.

– Text files (CSV) with coordinates or addresses

– Every commercial GIS has own format(s)

– Free converter: http://www.gdal.org/ogr/ogr_formats.html

Page 42: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Spatial SQL database basics

• Special column data types(s):

– Geometry, Point, Polygon ...

• Geographical indexing

– Usually R-Tree, based on object bounds

• Geographical functions:

– Manipulations, relations, queries etc

• Metadata table:

– Defines coordinate system, data type for every

Geometry column

Page 43: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Geometry primitives in WKT (2D)

Page 44: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Multipart geometries in WKT (2D)

Page 45: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

PostGIS sample: spatial query

• Be careful with :

– Coordinate systems – distances in meters vs

degrees

– Big data: use two-phase filters for spatial

indexes

Page 46: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

PostGIS : spatial query

Page 47: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

OpenStreetmapAs key data source

Page 48: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

OpenStreetMap (OSM)

• Free and open data

– Vector data in 2D

– Streets, roads, buildings, amenities etc

• A lot of services

– Map images (tiles), geocoders, routers etc

– Special views: opencyclemap, openpistemap etc

• Everyone can improve the map

– www.openstreetmap.org

– www.maakaart.ee – in Estonian

Page 49: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

ID – web-based OSM editor

Page 50: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

JOSM – OSM main editor

Page 51: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning
Page 52: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

OSM advantages

• Free and open to use

– No advertising, restrictions

• Vector data access

– Custom styles for mapping

– Own filters of data on map (layers)

– Interactive data overlays (POI layers)

– Advanced services: routing, search, analysis, ...

• Fast and easy updates

– Find error – go fix it yourself!

– Note: follow community guidelines

Page 53: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Commercial map data

• Global vendors

– Vector: HERE, TomTom, AND

– Aerial/Satellite: DigitalGlobe, Planet Labs

• Local vendors

– Estonia: Regio, Maa-amet

– In almost every country, quite detailed

• Specifics

– Technically quite flexible

– Usually quite expensive

Page 54: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

CARTO in mobile app

Page 55: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

CARTO intro• Cloud-based geo data storage

– Like google drive, dropbox etc, but with geo dimension and logic

• Spatial data view

– Map visualizations (thematic maps)

– Edit geometries on map

• Analytics

– Calculate derived data, create models etc

• Developer APIs

– SQL API

– Map tile API – raster map

– CARTO.JS for web

– Mobile SDK

Page 56: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Demo data for your app

• http://nutiteq.carto.com

– Estonian speed cameras from poiplaza.com

– Estonian villages and counties (külad ja maakonnad)

– About 1M OpenStreetMap amenities from Europe

• Datasets and Maps

– Table and Map views

– Thematic map for speed cameras

– Joined dataset for speed cameras and admin borders

Page 57: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Load and show speed cameras

• CARTO SQL API

– <API CALL> link under dataset

• Combine data from several tables:

SELECT sc.*,ay.a_nimi,ay.m_nimi,ay.o_nimi

FROM ee_speedcams sc,

asustusyksus_2017_reformitud ay

WHERE

st_contains(ay.the_geom,sc.the_geom)

Page 58: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Load GeoJSON, create Markers

• Use Thread for multi-threading

• Define service, set account

final CartoSQLService service = new CartoSQLService();service.setUsername("nutiteq");

• Load GeoJSON from GeometryCollectionThread thread = new Thread(new Runnable() {

@Override

public void run() {

try {

PointStyleBuilder pointStyleBuilder = new PointStyleBuilder();pointStyleBuilder.setColor(new Color(android.graphics.Color.MAGENTA));pointStyleBuilder.setSize(3);

String query = "SELECT sc.*,ay.a_nimi,ay.m_nimi,ay.o_nimi FROMee_speedcams sc, asustusyksus_2017_reformitud ay WHEREst_contains(ay.the_geom,sc.the_geom)";

FeatureCollection features = service.queryFeatures(query, projection);

source.addFeatureCollection(features,pointStyleBuilder.buildStyle());

} catch (IOException e) {e.printStackTrace();

}}

});

thread.start();

http://bit.do/ut-lbs

Page 59: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Useful geo tools

Page 60: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Free GIS tools

• Desktop tools – mapping, analysis, processing

– QGIS - freeware

– Google Earth Pro - view/create KML, free

– Trimble SketchUp – create 3D models

• Databases

– PostGIS – Postgre add-on.

– GeoPackage or Spatialite – SQLite extension (not

enabled on Android/iOS)

• Processing

– GDAL/OGR – raster and vector library, command-line

converters

Page 61: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Free GIS tools for developers

• PostGIS

– Postgre SQL server extension

– Raster features, Topology

• JTS

– Java Topology Suite, ports in C (GEOS) etc

– Lot of complex algorithms, geometries, graphs, geographical indexes

• Proj.4

– C-based, has few ports. Proj4J for Java

– Hundreds of predefined projections

• Web platforms

– GeoDjango (Python), GeoNode (Node.js), GeoTools(Java)

Page 62: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Some GeoWebServices SaaS

• CARTO.com

– Hosted PostGIS

– Location Intelligence

• Other similars

– Mapbox – Google Maps clone

– GISCloud.com

– ESRI ArcGIS Online - commercial

• OpenStreetMap.org

– Only for community-created data

– Content requirements: verifyable objects etc

• Github

– GeoJSON and TopoJSON support

– geojson.io – GeoJSON editor

• Google Fusion Tables

– General data table API service

– Includes basic geo-features

Page 63: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Some cool future geo things

• Cesium JS – 3D in web browser

• D3 JS – cool rendering

• MapD – GPU-based superfast database

• Augmented Reality maps?

– https://drive.google.com/open?id=0B3Rm1qU6

KnySN0lEXzAtOFZQeU0

Page 64: Mobile location-based apps · Location-Based Services 1. Location-based: 80% of data 2. Service (or mobile application) 3. Mobile technologies (phones, networks) 4. Mobile positioning

Thank you!

Jaak Laineste

Head of Mobile, CARTO

www.carto.com

[email protected]