Jump to content

User:Siriuswapnil/Blogs/week2

From mediawiki.org

Coding Period - Weekly Report II

[edit]

With yesterday’s call, the following things were decided to be worked on :

  1. Displaying multiple GeoJSON files by looping through them, while they are stored offline.
  2. Replace the blue dots with some labels and markers.

Displaying multiple GeoJSON files by looping through them, while they are stored offline.

[edit]

Having multiple GeoJSON files displayed as a layer on the maps would require to have a PHP server, that would give the list of files as an array. Each file in the array should be parsed an a JSON file by means of AJAX. Currently, this is the challenge for me, since I neither know AJAX nor PHP. Working on it currently.

UPDATE: I managed to write a PHP script to return the file names of the geojson files available in a particular directory. It was nothing huge. It just made use of the glob() function that enters all the relevant files matching a particular string into an array. Then simply an echo statement to return the array to the AJAX call, made it work.

<?php
$files = glob('./data/geojson/*.geojson');
echo json_encode($files);
?>

The array was received into the function, which then looped through each element present in the array( in this case, geojson filenames) and then passes each of those file names into a VectorLayer functions, that store each layer formed, into a layerjson{} object. This way, it’s just a matter of calling the function ```map.addLayer()``` in the correct order, to get the points marked on the map.

Fixing the SPARQL Queries

[edit]

The SPARQL I had made weren’t properly formatted for being parsed as JSON files. They weren’t returning the correct parameters to be judged as geojson. After playing with multiple geojson files, I found that, instead of passing the coordinates in a single comma-separated field of location, it was essential to convert them to different fields of lat and long to get it working. So, if initially, ?loc contained the location in a single field,

BIND(STRBEFORE(STRAFTER(STR(?dplLoc), ' '), ')') AS ?lat)
BIND(STRBEFORE(STRAFTER(STR(?dplLoc), 'Point('), ' ') AS ?long)

These lines made sure that we had two different fields for latitude and longitude. Hence, I was able to get the geojson files working.

Working with Guest Additions

[edit]

I wasn’t able to download the South Asia .mbtiles from the admin console. It was getting cancelled everytime. Maybe some connection issue. So I downloaded it into my Host Windows from Archive.org. The file was around 11GB. A challenge was to get the mbtiles into the Ub18 VM. Standard processes like Filezilla and SCP, required an internet connection, I guess. So I thought of trying out VirtualBox’s Shared Folder feature. The process to get started is nicely mentioned here. I had to do a few additional steps. I wasn’t able to get VBoxAdditions in the first step, so I did

sudo apt-get install virtualbox-guest-utils

Although, this seemed to install a non-compatible version for my version, it did the job well. Another thing I had to take care of was adding my <username> to the list as I was initially not being able to mount and then not being able to access the shared folder. So for that this worked,

sudo adduser <yourUsername> vboxsf

Thus, I was able to get the mbtiles inside my VM,and also this would work as a viable option for file sharing between the systems during functional tests.

Replace the blue dots with some labels and markers.

[edit]

Regarding the blue dots, we need to find a way to include more locational metadata into a single GeoJSON file. This could possibly be markers, labels, popups and other forms of data. I have been able to get some heading and description into the points, but they can be much better expressed with images and additional information. Will have to work on that.

Let’s see where we get.

Peace.