ol 10.7.1-dev.1763907276207 → 10.7.1-dev.1763923413317

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol",
3
- "version": "10.7.1-dev.1763907276207",
3
+ "version": "10.7.1-dev.1763923413317",
4
4
  "description": "OpenLayers mapping library",
5
5
  "keywords": [
6
6
  "map",
package/proj/proj4.d.ts CHANGED
@@ -30,26 +30,61 @@ export function register(proj4: typeof import("proj4/dist/lib/core.js").default
30
30
  version: string;
31
31
  }): void;
32
32
  /**
33
- * Set the lookup function for getting proj4 definitions given an EPSG code.
33
+ * Set the lookup function for getting proj4 or WKT definitions given an
34
+ * projection code. By default, the {@link module:ol/proj/proj4.fromProjectionCode}
35
+ * function uses the spatialreference.org website for WKT definitions.
36
+ * This can be changed by providing a different lookup function.
37
+ *
38
+ * @param {function(string):Promise<string>} func The lookup function.
39
+ * @api
40
+ */
41
+ export function setProjectionCodeLookup(func: (arg0: string) => Promise<string>): void;
42
+ /**
43
+ * Get the current projection code lookup function.
44
+ *
45
+ * @return {function(string):Promise<string>} The projection lookup function.
46
+ */
47
+ export function getProjectionCodeLookup(): (arg0: string) => Promise<string>;
48
+ /**
49
+ * Get a projection from a projection code (i.e., authority:number).
50
+ * This function fetches the projection definition from the
51
+ * https://spatialreference.org website, registers this definition for use with
52
+ * proj4, and returns a configured projection. You must call import proj4 and
53
+ * call {@link module:ol/proj/proj4.register} before using this function.
54
+ *
55
+ * If the projection definition is already registered with proj4, it will not
56
+ * be fetched again (so it is ok to call this function multiple times with the
57
+ * same code).
58
+ *
59
+ * @param {string} code The projection code (e.g., 'EPSG:4326' or 'OGC:CRS84').
60
+ * @return {Promise<Projection>} The projection.
61
+ * @api
62
+ */
63
+ export function fromProjectionCode(code: string): Promise<Projection>;
64
+ /**
65
+ * Set the lookup function for getting proj4 or WKT definitions given an EPSG code.
34
66
  * By default, the {@link module:ol/proj/proj4.fromEPSGCode} function uses the
35
- * epsg.io website for proj4 definitions. This can be changed by providing a
36
- * different lookup function.
67
+ * spatialreference.org website for WKT definitions.
68
+ * This can be changed by providing a different lookup function.
37
69
  *
38
70
  * @param {function(number):Promise<string>} func The lookup function.
39
71
  * @api
72
+ * @deprecated Use {@link module:ol/proj/proj4.setProjectionCodeLookup} instead.
40
73
  */
41
74
  export function setEPSGLookup(func: (arg0: number) => Promise<string>): void;
42
75
  /**
43
76
  * Get the current EPSG lookup function.
44
77
  *
45
78
  * @return {function(number):Promise<string>} The EPSG lookup function.
79
+ * @deprecated Use {@link module:ol/proj/proj4.getProjectionCodeLookup} instead.
46
80
  */
47
81
  export function getEPSGLookup(): (arg0: number) => Promise<string>;
48
82
  /**
49
83
  * Get a projection from an EPSG code. This function fetches the projection
50
- * definition from the epsg.io website, registers this definition for use with
51
- * proj4, and returns a configured projection. You must call import proj4 and
52
- * call {@link module:ol/proj/proj4.register} before using this function.
84
+ * definition from the spatialreference.org website, registers this definition
85
+ * for use with proj4, and returns a configured projection. You must call
86
+ * import proj4 and call {@link module:ol/proj/proj4.register} before using this
87
+ * function.
53
88
  *
54
89
  * If the projection definition is already registered with proj4, it will not
55
90
  * be fetched again (so it is ok to call this function multiple times with the
@@ -58,6 +93,7 @@ export function getEPSGLookup(): (arg0: number) => Promise<string>;
58
93
  * @param {number|string} code The EPSG code (e.g. 4326 or 'EPSG:4326').
59
94
  * @return {Promise<Projection>} The projection.
60
95
  * @api
96
+ * @deprecated Use {@link module:ol/proj/proj4.fromProjectionCode} instead.
61
97
  */
62
98
  export function fromEPSGCode(code: number | string): Promise<Projection>;
63
99
  /**
@@ -69,6 +105,7 @@ export function fromEPSGCode(code: number | string): Promise<Projection>;
69
105
  * @param {string} key MapTiler API key. Get your own API key at https://www.maptiler.com/cloud/.
70
106
  * @return {function(number):Promise<string>} The EPSG lookup function.
71
107
  * @api
108
+ * @deprecated Not needed any more, the default lookup provides this functionality now.
72
109
  */
73
110
  export function epsgLookupMapTiler(key: string): (arg0: number) => Promise<string>;
74
111
  import Projection from './Projection.js';
@@ -1 +1 @@
1
- {"version":3,"file":"proj4.d.ts","sourceRoot":"","sources":["proj4.js"],"names":[],"mappings":"AAkBA;;GAEG;AACH,gCAFY,OAAO,CAIlB;AAED;;GAEG;AACH,mCAEC;AAED;;;;;;;;;;GAUG;AACH;;;;;;;;;;;SA6CC;AAcD;;;;;;;;GAQG;AACH,oCAHW,CAAS,IAAM,EAAN,MAAM,KAAE,OAAO,CAAC,MAAM,CAAC,QAK1C;AAED;;;;GAIG;AACH,iCAFY,CAAS,IAAM,EAAN,MAAM,KAAE,OAAO,CAAC,MAAM,CAAC,CAI3C;AAED;;;;;;;;;;;;;GAaG;AACH,mCAJW,MAAM,GAAC,MAAM,GACZ,OAAO,CAAC,UAAU,CAAC,CAsB9B;AAED;;;;;;;;;GASG;AACH,wCAJW,MAAM,GACL,CAAS,IAAM,EAAN,MAAM,KAAE,OAAO,CAAC,MAAM,CAAC,CA0D3C;uBAvNsB,iBAAiB"}
1
+ {"version":3,"file":"proj4.d.ts","sourceRoot":"","sources":["proj4.js"],"names":[],"mappings":"AAkBA;;GAEG;AACH,gCAFY,OAAO,CAIlB;AAED;;GAEG;AACH,mCAEC;AAED;;;;;;;;;;GAUG;AACH;;;;;;;;;;;SA6CC;AAsBD;;;;;;;;GAQG;AACH,8CAHW,CAAS,IAAM,EAAN,MAAM,KAAE,OAAO,CAAC,MAAM,CAAC,QAK1C;AAED;;;;GAIG;AACH,2CAFY,CAAS,IAAM,EAAN,MAAM,KAAE,OAAO,CAAC,MAAM,CAAC,CAI3C;AAED;;;;;;;;;;;;;;GAcG;AACH,yCAJW,MAAM,GACL,OAAO,CAAC,UAAU,CAAC,CAiB9B;AAWD;;;;;;;;;GASG;AACH,oCAJW,CAAS,IAAM,EAAN,MAAM,KAAE,OAAO,CAAC,MAAM,CAAC,QAM1C;AAED;;;;;GAKG;AACH,iCAHY,CAAS,IAAM,EAAN,MAAM,KAAE,OAAO,CAAC,MAAM,CAAC,CAK3C;AAED;;;;;;;;;;;;;;;GAeG;AACH,mCALW,MAAM,GAAC,MAAM,GACZ,OAAO,CAAC,UAAU,CAAC,CAS9B;AAED;;;;;;;;;;GAUG;AACH,wCALW,MAAM,GACL,CAAS,IAAM,EAAN,MAAM,KAAE,OAAO,CAAC,MAAM,CAAC,CA2D3C;uBApRsB,iBAAiB"}
package/proj/proj4.js CHANGED
@@ -89,25 +89,96 @@ export function register(proj4) {
89
89
  }
90
90
 
91
91
  /**
92
- * @param {number} code The EPSG code.
93
- * @return {Promise<string>} The proj4 definition.
92
+ * @param {string} code The projection code.
93
+ * @return {Promise<string>} The WKT definition.
94
94
  */
95
- let epsgLookup = async function (code) {
96
- const response = await fetch(`https://epsg.io/${code}.proj4`);
95
+ let projLookup = async function (code) {
96
+ if (typeof code !== 'string' || !code.includes(':')) {
97
+ throw new Error('Invalid code');
98
+ }
99
+ const [authority, num] = code.toLowerCase().split(':', 2);
100
+ const response = await fetch(
101
+ `https://spatialreference.org/ref/${authority}/${num}/ogcwkt/`,
102
+ );
97
103
  if (!response.ok) {
98
- throw new Error(`Unexpected response from epsg.io: ${response.status}`);
104
+ throw new Error(
105
+ `Unexpected response from spatialreference.org: ${response.status}`,
106
+ );
99
107
  }
100
108
  return response.text();
101
109
  };
102
110
 
103
111
  /**
104
- * Set the lookup function for getting proj4 definitions given an EPSG code.
112
+ * Set the lookup function for getting proj4 or WKT definitions given an
113
+ * projection code. By default, the {@link module:ol/proj/proj4.fromProjectionCode}
114
+ * function uses the spatialreference.org website for WKT definitions.
115
+ * This can be changed by providing a different lookup function.
116
+ *
117
+ * @param {function(string):Promise<string>} func The lookup function.
118
+ * @api
119
+ */
120
+ export function setProjectionCodeLookup(func) {
121
+ projLookup = func;
122
+ }
123
+
124
+ /**
125
+ * Get the current projection code lookup function.
126
+ *
127
+ * @return {function(string):Promise<string>} The projection lookup function.
128
+ */
129
+ export function getProjectionCodeLookup() {
130
+ return projLookup;
131
+ }
132
+
133
+ /**
134
+ * Get a projection from a projection code (i.e., authority:number).
135
+ * This function fetches the projection definition from the
136
+ * https://spatialreference.org website, registers this definition for use with
137
+ * proj4, and returns a configured projection. You must call import proj4 and
138
+ * call {@link module:ol/proj/proj4.register} before using this function.
139
+ *
140
+ * If the projection definition is already registered with proj4, it will not
141
+ * be fetched again (so it is ok to call this function multiple times with the
142
+ * same code).
143
+ *
144
+ * @param {string} code The projection code (e.g., 'EPSG:4326' or 'OGC:CRS84').
145
+ * @return {Promise<Projection>} The projection.
146
+ * @api
147
+ */
148
+ export async function fromProjectionCode(code) {
149
+ const proj4 = registered;
150
+ if (!proj4) {
151
+ throw new Error('Proj4 must be registered first with register(proj4)');
152
+ }
153
+
154
+ if (proj4.defs(code)) {
155
+ return getCachedProjection(code);
156
+ }
157
+
158
+ proj4.defs(code, await projLookup(code));
159
+ register(proj4);
160
+
161
+ return getCachedProjection(code);
162
+ }
163
+
164
+ /**
165
+ * @param {number} code The EPSG code.
166
+ * @return {Promise<string>} The proj4 or WKT definition.
167
+ * @deprecated Use {@link module:ol/proj/proj4.projLookup} instead.
168
+ */
169
+ let epsgLookup = async function (code) {
170
+ return await projLookup('EPSG:' + code);
171
+ };
172
+
173
+ /**
174
+ * Set the lookup function for getting proj4 or WKT definitions given an EPSG code.
105
175
  * By default, the {@link module:ol/proj/proj4.fromEPSGCode} function uses the
106
- * epsg.io website for proj4 definitions. This can be changed by providing a
107
- * different lookup function.
176
+ * spatialreference.org website for WKT definitions.
177
+ * This can be changed by providing a different lookup function.
108
178
  *
109
179
  * @param {function(number):Promise<string>} func The lookup function.
110
180
  * @api
181
+ * @deprecated Use {@link module:ol/proj/proj4.setProjectionCodeLookup} instead.
111
182
  */
112
183
  export function setEPSGLookup(func) {
113
184
  epsgLookup = func;
@@ -117,6 +188,7 @@ export function setEPSGLookup(func) {
117
188
  * Get the current EPSG lookup function.
118
189
  *
119
190
  * @return {function(number):Promise<string>} The EPSG lookup function.
191
+ * @deprecated Use {@link module:ol/proj/proj4.getProjectionCodeLookup} instead.
120
192
  */
121
193
  export function getEPSGLookup() {
122
194
  return epsgLookup;
@@ -124,9 +196,10 @@ export function getEPSGLookup() {
124
196
 
125
197
  /**
126
198
  * Get a projection from an EPSG code. This function fetches the projection
127
- * definition from the epsg.io website, registers this definition for use with
128
- * proj4, and returns a configured projection. You must call import proj4 and
129
- * call {@link module:ol/proj/proj4.register} before using this function.
199
+ * definition from the spatialreference.org website, registers this definition
200
+ * for use with proj4, and returns a configured projection. You must call
201
+ * import proj4 and call {@link module:ol/proj/proj4.register} before using this
202
+ * function.
130
203
  *
131
204
  * If the projection definition is already registered with proj4, it will not
132
205
  * be fetched again (so it is ok to call this function multiple times with the
@@ -135,26 +208,13 @@ export function getEPSGLookup() {
135
208
  * @param {number|string} code The EPSG code (e.g. 4326 or 'EPSG:4326').
136
209
  * @return {Promise<Projection>} The projection.
137
210
  * @api
211
+ * @deprecated Use {@link module:ol/proj/proj4.fromProjectionCode} instead.
138
212
  */
139
213
  export async function fromEPSGCode(code) {
140
- if (typeof code === 'string') {
141
- code = parseInt(code.split(':').pop(), 10);
214
+ if (typeof code === 'number') {
215
+ code = 'EPSG:' + code;
142
216
  }
143
-
144
- const proj4 = registered;
145
- if (!proj4) {
146
- throw new Error('Proj4 must be registered first with register(proj4)');
147
- }
148
-
149
- const epsgCode = 'EPSG:' + code;
150
- if (proj4.defs(epsgCode)) {
151
- return getCachedProjection(epsgCode);
152
- }
153
-
154
- proj4.defs(epsgCode, await epsgLookup(code));
155
- register(proj4);
156
-
157
- return getCachedProjection(epsgCode);
217
+ return await fromProjectionCode(code);
158
218
  }
159
219
 
160
220
  /**
@@ -166,6 +226,7 @@ export async function fromEPSGCode(code) {
166
226
  * @param {string} key MapTiler API key. Get your own API key at https://www.maptiler.com/cloud/.
167
227
  * @return {function(number):Promise<string>} The EPSG lookup function.
168
228
  * @api
229
+ * @deprecated Not needed any more, the default lookup provides this functionality now.
169
230
  */
170
231
  export function epsgLookupMapTiler(key) {
171
232
  return async function (code) {
package/proj.js CHANGED
@@ -23,8 +23,8 @@
23
23
  * Proj4js, or create a custom build to support those projections you need; see
24
24
  * the Proj4js website for how to do this. You also need the Proj4js definitions
25
25
  * for the required projections. These definitions can be obtained from
26
- * https://epsg.io/, and are a JS function, so can be loaded in a script
27
- * tag (as in the examples) or pasted into your application.
26
+ * https://spatialreference.org/, and are a JS function, so can be loaded in a
27
+ * script tag (as in the examples) or pasted into your application.
28
28
  *
29
29
  * After all required projection definitions are added to proj4's registry (by
30
30
  * using `proj4.defs()`), simply call `register(proj4)` from the `ol/proj/proj4`
package/util.js CHANGED
@@ -33,4 +33,4 @@ export function getUid(obj) {
33
33
  * OpenLayers version.
34
34
  * @type {string}
35
35
  */
36
- export const VERSION = '10.7.1-dev.1763907276207';
36
+ export const VERSION = '10.7.1-dev.1763923413317';