building location-aware apps using open source (andevcon sf 2014)
Post on 13-Jul-2015
289 Views
Preview:
TRANSCRIPT
Building Location-Aware Appswith Open Source & Open Data
Chuck Greb | 11·18·2014 | AnDevCon
Mapzen is an open source mapping lab building and supporting open data and software to promote a healthy mapping
ecosystem.
start where you are
Hour 1: Overview
⇢ Location-aware apps
⇢ Open source
⇢ Open data
Hour 2: Rendering
⇢ Raster tiles
⇢ Vector tiles
Hour 3: Search & Navigation
⇢ Location services
⇢ Geocoding
⇢ Routing
Agenda
start where you are
Building Location-Aware Appswith Open Source & Open Data
3 kinds of location-aware apps
⇢ Mapping applications
⇢ Location-based apps
⇢ Apps with location-aware features
Location-Aware Apps
Mapping applications
Location-based apps
Apps with location-aware features
Common features
⇢ Maps
⇢ Geolocation
⇢ Geocoding
⇢ Reverse geocoding
⇢ Search
⇢ Navigation
Location-Aware Apps
Building Location-Aware Appswith Open Source & Open Data
Philosophy
Open Source
Code
Open Source
License
Open Source
Community
Open Source
Advantages
⇢ Transparency
⇢ Flexibility
⇢ Compatibility
⇢ Free!
Open Source
Open source is not free like beer
Open Source
Open source is free like a puppy
Open Source
Building Location-Aware Appswith Open Source & Open Data
Availability & Access
Open Data
Reuse & Redistribution
Open Data
Universal participation
Open Data
Building Location-Aware Appswith Open Source & Open Data
Components
Open Location Applications
Datasource
Open Location Applications
Vector Tiles
Open Location Applications
Renderer
Open Location Applications
Location Services
Open Location Applications
GPS, WiFi, Network, Sensors, BLE
Geocoder
Open Location Applications
Search Engine
Open Location Applications
Route Engine
Open Location Applications
OpenStreetMap (OSM)
⇢ Crowdsourced Data
⬝ Local knowledge
⬝ Community driven
⇢ Public Data
⬝ 2007 TIGER import
⬝ Manual import process
⇢ Open Data Commons Open Database License (ODbL)
⬝ Attribution
⬝ Share-Alike
⬝ Keep Open
OpenStreetMap (OSM)
osmdroid
2008
osmdroid
Based on Google Maps API v1
osmdroid
Support for online and offline tile source
osmdroid
Icons, tracking, and shapes
osmdroid
Mapbox
Fork of osmdroid
Mapbox
Easy integration with Mapbox tile server
Mapbox
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:mapid="Your Mapbox mapid" />
Mapbox
MapView mapView = new MapView(this, "Your Mapbox mapid");
this.setContentView(mapView);
Mapbox
(Alternate tile servers also supported)
Mapbox
Custom styles & satellite imagery
Mapbox
OpenScienceMap
Universität Bremen
OpenScienceMap
“OpenScienceMap provides free and open maps for Android with the fastest and 100% pure vector maps around.”
OpenScienceMap
<org.oscim.android.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
OpenScienceMap
public class MyActivity extends MapActivity {
...
public Map getMap() {
return super.map();
}
}
OpenScienceMap
@Override public void onCreate(Bundle icicle) {
super.onCreate(icicle);
UrlTileSource tileSource = new OSciMap4TileSource("http://vector.example.com/all");
VectorTileLayer baseLayer = getMap().setBaseMap(tileSource);
getMap().layers().add(new BuildingLayer(getMap(), baseLayer));
getMap().layers().add(new PoiLayer(getMap(), baseLayer));
getMap().layers().add(new LabelLayer(getMap(), baseLayer));
baseLayer.setRenderTheme(ThemeLoader.load(
AssetAdapter.g.openFileAsStream("styles/map.xml)")));
}
OpenScienceMap
Pelias
modular open-source geocoder
Pelias
ElasticSearch
Pelias
OSMGeoanmes
Quattroshapes
Pelias
Pelias Android SDK
Pelias
Pelias.getPelias().suggest("Empire State Build", Callback<Result>);
Pelias.getPelias().search("Empire State Building", "x1,y1,x2,y2", Callback<Result>);
Pelias
{ "type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ -73.98597, 40.74871 ]},
"properties": {
"text": "Empire State Building, New York County, New York",
"score": 1,
"type": "geoname",
"id": "5116597"
}
}, ...
}
Pelias
On the Road
Routing and Navigation
On the Road
OSRM
On the Road
Router.getRouter().setEndpoint("http://osrm.example.com")
.setDriving()
.setLocation(new double[]{lat, lng})
.setLocation(new double[]{lat, lng})
.setCallback(new Callback() {
@Override
public void success(Route route) {
// do stuff
}
@Override
public void failure(int statusCode) {
// do stuff
}
}).fetch();
On the Road
Features
⇢ Navigation
⇢ Snap to location
⇢ Calculate distances
⇢ Reroute
On the Road
Location Open Source Tracker(LOST)
Drop-in replacement forFusedLocationProvider
LOST
talks directly to LocationManager
LOST
GPSWi-Fi
Cell Network
LOST
FrequencyAccuracy
Battery Life
LOST
Replay GPX trace file
LOST
LocationClient locationClient = new LocationClient(context,
new LocationClient.ConnectionCallbacks() {
@Override public void onConnected(Bundle bundle) {
onLocationClientConnected();
}
@Override public void onDisconnected() {
onLocationClientDisconnected();
}
});
LOST
private void onLocationClientConnected() {
Location lastLocation = locationClient.getLastLocation();
if (lastLocation != null) {
// do stuff
}
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setInterval(5000);
locationClient.requestLocationUpdates(locationRequest,
new LocationListener() {
@Override public void onLocationChanged(Location location) {
// do more stuff
}
});
}
LOST
Speakerbox
Features
⇢ Text-to-Speech
⇢ Initialization/Shutdown
⇢ Mute/Unmute
⇢ Remix!
Speakerbox
Open by Mapzen
Pelias Android SDK On the Road LOSTOpenScienceMap
VTM Speakerbox
TTSLocationManagerOSRMPelias
MapzenVector Tile
ServiceOpenGL ES
start where you are
Break.
osmdroidExercise #1
OpenScienceMapExercise #2
Break.
OpenScienceMap + LOSTExercise #3
OpenScienceMap + LOST + PeliasExercise #4
OpenScienceMap + LOST + Pelias + On the RoadExercise #5
thanksChuck Greb | @ecgreb
github.com/mapzen
top related