Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

global-mercator

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

global-mercator - npm Package Compare versions

Comparing version 2.8.3 to 2.8.4

5

CHANGELOG.md
# Changelog
## 2.8.4 - 2017-08-02
- Update docs to match https://wzrd.in
- Drop Tile Y wrapping
## 2.8.1 - 2017-07-19

@@ -5,0 +10,0 @@

87

index.js

@@ -15,3 +15,3 @@ var originShift = 2 * Math.PI * 6378137 / 2.0

* @example
* var id = mercator.hash([312, 480, 4])
* var id = globalMercator.hash([312, 480, 4])
* //=5728

@@ -35,3 +35,3 @@ */

* @example
* var tile = mercator.pointToTile([1, 1], 12)
* var tile = globalMercator.pointToTile([1, 1], 12)
* //= [ 2059, 2036, 12 ]

@@ -55,3 +55,3 @@ */

* @returns {Google} Google (XYZ) Tile
* var tile = mercator.pointToTileFraction([1, 1], 12)
* var tile = globalMercator.pointToTileFraction([1, 1], 12)
* //= [ 2059.3777777777777, 2036.6216445333432, 12 ]

@@ -77,3 +77,3 @@ */

* @example
* var center = mercator.bboxToCenter([90, -45, 85, -50])
* var center = globalMercator.bboxToCenter([90, -45, 85, -50])
* //= [ 87.5, -47.5 ]

@@ -100,3 +100,3 @@ */

* @example
* var meters = mercator.lngLatToMeters([126, 37])
* var meters = globalMercator.lngLatToMeters([126, 37])
* //=[ 14026255.8, 4439106.7 ]

@@ -122,3 +122,3 @@ */

* @example
* var lnglat = mercator.metersToLngLat([14026255, 4439106])
* var lnglat = globalMercator.metersToLngLat([14026255, 4439106])
* //=[ 126, 37 ]

@@ -145,3 +145,3 @@ */

* @example
* var pixels = mercator.metersToPixels([14026255, 4439106], 13)
* var pixels = globalMercator.metersToPixels([14026255, 4439106], 13)
* //=[ 1782579.1, 1280877.3, 13 ]

@@ -166,3 +166,3 @@ */

* @example
* var tile = mercator.lngLatToTile([126, 37], 13)
* var tile = globalMercator.lngLatToTile([126, 37], 13)
* //=[ 6963, 5003, 13 ]

@@ -185,3 +185,3 @@ */

* @example
* var google = mercator.lngLatToGoogle([126, 37], 13)
* var google = globalMercator.lngLatToGoogle([126, 37], 13)
* //=[ 6963, 3188, 13 ]

@@ -206,3 +206,3 @@ */

* @example
* var tile = mercator.metersToTile([14026255, 4439106], 13)
* var tile = globalMercator.metersToTile([14026255, 4439106], 13)
* //=[ 6963, 5003, 13 ]

@@ -225,3 +225,3 @@ */

* @example
* var meters = mercator.pixelsToMeters([1782579, 1280877, 13])
* var meters = globalMercator.pixelsToMeters([1782579, 1280877, 13])
* //=[ 14026252.0, 4439099.5 ]

@@ -249,3 +249,3 @@ */

* @example
* var tile = mercator.pixelsToTile([1782579, 1280877, 13])
* var tile = globalMercator.pixelsToTile([1782579, 1280877, 13])
* //=[ 6963, 5003, 13 ]

@@ -279,3 +279,3 @@ */

* @example
* var bbox = mercator.tileToBBoxMeters([6963, 5003, 13])
* var bbox = globalMercator.tileToBBoxMeters([6963, 5003, 13])
* //=[ 14025277.4, 4437016.6, 14030169.4, 4441908.5 ]

@@ -305,3 +305,3 @@ */

* @example
* var bbox = mercator.tileToBBox([6963, 5003, 13])
* var bbox = globalMercator.tileToBBox([6963, 5003, 13])
* //=[ 125.991, 36.985, 126.035, 37.020 ]

@@ -334,3 +334,3 @@ */

* @example
* var bbox = mercator.googleToBBoxMeters([6963, 3188, 13])
* var bbox = globalMercator.googleToBBoxMeters([6963, 3188, 13])
* //=[ 14025277.4, 4437016.6, 14030169.4, 4441908.5 ]

@@ -349,3 +349,3 @@ */

* @example
* var bbox = mercator.googleToBBox([6963, 3188, 13])
* var bbox = globalMercator.googleToBBox([6963, 3188, 13])
* //=[ 125.991, 36.985, 126.035, 37.020 ]

@@ -365,3 +365,3 @@ */

* @example
* var google = mercator.tileToGoogle([6963, 5003, 13])
* var google = globalMercator.tileToGoogle([6963, 5003, 13])
* //=[ 6963, 3188, 13 ]

@@ -389,3 +389,3 @@ */

* @example
* var tile = mercator.googleToTile([6963, 3188, 13])
* var tile = globalMercator.googleToTile([6963, 3188, 13])
* //=[ 6963, 5003, 13 ]

@@ -408,3 +408,3 @@ */

* @example
* var quadkey = mercator.googleToQuadkey([6963, 3188, 13])
* var quadkey = globalMercator.googleToQuadkey([6963, 3188, 13])
* //='1321102330211'

@@ -424,3 +424,3 @@ */

* @example
* var quadkey = mercator.tileToQuadkey([6963, 5003, 13])
* var quadkey = globalMercator.tileToQuadkey([6963, 5003, 13])
* //='1321102330211'

@@ -460,3 +460,3 @@ */

* @example
* var tile = mercator.quadkeyToTile('1321102330211')
* var tile = globalMercator.quadkeyToTile('1321102330211')
* //=[ 6963, 5003, 13 ]

@@ -475,3 +475,3 @@ */

* @example
* var google = mercator.quadkeyToGoogle('1321102330211')
* var google = globalMercator.quadkeyToGoogle('1321102330211')
* //=[ 6963, 3188, 13 ]

@@ -511,3 +511,3 @@ */

* @example
* var meters = mercator.bboxToMeters([ 125, 35, 127, 37 ])
* var meters = globalMercator.bboxToMeters([ 125, 35, 127, 37 ])
* //=[ 13914936.3, 4163881.1, 14137575.3, 4439106.7 ]

@@ -529,7 +529,7 @@ */

* @example
* mercator.validateTile([60, 80, 12])
* globalMercator.validateTile([60, 80, 12])
* //=[60, 80, 12]
* mercator.validateTile([60, -43, 5])
* globalMercator.validateTile([60, -43, 5])
* //= Error: Tile <y> must not be less than 0
* mercator.validateTile([25, 60, 3])
* globalMercator.validateTile([25, 60, 3])
* //= Error: Illegal parameters for tile

@@ -565,5 +565,5 @@ */

* @example
* mercator.wrapTile([0, 3, 2])
* globalMercator.wrapTile([0, 3, 2])
* //= [0, 3, 2] -- Valid Tile X
* mercator.wrapTile([4, 2, 2])
* globalMercator.wrapTile([4, 2, 2])
* //= [0, 2, 2] -- Tile 4 does not exist, wrap around to TileX=0

@@ -581,3 +581,3 @@ */

// zoom 3 => 8
var maxTile = 1 << zoom
var maxTile = Math.pow(2, zoom)

@@ -588,5 +588,2 @@ // Handle Tile X

// Handle Tile Y
ty = ty % maxTile
if (ty < 0) ty = ty + maxTile
return [tx, ty, zoom]

@@ -603,7 +600,7 @@ }

* @example
* mercator.validateZoom(12)
* globalMercator.validateZoom(12)
* //=12
* mercator.validateZoom(-4)
* globalMercator.validateZoom(-4)
* //= Error: <zoom> cannot be less than 0
* mercator.validateZoom(32)
* globalMercator.validateZoom(32)
* //= Error: <zoom> cannot be greater than 30

@@ -627,5 +624,5 @@ */

* @example
* mercator.validateLngLat([-115, 44])
* globalMercator.validateLngLat([-115, 44])
* //= [ -115, 44 ]
* mercator.validateLngLat([-225, 44])
* globalMercator.validateLngLat([-225, 44])
* //= Error: LngLat [lng] must be within -180 to 180 degrees

@@ -653,3 +650,3 @@ */

* @example
* var res = mercator.resolution(13)
* var res = globalMercator.resolution(13)
* //=19.109257071294063

@@ -670,7 +667,7 @@ */

* @example
* mercator.range(3)
* globalMercator.range(3)
* //=[ 0, 1, 2 ]
* mercator.range(3, 6)
* globalMercator.range(3, 6)
* //=[ 3, 4, 5 ]
* mercator.range(6, 3, -1)
* globalMercator.range(6, 3, -1)
* //=[ 6, 5, 4 ]

@@ -700,3 +697,3 @@ */

* @example
* var bbox = mercator.maxBBox([[-20, -30, 20, 30], [-110, -30, 120, 80]])
* var bbox = globalMercator.maxBBox([[-20, -30, 20, 30], [-110, -30, 120, 80]])
* //=[-110, -30, 120, 80]

@@ -735,7 +732,7 @@ */

* @example
* mercator.validTile([60, 80, 12])
* globalMercator.validTile([60, 80, 12])
* //= true
* mercator.validTile([60, -43, 5])
* globalMercator.validTile([60, -43, 5])
* //= false
* mercator.validTile([25, 60, 3])
* globalMercator.validTile([25, 60, 3])
* //= false

@@ -742,0 +739,0 @@ */

{
"name": "global-mercator",
"version": "2.8.3",
"version": "2.8.4",
"description": "Tools to help with TMS, Quadkey & Google (XYZ) Tiles",

@@ -5,0 +5,0 @@ "repository": {

@@ -7,2 +7,3 @@ # [Global Mercator](https://www.npmjs.com/package/global-mercator)

[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/DenisCarriere/global-mercator/master/LICENSE)
[![ES5](https://camo.githubusercontent.com/d341caa63123c99b79fda7f8efdc29b35f9f2e70/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f65732d352d627269676874677265656e2e737667)](http://kangax.github.io/compat-table/es5/)

@@ -25,8 +26,14 @@ [![Standard - JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

**web**
```html
<script src="https://wzrd.in/standalone/global-mercator@latest"></script>
```
## Quickstart
```javascript
var mercator = require('global-mercator')
var globalMercator = require('global-mercator')
var tile = [10, 15, 8] // [x, y, zoom]
mercator.tileToBBox(tile)
globalMercator.tileToBBox(tile)
// [ -165.937, -82.853, -164.531, -82.676 ]

@@ -68,3 +75,3 @@ ```

| [pointToTileFraction(lnglat, zoom)](#pointtotilefraction) | Get the precise fractional tile location for a point at a zoom level |
| [wrapTile(tile)](#wraptile) | Handles tiles which crosses the 180th meridian or 90th parallel |
| [wrapTile(tile)](#wraptile) | Handles tiles which crosses the 180th meridian |

@@ -86,3 +93,3 @@ ## API

```javascript
var id = mercator.hash([312, 480, 4])
var id = globalMercator.hash([312, 480, 4])
//=5728

@@ -107,3 +114,3 @@ ```

```javascript
var tile = mercator.pointToTile([1, 1], 12)
var tile = globalMercator.pointToTile([1, 1], 12)
//= [ 2059, 2036, 12 ]

@@ -126,3 +133,3 @@ ```

Returns **Google** Google (XYZ) Tile
var tile = mercator.pointToTileFraction([1, 1], 12)
var tile = globalMercator.pointToTileFraction([1, 1], 12)
//= [ 2059.3777777777777, 2036.6216445333432, 12 ]

@@ -141,3 +148,3 @@

```javascript
var center = mercator.bboxToCenter([90, -45, 85, -50])
var center = globalMercator.bboxToCenter([90, -45, 85, -50])
//= [ 87.5, -47.5 ]

@@ -160,3 +167,3 @@ ```

```javascript
var meters = mercator.lngLatToMeters([126, 37])
var meters = globalMercator.lngLatToMeters([126, 37])
//=[ 14026255.8, 4439106.7 ]

@@ -178,3 +185,3 @@ ```

```javascript
var lnglat = mercator.metersToLngLat([14026255, 4439106])
var lnglat = globalMercator.metersToLngLat([14026255, 4439106])
//=[ 126, 37 ]

@@ -198,3 +205,3 @@ ```

```javascript
var pixels = mercator.metersToPixels([14026255, 4439106], 13)
var pixels = globalMercator.metersToPixels([14026255, 4439106], 13)
//=[ 1782579.1, 1280877.3, 13 ]

@@ -218,3 +225,3 @@ ```

```javascript
var tile = mercator.lngLatToTile([126, 37], 13)
var tile = globalMercator.lngLatToTile([126, 37], 13)
//=[ 6963, 5003, 13 ]

@@ -238,3 +245,3 @@ ```

```javascript
var google = mercator.lngLatToGoogle([126, 37], 13)
var google = globalMercator.lngLatToGoogle([126, 37], 13)
//=[ 6963, 3188, 13 ]

@@ -257,3 +264,3 @@ ```

```javascript
var tile = mercator.metersToTile([14026255, 4439106], 13)
var tile = globalMercator.metersToTile([14026255, 4439106], 13)
//=[ 6963, 5003, 13 ]

@@ -276,3 +283,3 @@ ```

```javascript
var meters = mercator.pixelsToMeters([1782579, 1280877, 13])
var meters = globalMercator.pixelsToMeters([1782579, 1280877, 13])
//=[ 14026252.0, 4439099.5 ]

@@ -296,3 +303,3 @@ ```

```javascript
var tile = mercator.pixelsToTile([1782579, 1280877, 13])
var tile = globalMercator.pixelsToTile([1782579, 1280877, 13])
//=[ 6963, 5003, 13 ]

@@ -319,3 +326,3 @@ ```

```javascript
var bbox = mercator.tileToBBoxMeters([6963, 5003, 13])
var bbox = globalMercator.tileToBBoxMeters([6963, 5003, 13])
//=[ 14025277.4, 4437016.6, 14030169.4, 4441908.5 ]

@@ -341,3 +348,3 @@ ```

```javascript
var bbox = mercator.tileToBBox([6963, 5003, 13])
var bbox = globalMercator.tileToBBox([6963, 5003, 13])
//=[ 125.991, 36.985, 126.035, 37.020 ]

@@ -359,3 +366,3 @@ ```

```javascript
var bbox = mercator.googleToBBoxMeters([6963, 3188, 13])
var bbox = globalMercator.googleToBBoxMeters([6963, 3188, 13])
//=[ 14025277.4, 4437016.6, 14030169.4, 4441908.5 ]

@@ -377,3 +384,3 @@ ```

```javascript
var bbox = mercator.googleToBBox([6963, 3188, 13])
var bbox = globalMercator.googleToBBox([6963, 3188, 13])
//=[ 125.991, 36.985, 126.035, 37.020 ]

@@ -396,3 +403,3 @@ ```

```javascript
var google = mercator.tileToGoogle([6963, 5003, 13])
var google = globalMercator.tileToGoogle([6963, 5003, 13])
//=[ 6963, 3188, 13 ]

@@ -414,3 +421,3 @@ ```

```javascript
var tile = mercator.googleToTile([6963, 3188, 13])
var tile = globalMercator.googleToTile([6963, 3188, 13])
//=[ 6963, 5003, 13 ]

@@ -432,3 +439,3 @@ ```

```javascript
var quadkey = mercator.googleToQuadkey([6963, 3188, 13])
var quadkey = globalMercator.googleToQuadkey([6963, 3188, 13])
//='1321102330211'

@@ -451,3 +458,3 @@ ```

```javascript
var quadkey = mercator.tileToQuadkey([6963, 5003, 13])
var quadkey = globalMercator.tileToQuadkey([6963, 5003, 13])
//='1321102330211'

@@ -469,3 +476,3 @@ ```

```javascript
var tile = mercator.quadkeyToTile('1321102330211')
var tile = globalMercator.quadkeyToTile('1321102330211')
//=[ 6963, 5003, 13 ]

@@ -487,3 +494,3 @@ ```

```javascript
var google = mercator.quadkeyToGoogle('1321102330211')
var google = globalMercator.quadkeyToGoogle('1321102330211')
//=[ 6963, 3188, 13 ]

@@ -505,3 +512,3 @@ ```

```javascript
var meters = mercator.bboxToMeters([ 125, 35, 127, 37 ])
var meters = globalMercator.bboxToMeters([ 125, 35, 127, 37 ])
//=[ 13914936.3, 4163881.1, 14137575.3, 4439106.7 ]

@@ -524,7 +531,7 @@ ```

```javascript
mercator.validateTile([60, 80, 12])
globalMercator.validateTile([60, 80, 12])
//=[60, 80, 12]
mercator.validateTile([60, -43, 5])
globalMercator.validateTile([60, -43, 5])
//= Error: Tile <y> must not be less than 0
mercator.validateTile([25, 60, 3])
globalMercator.validateTile([25, 60, 3])
//= Error: Illegal parameters for tile

@@ -549,9 +556,9 @@ ```

```javascript
mercator.wrapTile([0, 3, 2])
globalMercator.wrapTile([0, 3, 2])
//= [0, 3, 2] -- Valid Tile X
mercator.wrapTile([4, 2, 2])
//= [0, 2, 2] -- Tile 4 does not exist, wrap around to TileX=0
globalMercator.wrapTile([4, 2, 2])
//= [0, 2, 2] -- Tile 4 does not exist, wrap around to TileX=0
```
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Tile X
Returns **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** Wrapped Tile

@@ -570,7 +577,7 @@ ### validateZoom

```javascript
mercator.validateZoom(12)
globalMercator.validateZoom(12)
//=12
mercator.validateZoom(-4)
globalMercator.validateZoom(-4)
//= Error: <zoom> cannot be less than 0
mercator.validateZoom(32)
globalMercator.validateZoom(32)
//= Error: <zoom> cannot be greater than 30

@@ -595,5 +602,5 @@ ```

```javascript
mercator.validateLngLat([-115, 44])
globalMercator.validateLngLat([-115, 44])
//= [ -115, 44 ]
mercator.validateLngLat([-225, 44])
globalMercator.validateLngLat([-225, 44])
//= Error: LngLat [lng] must be within -180 to 180 degrees

@@ -617,3 +624,3 @@ ```

```javascript
var bbox = mercator.maxBBox([[-20, -30, 20, 30], [-110, -30, 120, 80]])
var bbox = globalMercator.maxBBox([[-20, -30, 20, 30], [-110, -30, 120, 80]])
//=[-110, -30, 120, 80]

@@ -635,7 +642,7 @@ ```

```javascript
mercator.validTile([60, 80, 12])
globalMercator.validTile([60, 80, 12])
//= true
mercator.validTile([60, -43, 5])
globalMercator.validTile([60, -43, 5])
//= false
mercator.validTile([25, 60, 3])
globalMercator.validTile([25, 60, 3])
//= false

@@ -642,0 +649,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc