A "tile" represents a quadrilatareal that has asimilar functionalilty of a square pixel in HD screens, where the screen is replaced by a map superimposed on a digital canvas. A tile is instantiated by a constructor that takes g,x and y parameters. "g" represents the granualrity, x the distance in tiles from the anti-meridian to the east and y the distance in tiles from the north pole. The API calculates the tile boundaries with its method "coords" and can be "inflated" into a grid of tiles (Tbox). At granularity level 1, 100 tiles or (10 x 10) would cover the Mercator projection base layer. In granuarity 2 the Base offset contains 100 x 100 tiles and so on. Decimal tiles are represented by one number instead of a vector by concatenating the drill-down level with row number and column number (padded with zeros). A tile number shares the digits of its ancestors, which makes zooming and joining or splitting tiles more understandable and easier to program or share.
A tile box represents a quadrilateral perimeter that encloses tiles. It is instantiated by assigning an northwestern anchor tile number and increments to the east and south. A Tbox is denoted by concatenating a dot and the xi and yi increment to the anchor number. The API can convert a tile to a tilebox by surrounding it or extending it or using a function that has the coordinates of opposing corners. A Tbox has methods that create the set of coordinates that represent grid lines or geoJSON string that includes the coordinates of its tiles. Thus, the use of a Tbox is effective when suppoerimposing floating grids of different resolution on mapping applications.<script src="https://cdn.jsdelivr.net/gh/dTile/tiler/dist/tiler.js"></script>const DT = require('./YourAPPDirectory/tiler');
// Intantiate a tile that encloses "Null Island" in granularity level 2
var tile = DT.find(0,0,2);
//or
var tile = new DT.Tile(2,50,50);
//or
var tile = new DT.Tile(25050);
//set the decimal precision to 6 and get the bounding coordinates;
tile.p=6;
console.log(tile.coords);
// result [[0,0],[0,3.6],[-3.597634,3.6],[-3.597634,0]]
//instantiate a tile-box (tbox) that surrounds "tile" with 10 tiles in each side and print corners' coordinates;
var tbox = tile.surround(10);
console.log(tbox.coords);
//Output a geoJSON string with the coordinates of 200 tiles that are adjacent to the equator at granularity 2
var geoJSON2 = new DT.Tbox(20049,99,1).gridSON
//Output a geoJSON string with 100 tiles that cover the earth at granularity 1 (base offset)
var geoJSON = new DT.Tbox(100,9,9).gridSON
View a tile or a tilebox on a map
The base offset (or "offset 0") is the area confined by [90°,-180°] in the northwest and [-90°.180°] in the southeast. At offset 1 a tile would increment its longitude by 360° and at offset -1 it would dercrease the longitude by 360° and so on. This would enable a tile or a Tbox to be displayed west to the meridian or displayed at any selected offset of a Mercator projection layer. The offset attribute enables displaying Tbox grids that intersect with the anti-meridian. An offset attrbute of a Tbox is derived from the offset of its anchor at the northwest which may imply that some of its other tiles may be in an adjacent offset.
The antimeridian is the 180° line of longitude. The Aleutian Islands archipelago, which includes Attu Island, crosses this line. Attu Island is located at approximately 172° 55' East longitude. Because it is east of the 180° meridian, it is technically in the Eastern Hemisphere, even though it is part of the United States. The offseting system enables diplaying a contiguous Tbox that is composed by tiles that are located in the western and eastern hemisphere.
Note
Tiles visually seem to form perfect adjacent squares or a grid. The tiles are actually trapezoids that look like squares due to earth curvature under the anomality of the Mercator projection model. The anomality is accentuanted when moving towards the north or south poles.
Tiler is released under the MIT license

