Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Start on 1.3, with resolution fix. Refs danzel/Leaflet.utfgrid#10

  • Loading branch information...
commit 984bdcd94b1d6d8a56521f711f25672505e9cf38 1 parent 7a5b4ef
@tmcw tmcw authored
Showing with 400 additions and 0 deletions.
  1. +1 −0  1.3/demo.json
  2. +108 −0 1.3/interaction.md
  3. +285 −0 1.3/utfgrid.md
  4. +6 −0 CHANGELOG.md
View
1  1.3/demo.json
1 addition, 0 deletions not shown
View
108 1.3/interaction.md
@@ -0,0 +1,108 @@
+# Interaction
+
+Tile servers can enhance tilesets with interactivity by implementing two additional HTTP endpoints.
+
+* `[base path]/layer.json`: A layer manifest JSON containing the interaction formatter function and other optional attributes.
+* `[base path]/{n}/{n}/{n}.grid.json`: A UTFGrid JSON file corresponding to its adjacent tile image.
+
+`[base path]` refers to the full layer URL prior to any x, y or z coordinates.
+
+Examples:
+
+OSM-style URL schema
+
+ http://example.com/0/0/0.png // tile image for 0/0/0
+ http://example.com/0/0/0.grid.json // utfgrid for 0/0/0
+ http://example.com/layer.json // layer manifest
+
+## TileJSON
+
+UTFGrid requires additions to the [TileJSON](https://github.com/mapbox/tilejson-spec)
+payload for a layer:
+
+* `template`: String. In the format of a mustache template.
+* `legend`: String. Self-contained HTML that may be displayed as a legend for
+ this layer. **Optional**.
+
+Example response from `layer.json`:
+
+ {
+ "template": "{{NAME}}",
+ "legend": "<strong>Countries of the World</strong>"
+ }
+
+Each `layer.json` item should be represented by a single row in the `metadata` table where `key,value` match its key and value in the `layer.json` object.
+
+### Template
+
+As of UTFGrid 1.1, the `formatter` key is deprecated and replaced by `template`.
+Template is to be a [mustache](http://mustache.github.com/) format string that
+produces
+HTML, which will be cleaned with an HTML whitelist after generation.
+
+#### Mustache
+
+Template data is specified according to the
+[mustache specification](http://mustache.github.com/mustache.5.html).
+The full specification is supported, but no partials are provided,
+or should be provided by implementations.
+
+Given the switch to templates from formatters, the `options` object
+is no longer available. Its functionality is emulated by setting
+'format flags' on each data object.
+
+For an example data object like
+
+
+ {
+ "id": "helloworld"
+ }
+
+
+This will be transformed into
+
+
+ {
+ "id": "helloworld"
+ "__location__": true
+ }
+
+
+By the tooltip/interaction implementation, in order to trigger
+the `location` template. Note that `true`, `1`, and all non-false
+values are equal to template, so implementations may set
+`"__location__": 1` to save bytes.
+
+The template implementation could be:
+
+
+ {{#__location__}}
+ http://your.com/{{id}}
+ {{/__location__}}
+ {{#__full__}}
+ This content has the id {{id}}
+ {{/__full__}}
+ {{#__teaser__}}
+ {{id}}
+ {{/__teaser__}}
+
+
+Which, for this implementation, will produce the output
+
+
+ http://your.com/helloworld
+
+
+### legend
+
+A tileset may provide an HTML string that can be rendered by the client as a legend. The string should be self-contained and not reference external stylesheets, scripts or images. The [Data URI scheme](http://en.wikipedia.org/wiki/Data_URI_scheme) may be used to embed images or other data if necessary.
+
+ <div><span style='padding:0px 10px; background:#333;'></span> +10% population</div>
+ <div><span style='padding:0px 10px; background:#666;'></span> +5% population</div>
+ <div><span style='padding:0px 10px; background:#999;'></span> +0% population</div>
+ <div><span style='padding:0px 10px; background:#ccc;'></span> -5% population</div>
+
+## grid.json
+
+See `utfgrid.md` for the format and storage of UTFGrid JSON.
+
View
285 1.3/utfgrid.md
@@ -0,0 +1,285 @@
+# UTFGrid
+
+The UTFGrid encoding scheme encodes interactivity data for a tile in a space
+efficient manner. It is designed to be used in browsers, e.g. for displaying
+tooltips when hovering over certain features of a map tile.
+
+Since slower browsers and machines can't cope with rendering the actual
+polygons used to draw vectors on the map tile, we use a grid-based approach
+where we store the associated information for each pixel.
+
+UTFGrid uses [JSON](http://en.wikipedia.org/wiki/JSON) as a container format.
+It is exclusively geared towards square tiles.
+
+## Grid
+
+To achieve reasonable speed in browsers, we store information for a pixel in
+long strings, where each character's Unicode code point is the key for retrieving
+the information associated with that pixel. When we have less than 96 unique
+IDs, this means that the space taken up by storing each pixel separately is
+256 * 256 = 64 KB. Gzipping the grid data typically reduces it to a size below 2K.
+
+By default, UTFGrid operates on a 4x4 grid, meaning that a tile at zoom level
+0 that contains the entire world in its extent will have an grid resolution
+of 64x64. We take advantage of UTF-8's variable length codepoint encoding:
+all ASCII characters are encoded as is, that means that the first 94 codepoints
+are encoded with their code number as a single byte (codes `0x20`, `0x21`,
+`0x23`-`0x5B` and `0x5D`-`0x7F`).
+IDs with a number larger than that will get encoded as multiple bytes.
+
+## Encoding IDs
+
+[JSON](http://www.ietf.org/rfc/rfc4627) doesn't allow control characters, `"`
+and `\` to be encoded as their literal UTF-8 representation. **Encoding** an
+ID works as follows:
+
+* Add 32<sub>10</sub>.
+* If the result is >= 34<sub>10</sub>, add 1.
+* If the result is >= 92<sub>10</sub>, add 1.
+
+This ensures that all characters that cannot be represented natively are skipped.
+
+**Decoding** works as follows:
+
+* If the codepoint is >= 93<sub>10</sub>, subtract 1.
+* If the codepoint is >= 35<sub>10</sub>, subtract 1.
+* Subtract 32<sub>10</sub>.
+
+## Mapping an ID to a key
+
+The UTFgrid file contains an array in a property named `grid` at the root level.
+Each entry represents a row in the grid. Each array entry is a string that
+contains the UTF-8 encoded codepoint for each column. The string length
+corresponds to the number of entries in the `grid` array. Only powers of two are allowed.
+
+The keys are stored in an array named `keys` at the root level. The index of
+each key represents the ID that it is associated to.
+
+Retrieving a key from a coordinate works as follows (`json` is the root level
+object, `x` and `y` are the coordinates, starting from top left at 0, and
+`size` is the number of entries in the `grid` key):
+
+* `var factor = 256 / size, row = y / factor, col = x / factor`
+* `var id = json.grid[row].charCodeAt(col);` is the character that contains the encoded ID.
+* Decode the id as described in *"Encoding IDs"*.
+* `var key = json.keys[id];` retrieves the ID associated with the coordinate.
+
+All divisions are integer divisions.
+
+## Mapping a key to data
+
+The JSON file may contain an optional `data` property at the root level.
+If it isn't present, the client looks up the obtained key in its internal data
+store. If the lookup key is not present, it queries the server with the
+missing keys. If the `data` property is present, but the key cannot be found,
+the client must behave as if there were no `data` property.
+
+An empty key signifies the unavailability of information for that pixel.
+No action may be taken to retrieve data for an empty (`""`) key.
+
+
+## Example UTFGrid JSON file
+
+ { "grid":
+ [
+ " !!!!!!!########################$$$$$$$$$$$$$$$$%%%%%%%%%% %%%%%%%%%%%%%%%% % %",
+ " !!!!!!########################$$$$$$$$$$$$$$$$$%%%%%%%%%%% %%%%%%%%%%%%% %%%% %%",
+ " !!!!!########################$$$$$$$$$$$$$$$$$%%%%%%%%%%%%% %%%%%%% %%%%%% %%",
+ " !!!!!###########################$$$$$$$$$$$$$$$$$%%%%%%%%%%%%% %%% %%%%%%%%%%",
+ " !!!!###########################$$$$$$$$$$$$$$$$$%%%%%%%%%%%%% %%%%%%%%%%%%",
+ " !!!!!!###################### ###$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%",
+ " ! !!!!!###################### $$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%%%",
+ " !!!!!!!##################### $$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%%%%",
+ " !!!!!!!#################### $$$$$$$$$$$$%%%%%%%%%%%%% %%%%%%%%%%%%%%",
+ " !!!!!##################### $$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%%%",
+ " ! !!!!!##################### $$$$$$$$$$$$%%%%%%%%%%%%%% % %%% %%%%%%%%%%%%%",
+ " ! !!!!!!!##################### $$$$$$$$$$$$$%%%%%%%%%%%%%%% %%%% %%%%%%%%%%%%%",
+ " !!!!!!##################### $$$$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%% % %%%%%%%%%%%%",
+ " !!!!!!###################### $$$$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%% %%%%%%%%%%%%%",
+ " ! !!!!!!!!##################### $$$$$$$$$$$$$$$$$%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!#################### $$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!################### $$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%",
+ " !!! !!!!####################### $$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%",
+ " !!!! !!!######################## $$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%",
+ " ! !! !!!!####################### $$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!! ! !!!###################### $$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ! ! !!!!!!!!#################### $$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!#################### $ $$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!################## $$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!! !!!!!!!!!!################## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!! !!!!!!!!!!################# $$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!! !!!!!!!!!!!!!################# $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!############### $$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!!############# $$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!!!############ $$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!!!############ $$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ! ! !!!!!!!!!!!!!!!!!!############ $$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!############## $$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!!############## $$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!!################ $ $$$$$$$$$$$$$ $$$% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!! !!!!!!!!!!!!!!!!################ $ $$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!!!!!!!!!################# & & $ $$$$$$ $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ! !!!!!!!!!!!!!!!!!!################## & $ $$$$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ! !!!!!!!!!!!!!!!!!##################### $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!!! !!!#################### %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!! !!!!!!!!!!! !!!############## ##### ''' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ! !!!!!!!!!!!! !!!################### ''''''''''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!! !!!################### '''''''''''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!!! #!################## '''''''''''''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!!! ################## '' ''''''''''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!!!! ################ '''''''''''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!!!! ################ '''' '''''''''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!!!! ############### '' '''''''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " !!!! ############## ' ''(''''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ############# # ((((''''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ) ############## # ( (((((''''%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ) ############## ## ((( (((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " )) ############ ## (((( ((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " )))) ############ # (((((( (((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ) ))) ########### # # ((((((((((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " )) ))) ########### ((((((((((((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " )))))) ########### ((((((((((((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " )))))))) ######### # (((****((((*(((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ))))))) ########## (************((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ))))))) )) #### **************(((((+++%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ))))) ) ))) #### ***************((+++++++%++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " )))) ) )))) #### ***************++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " )))) )) )))) # ***************++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ))) )) ) ) %**************+++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " )))) ) ) %%%%**********++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ,,,, ))) -- %%%%%%%%*********++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ,,, ) , ----- %%%%%%%*********+++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ,,,,,, ,,,, ------- ----%%%%%%-*******+++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ,,,,,, ,,,,,, -----------------------*****+*++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " , ,,,,, ,,,,,,,, -------------------------***+++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ ". ,,,,,,,,,,,,,,, --------------------------+++++++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " ,,,,,,,,,,,,,,,,,,,,---------------------------+++++++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ ". /// ,,,,,,,,,,,,,,,,,,,,---------------------------+++++++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ ". /////,,,,,,,,,,,,,,,,,,,,---------------------------++++++++++++++++++++++%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ ". .. /////,,,,,,,,,,,,,,,,,,,,----------------------------+++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ "..... ///////,,,,,,,,,,,,,,,,,,,,,---------------------------+++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ "..... //////,,,,,,,,,,,,,,,,,,,,,,-------------------------+++++++++++++++++++++++%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ "..... ////////,,,,,,,,,,,,,,,,,,,,,------------------------+++++++++++++++++++++++++%%0000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ "..... ////////,,,,,,,,,,,,,,,,,,,,,,--------------------------++++++++++++++++++++000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ ".... //////,,,,,,,,,,,,,,,,,,,,,,,,--------------------------++000000++++++++++++0000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ "... //////,,,,,,,,,,,,,,,,,,,,,,,,-------------------------+0000000000+++++0+++00000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ ".. ///11///,,,,,,,,,,,,,,,,,,,,,,,,,-------------------------0000000000000000000+0000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ "..... 111111111/,,,,,,,,,,,,,,,,,,,,,,,,,-------------------------0000000000000000000000000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ "... 22111111111/,,,,,,,,,,,,,,,,,,,,,,,3,3-------------------------00000000000000000000000000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " 2222211111111,,,,,,,,,,,,,,,,,,,,,,33333------------------------00000000000000000000000000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " 2222221111111,,,,,,,,,,,,,,,,,,,,333333333----------------------00000000000000000000000000000000%%%%%%%%%%%%%%%%%%%%%%%%%%%",
+ " 2222222111111,,,,,,,,,,,,,,,,,,33333333333--3------------------000000000000000000000000000000000000%00%%%%%%%%%%%%%%%%%%%%%",
+ " 22222222111114,,,,,,,,,,,,,,,,,3333333333333333----------------00000000000000000000000000000000000000000%0%%%%%%%%%%%%%%%%%%",
+ " 22222222222211144,,,,,,,,,,,,,,,,,33333333333333333-------------000000000000000000000000000000000000000000000%%%%%%%%%%%%%%%%%",
+ " 222222222222222144,,,,,,,,,,,,,,,,,333333333333333333-----------000000000000000000000000000000000000000000000000%0%%%%%%%%%%%%%",
+ " 222222222222222222,,,,,,,,,,,,,,,,,,33333333333333335555-55555--00000000000000000000000000000000000000000000000000%%%%%%%%%%%%%",
+ "2222222222222222222222,,,,,,,,,,,,,,,,33333333333333555555555555-0000000000000000000000000000000000000000000000000%%%%%%%%%%%%%%",
+ "222222222222222222222222,,,,,,,,,,,,,,,333366333333555555555555500000000000000000000000000000000000000000000000000%%%%%%%%%%%%%%",
+ "22222222222222222222222,,,,,,,,,,,,,,,,,3366666665555555555555550000000000000000000000000000000000000000000000000%%%%%%%%%%%%%%%",
+ "22222222222222222222222,,,,,,,,,,,,,,,,666666666555555555557775500000000000000000000000000000000000000000000000000%%%%%%%%%%%%%%",
+ "2222222222222222222222,,,,,,,,,,,,,,,66666666666655555557577777770000000000089990000000000000000000000000000000000%%%%%%%%%%%%%%",
+ "2222222222222222222222,,,,,,,,,,,,,,,66666666666675555777777777777880000000888999990000000000000000000000000000000%%%%%%%%%%%%%%",
+ "2222222222222222222222,,,,,,,,,,,,,,,66666666666677757777777777788888880888888999999000000000000000000000000000%%%%%%%%%%%%%%%%%",
+ "2222222222222222222222::::::6,66,6666,66666666667777777777777778888888888888888999900000000000000000000000000%%%%%%%%%%%%%%%%%%%",
+ "22222222222222222222::::::::6,6666666666666666677777777777777778888888888888888999999000000000000000000000000%%%%%%%%%%%%%%%%%%%",
+ "22222222222222222222::::::::6666666666666666666777777777777777888888888888888888999990000000000000000000000 %%%%%%%%%%%%%%%%",
+ "2222222222222222222:::::::::::;6;;;;6666666666<7777777777777778888888888888888888999990000000000000000000 %%%%%%%%%%%%%%%%%%",
+ "222222222222222222:::::::::::;;;;;;;;;;6666<<<<77777777777777888888888888888888889999900 0000000000 %%%%%%%%%%%%%%%%%%%%",
+ "22222222222222222222::::;::;;;;;;;;;;;;<<<<<<<===777777777777888888888888888888889900000 000000000 %%%%%%%%%%%%%%%%%%%",
+ "22222222222222222222:::;;;;;;;;;;;;;;;;<<<<<<=====777777>>88888888888888888888889990000 00 00 %%%%%%%%%%%%%%%%%%%",
+ "22222222222222222222;;;;;;;;;;;;;;;;;;;<<<<<<======77=>>>>>888888888888888888888890000 000 %%%%%%%%%%%%%%%%%%%%",
+ "22222222222222222222;;;;;;;;;;;;;;;;; <<<<==========>>>>>>8888888888888888888899000 000000 %%%%%%%%%%%%%%%%%%%%%",
+ "222222222222222222222;;;;;;;;;;;;;; ================>>>>>8888888888888888888880088 000000 000% %%%%%%%%%%%%%%%%%%%%",
+ "2222222222222222222;;;;;;;;;;;;;;;;; == ==?=????=?==>>>>>>>88888888888888888888888 00000 00 %%%%%%%%%%%%%%%%%%%%%%%",
+ "22222222222222222222;;;;;;;;;;;;;;; = ==???????????>>>>>888888888888888888888888 0000 %%%%%%%%%%%%%%%%%%%%%",
+ "22222222222222222222;;;;;;;;;;;;;;; = ===?????????>>>>>>>>8>88888888888888888 000 %%%%%%%%%%%%%%%%%%%",
+ "22222222222222222222;;;;; ;;;;;;;;; ====????????>>>>>>>>>>88888888888888888 %%%%%%%%%%%%%%%%%%",
+ "2222222222222222222222;; ;;;;;;;; ===?????????>>>>>>>>>@88888888888@8888 %%%%%%%%%%%%%%%%",
+ "2222222222222222222222; ;;;;;;;; ===????????>>>>>>>>@@88888888@@@@@@88 %%%%%%%%%%%%%%%",
+ "222222222222222222222 ;;;;;;;;; ===???????>>>>>>>>@@@@@@@@@@@@@@@@@@ %%%%%%%%%%%%%%",
+ "22222222222 222 ;;;;;;;;;; = =?????A>>>>>>>>>@@@@@@@@@@@@@@@ BBB%%%%%%%%%%",
+ "222222222 ;;;;;;;;;; = =???AAA>>>>>>>>>@@@@@@@@@@@@@@ BBBBBB%%%%%",
+ "22C222222 ;;;;;;;;; ??AAAAA>>>>>>@@@@@@@@@@@@@@@@ BBBBBBBB%%%",
+ "CCCCC2222 222 ;;;;;;;;; =AAADD>>>>>>@@@@@@@@@@@@@@@ BBBBBBBBB",
+ "CCCCCCCCCC 222 ;;;;;;;; AADDD>>>>E@@@@@@@@@@@@@@@ BBBBBBBBB",
+ "CCCCCCCCCC 22 ;;;;;;;;; ADDD>EEEEE@@@@@@@@@@@@F@@ BBBBBBBBB",
+ "CCCCCCCCC 22 ;;;;;;;;;;;; DDDEEEEEEE@@@@@@@@@FFFFF FFFFFFFF BBBBBBBBB",
+ "CCCCCCC 2 ;;;;;;;;;; DDDEEEEEEE@@@G@@@@@GFFFFF FFFFFFFFFFFF BBBFBBBBB",
+ "CCCCCC ;;;;;;; DDDEEEEEEGGGGGGGGGGFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFBBBBB"
+ ],
+ "keys": [ "", "578", "752", "246", "643", "248", "233", "428", "208", "440", "112", "276", "616", "826", "528", "804", "56", "250",
+ "203", "442", "703", "40", "348", "642", "498", "756", "380", "705", "191", "688", "70", "100", "499", "268", "724", "8",
+ "807", "792", "300" ],
+ "data": {
+ "8": "Albania",
+ "40": "Austria",
+ "56": "Belgium",
+ "70": "Bosnia and Herzegovina",
+ "100": "Bulgaria",
+ "112": "Belarus",
+ "191": "Croatia",
+ "203": "Czech Republic",
+ "208": "Denmark",
+ "233": "Estonia",
+ "246": "Finland",
+ "250": "France",
+ "268": "Georgia",
+ "276": "Germany",
+ "300": "Greece",
+ "348": "Hungary",
+ "380": "Italy",
+ "428": "Latvia",
+ "440": "Lithuania",
+ "442": "Luxembourg",
+ "498": "Republic of Moldova",
+ "499": "Montenegro",
+ "528": "Netherlands",
+ "578": "Norway",
+ "616": "Poland",
+ "642": "Romania",
+ "643": "Russia",
+ "688": "Serbia",
+ "703": "Slovakia",
+ "705": "Slovenia",
+ "724": "Spain",
+ "752": "Sweden",
+ "756": "Switzerland",
+ "792": "Turkey",
+ "804": "Ukraine",
+ "807": "The former Yugoslav Republic of Macedonia",
+ "826": "United Kingdom"
+ }
+ }
+
+When minified and gzipped, the resulting file is 2071 bytes with the key to data mapping and 1645 bytes without.
+
+To test implementations, [`demo.json`](https://github.com/mapbox/mbtiles-spec/blob/master/1.1/demo.json) contains a grid that consists of 65501 different keys. This is the maximum possible in this version of UTFGrid. Implementors should check that obtaining a coordinate should return the key `y * 256 + x` for all x/y, with the exception of y = 255 and x >= 222 and x <= 255 returning 65501 due to the maximum codepoint allowed in JSON.
+
+A dummy code validation routine is given here:
+
+```javascript
+var json = JSON.parse(/* demo.json */);
+
+// the resolution of the grid. adjust this for your grid.
+var resolution = 4;
+
+var key = 0,
+ dimension = 256 / resolution;
+
+for (var y = 0; y < dimension; y++) {
+ for (var x = 0; x < dimension; x++) {
+ var code = json.grid[y].charCodeAt(x);
+ if (code >= 93) code--;
+ if (code >= 35) code--;
+ code -= 32;
+
+ assert(code == key) {
+
+ if (key < 65501) key++;
+ }
+}
+```
View
6 CHANGELOG.md
@@ -1,3 +1,9 @@
+## 1.3
+
+* Adjusts default resolution to 4 from 2
+* Improves Javascript validation example for variable-resolution grids
+* Rewords sections to accomodate variable-dpi tiles.
+
## 1.2
* Deprecates the `formatter` option and adds `template`, a replacement
Please sign in to comment.
Something went wrong with that request. Please try again.