The integration of OpenStreetMap in Roassal has been contributed by Onil Goubier and Thierry Goubier. The GoogleMaps API has been written by Sergio Maass. Both these contributes are under the MIT License.
OpenStreetMap is a collaborative project to create maps (http://openstreetmap.org) which offers a nice API to access and download map tiles.
RTOSM stands fos OpenStreetMap and is a shape that download and render tiles. Consider the following example:
Figure 0.1 is obtained by simply creating an element from the shape
RTOSM and adding it to a view. The map can be scrolled (thanks to
v @ RTDraggableView). The Pharo inspector offers zooming in and out.
The camera represents the location the user will see the roassal output, and is located at the center of the window that renders the scene. The camera could be located to any particular geographical location. Consider the following:
paris contains a point
latitude @ longitude. These coordinate are easily obtained by googling for it (e.g.,
paris latitude and longitude location is good enough).
Consider the following variation (Figure 1.2):
The script above defines the block called
movingCamera which takes as argument a geographical location. The blocks moves the camera accordingly and signal a refresh.
A menu is then defined to let the user click on each city name to move the camera.
Roassal elements may be added to a view, on top a map. The method
RTOSM>>latLonToRoassal: is used to translate geographical coordinates into Roassal space. Consider the following example that shows seisms on Earth (Figure 2.1):
The script begins by fetching data from the Earthquake Hazards Program server. The fetched CSV file has to be slightly processed to replace
,, entries by
,0, and convert some columns into float numbers. Column 2 of the file coorrespond to the latitude of the event; Column 3 to the longitude; Column 5 to the seism intensity.
For each table row an ellipse is created with an exponential size. Each produced element has a popup and is highlightable. The ellipse is then translated to its position in the Roassal space.
A scale of 0.02 is used to give an overview of the map. Thanks to the
noInitializationWhenOpen setting the map keeps the 0.02 scale value when opened. Without this setting, the value of 1 is used.
Finally, the view is made as draggable.
It is frequent that some data are given for a particular country. Visualizing data-related country involves a translation from the country name to the geographical location. Consider the data offered by the United Nations High Commissioner for Refugees (unhcr) (UNHCR, http://popstats.unhcr.org).
Here is a exceprt of a file obtained from the UNHCR server:
Visually representing the number of refugies on an OpenStreetMap requires translating the word
Afghanistan and all other country names into points as
latitude @ longitude. Since this is a frequent need, we provide facilities for this. The expression
RTOSM downloadCountries at: 'result' uses
googleapis.com to extract the list of countries and their position. The expression returns a list of dictionaries. Since the result is faithfully structured as the HTTP request, extracting data is a bit cumbersome. Here is an example of getting the geolocation of Afghanistan:
Consider the following script (Figure 3.1):
peopleForUNHCR contains the data fetched from the UNHCR server.