global-mercator
Advanced tools
Comparing version 2.8.4 to 3.0.0
# Changelog | ||
## 3.0.0 - 2017-09-29 | ||
- Support ES modules | ||
## 2.8.4 - 2017-08-02 | ||
@@ -5,0 +9,0 @@ |
111
index.js
var originShift = 2 * Math.PI * 6378137 / 2.0 | ||
var d2r = Math.PI / 180 | ||
// var r2d = 180 / Math.PI | ||
function initialResolution (tileSize) { | ||
export function initialResolution (tileSize) { | ||
tileSize = tileSize || 256 | ||
@@ -18,3 +18,3 @@ return 2 * Math.PI * 6378137 / tileSize | ||
*/ | ||
function hash (tile) { | ||
export function hash (tile) { | ||
var x = tile[0] | ||
@@ -38,3 +38,3 @@ var y = tile[1] | ||
*/ | ||
function pointToTile (lnglat, zoom, validate) { | ||
export function pointToTile (lnglat, zoom, validate) { | ||
var tile = pointToTileFraction(lnglat, zoom, validate) | ||
@@ -55,6 +55,7 @@ tile[0] = Math.floor(tile[0]) | ||
* @returns {Google} Google (XYZ) Tile | ||
* @example | ||
* var tile = globalMercator.pointToTileFraction([1, 1], 12) | ||
* //= [ 2059.3777777777777, 2036.6216445333432, 12 ] | ||
*/ | ||
function pointToTileFraction (lnglat, zoom, validate) { | ||
export function pointToTileFraction (lnglat, zoom, validate) { | ||
// lnglat = validateLngLat(lnglat, validate) | ||
@@ -80,3 +81,3 @@ var z = zoom | ||
*/ | ||
function bboxToCenter (bbox) { | ||
export function bboxToCenter (bbox) { | ||
var west = bbox[0] | ||
@@ -103,3 +104,3 @@ var south = bbox[1] | ||
*/ | ||
function lngLatToMeters (lnglat, validate) { | ||
export function lngLatToMeters (lnglat, validate) { | ||
lnglat = validateLngLat(lnglat, validate) | ||
@@ -125,3 +126,3 @@ var lng = lnglat[0] | ||
*/ | ||
function metersToLngLat (meters) { | ||
export function metersToLngLat (meters) { | ||
var x = meters[0] | ||
@@ -148,3 +149,3 @@ var y = meters[1] | ||
*/ | ||
function metersToPixels (meters, zoom, tileSize) { | ||
export function metersToPixels (meters, zoom, tileSize) { | ||
var x = meters[0] | ||
@@ -169,3 +170,3 @@ var y = meters[1] | ||
*/ | ||
function lngLatToTile (lnglat, zoom, validate) { | ||
export function lngLatToTile (lnglat, zoom, validate) { | ||
lnglat = validateLngLat(lnglat, validate) | ||
@@ -188,3 +189,3 @@ var meters = lngLatToMeters(lnglat) | ||
*/ | ||
function lngLatToGoogle (lnglat, zoom, validate) { | ||
export function lngLatToGoogle (lnglat, zoom, validate) { | ||
lnglat = validateLngLat(lnglat, validate) | ||
@@ -209,3 +210,3 @@ | ||
*/ | ||
function metersToTile (meters, zoom) { | ||
export function metersToTile (meters, zoom) { | ||
if (zoom === 0) { | ||
@@ -228,3 +229,3 @@ return [0, 0, 0] | ||
*/ | ||
function pixelsToMeters (pixels, tileSize) { | ||
export function pixelsToMeters (pixels, tileSize) { | ||
var px = pixels[0] | ||
@@ -252,3 +253,3 @@ var py = pixels[1] | ||
*/ | ||
function pixelsToTile (pixels, tileSize, validate) { | ||
export function pixelsToTile (pixels, tileSize, validate) { | ||
tileSize = tileSize || 256 | ||
@@ -282,3 +283,3 @@ var px = pixels[0] | ||
*/ | ||
function tileToBBoxMeters (tile, tileSize, validate) { | ||
export function tileToBBoxMeters (tile, tileSize, validate) { | ||
validateTile(tile, validate) | ||
@@ -308,3 +309,3 @@ | ||
*/ | ||
function tileToBBox (tile, validate) { | ||
export function tileToBBox (tile, validate) { | ||
validateTile(tile, validate) | ||
@@ -337,3 +338,3 @@ | ||
*/ | ||
function googleToBBoxMeters (google) { | ||
export function googleToBBoxMeters (google) { | ||
var Tile = googleToTile(google) | ||
@@ -352,3 +353,3 @@ return tileToBBoxMeters(Tile) | ||
*/ | ||
function googleToBBox (google) { | ||
export function googleToBBox (google) { | ||
var Tile = googleToTile(google) | ||
@@ -368,3 +369,3 @@ return tileToBBox(Tile) | ||
*/ | ||
function tileToGoogle (tile, validate) { | ||
export function tileToGoogle (tile, validate) { | ||
validateTile(tile, validate) | ||
@@ -392,3 +393,3 @@ | ||
*/ | ||
function googleToTile (google) { | ||
export function googleToTile (google) { | ||
var x = google[0] | ||
@@ -411,3 +412,3 @@ var y = google[1] | ||
*/ | ||
function googleToQuadkey (google) { | ||
export function googleToQuadkey (google) { | ||
var Tile = googleToTile(google) | ||
@@ -427,3 +428,3 @@ return tileToQuadkey(Tile) | ||
*/ | ||
function tileToQuadkey (tile, validate) { | ||
export function tileToQuadkey (tile, validate) { | ||
validateTile(tile, validate) | ||
@@ -463,3 +464,3 @@ | ||
*/ | ||
function quadkeyToTile (quadkey) { | ||
export function quadkeyToTile (quadkey) { | ||
var Google = quadkeyToGoogle(quadkey) | ||
@@ -478,3 +479,3 @@ return googleToTile(Google) | ||
*/ | ||
function quadkeyToGoogle (quadkey) { | ||
export function quadkeyToGoogle (quadkey) { | ||
var x = 0 | ||
@@ -514,3 +515,3 @@ var y = 0 | ||
*/ | ||
function bboxToMeters (bbox) { | ||
export function bboxToMeters (bbox) { | ||
var min = lngLatToMeters([bbox[0], bbox[1]]) | ||
@@ -536,3 +537,3 @@ var max = lngLatToMeters([bbox[2], bbox[3]]) | ||
*/ | ||
function validateTile (tile, validate) { | ||
export function validateTile (tile, validate) { | ||
var tx = tile[0] | ||
@@ -570,3 +571,3 @@ var ty = tile[1] | ||
*/ | ||
function wrapTile (tile) { | ||
export function wrapTile (tile) { | ||
var tx = tile[0] | ||
@@ -605,3 +606,3 @@ var ty = tile[1] | ||
*/ | ||
function validateZoom (zoom) { | ||
export function validateZoom (zoom) { | ||
if (zoom === false) return zoom | ||
@@ -627,3 +628,3 @@ if (zoom === undefined || zoom === null) { throw new Error('<zoom> is required') } | ||
*/ | ||
function validateLngLat (lnglat, validate) { | ||
export function validateLngLat (lnglat, validate) { | ||
if (validate === false) return lnglat | ||
@@ -651,3 +652,3 @@ | ||
*/ | ||
function resolution (zoom, tileSize) { | ||
export function resolution (zoom, tileSize) { | ||
return initialResolution(tileSize) / Math.pow(2, zoom) | ||
@@ -672,3 +673,3 @@ } | ||
*/ | ||
function range (start, stop, step) { | ||
export function range (start, stop, step) { | ||
if (stop == null) { | ||
@@ -698,3 +699,3 @@ stop = start || 0 | ||
*/ | ||
function maxBBox (array) { | ||
export function maxBBox (array) { | ||
if (!array) throw new Error('array is required') | ||
@@ -737,3 +738,3 @@ | ||
*/ | ||
function validTile (tile) { | ||
export function validTile (tile) { | ||
try { | ||
@@ -753,6 +754,6 @@ validateTile(tile) | ||
* @example | ||
* dateline.latitude(100) | ||
* globalMercator.latitude(100) | ||
* //= -80 | ||
*/ | ||
function latitude (lat) { | ||
export function latitude (lat) { | ||
if (lat === undefined || lat === null) throw new Error('lat is required') | ||
@@ -776,6 +777,6 @@ | ||
* @example | ||
* dateline.longitude(190) | ||
* globalMercator.longitude(190) | ||
* //= -170 | ||
*/ | ||
function longitude (lng) { | ||
export function longitude (lng) { | ||
if (lng === undefined || lng === null) throw new Error('lng is required') | ||
@@ -792,37 +793,1 @@ | ||
} | ||
module.exports = { | ||
hash: hash, | ||
longitude: longitude, | ||
latitude: latitude, | ||
bboxToCenter: bboxToCenter, | ||
lngLatToMeters: lngLatToMeters, | ||
metersToLngLat: metersToLngLat, | ||
metersToPixels: metersToPixels, | ||
lngLatToTile: lngLatToTile, | ||
lngLatToGoogle: lngLatToGoogle, | ||
metersToTile: metersToTile, | ||
pixelsToMeters: pixelsToMeters, | ||
pixelsToTile: pixelsToTile, | ||
tileToBBoxMeters: tileToBBoxMeters, | ||
tileToBBox: tileToBBox, | ||
googleToBBoxMeters: googleToBBoxMeters, | ||
googleToBBox: googleToBBox, | ||
tileToGoogle: tileToGoogle, | ||
googleToTile: googleToTile, | ||
googleToQuadkey: googleToQuadkey, | ||
tileToQuadkey: tileToQuadkey, | ||
quadkeyToTile: quadkeyToTile, | ||
quadkeyToGoogle: quadkeyToGoogle, | ||
bboxToMeters: bboxToMeters, | ||
validateTile: validateTile, | ||
validateZoom: validateZoom, | ||
validateLngLat: validateLngLat, | ||
resolution: resolution, | ||
range: range, | ||
maxBBox: maxBBox, | ||
validTile: validTile, | ||
pointToTileFraction: pointToTileFraction, | ||
pointToTile: pointToTile, | ||
wrapTile: wrapTile | ||
} |
{ | ||
"name": "global-mercator", | ||
"version": "2.8.4", | ||
"version": "3.0.0", | ||
"description": "Tools to help with TMS, Quadkey & Google (XYZ) Tiles", | ||
@@ -9,12 +9,16 @@ "repository": { | ||
}, | ||
"main": "index.js", | ||
"main": "global-mercator.js", | ||
"module": "index.js", | ||
"jsnext:main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.d.ts", | ||
"index.js" | ||
"index.js", | ||
"global-mercator.js" | ||
], | ||
"scripts": { | ||
"pretest": "standard", | ||
"test": "tap test.js", | ||
"bench": "node bench.js", | ||
"test": "node -r @std/esm test.js", | ||
"postest": "rollup -f cjs -o global-mercator.js index.js", | ||
"bench": "node -r @std/esm bench.js", | ||
"docs": "documentation readme index.js --shallow --section=API" | ||
@@ -49,10 +53,14 @@ }, | ||
"devDependencies": { | ||
"@mapbox/tilebelt": "^1.0.1", | ||
"benchmark": "^2.1.4", | ||
"documentation": "^4.0.0-rc.1", | ||
"standard": "^10.0.2", | ||
"tap": "^10.7.0", | ||
"tape": "^4.7.0" | ||
"@mapbox/tilebelt": "*", | ||
"@std/esm": "*", | ||
"benchmark": "*", | ||
"documentation": "*", | ||
"standard": "*", | ||
"tape": "*" | ||
}, | ||
"dependencies": {} | ||
"dependencies": {}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# [Global Mercator](https://www.npmjs.com/package/global-mercator) | ||
# Global Mercator | ||
@@ -127,6 +127,11 @@ [![Build Status](https://travis-ci.org/DenisCarriere/global-mercator.svg?branch=master)](https://travis-ci.org/DenisCarriere/global-mercator) | ||
Returns **Google** Google (XYZ) Tile | ||
**Examples** | ||
```javascript | ||
var tile = globalMercator.pointToTileFraction([1, 1], 12) | ||
//= [ 2059.3777777777777, 2036.6216445333432, 12 ] | ||
``` | ||
Returns **Google** Google (XYZ) Tile | ||
### bboxToCenter | ||
@@ -633,3 +638,3 @@ | ||
```javascript | ||
dateline.latitude(100) | ||
globalMercator.latitude(100) | ||
//= -80 | ||
@@ -651,3 +656,3 @@ ``` | ||
```javascript | ||
dateline.longitude(190) | ||
globalMercator.longitude(190) | ||
//= -170 | ||
@@ -654,0 +659,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73272
7
1495
659