How to – Add “city search” to a location question

Overview

The SurveyToGo location question can work in both online and offline modes. For both offline and online modes, you can add the ability to search for a city within the map and have the map automatically center to the selected city. The city search feature works for offline maps as well. Here is how to do it:

 

  1. Step 1: Download the corresponding country cities information file
  2. Step 2: Convert the file to SQLITE format
  3. Step 3: Load the cities-database file to the SurveyToGo survey and configure the location question to use that file as a cities source
  4. Step 4: Searching on the tablet

 

 Step 1: Download the corresponding country cities information file

 

In order to download the country cities information file please follow these steps:

 

  1. Open the browser here: http://download.geofabrik.de/
  2. Click on the relevant continent, for example Europe:

  3. Next, click on the “.osm.pbf” link next to the country you would like to download:

  4. This will download the relevant country .pbf file to your computer. Please note the country files can be relatively large and might take some time to download.

 

 

Step 2: Convert the file to SQLITE format

 

Now you need to create the SQLITE database file from the relevant country cities pbf file. To create the SQLLITE file, please follow these steps:

 

  1. Download the Dooblo-Converter package from here:http://www.dooblo.net/downloads/LocationQuestionCitySearch.zip
  2. Extract the contents of the zip file to a folder
  3. Copy the city .pbf file you downloaded from “Step 1″ to this folder, then open a command prompt, switch to the folder and put in the following command:”ProcessPBF.bat <cities-file.osm.pbf>”(where “cities-file.osm.pbf” should be replaced with your file. So for example, here is how it would look for the Portugal cities .pbf file:

  4. This will generate the “portugal-latest_cities.sqlite” file which you can now use in “Step 3″. IMPORTANT NOTE: This step can potentially take a long time to complete!!!

 

Note: The file generated will include the cities of the country in both English plus the 3 most used languages in the cities pbf file. The non-english city name will appear on the tablet next to the English name in parenthesis.

 

Step 3: Load the cities-database file to the SurveyToGo survey and configure the location question to use that file as a cities source

 

Once you created the “cities.sqlite” file in Step 2 (you can rename it to any file name you wish) you are now ready to use this file from within the SurveyToGo location question. There are 2 ways of using this file:

  1. Copy the file to the devices by yourself, then point the map question to use the already existing file.
  2. Attach the file as a survey attachments, then point the map question to use the survey attachment.

 

There are pros and cons to each approach, but our guideline is to use option #1 for any SQLite file bigger than 15MBs:

 

Approach Pros Cons
Option 1: Copy the “Sqllite” file to the devices by yourself
  • For large “Sqllite” files, copying the files to many devices will be much quicker
  • Syncing of the survey will be much quicker as the survey itself will not include the “Sqllite” file as an attachment
  • The download of the file to the devices is done manually by the customer and not by SurveyToGo
Option 2: Attach the “SQLite” file as a survey attachment
  • SurveyToGo will take care of downloading the file to all the devices that sync this survey
  • The upload of the SQLite file will take time, if this file is over 15MB of size the upload of the file might fail due to file size restrictions.
  • The download of the SQLite file will be much slower as it will use the SurveyToGo download attachments mechanism

 

We will now show you how to use each approach.

 

 

Option 1: Copy the cities “SQLITE” file to the devices by yourself

In this approach you simply copy the file to the device. Then, in the survey do the following steps:

  1. Add a location question and configure it, then in the answers check the “Use Cities Search”:

  2. Next, set the “Cities Source” to “New”:


  3. Now you’ll need to add a new attachment source by clicking on the “+” sign, and entering the path to the file that you copied to the device. The script to use is in the form of: “list.Add(“$ROOT$/Portugal-latest_cities.sqlite”,“1”);” , lastly you need to give this attachment source a name and click on OK to approve:


  4. Finally, select the new Attachment Source name you just created from the list:

  5. That’s it!

 

Option 2:

In this approach you first attach the sqlite file to the survey and then configure the survey to use the attachment. Here is how to do it:

  1. Click the main survey and then select the “Advanced tab”, and click on the “Edit Survey Attachments” link:

  2. Click the “New” button to add a new attachment:

  3. Click the “Add files” button and locate the sqlite file. Then click on open to add it to the list of files to upload:


  4. To complete the upload click the “Upload” button:


  5. Once the upload complete you will be able to use this uploaded file when configuring the location question.
  6. Add a location question and configure it, then in the answers check the “Use Cities Search”:


  7. Next, set the “Cities Source” to “New”:

  8. Important note:This step is slightly different than in the other option, please note the change in the script syntax and do not use the script from the previous approach.
  9. Now you’ll need to add a new attachment source by clicking on the “+” sign, and entering the name of the attachment. The script to use is in the form of: “list.AddFromAttachment(“portugal-latest_cities.sqlite”);“, lastly you need to give this attachment source a name and click on OK to approve:


  10. Finally, select the new Attachment Source name you just created from the list:

  11. That’s it!

 

Step 4: Searching on the tablet

 

Once everything is configured correctly and after the survey is synchronized to the tablet the location question will show on the tablet:

 

Clicking on the “Open Map” button will open the map. It will then allow you to search for a city:

 

As you type any 2 letters the search will show you a list of relevant cities for you to choose from:

 

You are now able to select from the city and the map will center the map (in the current zoom factor) to the selected city.

 

 

That’s it!

 

 

 

Visit us at: http://www.dooblo.net

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.