Offline Mobile Map Solutions – Nick Peihl, San Juan County



Offline Mobile Map Solutions – Nick Peihl, San Juan County

0 3


offline-maps-presentation

Work in progress

On Github npeihl / offline-maps-presentation

Offline Mobile Map Solutions

Nick Peihl, San Juan County

npeihl.com / @npeihl

Today I'm here to talk about offline mobile map solutions currently in experimentation at San Juan County.

About San Juan County

Total Population: ~16,000

San Juan

San Juan has county seat, Friday Harbor. Also the island I live and work on.

Orcas

Lopez

Shaw

Others

Those who desire to be even more remote, live on outer islands
Also, San Juan has a [next slide]
picture: Camel credit:KnowItSome CC BY-SA 3.0 camel. [next slide]
picture: Bactrian Camel Smiling credit:frted CC BY-SA 2.0 Please don't feed it.

Getting to the islands

How do I get there? Two ways.
picture: Kenmore Air Cessna Grand Caravan credit: Michael Hays CC BY-2.0 Take a small plane
picture: Samish credit: Snowy Ferries CC BY-SA 4.0 Take a ferry. Most folks take a ferry.
Our economy is heavily tourism-driven. So tourists get on the ferry and want to Tweet or Instagram their photos and are met with this...
Lousy data service on the ferry. Want to go for a drive out of town? Make sure you pack paper maps. Opportunity?

Case Studies

So that's some background. At the County we're experimenting with solutions to get around this dis-connectivity issue.

Case Study 1

Public Works needs to collect data points from several locations in field

Public Works calls me and asks what to do? They need aerial photos to help orient themselves.

Assets

  • Android phones w GPS
  • Aerial Imagery TMS (2013)
Well, what have we got? Android phones with GPS and a tiled map service of 2013 aerial imagery running on ArcGIS Server.

Limitations

  • No mobile data service
  • Low storage space
  • No mobile app dev
Locations are remote so no data service and can't use online maps. Android phones have little storage space, so we can't load the entire 36GB aerial photo set on them. And I'm not a mobile app developer. I could try, but it would take me a long time.

Solution

So I did some research on possible existing solutions.
Geopaparazzi I found the Geopaparazzi Android app.

Geopaparazzi

  • Open Source App
  • Collect GPS locations and paths
  • Reads MBTiles
It's open source (neat!) It can collect GPS locations and paths And it can load tile caches stored locally as an MBTiles database.

MBTiles

MBTiles is a specification for storing tiled map data in SQLite databases for immediate usage and for transfer. Details MBTiles was created by Mapbox for storing tiled maps.

.mapurl files

url=http://tile.openstreetmap.org/ZZZ/XXX/YYY.png
minzoom=0
maxzoom=19
center=11.42 46.8
type=google
format=png
defaultzoom=13
mbtiles=defaulttiles/_mapnik.mbtiles
description=Mapnik - Openstreetmap Slippy Map Tileserver
		    
parameter details Geopaparazzi uses parameters in .mapurl files to pull in data. The .mapurl files go into the device's storage/maps directory. url parameter - URL to TMS with ZZZ XXX and YYY standing in for zoom level, tile column and tile row, respectively. minzoom, maxzoom - sets the zoom levels center - sets the longitude and latitude to open to defaultzoom - the zoom level the map defaults to on open mbtiles - this is the subdirectory/filename in the device's storage/maps directory where the tiles are cached

Tiled ArcGIS Service example

url=http://sjcgis.org/arcgis/rest/services/Basemaps/Aerials_2013_WM/MapServer/tile/ZZZ/YYY/XXX
minzoom=10
maxzoom=19
center=-123.0 48.5
type=google
bounds=-123.395004 48.354880 -122.417221 48.749851
format=jpg
defaultzoom=13
mbtiles=defaulttiles/_sjc-aerial2013.mbtiles
description=San Juan County WA Aerials 2013
		    
Esri flips the X and Y in their URLs compared to most other tiled map services.

Workflow

Before leaving office...

Add .mapurl file to device Open Geopaparazzi and load .mapurl source Pan to location(s) for field work Zoom to all levels in location(s) Tiles are saved on device for offline use Can verify tiles exist by going into airplane mode before leaving office. After collecting points in the field, staff comes back to the office and exports collected points and paths to GPX.

Advantages

  • Very stable app
  • Small storage footprint
  • Fairly easy setup

Disadvantages

  • TMS must be Slippy Map specs (Web Mercator)
  • Pre-cache all locations
  • Limited to single visible tile source (issue 286)
Tiled map service must be cached as web mercator and use the Slippy Map zoom levels. Only pre-cached locations are available. Can't change your mind once in the field, unless you find mobile data connectivity (4G, etc.). You can also only display one tile source at a time in Geoopaparazzi. I'd love to have two, so I could display a separate reference overlay on top of aerials. Could burn in, but increases time to cache entire dataset by tens of hours per month.

Case Study 2

Appraisers from Assessor's Office getting lost in field

Appraisers collecting data in field need help finding addresses, driveways in remote locations

Assets

  • iPad Air w GPS & 64GB
  • Aerial Imagery TMS
  • Reference Overlay TMS
The iPads will run the field assessment software, but they don't have offline maps. As stated, we have an aerial imagery TMS which is static and doesn't need recaching. And we have a reference overlay TMS which is updated and recached often.

Limitations

  • No mobile data service
  • No mobile app dev
Again, we have no mobile data service while in field. And we don't have a iOS developer on staff.

Solution

So I did more research and came up with another solution.
MBTiles GPS MBTiles GPS App on iTunes is free. And it can display from more than one tile source at the same time.
Portable Basemap Server Since we have more storage space, why not put the entire tile set on there? I found Portable Basemap Server (Windows only) which can convert from an ArcGIS Server tile cache to MBTiles. This requires admin access to the server hosting the ArcGIS service.

But I don't have admin access

var tilelive = require("tilelive");
require("tilelive-http")(tilelive);
require("mbtiles").registerProtocols(tilelive);

var template = "http://tile.openstreetmap.org/{z}/{x}/{y}.png";

var scheme = tilelive.Scheme.create("scanline", {
  minzoom: 12,
  maxzoom: 15,
  bbox: [-122.578926,47.509548,-122.051926,47.684575]
});

var copyTask = new tilelive.CopyTask(template, "mbtiles://./osm-sea.mbtiles", scheme);
copyTask.formats = ["tile"];

copyTask.start(function(err) {
  if (err) {
    throw err;
  }
});

copyTask.on("progress", console.log);
copyTask.on("finished", function() {
  console.log("Done!");
});

                    
tilelive-http CUGOS member Seth Fitzsimmons wrote tilelive-http which has a great example which may work. Just remember... [next]

DON'T

BE

EVIL

Adhere to usage restrictions and licenses

Some aerial imagery or basemaps are protected by copyright or other restrictions. Do your homework and make sure you aren't violating those.

Limit your bbox and levels

/* DON'T DO THIS */
var scheme = tilelive.Scheme.create("scanline", {
  minzoom: 0,
  maxzoom: 19,
  bbox: [-180,-90,180,90]
});

var copyTask = new tilelive.CopyTask(template, "mbtiles://./all-the-things.mbtiles", scheme);
copyTask.formats = ["tile"];

copyTask.start(function(err) {
  if (err) {
    throw err;
  }
});

copyTask.on("progress", console.log);
copyTask.on("finished", function() {
  console.log("I've taken over the world!");
});
                    
Don't get greedy. Limit the bbox and levels only to what you need. Otherwise you're hammering servers and will quickly run into usage limits or IP bans. The example above would download about 54TB.

MBTiles GPS

Here's what it looks like after the MBTiles databases have been created and loaded into the MBTiles app. Since we've generated this countywide, there is no need to do the same prep work as needed with the Android solution. Both the aerial background and the reference overlay can be seen here.

Advantages

  • Countywide offline tiles
  • Multiple tile sources visible
  • No prep work

Disadvantages

  • TMS must be Slippy Map specs
  • Unstable app
  • Moderately difficult setup

Questions?

Offline Mobile Map Solutions Nick Peihl, San Juan County npeihl.com / @npeihl Today I'm here to talk about offline mobile map solutions currently in experimentation at San Juan County.