OpenStreetMap is a collaborative project to create maps (http://openstreetmap.org) which offers a nice API to access and download map tiles.
Onil Goubier (email@example.com), Thierry Goubier (firstname.lastname@example.org), and Sergio Maass (email@example.com) have contributed to integration of OpenStreetMap in Roassal. These contributions are under the MIT License.
RTOSM stands for OpenStreetMap and is a shape that downloads and renders 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. When visualizing OpenStreet map tiles, you may want to disable the automatic camera positioning. This is achieved with
RTEmptyViewContext setOnView: v.
The camera represents the location where the user sees the Roassal output, and is located at the center of the window that renders the scene. The camera may be located at any particular geographical location. Consider the following example that points to Paris:
paris contains a point
latitude @ longitude. This coordinate is easily obtained by googling for it or is available from Wikipedia.
Consider the following variation (Figure 1.2):
The script above defines the block called
movingCamera which takes as argument a geographical location. The blocks move 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, over a map. The method
RTOSM>>latLonToRoassal: is used to translate geographical coordinates into Roassal space. Consider the following example that shows seismic activity 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 double commas (
,,) entries by a zero (
,0,) and to convert some columns into float numbers. Column 2 of the file corresponds 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 calculated 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. The view is made draggable.
Some data are frequently 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, http://popstats.unhcr.org).
Here is an excerpt 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 uses
restcountries.eu 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.