[Pharo-users] Mapping graphs on a open street map

Alexandre Bergel alexandre.bergel at me.com
Tue Apr 7 19:12:10 EDT 2015


Hi!

Several times we were asked how to map chart and graph on top of a geographical map. Here is a short example. Hope it is useful to someone.

http://ws.stfx.eu/11NOBLH3SIYO <http://ws.stfx.eu/11NOBLH3SIYO>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	v := RTView new.
	map := RTOSM new.
	e := map element.


	v add: e.

	paris := 48.8567 @ 2.3508.
	newyork := 40.7127 @ -74.0059.
	london := 51.507222@ -0.1275.
	
	v @ RTDraggableView.
	
	data := { { paris . { 10 . 5 . 10 . 3 . 10 .6 . 8 } }.
					{london . { 5 . 3 .3 . -5 } } .
					{newyork . { 5 . -2 . 10 . 15 . -10 }}  }.
	
	data do: [ :tupple |
			| grapher dataSet |
			grapher := RTGrapher new.
			grapher extent: 150 @ 100.
			
			dataSet := RTStackedDataSet new 
				points: tupple second.
			dataSet barShape width: 10; color: Color red.
			grapher add: dataSet.

			grapher axisY.
			grapher axisX noLabel; noTick.
			grapher build.

			allGraphElements := grapher view elements.
			v addAll: allGraphElements.
			allGraphElements translateTo: (map latLonToRoassal: tupple first)
		
	].
	
	v canvas camera translateTo: (map latLonToRoassal: paris).
	v canvas camera noInitializationWhenOpen.
	v canvas camera scale: 0.1.
	v
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Cheers,
Alexandre

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20150407/1b534958/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2015-04-07 at 8.10.45 PM.png
Type: image/png
Size: 262736 bytes
Desc: not available
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20150407/1b534958/attachment-0001.png>


More information about the Pharo-users mailing list