global-mercator
Advanced tools
Comparing version 0.4.1 to 0.4.2
53
index.ts
@@ -1,10 +0,2 @@ | ||
import * as Debug from 'debug' | ||
import { range, isUndefined, keys } from 'lodash' | ||
export const debug = { | ||
error: Debug('global-mercator:error'), | ||
log: Debug('global-mercator:log'), | ||
warning: Debug('global-mercator:warning'), | ||
} | ||
export const tileSize = 256 | ||
@@ -453,3 +445,2 @@ export const initialResolution = 2 * Math.PI * 6378137 / tileSize | ||
const message = '<zoom> is required' | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -481,7 +472,5 @@ } | ||
const message = `${ name } <tx> must not be less than 0` | ||
debug.error(message) | ||
throw new Error(message) | ||
} else if (ty < 0) { | ||
const message = `${ name } <ty> must not be less than 0` | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -510,7 +499,5 @@ } | ||
const message = (name) ? `${ name } <zoom> cannot be less than 0` : '<zoom> cannot be less than 0' | ||
debug.error(message) | ||
throw new Error(message) | ||
} else if (zoom > 30) { | ||
const message = (name) ? `${ name } <zoom> cannot be greater than 30` : '<zoom> cannot be greater than 30' | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -535,3 +522,2 @@ } | ||
const message = 'Pixels must be an Array of 2 numbers' | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -542,9 +528,5 @@ } | ||
px = px - px % 1 | ||
const message = `Pixels [px] has been modified to ${ px }` | ||
debug.warning(message) | ||
} | ||
if (py % 1 !== 0) { | ||
py = py - py % 1 | ||
const message = `Pixels [py] has been modified to ${ py }` | ||
debug.warning(message) | ||
} | ||
@@ -568,3 +550,2 @@ return [px, py] | ||
const message = 'Meters must be an Array of 2 numbers' | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -577,3 +558,2 @@ } | ||
const message = `Meters [my] cannot be greater than ${ max }` | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -583,3 +563,2 @@ } | ||
const message = `Meters [my] cannot be less than ${ min }` | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -589,3 +568,2 @@ } | ||
const message = `Meters [mx] cannot be greater than ${ max }` | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -595,3 +573,2 @@ } | ||
const message = `Meters [mx] cannot be less than ${ min }` | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -636,3 +613,2 @@ } | ||
const message = 'LatLng must be an Array of 2 numbers' | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -643,17 +619,11 @@ } | ||
const message = 'LatLng [lat] must be within -90 to 90 degrees' | ||
debug.error(message) | ||
throw new Error(message) | ||
} else if (lng < -180 || lng > 180) { | ||
const message = 'LatLng [lng] must be within -180 to 180 degrees' | ||
debug.error(message) | ||
throw new Error(message) | ||
} | ||
if (lat > 85) { | ||
const message = 'LatLng [lat] has been modified to 85' | ||
debug.warning(message) | ||
lat = 85 | ||
} | ||
if (lat < -85) { | ||
const message = 'LatLng [lat] has been modified to -85' | ||
debug.warning(message) | ||
lat = -85 | ||
@@ -680,3 +650,2 @@ } | ||
const message = '[bbox] must be an Array of 4 numbers' | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -705,3 +674,2 @@ } | ||
const message = (name) ? `${ name } <${ key }> is required` : `<${ key }> is required` | ||
debug.error(message) | ||
throw new Error(message) | ||
@@ -827,22 +795,1 @@ } | ||
} | ||
/* istanbul ignore next */ | ||
if (require.main === module) { | ||
// const bbox = bboxLatLngToMeters([ -75.01464843750001, 44.99588261816546, -74.97070312499999, 45.02695045318546 ]) | ||
// console.log(bbox) | ||
// const meters = pixelsToMeters({ px: 611669, py: 1342753, zoom: 13 }) | ||
// console.log(meters) | ||
// console.log(metersToPixels(meters)) | ||
// console.log(metersToLatLng(meters)) | ||
// gdalwarp -of GTiff -te -8581121.501851652 -1353354.7654779512 -8575634.45283096 -1349909.177990999 lima_imagery.mbtiles lima_imagery.tif | ||
// console.log(validateLatLng([-120, 45, 1])) | ||
// validateMeters([200000, 999150000]) | ||
// validateMeters([200000, 150000, 1]) | ||
// validatePixels([200000, 150000, 1]) | ||
// assertUndefined({x: null}) | ||
// console.log(metersToLatLng({mx: 10018754.171394622, my: 5621521.486192067})) | ||
// console.log(metersToPixels({mx: 10000000, my: 5500000, zoom: 13})) | ||
// console.log(metersToPixels({mx: 3000, my: 4000})) | ||
console.log(latLngToMeters({lat: 23, lng: 23})) | ||
console.log(validateBbox([ -75, 44, -74 ])) | ||
} |
{ | ||
"name": "global-mercator", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Global Mercator", | ||
@@ -31,9 +31,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"debug": "^2.2.0", | ||
"lodash": "^4.16.1" | ||
"lodash": "^4.16.1", | ||
"@types/lodash": "^4.14.36" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "0.0.29", | ||
"@types/lodash": "^4.14.36", | ||
"@types/node": "^6.0.41", | ||
"ava": "^0.16.0", | ||
@@ -40,0 +37,0 @@ "coveralls": "^2.11.14", |
7
157577
1867
+ Added@types/lodash@^4.14.36
+ Added@types/lodash@4.17.14(transitive)
- Removeddebug@^2.2.0
- Removeddebug@2.6.9(transitive)
- Removedms@2.0.0(transitive)