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:
- Step 1: Download the corresponding country cities information file
- Step 2: Convert the file to SQLITE format
- Step 3: Load the cities-database file to the SurveyToGo survey and configure the location question to use that file as a cities source
- 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:
- Open the browser here: http://download.geofabrik.de/
- Click on the relevant continent, for example Europe:
- Next, click on the “.osm.pbf” link next to the country you would like to download:
- 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:
- Download the Dooblo-Converter package from here: https://dblstg.dooblo.net/downloads/LocationQuestionCitySearch.zip
- Extract the contents of the zip file to a folder
- 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:
- 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.
Convert Excel/CSV to SQLITE
If you can't find the list of cities needed, you can use a Excel/CSV file with the information and convert it to SQLITE.
Please create an Excel/CSV file that complies with the following:
- No headers, the file should only contain data.
- 6 columns: The first column is the city name in English.
- The next 3 columns are translations of the city name in various languages. (only one translation needed then keep the other columns empty)
- Two columns for Latitude and Longitude in decimal format.
So the columns are: Name, Language1, Language2, Language3, Latitude, Longitude
Important Notice: CSV files by default are ASCII files (so no Unicode, thus no Arabic), the file should be converted to CSV Unicode (there are instructions online on how to convert from Excel to CSV)
Once the file is read run the below in Command Line:
ProcessCSV.bat <nameOfCSVFile without extension> <FirstLang> <SecondLang> <ThirdLang>
For example: if you have a CSV file name "MyCities.csv" with translation in column 1 for French, column 2 Arabic and column 3 German then you should run:
ProcessCSV.bat MyCities French Arabic German
If column 2 and 3 are empty, it doesn't really what you declare (but you still need to declare those) so in your specific case:
ProcessCSV.bat MyCities Arabic Arabic2 Arabic3
This will create MyCities.sqlite that can be used as the cities search database.
Attached you can find the batch file ProcessCSV.bat
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:
- Copy the file to the devices by yourself, then point the map question to use the already existing file.
- 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 |
|
|
Option 2: Attach the “SQLite” file as a survey attachment |
|
|
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:
- Add a location question and configure it, then in the answers check the “Use Cities Search”:
- Next, set the “Cities Source” to “New”:
- 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:
- Finally, select the new Attachment Source name you just created from the list:
- 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:
- Click the main survey and then select the “Advanced tab”, and click on the “Edit Survey Attachments” link:
- Click the “New” button to add a new attachment:
- Click the “Add files” button and locate the sqlite file. Then click on open to add it to the list of files to upload:
- To complete the upload click the “Upload” button:
- Once the upload complete you will be able to use this uploaded file when configuring the location question.
- Add a location question and configure it, then in the answers check the “Use Cities Search”:
- Next, set the “Cities Source” to “New”:
- 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.
- 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:
- Finally, select the new Attachment Source name you just created from the list:
- 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
Comments
Please sign in to leave a comment.