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 an XYZ world 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 Map" |
---|
24 | description "MapQuest OpenStreetMap Street base layer" |
---|
25 | } |
---|
26 | |
---|
27 | # create an feature point 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://[file join [file dirname [info script]] coord.csv]" |
---|
35 | set path "local://station_clean.csv" |
---|
36 | array set ogrParams [subst { |
---|
37 | url {$path} |
---|
38 | }] |
---|
39 | array set stations { |
---|
40 | label "CSV data" |
---|
41 | description "using OGR data provider to load data from a CSV file" |
---|
42 | } |
---|
43 | array set placardAttributes { |
---|
44 | latitude Lat |
---|
45 | longitude Lon |
---|
46 | } |
---|
47 | set placardStyle { |
---|
48 | fill: #B6B6B688; |
---|
49 | text-fill: #000000; |
---|
50 | text-size: 12.0; |
---|
51 | } |
---|
52 | set placardPadding 5 |
---|
53 | |
---|
54 | # create a map object |
---|
55 | set map [Rappture::Map #auto] |
---|
56 | |
---|
57 | # add all layers to the map object |
---|
58 | $map addLayer image \ |
---|
59 | osm [array get osm] \ |
---|
60 | xyz [array get xyzParams] |
---|
61 | $map addLayer icon \ |
---|
62 | stations [array get stations] \ |
---|
63 | ogr [array get ogrParams] |
---|
64 | $map setPlacardConfig stations \ |
---|
65 | [array get placardAttributes] \ |
---|
66 | $placardStyle \ |
---|
67 | $placardPadding |
---|
68 | |
---|
69 | # add a map to the vis client |
---|
70 | $mapviewer scale $map |
---|
71 | $mapviewer add $map |
---|
72 | |
---|
73 | # Make sure the MapViewer rebuilds the map |
---|
74 | update idletasks |
---|
75 | |
---|
76 | # disable the placard for the "stations" layer of $map |
---|
77 | $mapviewer placard enable off "$map-stations" |
---|