libtiles.tcl - Tiles Common Framework -a micro-framework implementing common procedures for geo-tile processing. An extension of slippy map library.References and credits:
(1) https://wiki.tcl.tk/ (2) https://msdn.microsoft.com/en-us/library/bb259689.aspx (3) http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames (4) http://wiki.openstreetmap.org/wiki/Zoom_levels (5) https://en.wikipedia.org/wiki/Well-known_text (6) https://en.wikipedia.org/wiki/GeoJSON (7) http://docs.activestate.com/activetcl/8.6/tcllib/math/math_geometry.htmlBugs: it looks that the current implementation of the slippy map library does not take into account sign of lat/lon (all coordinates are positive only). It is fixed by functions tile2geo getEpsilon 0 70 21
tile2quadkey --
Convert tile coordinate (z/x/y) to quadkey. See (2) for details.Arguments: col x tile coordinate, row y tile coordinate, zl zoom level.
Results: quadkey
quadkey2tile --Convert quadkey to tile coordinates (z/x/y). See (2) for details.Arguments: qkey quadkey of tile
Results: "x y zl" returns tile coordinate
tile2geo --Convert tile coordinates (z/x/y) to lat/long. See (2) for details. Refinement of {::map::slippy tile 2geo} function. Order of input and output has been changes.Arguments: col x tile coordinate, row y tile coordinate, zl zoom level.
Results: "x y" lat/long coordinates.
See Bugs above. trying to resolve a bug.
geo2tile --Convert tile lat/long coordinates to tile coordinates. See (2) for details. Refinement of {::map::slippy geo 2tile} function. Order of input and output has been changes.Arguments: x longitude, y latitude, zl zoom level.
Results: "col row" col and row tile coordinates.
See Bugs above.
getPixelSize --Get tiles' pixel width in meters.Arguments: y latitude, zl zoom level.
Results: width (or height) in meters.
getEpsilon --
Get tiles' pixel width in meters.Arguments: x longitude, y latitude, zl zoom level.
Results: width (or height) in meters.
See (4).
tile2geom --Arguments: col x tile coordinate, row y tile coordinate, zl zoom level, type (optional, default 0): 0 - EXTENT - extent "Xmin Ymin Xmax Ymax", 1 - Tcl LIST - tcl polygon and central point (first and last points are same) {{Xcent Ycent} {x1 y1 x2 y2 x3 y3 x4 y4 x1 y1}}, 2 - WKT LIST - Tcl list of WKT data (See (5)) - first element is central point, second element is polygon (first and last poins are same), 3 - GEOJSON LIST - GeoJSON data list (first is central point, second is polygon).
Results: "x y" lat/long coordinates.
isIn --
Checks if any tile of one tile list is inside of any tileanother tiles list. Order of tile lists is not taken into account.Arguments: list_a list of tile quadkeys, list_b list of tile quadkeys, order (optional,bool, default False) if order in important. True means that right need to be inside or equal left.
Results: 0 - false, 1 - true. If a and b equal retuns true.
isTouch --
Checks if any tile of one tile list touches any tileanother tiles list.Arguments: list_a list of tile quadkeys, list_b list of tile quadkeys,
Results: 0 - false, 1 - true. If a and b equal returns true.
polygonTileIntersect --
cheks if a polygon and a tile are intersectedArguments: pol - Tcl polygon (see (7)), col row zl - tile coordinates
Results: boolean
getTilesOfPolygon --
returns list of tiles of the intersecting a polygon.Arguments: pol - Tcl polygon (see (7)), from_zl - from zoom level, to_zl - (optional) if set, all tiles between defined zoom levels will be returned. It has to be bigger than from_zl.
Results: list of tiles
For testing/debugging:
--> https://t1.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/12023022311?mkt=en-US&it=G,BX,L,LA&shading=hill&og=88&n=z&c4w=1 lassign "1095 732 11" col row zl set pol "12.55146 45.65106 12.54358 45.62229 12.57965 45.60649 12.60872 45.62890 12.59541 45.65461"