Skip to content

Commit

Permalink
v0.6.102
Browse files Browse the repository at this point in the history
  • Loading branch information
mbloch committed Nov 19, 2024
1 parent c3640a7 commit fbceb42
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v0.6.102
* Added Nicolosi Globular (nicol) projection.

v0.6.101
* Added -affine fit-bbox= option, for transforming data to fit within a bounding box.
* Improved arrow symbols.
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mapshaper",
"version": "0.6.101",
"version": "0.6.102",
"description": "A tool for editing vector datasets for mapping and GIS.",
"keywords": [
"shapefile",
Expand Down Expand Up @@ -56,7 +56,7 @@
"iconv-lite": "^0.6.3",
"idb-keyval": "^6.2.0",
"kdbush": "^3.0.0",
"mproj": "0.0.39",
"mproj": "0.0.40",
"msgpackr": "^1.10.1",
"opn": "^5.3.0",
"rw": "~1.3.3",
Expand Down
3 changes: 2 additions & 1 deletion src/crs/mapshaper-proj-extents.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function getClampBBox(P) {
}

export function isCircleClippedProjection(P) {
return inList(P, 'stere,sterea,ups,ortho,gnom,laea,nsper,tpers,geos');
return inList(P, 'stere,sterea,ups,ortho,gnom,laea,nsper,tpers,geos,nicol');
}

function getPerspectiveClipAngle(P) {
Expand All @@ -143,6 +143,7 @@ export function getDefaultClipAngle(P) {
laea: 179,
//ortho: 89.9, // projection errors betwen lat +/-35 to 55
ortho: 89.85, // TODO: investigate
nicol: 89.85,
stere: 142,
sterea: 142,
ups: 10.5 // TODO: should be 6.5 deg at north pole
Expand Down
2 changes: 1 addition & 1 deletion src/crs/mapshaper-proj-info.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function isAxisAligned(P) {
// TODO: consider projections that may or may not be aligned,
// depending on parameters
if (inList(P, 'cassini,gnom,bertin1953,chamb,ob_tran,tpeqd,healpix,rhealpix,' +
'ocea,omerc,tmerc,etmerc')) {
'ocea,omerc,tmerc,etmerc,nicol')) {
return false;
}
if (isAzimuthal(P)) {
Expand Down
60 changes: 60 additions & 0 deletions www/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -20279,6 +20279,7 @@ function pj_phi2(ts, e) {


pj_add(pj_merc, 'merc', 'Mercator', 'Cyl, Sph&Ell\nlat_ts=');
pj_add(pj_webmerc, 'webmerc', 'Web Mercator / Pseudo Mercator', 'Cyl, Ell');

function pj_merc(P) {
var EPS10 = 1e-10;
Expand Down Expand Up @@ -20333,6 +20334,26 @@ function pj_merc(P) {
}
}

function pj_webmerc(P) {
P.k0 = 1;
P.inv = s_inv;
P.fwd = s_fwd;

function s_fwd(lp, xy) {
if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10) {
f_error();
}
xy.x = P.k0 * lp.lam;
xy.y = P.k0 * log(tan(M_FORTPI + 0.5 * lp.phi));
}

function s_inv(xy, lp) {
lp.phi = M_HALFPI - 2 * atan(exp(-xy.y / P.k0));
lp.lam = xy.x / P.k0;
}
}



pj_add(pj_mill, 'mill', 'Miller Cylindrical', 'Cyl, Sph');

Expand Down Expand Up @@ -20790,6 +20811,45 @@ var NITER = 9,
}


pj_add(pj_nicol, 'nicol', 'Nicolosi Globular', 'Misc Sph, no inv');

function pj_nicol(P) {
P.es = 0;
P.fwd = s_fwd;

function s_fwd(lp, xy) {
var EPS = 1e-10;
if (fabs(lp.lam) < EPS) {
xy.x = 0;
xy.y = lp.phi;
} else if (fabs(lp.phi) < EPS) {
xy.x = lp.lam;
xy.y = 0;
} else if (fabs(fabs(lp.lam) - M_HALFPI) < EPS) {
xy.x = lp.lam * cos(lp.phi);
xy.y = M_HALFPI * sin(lp.phi);
} else if (fabs(fabs(lp.phi) - M_HALFPI) < EPS) {
xy.x = 0;
xy.y = lp.phi;
} else {
var tb = M_HALFPI / lp.lam - lp.lam / M_HALFPI;
var c = lp.phi / M_HALFPI;
var sp = sin(lp.phi);
var d = (1 - c * c) / (sp - c);
var r2 = tb / d;
r2 *= r2;
var m = (tb * sp / d - 0.5 * tb) / (1 + r2);
var n = (sp / r2 + 0.5 * d) / (1 + 1 / r2);
xy.x = cos(lp.phi);
xy.x = sqrt(m * m + xy.x * xy.x / (1 + r2));
xy.x = M_HALFPI * (m + (lp.lam < 0. ? -xy.x : xy.x));
xy.y = sqrt(n * n - (sp * sp / r2 + d * sp - 1) / (1 + 1 / r2));
xy.y = M_HALFPI * (n + (lp.phi < 0. ? xy.y : -xy.y));
}
}
}


pj_add(pj_nsper, 'nsper', 'Near-sided perspective', 'Azi, Sph\nh=');
pj_add(pj_tpers, 'tpers', 'Tilted perspective', 'Azi, Sph\ntilt= azi= h=');

Expand Down

0 comments on commit fbceb42

Please sign in to comment.