SEL-Columbia / formhub

Mobile Data Collection made easy.
http://formhub.org
BSD 2-Clause "Simplified" License
259 stars 163 forks source link

Offline map tiles? #1347

Closed edrex closed 9 years ago

edrex commented 9 years ago

We are exploring using Formhub for a survey where interviewers in the field will be collecting spatial data not using GPS but by selecting points on a map. Because the collection will be happening in the field in areas which are unlikely to have a data connection, we have a requirement to cache map tiles for the survey region. Has anybody done something similar with Formhub? Ideas for implementation? If we go ahead with this it would be great if the implementation was clean enough to contribute upstream.

One approach we are thinking about, based on a brief hallway conversation, is to run a modified Formhub with the tiles included in the application cache manifest and the map modified to use the local tiles as the default baselayer. I haven't dug into the Formhub code yet to see where changes would be needed. This approach would unfortunately not be very reusable. If anyone has ideas for ways to make this a feature that could work in the default configuration, we'd love to hear them.

prabhasp commented 9 years ago

Hi Eric, will your data collection be done on the laptop or phone? Ie, via enketo or ODK collect? That separates the possible approaches somewhat. On Oct 29, 2014 6:04 AM, "Eric Drechsel" notifications@github.com wrote:

We are exploring using Formhub for a survey where interviewers in the field will be collecting spatial data not using GPS but by selecting points on a map. Because the collection will be happening in the field in areas which are unlikely to have a data connection, we have a requirement to cache map tiles for the survey region. Has anybody done something similar with Formhub? Ideas for implementation? If we go ahead with this it would be great if the implementation was clean enough to contribute upstream.

One approach we are thinking about, based on a brief hallway conversation, is to run a modified Formhub with the tiles included in the application cache manifest and the map modified to use the local tiles as the default baselayer. I haven't dug into the Formhub code yet to see where changes would be needed. This approach would unfortunately not be very reusable. If anyone has ideas for ways to make this a feature that could work in the default configuration, we'd love to hear them.

Reply to this email directly or view it on GitHub https://github.com/SEL-Columbia/formhub/issues/1347.

MartijnR commented 9 years ago

I think you're referring to Enketo (an app separate from formhub). The approach you suggested would seem interesting for https://github.com/enketo/enketo-legacy (which is the app currently running in formhub.org). However, enketo-legacy is no longer actively developed on (just bug fixes until it gets dumped at some point in 2015 (at least by me)). The new app that will replace it is https://github.com/enketo/enketo-express. This one will use indexedDb for all browser storage including external resources such as media (except the app itself which will continue to use the applicationCache). I would be very interested in a contribution for this feature to enketo-express (using a similar approach as the one that will be used for media labels), but it would probably be good to wait until enketo-express becomes offline-capable. Feel free to open an issue there if you'd like to discuss further.

One of the challenges will be to define in the form format which tiles should be stored.

P.S. another approach if you can run this on a local network (without browser storage) is to serve the tiles from a local tile server. This will work without modifications in Enketo.

MartijnR commented 9 years ago

closing to continue discussion in relevant Enketo repository

edrex commented 9 years ago

Thanks for answering my questions. I researched a variety of options yesterday and decided to go ahead with putting together a prototype tile caching feature using IndexedDB. Looking for existing implementations, I found https://github.com/mWater/offline-leaflet-map; a complete implementation, with tests! Will continue on Enketo issue queues.

Since we are looking at a short timeline for getting our survey out, we will want to add the offline tile cache feature to enketo-legacy first. Should we just maintain a fork, since that project isn't accepting feature patches?

MartijnR commented 9 years ago

Sounds great. Yes, a fork would be best. Good luck! (Sorry in advance that enketo-legacy is not very dev friendly... Enketo-express will be!)

edrex commented 9 years ago

Continued on enketo/enketo#521