Readme
Readme
on OpenStreetMap.
Note: After Windows, we recommend that you use the PowerShell terminal so that it
doesn't
problems with displaying UTF-8 characters.
https://sqlitebrowser.org/
In the first phase, we take our input from where.data and read it
them line by line while reading the server's geocoded response
Nominatim and store it in the database (opengeo.sqlite file). Before we use
Geocoding API, we just check if we already have data for this particular one
line, so we won't be able to restart the program
they had to query the API a second time.
At any time, you can start the entire process from scratch by simply deleting
the generated opengeo.sqlite file.
Run the geoload.py program. This program will read input lines from the file
where.data and check for each row to see if it's already in the database, and
if we do not have data for the location being processed, it will trigger an API
query
geocoding to retrieve data and store it in SQLite.
python3 geoload.py
Retrieving https://py4e-data.dr-chuck.net/opengeo?q=BITS+Pilani
Retrieved 794 characters {"type":"FeatureColl
Retrieving https://py4e-data.dr-chuck.net/opengeo?q=Babcock+University
Retrieved 760 characters {"type":"FeatureColl
Retrieving https://py4e-data.dr-chuck.net/opengeo?q=Banaras+Hindu+University
Retrieved 866 characters {"type":"FeatureColl
...
The first five locations are already in the database, and so are they
omitted. The program processes data until it finds unsaved
locations and starts asking the API for them.
The geoload.py file can be stopped at any time, plus the code
contains a counter (the variable 'count') that can be used to limit the number
connections to the geocoding API in a given program startup.
After the data has been loaded into opengeo.sqlite, you can visualize it with
geodump.py. This program reads the database and writes the where.js file
containing locations, latitudes, and longitudes in the form
JavaScript executable. The ZIP file you downloaded already contains
where.js generated, but you can generate it again to check
operation of the geodump.py program.
python3 geodump.py
The where.html file consists of HTML and JavaScript that are used for visualization
OpenStreetMap maps using the OpenLayers library. The page reads
the most recent data from the where.js file to get the data necessary for
visualization. Here is the format of the where.js file:
myData = [
[50.065703299999996,19.918958667058632, 'AGH University of Science and Technology,
Czarnowiejs
ka, Czarna Wieś, Krowodrza, Kraków, Lesser Poland Voivodeship, 31-126, Poland '],
[52.2397515,21.015564130658333, 'Academy of Fine Arts, Krakowskie Przedmieście
e, Śródmieście Północne, Śródmieście, Warsaw, Masovian Voivodeship, 00-046,
Poland'],
...
];
To see the locations on the map, open the where.html file in your browser
website. You can hover over each map pin and click on it,
so as to find the location that the encoding API returned for the input
entered by the user. If you don't see the where.html file when you open it
no data, check if JavaScript is enabled in the browser or in
your browser's development console, check if there are any errors.