ol 10.2.2-dev.1730915520848 → 10.2.2-dev.1730934210683
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ol.d.ts +10 -0
- package/dist/ol.d.ts.map +1 -1
- package/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/geom/Geometry.js +5 -5
- package/math.d.ts +8 -0
- package/math.d.ts.map +1 -1
- package/math.js +15 -0
- package/package.json +1 -1
- package/proj/Projection.d.ts +21 -19
- package/proj/Projection.d.ts.map +1 -1
- package/proj/Projection.js +21 -19
- package/proj/proj4.js +6 -6
- package/proj/projections.d.ts +2 -2
- package/proj/projections.d.ts.map +1 -1
- package/proj/projections.js +1 -1
- package/proj/transforms.d.ts +2 -2
- package/proj/transforms.d.ts.map +1 -1
- package/proj/transforms.js +3 -4
- package/proj/utm.d.ts +26 -0
- package/proj/utm.d.ts.map +1 -0
- package/proj/utm.js +292 -0
- package/proj.d.ts +17 -5
- package/proj.d.ts.map +1 -1
- package/proj.js +120 -16
- package/util.js +1 -1
package/proj.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proj.d.ts","sourceRoot":"","sources":["proj.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proj.d.ts","sourceRoot":"","sources":["proj.js"],"names":[],"mappings":"AAgIA;;GAEG;AACH,8EAGC;AAED;;;;;GAKG;AACH,sCALW,KAAK,CAAC,MAAM,CAAC,kCAEZ,KAAK,CAAC,MAAM,CAAC,CAaxB;AAED;;;;GAIG;AACH,yCAJW,KAAK,CAAC,MAAM,CAAC,kCAEZ,KAAK,CAAC,MAAM,CAAC,CAUxB;AAED;;;;;;GAMG;AACH,0CAHW,UAAU,QAMpB;AAED;;GAEG;AACH,4CAFW,KAAK,CAAC,UAAU,CAAC,QAI3B;AAED;;;;;;;;GAQG;AACH,oCANW,cAAc,GAGb,UAAU,GAAC,IAAI,CAkB1B;AAED;;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OAAO,iBAAiB,EAAE,UAAU,CA0B/F;AAED;;;;GAIG;AACH,kCAaC;;;;;6BAtwBY,UAAU,GAAC,MAAM,GAAC,SAAS;;;;;aAM1B,iBAAiB;;;;aACjB,iBAAiB;;;;;;;;wCAoBpB,KAAK,CAAC,MAAM,CAAC,iGAIZ,KAAK,CAAC,MAAM,CAAC;uBA9DF,sBAAsB;gCAOf,iBAAiB"}
|
package/proj.js
CHANGED
|
@@ -75,6 +75,10 @@ import {applyTransform, getWidth} from './extent.js';
|
|
|
75
75
|
import {clamp, modulo} from './math.js';
|
|
76
76
|
import {equals, getWorldsAway} from './coordinate.js';
|
|
77
77
|
import {getDistance} from './sphere.js';
|
|
78
|
+
import {
|
|
79
|
+
makeProjection as makeUTMProjection,
|
|
80
|
+
makeTransforms as makeUTMTransforms,
|
|
81
|
+
} from './proj/utm.js';
|
|
78
82
|
import {warn} from './console.js';
|
|
79
83
|
|
|
80
84
|
/**
|
|
@@ -84,6 +88,22 @@ import {warn} from './console.js';
|
|
|
84
88
|
* @api
|
|
85
89
|
*/
|
|
86
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @typedef {Object} Transforms
|
|
93
|
+
* @property {TransformFunction} forward The forward transform (from geographic).
|
|
94
|
+
* @property {TransformFunction} inverse The inverse transform (to geographic).
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @type {Array<function(Projection): Transforms|null>}
|
|
99
|
+
*/
|
|
100
|
+
const transformFactories = [makeUTMTransforms];
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @type {Array<function(string): Projection|null>}
|
|
104
|
+
*/
|
|
105
|
+
const projectionFactories = [makeUTMProjection];
|
|
106
|
+
|
|
87
107
|
/**
|
|
88
108
|
* A transform function accepts an array of input coordinate values, an optional
|
|
89
109
|
* output array, and an optional dimension (default should be 2). The function
|
|
@@ -176,9 +196,20 @@ export function addProjections(projections) {
|
|
|
176
196
|
* @api
|
|
177
197
|
*/
|
|
178
198
|
export function get(projectionLike) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
199
|
+
if (!(typeof projectionLike === 'string')) {
|
|
200
|
+
return projectionLike;
|
|
201
|
+
}
|
|
202
|
+
const projection = getProj(projectionLike);
|
|
203
|
+
if (projection) {
|
|
204
|
+
return projection;
|
|
205
|
+
}
|
|
206
|
+
for (const makeProjection of projectionFactories) {
|
|
207
|
+
const projection = makeProjection(projectionLike);
|
|
208
|
+
if (projection) {
|
|
209
|
+
return projection;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
182
213
|
}
|
|
183
214
|
|
|
184
215
|
/**
|
|
@@ -226,7 +257,7 @@ export function getPointResolution(projection, resolution, point, units) {
|
|
|
226
257
|
projection,
|
|
227
258
|
get('EPSG:4326'),
|
|
228
259
|
);
|
|
229
|
-
if (toEPSG4326
|
|
260
|
+
if (!toEPSG4326 && projUnits !== 'degrees') {
|
|
230
261
|
// no transform is available
|
|
231
262
|
pointResolution = resolution * projection.getMetersPerUnit();
|
|
232
263
|
} else {
|
|
@@ -460,24 +491,88 @@ export function equivalent(projection1, projection2) {
|
|
|
460
491
|
* Searches in the list of transform functions for the function for converting
|
|
461
492
|
* coordinates from the source projection to the destination projection.
|
|
462
493
|
*
|
|
463
|
-
* @param {Projection}
|
|
464
|
-
* @param {Projection}
|
|
494
|
+
* @param {Projection} source Source Projection object.
|
|
495
|
+
* @param {Projection} destination Destination Projection
|
|
465
496
|
* object.
|
|
466
|
-
* @return {TransformFunction} Transform function.
|
|
497
|
+
* @return {TransformFunction|null} Transform function.
|
|
467
498
|
*/
|
|
468
|
-
export function getTransformFromProjections(
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
) {
|
|
472
|
-
const sourceCode = sourceProjection.getCode();
|
|
473
|
-
const destinationCode = destinationProjection.getCode();
|
|
499
|
+
export function getTransformFromProjections(source, destination) {
|
|
500
|
+
const sourceCode = source.getCode();
|
|
501
|
+
const destinationCode = destination.getCode();
|
|
474
502
|
let transformFunc = getTransformFunc(sourceCode, destinationCode);
|
|
475
|
-
if (
|
|
476
|
-
transformFunc
|
|
503
|
+
if (transformFunc) {
|
|
504
|
+
return transformFunc;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* @type {Transforms|null}
|
|
509
|
+
*/
|
|
510
|
+
let sourceTransforms = null;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* @type {Transforms|null}
|
|
514
|
+
*/
|
|
515
|
+
let destinationTransforms = null;
|
|
516
|
+
|
|
517
|
+
// lazily add projections if we have supported transforms
|
|
518
|
+
for (const makeTransforms of transformFactories) {
|
|
519
|
+
if (!sourceTransforms) {
|
|
520
|
+
sourceTransforms = makeTransforms(source);
|
|
521
|
+
}
|
|
522
|
+
if (!destinationTransforms) {
|
|
523
|
+
destinationTransforms = makeTransforms(destination);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (!sourceTransforms && !destinationTransforms) {
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const intermediateCode = 'EPSG:4326';
|
|
532
|
+
if (!destinationTransforms) {
|
|
533
|
+
const toDestination = getTransformFunc(intermediateCode, destinationCode);
|
|
534
|
+
if (toDestination) {
|
|
535
|
+
transformFunc = composeTransformFuncs(
|
|
536
|
+
sourceTransforms.inverse,
|
|
537
|
+
toDestination,
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
} else if (!sourceTransforms) {
|
|
541
|
+
const fromSource = getTransformFunc(sourceCode, intermediateCode);
|
|
542
|
+
if (fromSource) {
|
|
543
|
+
transformFunc = composeTransformFuncs(
|
|
544
|
+
fromSource,
|
|
545
|
+
destinationTransforms.forward,
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
} else {
|
|
549
|
+
transformFunc = composeTransformFuncs(
|
|
550
|
+
sourceTransforms.inverse,
|
|
551
|
+
destinationTransforms.forward,
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (transformFunc) {
|
|
556
|
+
addProjection(source);
|
|
557
|
+
addProjection(destination);
|
|
558
|
+
addTransformFunc(source, destination, transformFunc);
|
|
477
559
|
}
|
|
560
|
+
|
|
478
561
|
return transformFunc;
|
|
479
562
|
}
|
|
480
563
|
|
|
564
|
+
/**
|
|
565
|
+
* @param {TransformFunction} t1 The first transform function.
|
|
566
|
+
* @param {TransformFunction} t2 The second transform function.
|
|
567
|
+
* @return {TransformFunction} The composed transform function.
|
|
568
|
+
*/
|
|
569
|
+
function composeTransformFuncs(t1, t2) {
|
|
570
|
+
return function (input, output, dimensions, stride) {
|
|
571
|
+
output = t1(input, output, dimensions, stride);
|
|
572
|
+
return t2(output, output, dimensions, stride);
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
|
|
481
576
|
/**
|
|
482
577
|
* Given the projection-like objects, searches for a transformation
|
|
483
578
|
* function to convert a coordinates array from the source projection to the
|
|
@@ -496,7 +591,9 @@ export function getTransform(source, destination) {
|
|
|
496
591
|
|
|
497
592
|
/**
|
|
498
593
|
* Transforms a coordinate from source projection to destination projection.
|
|
499
|
-
* This returns a new coordinate (and does not modify the original).
|
|
594
|
+
* This returns a new coordinate (and does not modify the original). If there
|
|
595
|
+
* is no available transform between the two projection, the function will throw
|
|
596
|
+
* an error.
|
|
500
597
|
*
|
|
501
598
|
* See {@link module:ol/proj.transformExtent} for extent transformation.
|
|
502
599
|
* See the transform method of {@link module:ol/geom/Geometry~Geometry} and its
|
|
@@ -510,6 +607,13 @@ export function getTransform(source, destination) {
|
|
|
510
607
|
*/
|
|
511
608
|
export function transform(coordinate, source, destination) {
|
|
512
609
|
const transformFunc = getTransform(source, destination);
|
|
610
|
+
if (!transformFunc) {
|
|
611
|
+
const sourceCode = get(source).getCode();
|
|
612
|
+
const destinationCode = get(destination).getCode();
|
|
613
|
+
throw new Error(
|
|
614
|
+
`No transform available between ${sourceCode} and ${destinationCode}`,
|
|
615
|
+
);
|
|
616
|
+
}
|
|
513
617
|
return transformFunc(coordinate, undefined, coordinate.length);
|
|
514
618
|
}
|
|
515
619
|
|
package/util.js
CHANGED