1 | package require Rappture |
---|
2 | package require RapptureGUI |
---|
3 | |
---|
4 | Rappture::resources::load |
---|
5 | |
---|
6 | set commondir [file join [file dirname [info script]] .. common] |
---|
7 | source [file join $commondir geovis_settings.tcl] |
---|
8 | |
---|
9 | set width 400 |
---|
10 | set height 300 |
---|
11 | wm geometry . ${width}x${height} |
---|
12 | update |
---|
13 | |
---|
14 | set mapviewer [Rappture::MapViewer .g] |
---|
15 | |
---|
16 | pack .g -expand yes -fill both |
---|
17 | |
---|
18 | # create xyz layer |
---|
19 | array set xyzParams { |
---|
20 | url {http://otile[1234].mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg} |
---|
21 | } |
---|
22 | array set osm { |
---|
23 | label "OSM" |
---|
24 | cache false |
---|
25 | } |
---|
26 | |
---|
27 | # create an feature icon layer from a csv file using the OGR driver |
---|
28 | # the longitude and latitude fields must be named "longitude" and |
---|
29 | # "latitude" respectively |
---|
30 | # |
---|
31 | # we add the local:// prefix to tell the map viewer widget that |
---|
32 | # the file exists locally and needs to be transferred to the |
---|
33 | # geovis server. |
---|
34 | # set path "local://coord.csv" |
---|
35 | set path "local://coord1.csv" |
---|
36 | array set ogrParams1 [subst { |
---|
37 | url {$path} |
---|
38 | }] |
---|
39 | array set iconParams1 { |
---|
40 | label "CSV data 1" |
---|
41 | description "using OGR data provider to load data from a CSV file" |
---|
42 | style "-icon pin3" |
---|
43 | } |
---|
44 | |
---|
45 | set path "local://coord2.csv" |
---|
46 | array set ogrParams2 [subst { |
---|
47 | url {$path} |
---|
48 | }] |
---|
49 | array set iconParams2 { |
---|
50 | label "CSV data 2" |
---|
51 | description "using OGR data provider to load data from a CSV file" |
---|
52 | style "-icon pin7" |
---|
53 | } |
---|
54 | |
---|
55 | # create a map object |
---|
56 | set map [Rappture::Map #auto] |
---|
57 | |
---|
58 | # add a layer to the map object |
---|
59 | $map addLayer image \ |
---|
60 | osm [array get osm] \ |
---|
61 | xyz [array get xyzParams] |
---|
62 | |
---|
63 | # add csv layer 1 to the map object |
---|
64 | $map addLayer icon \ |
---|
65 | csvdata [array get iconParams1] \ |
---|
66 | ogr [array get ogrParams1] |
---|
67 | |
---|
68 | $mapviewer scale $map |
---|
69 | $mapviewer add $map |
---|
70 | |
---|
71 | |
---|
72 | after 5000 { |
---|
73 | # remove csv layer 1 from the map object |
---|
74 | $map deleteLayer csvdata |
---|
75 | |
---|
76 | # add csv layer 2 to the map object |
---|
77 | # with the same layer name as our previous layer |
---|
78 | $map addLayer icon \ |
---|
79 | csvdata [array get iconParams2] \ |
---|
80 | ogr [array get ogrParams2] |
---|
81 | |
---|
82 | # Update map viewer |
---|
83 | $mapviewer clear |
---|
84 | $mapviewer add $map |
---|
85 | puts stderr "Deleted csv layer 1, Added csv layer 2" |
---|
86 | } |
---|