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

@turf/projection

Package Overview
Dependencies
Maintainers
6
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/projection - npm Package Compare versions

Comparing version 6.2.0-alpha.2 to 6.2.0-alpha.3

dist/es/package.json

31

dist/es/index.js

@@ -1,4 +0,4 @@

import { coordEach } from '@turf/meta';
import { isNumber } from '@turf/helpers';
import clone from '@turf/clone';
import { coordEach } from "@turf/meta";
import { isNumber } from "@turf/helpers";
import clone from "@turf/clone";
/**

@@ -21,3 +21,3 @@ * Converts a WGS84 GeoJSON object into Mercator (EPSG:900913) projection

if (options === void 0) { options = {}; }
return convert(geojson, 'mercator', options);
return convert(geojson, "mercator", options);
}

@@ -41,3 +41,3 @@ /**

if (options === void 0) { options = {}; }
return convert(geojson, 'wgs84', options);
return convert(geojson, "wgs84", options);
}

@@ -61,6 +61,9 @@ /**

if (!geojson)
throw new Error('geojson is required');
throw new Error("geojson is required");
// Handle Position
if (Array.isArray(geojson) && isNumber(geojson[0]))
geojson = (projection === 'mercator') ? convertToMercator(geojson) : convertToWgs84(geojson);
geojson =
projection === "mercator"
? convertToMercator(geojson)
: convertToWgs84(geojson);
// Handle GeoJSON

@@ -72,3 +75,5 @@ else {

coordEach(geojson, function (coord) {
var newCoord = (projection === 'mercator') ? convertToMercator(coord) : convertToWgs84(coord);
var newCoord = projection === "mercator"
? convertToMercator(coord)
: convertToWgs84(coord);
coord[0] = newCoord[0];

@@ -94,6 +99,6 @@ coord[1] = newCoord[1];

// from https://github.com/proj4js/proj4js/blob/master/lib/common/adjust_lon.js
var adjusted = (Math.abs(lonLat[0]) <= 180) ? lonLat[0] : (lonLat[0] - (sign(lonLat[0]) * 360));
var adjusted = Math.abs(lonLat[0]) <= 180 ? lonLat[0] : lonLat[0] - sign(lonLat[0]) * 360;
var xy = [
A * adjusted * D2R,
A * Math.log(Math.tan((Math.PI * 0.25) + (0.5 * lonLat[1] * D2R)))
A * Math.log(Math.tan(Math.PI * 0.25 + 0.5 * lonLat[1] * D2R)),
];

@@ -124,4 +129,4 @@ // if xy value is beyond maxextent (e.g. poles), return maxextent

return [
(xy[0] * R2D / A),
((Math.PI * 0.5) - 2.0 * Math.atan(Math.exp(-xy[1] / A))) * R2D
(xy[0] * R2D) / A,
(Math.PI * 0.5 - 2.0 * Math.atan(Math.exp(-xy[1] / A))) * R2D,
];

@@ -137,3 +142,3 @@ }

function sign(x) {
return (x < 0) ? -1 : (x > 0) ? 1 : 0;
return x < 0 ? -1 : x > 0 ? 1 : 0;
}

@@ -1,2 +0,2 @@

import { AllGeoJSON, Position } from '@turf/helpers';
import { AllGeoJSON, Position } from "@turf/helpers";
/**

@@ -3,0 +3,0 @@ * Converts a WGS84 GeoJSON object into Mercator (EPSG:900913) projection

@@ -26,3 +26,3 @@ "use strict";

if (options === void 0) { options = {}; }
return convert(geojson, 'mercator', options);
return convert(geojson, "mercator", options);
}

@@ -47,3 +47,3 @@ exports.toMercator = toMercator;

if (options === void 0) { options = {}; }
return convert(geojson, 'wgs84', options);
return convert(geojson, "wgs84", options);
}

@@ -68,6 +68,9 @@ exports.toWgs84 = toWgs84;

if (!geojson)
throw new Error('geojson is required');
throw new Error("geojson is required");
// Handle Position
if (Array.isArray(geojson) && helpers_1.isNumber(geojson[0]))
geojson = (projection === 'mercator') ? convertToMercator(geojson) : convertToWgs84(geojson);
geojson =
projection === "mercator"
? convertToMercator(geojson)
: convertToWgs84(geojson);
// Handle GeoJSON

@@ -79,3 +82,5 @@ else {

meta_1.coordEach(geojson, function (coord) {
var newCoord = (projection === 'mercator') ? convertToMercator(coord) : convertToWgs84(coord);
var newCoord = projection === "mercator"
? convertToMercator(coord)
: convertToWgs84(coord);
coord[0] = newCoord[0];

@@ -101,6 +106,6 @@ coord[1] = newCoord[1];

// from https://github.com/proj4js/proj4js/blob/master/lib/common/adjust_lon.js
var adjusted = (Math.abs(lonLat[0]) <= 180) ? lonLat[0] : (lonLat[0] - (sign(lonLat[0]) * 360));
var adjusted = Math.abs(lonLat[0]) <= 180 ? lonLat[0] : lonLat[0] - sign(lonLat[0]) * 360;
var xy = [
A * adjusted * D2R,
A * Math.log(Math.tan((Math.PI * 0.25) + (0.5 * lonLat[1] * D2R)))
A * Math.log(Math.tan(Math.PI * 0.25 + 0.5 * lonLat[1] * D2R)),
];

@@ -131,4 +136,4 @@ // if xy value is beyond maxextent (e.g. poles), return maxextent

return [
(xy[0] * R2D / A),
((Math.PI * 0.5) - 2.0 * Math.atan(Math.exp(-xy[1] / A))) * R2D
(xy[0] * R2D) / A,
(Math.PI * 0.5 - 2.0 * Math.atan(Math.exp(-xy[1] / A))) * R2D,
];

@@ -144,3 +149,3 @@ }

function sign(x) {
return (x < 0) ? -1 : (x > 0) ? 1 : 0;
return x < 0 ? -1 : x > 0 ? 1 : 0;
}
{
"name": "@turf/projection",
"version": "6.2.0-alpha.2",
"version": "6.2.0-alpha.3",
"description": "turf projection module",

@@ -38,2 +38,6 @@ "author": "Turf Authors",

"module": "dist/es/index.js",
"exports": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
},
"types": "dist/js/index.d.ts",

@@ -45,14 +49,13 @@ "sideEffects": false,

"scripts": {
"bench": "npm-run-all prepare bench:run",
"bench:run": "node bench.js",
"bench": "ts-node bench.js",
"build": "npm-run-all build:*",
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:js": "tsc",
"docs": "node ../../scripts/generate-readmes",
"prepare": "npm-run-all prepare:*",
"prepare:es": "tsc --outDir dist/es --module esnext --declaration false",
"prepare:js": "tsc",
"test": "npm-run-all prepare test:*",
"test:tape": "node -r esm test.js",
"test:types": "tsc --noEmit types.ts"
"test": "npm-run-all test:*",
"test:tape": "ts-node -r esm test.js",
"test:types": "tsc --esModuleInterop --noEmit types.ts"
},
"devDependencies": {
"@turf/truncate": "^6.2.0-alpha.2",
"@turf/truncate": "^6.2.0-alpha.3",
"@types/tape": "*",

@@ -64,2 +67,3 @@ "benchmark": "*",

"tape": "*",
"ts-node": "*",
"tslint": "*",

@@ -70,7 +74,7 @@ "typescript": "*",

"dependencies": {
"@turf/clone": "^6.2.0-alpha.2",
"@turf/helpers": "^6.2.0-alpha.2",
"@turf/meta": "^6.2.0-alpha.2"
"@turf/clone": "^6.2.0-alpha.3",
"@turf/helpers": "^6.2.0-alpha.3",
"@turf/meta": "^6.2.0-alpha.3"
},
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09"
"gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409"
}
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