1map::slippy(n) Mapping utilities map::slippy(n)
2
3
4
5______________________________________________________________________________
6
8 map::slippy - Common code for slippy based map packages
9
11 package require Tcl 8.4
12
13 package require Tk 8.4
14
15 package require map::slippy ?0.5?
16
17 ::map::slippy length level
18
19 ::map::slippy tiles level
20
21 ::map::slippy tile size
22
23 ::map::slippy tile valid tile levels ?msgvar?
24
25 ::map::slippy geo 2tile geo
26
27 ::map::slippy geo 2tile.float geo
28
29 ::map::slippy geo 2point geo
30
31 ::map::slippy tile 2geo tile
32
33 ::map::slippy tile 2point tile
34
35 ::map::slippy point 2geo point
36
37 ::map::slippy point 2tile point
38
39 ::map::slippy fit geobox canvdim geobox zmin zmax
40
41______________________________________________________________________________
42
44 This package provides a number of methods doing things needed by all
45 types of slippy-based map packages.
46
48 ::map::slippy length level
49 This method returns the width/height of a slippy-based map at
50 the specified zoom level, in pixels. This is, in essence, the
51 result of
52
53
54 expr { [tiles $level] * [tile size] }
55
56
57 ::map::slippy tiles level
58 This method returns the width/height of a slippy-based map at
59 the specified zoom level, in tiles.
60
61 ::map::slippy tile size
62 This method returns the width/height of a tile in a slippy-based
63 map, in pixels.
64
65 ::map::slippy tile valid tile levels ?msgvar?
66 This method checks whether tile described a valid tile in a
67 slippy-based map containing that many zoom levels. The result is
68 a boolean value, true if the tile is valid, and false otherwise.
69 For the latter a message is left in the variable named by msg‐
70 var, should it be specified.
71
72 A tile identifier as stored in tile is a list containing zoom
73 level, tile row, and tile column, in this order. The command
74 essentially checks this, i.e. the syntax, that the zoom level is
75 between 0 and "levels-1", and that the row/col information is
76 within the boundaries for the zoom level, i.e. 0 ... "[tiles
77 $zoom]-1".
78
79 ::map::slippy geo 2tile geo
80 Converts a geographical location at a zoom level (geo, a list
81 containing zoom level, latitude, and longitude, in this order)
82 to a tile identifier (list containing zoom level, row, and col‐
83 umn) at that level. The tile identifier uses pure integer num‐
84 bers for the tile coordinates, for all geographic coordinates
85 mapping to that tile.
86
87 ::map::slippy geo 2tile.float geo
88 Converts a geographical location at a zoom level (geo, a list
89 containing zoom level, latitude, and longitude, in this order)
90 to a tile identifier (list containing zoom level, row, and col‐
91 umn) at that level. The tile identifier uses floating point num‐
92 bers for the tile coordinates, representing not only the tile
93 the geographic coordinates map to, but also the fractional loca‐
94 tion inside of that tile.
95
96 ::map::slippy geo 2point geo
97 Converts a geographical location at a zoom level (geo, a list
98 containing zoom level, latitude, and longitude, in this order)
99 to a pixel position (list containing zoom level, y, and x) at
100 that level.
101
102 ::map::slippy tile 2geo tile
103 Converts a tile identifier at a zoom level (tile, list contain‐
104 ing zoom level, row, and column) to a geographical location
105 (list containing zoom level, latitude, and longitude, in this
106 order) at that level.
107
108 ::map::slippy tile 2point tile
109 Converts a tile identifier at a zoom level (tile, a list con‐
110 taining zoom level, row, and column, in this order) to a pixel
111 position (list containing zoom level, y, and x) at that level.
112
113 ::map::slippy point 2geo point
114 Converts a pixel position at a zoom level (point, list contain‐
115 ing zoom level, y, and x) to a geographical location (list con‐
116 taining zoom level, latitude, and longitude, in this order) at
117 that level.
118
119 ::map::slippy point 2tile point
120 Converts a pixel position at a zoom level (point, a list con‐
121 taining zoom level, y, and x, in this order) to a tile identi‐
122 fier (list containing zoom level, row, and column) at that
123 level.
124
125 ::map::slippy fit geobox canvdim geobox zmin zmax
126 Calculates the zoom level (whithin the bounds zmin and zmax)
127 such that geobox (a 4-element list containing the latitudes and
128 longitudes lat0, lat1, lon0 and lon1 of a geo box, in this
129 order) fits into a viewport given by canvdim, a 2-element list
130 containing the width and height of the viewport, in this order.
131
133 The commands of this package operate on three distinct coordinate sys‐
134 tems, which are explained below.
135
136 GEOGRAPHIC
137 Geographical coordinates are represented by Latitude and Longitude,
138 each of which is measured in degrees, as they are essentially angles.
139
140 Zero longitude is the Greenwich meridian, with positive values going
141 east, and negative values going west, for a total range of +/- 180
142 degrees. Note that +180 and -180 longitude are the same meridian, oppo‐
143 site to greenwich.
144
145 zero latitude the Equator, with positive values going north and nega‐
146 tive values going south. While the true range is +/- 90 degrees the
147 projection used by the package requires us to cap the range at +/-
148 85.05112877983284 degrees. This means that north and south pole are not
149 representable and not part of any map.
150
151 TILES
152 While Geographical coordinates of the previous section are independent
153 of zoom level the tile coordinates are not.
154
155 Generally the integer part of tile coordinates represent the row and
156 column number of the tile in question, wheras the fractional parts sig‐
157 nal how far inside the tile the location in question is, with pure
158 integer coordinates (no fractional part) representing the upper left
159 corner of the tile.
160
161 The zero point of the map is at the upper left corner, regardless of
162 zoom level, with larger coordinates going right (east) and down
163 (south), and smaller coordinates going left (west) and up (north).
164 Again regardless of zxoom level.
165
166 Negative tile coordinates are not allowed.
167
168 At zoom level 0 the whole map is represented by a single, putting the
169 geographic zero at 1/2, 1/2 of tile coordinates, and the range of tile
170 coordinates as [0...1].
171
172 To go from a zoom level N to the next deeper level N+1 each tile of
173 level N is split into its four quadrants, which then are the tiles of
174 level N+1.
175
176 This means that at zoom level N the map is sliced (horizontally and
177 vertically) into 2^N stripes, for a total of 4^N tiles, with tile coor‐
178 dinates ranging from 0 to 2^N+1.
179
180 PIXELS/POINTS
181 pixel coordinates, also called point coordinates are in essence tile
182 coordinates scaled by the size of the image representing a tile. This
183 tile size currently has a fixed value, 256.
184
186 [1] http://wiki.openstreetmap.org/wiki/Main_Page
187
189 geodesy, geography, latitute, location, longitude, map, slippy, zoom
190
191
192
193tcllib 0.5 map::slippy(n)