@allmaps/transform
Advanced tools
Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3
@@ -588,5 +588,3 @@ 'use strict'; | ||
const nOrder = 0; | ||
const hTransformArg = GDALCreateGCPTransformer(pasGCPs, nOrder, false); | ||
return hTransformArg | ||
return GDALCreateGCPTransformer(pasGCPs, nOrder, false) | ||
} | ||
@@ -593,0 +591,0 @@ |
@@ -584,5 +584,3 @@ const HUGE_VAL = Number.POSITIVE_INFINITY; | ||
const nOrder = 0; | ||
const hTransformArg = GDALCreateGCPTransformer(pasGCPs, nOrder, false); | ||
return hTransformArg | ||
return GDALCreateGCPTransformer(pasGCPs, nOrder, false) | ||
} | ||
@@ -589,0 +587,0 @@ |
@@ -1,3 +0,3 @@ | ||
// https://allmaps.org v1.0.0-alpha.2 Copyright 2021 Bert Spaan | ||
// https://allmaps.org v1.0.0-alpha.3 Copyright 2021 Bert Spaan | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).transform={})}(this,(function(e){"use strict";const t=Number.POSITIVE_INFINITY,n="PARAMETER ERROR",r="INTERNAL ERROR",o="NOT SOLVABLE",f="NOT ENOUGH POINTS";class s{constructor(e,t,n,r){this.dfGCPPixel=e,this.dfGCPLine=t,this.dfGCPX=n,this.dfGCPY=r}}class i{}class a{constructor(){this.adfToGeoX=[],this.adfToGeoY=[],this.adfFromGeoX=[],this.adfFromGeoY=[]}}class c{constructor(e=0){this.n=e,this.v=[]}getM(e,t){return this.v[(e-1)*this.n+t-1]}setM(e,t,n){this.v[(e-1)*this.n+t-1]=n}}function u(e,t,r){return function(e,t,r,o,f,s){const c=e.length;let u=new i,d=0,M=0,h=0,G=0;0===t&&(t=c>=10||c>=6?2:1);const w=new a;if(w.bReversed=r,w.nOrder=t,w.bRefine=o,w.dfTolerance=f,w.nMinimumGcps=s,w.nRefCount=1,w.pasGCPList=e,w.nGCPCount=c,0===c)throw new Error("NOT ENOUGH POINTS");if(o)throw new Error("remove_outliers not implemented");{let r=[],o=[],f=[],s=[],i=[];for(let t=0;t<c;t++)i[t]=1,r[t]=e[t].dfGCPX,o[t]=e[t].dfGCPY,f[t]=e[t].dfGCPPixel,s[t]=e[t].dfGCPLine,d+=e[t].dfGCPPixel,M+=e[t].dfGCPLine,h+=e[t].dfGCPX,G+=e[t].dfGCPY;w.x1Mean=d/c,w.y1Mean=M/c,w.x2Mean=h/c,w.y2Mean=G/c,u.count=c,u.e1=f,u.n1=s,u.e2=r,u.n2=o,u.status=i,function(e,t,r,o,f,s,i){let a;if(i<1||i>3)throw new Error(n);l(t,e.x1Mean,e.y1Mean,r,o,i),a=t.e1,t.e1=t.e2,t.e2=a,a=t.n1,t.n1=t.n2,t.n2=a,l(t,e.x2Mean,e.y2Mean,f,s,i),a=t.e1,t.e1=t.e2,t.e2=a,a=t.n1,t.n1=t.n2,t.n2=a}(w,u,w.adfToGeoX,w.adfToGeoY,w.adfFromGeoX,w.adfFromGeoY,t)}return w}(e,t,r,!1,-1,-1)}function l(e,t,n,o,s,i){const a=new c,u=[],l=[];let h=0,G=0;for(G=h=0;G<e.count;G++)e.status[G]>0&&h++;if(a.n=(i+1)*(i+2)/2,h<a.n)throw new Error(f);a.v=[],h===a.n?function(e,t,n,o,f,s,i,a){let c=1;for(let r=0;r<e.count;r++)if(e.status[r]>0){for(let f=1;f<=t.n;f++)t.setM(c,f,M(f,e.e1[r]-n,e.n1[r]-o));f[c-1]=e.e2[r],s[c-1]=e.n2[r],c++}if(c-1!==t.n)throw new Error(r);d(t,f,s,i,a)}(e,a,t,n,u,l,o,s):function(e,t,n,o,f,s,i,a){let c=0;for(let e=1;e<=t.n;e++){for(let n=e;n<=t.n;n++)t.setM(e,n,0);f[e-1]=s[e-1]=0}for(let r=0;r<e.count;r++)if(e.status[r]>0){c++;for(let i=1;i<=t.n;i++){for(let f=i;f<=t.n;f++)t.setM(i,f,t.getM(i,f)+M(i,e.e1[r]-n,e.n1[r]-o)*M(f,e.e1[r]-n,e.n1[r]-o));f[i-1]+=e.e2[r]*M(i,e.e1[r]-n,e.n1[r]-o),s[i-1]+=e.n2[r]*M(i,e.e1[r]-n,e.n1[r]-o)}}if(c<=t.n)throw new Error(r);for(let e=2;e<=t.n;e++)for(let n=1;n<e;n++)t.setM(e,n,t.getM(n,e));d(t,f,s,i,a)}(e,a,t,n,u,l,o,s)}function d(e,t,n,r,f){for(let r=1;r<=e.n;r++){let f=r,s=e.getM(r,f),i=r;for(let t=r+1;t<=e.n;t++)Math.abs(e.getM(t,f))>Math.abs(s)&&(s=e.getM(t,f),i=t);if(0===s)throw new Error(o);if(i!==r){for(let t=1;t<=e.n;t++){const n=e.getM(i,t),o=e.getM(r,t);e.setM(i,t,o),e.setM(r,t,n)}const o=t[i-1],f=t[r-1];t[r-1]=o,t[i-1]=f;const s=n[i-1],a=n[r-1];n[i-1]=a,n[r-1]=s}for(let o=1;o<=e.n;o++)if(o!==r){const i=e.getM(o,f)/s;for(let t=f;t<=e.n;t++){const n=i*e.getM(r,t);e.setM(o,t,e.getM(o,t)-n)}t[o-1]-=i*t[r-1],n[o-1]-=i*n[r-1]}}for(let o=1;o<=e.n;o++)r[o-1]=t[o-1]/e.getM(o,o),f[o-1]=n[o-1]/e.getM(o,o)}function M(e,t,n){switch(e){case 1:return 1;case 2:return t;case 3:return n;case 4:return t*t;case 5:return t*n;case 6:return n*n;case 7:return t*t*t;case 8:return t*t*n;case 9:return t*n*n;case 10:return n*n*n}return 0}function h(e,n,r){const o=r.length,f=e,s=[];f.bReversed&&(n=!n);for(let e=0;e<o;e++){if(r[e].x===t||r[e].y===t)throw new Error("HUGE_VAL");let o;o=n?G(r[e].x-f.x2Mean,r[e].y-f.y2Mean,f.adfFromGeoX,f.adfFromGeoY,f.nOrder):G(r[e].x-f.x1Mean,r[e].y-f.y1Mean,f.adfToGeoX,f.adfToGeoY,f.nOrder),s[e]={x:o[0],y:o[1]}}return s}function G(e,t,r,o,f){let s,i,a=0,c=0,u=0,l=0,d=0,M=0,h=0;if(1===f)return s=r[0]+r[1]*e+r[2]*t,i=o[0]+o[1]*e+o[2]*t,[s,i];if(2===f)return d=e*e,h=t*t,M=e*t,s=r[0]+r[1]*e+r[2]*t+r[3]*d+r[4]*M+r[5]*h,i=o[0]+o[1]*e+o[2]*t+o[3]*d+o[4]*M+o[5]*h,[s,i];if(3===f)return d=e*e,M=e*t,h=t*t,a=e*d,c=d*t,u=e*h,l=t*h,s=r[0]+r[1]*e+r[2]*t+r[3]*d+r[4]*M+r[5]*h+r[6]*a+r[7]*c+r[8]*u+r[9]*l,i=o[0]+o[1]*e+o[2]*t+o[3]*d+o[4]*M+o[5]*h+o[6]*a+o[7]*c+o[8]*u+o[9]*l,[s,i];throw new Error(n)}e.createTransformer=function(e){return u(e.map((e=>new s(e.image[0],e.image[1],e.world[1],e.world[0]))),0,!1)},e.toImage=function(e,t){const n=h(e,!0,[{x:t[1],y:t[0]}]);return[n[0].x,n[0].y]},e.toWorld=function(e,t){const n=h(e,!1,[{x:t[0],y:t[1]}]);return[n[0].y,n[0].x]}})); | ||
//# sourceMappingURL=transform.min.js.map |
{ | ||
"name": "@allmaps/transform", | ||
"version": "1.0.0-alpha.2", | ||
"version": "1.0.0-alpha.3", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Bert Spaan", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
126316
979