proj4rs 0.1.11 → 0.3.1
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/README.md +58 -20
- package/package.json +35 -35
- package/proj4rs.d.ts +24 -21
- package/proj4rs.js +5 -1
- package/proj4rs_bg.js +218 -243
- package/proj4rs_bg.wasm +0 -0
- package/proj4rs_bg.wasm.d.ts +2 -1
package/README.md
CHANGED
|
@@ -6,30 +6,46 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
9
|
---
|
|
12
10
|
|
|
13
|
-
Rust library for transforming geographic point coordinates
|
|
14
|
-
|
|
11
|
+
# Rust library for transforming geographic point coordinates from one coordinate system to another.
|
|
12
|
+
|
|
15
13
|
This is a pure Rust implementation
|
|
16
14
|
of the [PROJ.4 project](https://proj.org/en/9.2/faq.html#what-happened-to-proj-4).
|
|
17
15
|
|
|
18
16
|
The documentation is available on [docs.rs](https://docs.rs/proj4rs/) and the demo on [docs.3liz.org](https://docs.3liz.org/proj4rs/).
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
The original goal of Proj4rs was to provide a standalone, lightweight, pragmatic implementation of transformations
|
|
19
|
+
from CRS to CRS that can be used in Rust and WASM environment.
|
|
20
|
+
|
|
21
|
+
C, Python and PHP bindings are provided in order to get reliable and consistent results
|
|
22
|
+
across various contexts (client side JS/server side ....).
|
|
23
|
+
|
|
24
|
+
## Features and Limitations
|
|
25
|
+
|
|
26
|
+
Proj4rs is limited to CRS to CRS 2D transformations for an "everyday" use in context where the full
|
|
27
|
+
feature set of PROJ is not required or not appropriate. But in all cases, PROJ **is** the source of truth for all
|
|
28
|
+
projections results, and we require proj4rs to stick to this.
|
|
29
|
+
|
|
30
|
+
Projections are a transcript in Rust of the PROJ projections implementation. The required/expected accuracy
|
|
31
|
+
with PROJ 9.8 results is up to 1e-6 m (but in practice it is almost at double precision accuracy).
|
|
32
|
+
|
|
33
|
+
Have a look at the comparison [projection gallery](https://mdsumner.github.io/proj4rs/).
|
|
34
|
+
|
|
35
|
+
This port implements the PROJ.4 transformation, which means there's no 3D/4D/orthometric transformation ATM.
|
|
36
|
+
The transformations pipeline use the same WGS84 pivot datum as implemented in PROJ 4.x/5.x.
|
|
21
37
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
### Grid supports
|
|
39
|
+
|
|
40
|
+
Proj4rs support NTV2 and GeoTiff grids.
|
|
41
|
+
|
|
42
|
+
### Available Projections
|
|
43
|
+
|
|
44
|
+
See [PROJECTIONS.md](PROJECTIONS.md) for the list of implemented projections.
|
|
45
|
+
|
|
46
|
+
## Extra features:
|
|
47
|
+
|
|
48
|
+
* Geodesic api from `proj4rs-geodesic` crate.
|
|
33
49
|
|
|
34
50
|
## Basic usage in Rust
|
|
35
51
|
|
|
@@ -74,7 +90,10 @@ println!("{} {}",point_3d.0, point_3d.1); // 126.98069676435814, 37.583085346787
|
|
|
74
90
|
|
|
75
91
|
## WKT support
|
|
76
92
|
|
|
77
|
-
|
|
93
|
+
Support for WKT is not provided. Instead, there is a dedicated crate for transforming WKT
|
|
94
|
+
strings to proj string.
|
|
95
|
+
|
|
96
|
+
If you need full support for WKT, please rely on `PROJ` which provides
|
|
78
97
|
a great implementation of the standards.
|
|
79
98
|
|
|
80
99
|
If you want WKT support in WASM, please have a look at:
|
|
@@ -84,8 +103,27 @@ If you want WKT support in WASM, please have a look at:
|
|
|
84
103
|
|
|
85
104
|
## Grid shift supports
|
|
86
105
|
|
|
87
|
-
Nadgrid
|
|
88
|
-
|
|
106
|
+
Nadgrid is supported for native build and WAMS.
|
|
107
|
+
|
|
108
|
+
Support for:
|
|
109
|
+
|
|
110
|
+
* Ntv2 multi grids
|
|
111
|
+
* GDAL generated GeoTIFF multi grids
|
|
112
|
+
|
|
113
|
+
> [!WARNING]
|
|
114
|
+
> The current release of the [`tiff`](https://crates.io/crates/tiff) crate (0.11)
|
|
115
|
+
> has an unfixed bug when decoding tiled TIFF with `PlanarConfiguration=2`
|
|
116
|
+
> (see [image-tiff#403](https://github.com/image-rs/image-tiff/issues/403)).
|
|
117
|
+
>
|
|
118
|
+
> Until a fixed version is released, GeoTIFF grid support (`tiff` feature) should
|
|
119
|
+
> rely on the patched branch. This workspace already does so with a `[patch.crates-io]`
|
|
120
|
+
> section in the root `Cargo.toml`; downstream crates should add the same to their
|
|
121
|
+
> own root manifest:
|
|
122
|
+
>
|
|
123
|
+
> ```toml
|
|
124
|
+
> [patch.crates-io]
|
|
125
|
+
> tiff = { git = "https://github.com/dmarteau/image-tiff.git", branch = "stable-fix" }
|
|
126
|
+
> ```
|
|
89
127
|
|
|
90
128
|
## JavaScript API
|
|
91
129
|
|
|
@@ -107,4 +145,4 @@ Proj.transform(from, to, point);
|
|
|
107
145
|
|
|
108
146
|
## Contributing
|
|
109
147
|
|
|
110
|
-
You can contribute to this library by going on the [proj4rs](
|
|
148
|
+
You can contribute to this library by going on the [proj4rs](https://github.com/3liz/proj4rs) repository
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
2
|
+
"name": "proj4rs",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"David Marteau <dmarteau@3liz.com>"
|
|
6
|
+
],
|
|
7
|
+
"description": "Rust adaptation of Proj4",
|
|
8
|
+
"version": "0.3.1",
|
|
9
|
+
"license": "MIT OR Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/3liz/proj4rs/"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"proj4rs_bg.wasm",
|
|
16
|
+
"proj4rs.js",
|
|
17
|
+
"proj4rs_bg.js",
|
|
18
|
+
"proj4rs.d.ts",
|
|
19
|
+
"proj4rs_bg.wasm.d.ts",
|
|
20
|
+
"proj4.js"
|
|
21
|
+
],
|
|
22
|
+
"main": "proj4rs.js",
|
|
23
|
+
"homepage": "https://github.com/3liz/proj4rs/",
|
|
24
|
+
"types": "proj4rs.d.ts",
|
|
25
|
+
"sideEffects": [
|
|
26
|
+
"./proj4rs.js",
|
|
27
|
+
"./snippets/*"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"gis",
|
|
31
|
+
"proj",
|
|
32
|
+
"projection",
|
|
33
|
+
"geography",
|
|
34
|
+
"geospatial"
|
|
35
|
+
]
|
|
36
|
+
}
|
package/proj4rs.d.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Read a binary NTv2 from Dataview.
|
|
6
|
-
*
|
|
7
|
-
* Note: only NTv2 file format are supported.
|
|
8
|
-
*/
|
|
9
|
-
export function add_nadgrid(key: string, view: DataView): void;
|
|
3
|
+
|
|
10
4
|
export class Point {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
constructor(x: number, y: number, z: number);
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
z: number;
|
|
16
11
|
}
|
|
12
|
+
|
|
17
13
|
export class Projection {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
free(): void;
|
|
15
|
+
[Symbol.dispose](): void;
|
|
16
|
+
constructor(defn: string);
|
|
17
|
+
readonly axis: string;
|
|
18
|
+
readonly isGeocentric: boolean;
|
|
19
|
+
readonly isLatlon: boolean;
|
|
20
|
+
readonly isNormalizedAxis: boolean;
|
|
21
|
+
readonly projName: string;
|
|
22
|
+
readonly to_meter: number;
|
|
23
|
+
readonly units: string;
|
|
27
24
|
}
|
|
25
|
+
|
|
26
|
+
export function add_nadgrid(key: string, array: Uint8Array): void;
|
|
27
|
+
|
|
28
|
+
export function main(): void;
|
|
29
|
+
|
|
30
|
+
export function transform(src: Projection, dst: Projection, point: Point): void;
|
package/proj4rs.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./proj4rs.d.ts" */
|
|
1
2
|
import * as wasm from "./proj4rs_bg.wasm";
|
|
2
|
-
export * from "./proj4rs_bg.js";
|
|
3
3
|
import { __wbg_set_wasm } from "./proj4rs_bg.js";
|
|
4
|
+
|
|
4
5
|
__wbg_set_wasm(wasm);
|
|
5
6
|
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
Point, Projection, add_nadgrid, main, transform
|
|
9
|
+
} from "./proj4rs_bg.js";
|
package/proj4rs_bg.js
CHANGED
|
@@ -1,155 +1,10 @@
|
|
|
1
|
-
let wasm;
|
|
2
|
-
export function __wbg_set_wasm(val) {
|
|
3
|
-
wasm = val;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
8
|
-
|
|
9
|
-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
10
|
-
|
|
11
|
-
cachedTextDecoder.decode();
|
|
12
|
-
|
|
13
|
-
let cachedUint8ArrayMemory0 = null;
|
|
14
|
-
|
|
15
|
-
function getUint8ArrayMemory0() {
|
|
16
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
17
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
18
|
-
}
|
|
19
|
-
return cachedUint8ArrayMemory0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function getStringFromWasm0(ptr, len) {
|
|
23
|
-
ptr = ptr >>> 0;
|
|
24
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let WASM_VECTOR_LEN = 0;
|
|
28
|
-
|
|
29
|
-
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
30
|
-
|
|
31
|
-
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
32
|
-
|
|
33
|
-
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
34
|
-
? function (arg, view) {
|
|
35
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
36
|
-
}
|
|
37
|
-
: function (arg, view) {
|
|
38
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
39
|
-
view.set(buf);
|
|
40
|
-
return {
|
|
41
|
-
read: arg.length,
|
|
42
|
-
written: buf.length
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
47
|
-
|
|
48
|
-
if (realloc === undefined) {
|
|
49
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
50
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
51
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
52
|
-
WASM_VECTOR_LEN = buf.length;
|
|
53
|
-
return ptr;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let len = arg.length;
|
|
57
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
58
|
-
|
|
59
|
-
const mem = getUint8ArrayMemory0();
|
|
60
|
-
|
|
61
|
-
let offset = 0;
|
|
62
|
-
|
|
63
|
-
for (; offset < len; offset++) {
|
|
64
|
-
const code = arg.charCodeAt(offset);
|
|
65
|
-
if (code > 0x7F) break;
|
|
66
|
-
mem[ptr + offset] = code;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (offset !== len) {
|
|
70
|
-
if (offset !== 0) {
|
|
71
|
-
arg = arg.slice(offset);
|
|
72
|
-
}
|
|
73
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
74
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
75
|
-
const ret = encodeString(arg, view);
|
|
76
|
-
|
|
77
|
-
offset += ret.written;
|
|
78
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
WASM_VECTOR_LEN = offset;
|
|
82
|
-
return ptr;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function isLikeNone(x) {
|
|
86
|
-
return x === undefined || x === null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
let cachedDataViewMemory0 = null;
|
|
90
|
-
|
|
91
|
-
function getDataViewMemory0() {
|
|
92
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
93
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
94
|
-
}
|
|
95
|
-
return cachedDataViewMemory0;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function takeFromExternrefTable0(idx) {
|
|
99
|
-
const value = wasm.__wbindgen_export_0.get(idx);
|
|
100
|
-
wasm.__externref_table_dealloc(idx);
|
|
101
|
-
return value;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function _assertClass(instance, klass) {
|
|
105
|
-
if (!(instance instanceof klass)) {
|
|
106
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* @param {Projection} src
|
|
111
|
-
* @param {Projection} dst
|
|
112
|
-
* @param {Point} point
|
|
113
|
-
*/
|
|
114
|
-
export function transform(src, dst, point) {
|
|
115
|
-
_assertClass(src, Projection);
|
|
116
|
-
_assertClass(dst, Projection);
|
|
117
|
-
_assertClass(point, Point);
|
|
118
|
-
const ret = wasm.transform(src.__wbg_ptr, dst.__wbg_ptr, point.__wbg_ptr);
|
|
119
|
-
if (ret[1]) {
|
|
120
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Read a binary NTv2 from Dataview.
|
|
126
|
-
*
|
|
127
|
-
* Note: only NTv2 file format are supported.
|
|
128
|
-
* @param {string} key
|
|
129
|
-
* @param {DataView} view
|
|
130
|
-
*/
|
|
131
|
-
export function add_nadgrid(key, view) {
|
|
132
|
-
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
133
|
-
const len0 = WASM_VECTOR_LEN;
|
|
134
|
-
const ret = wasm.add_nadgrid(ptr0, len0, view);
|
|
135
|
-
if (ret[1]) {
|
|
136
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const PointFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
141
|
-
? { register: () => {}, unregister: () => {} }
|
|
142
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_point_free(ptr >>> 0, 1));
|
|
143
|
-
|
|
144
1
|
export class Point {
|
|
145
|
-
|
|
146
2
|
__destroy_into_raw() {
|
|
147
3
|
const ptr = this.__wbg_ptr;
|
|
148
4
|
this.__wbg_ptr = 0;
|
|
149
5
|
PointFinalization.unregister(this);
|
|
150
6
|
return ptr;
|
|
151
7
|
}
|
|
152
|
-
|
|
153
8
|
free() {
|
|
154
9
|
const ptr = this.__destroy_into_raw();
|
|
155
10
|
wasm.__wbg_point_free(ptr, 0);
|
|
@@ -161,12 +16,6 @@ export class Point {
|
|
|
161
16
|
const ret = wasm.__wbg_get_point_x(this.__wbg_ptr);
|
|
162
17
|
return ret;
|
|
163
18
|
}
|
|
164
|
-
/**
|
|
165
|
-
* @param {number} arg0
|
|
166
|
-
*/
|
|
167
|
-
set x(arg0) {
|
|
168
|
-
wasm.__wbg_set_point_x(this.__wbg_ptr, arg0);
|
|
169
|
-
}
|
|
170
19
|
/**
|
|
171
20
|
* @returns {number}
|
|
172
21
|
*/
|
|
@@ -174,12 +23,6 @@ export class Point {
|
|
|
174
23
|
const ret = wasm.__wbg_get_point_y(this.__wbg_ptr);
|
|
175
24
|
return ret;
|
|
176
25
|
}
|
|
177
|
-
/**
|
|
178
|
-
* @param {number} arg0
|
|
179
|
-
*/
|
|
180
|
-
set y(arg0) {
|
|
181
|
-
wasm.__wbg_set_point_y(this.__wbg_ptr, arg0);
|
|
182
|
-
}
|
|
183
26
|
/**
|
|
184
27
|
* @returns {number}
|
|
185
28
|
*/
|
|
@@ -187,12 +30,6 @@ export class Point {
|
|
|
187
30
|
const ret = wasm.__wbg_get_point_z(this.__wbg_ptr);
|
|
188
31
|
return ret;
|
|
189
32
|
}
|
|
190
|
-
/**
|
|
191
|
-
* @param {number} arg0
|
|
192
|
-
*/
|
|
193
|
-
set z(arg0) {
|
|
194
|
-
wasm.__wbg_set_point_z(this.__wbg_ptr, arg0);
|
|
195
|
-
}
|
|
196
33
|
/**
|
|
197
34
|
* @param {number} x
|
|
198
35
|
* @param {number} y
|
|
@@ -200,29 +37,57 @@ export class Point {
|
|
|
200
37
|
*/
|
|
201
38
|
constructor(x, y, z) {
|
|
202
39
|
const ret = wasm.point_new(x, y, z);
|
|
203
|
-
this.__wbg_ptr = ret
|
|
40
|
+
this.__wbg_ptr = ret;
|
|
204
41
|
PointFinalization.register(this, this.__wbg_ptr, this);
|
|
205
42
|
return this;
|
|
206
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @param {number} arg0
|
|
46
|
+
*/
|
|
47
|
+
set x(arg0) {
|
|
48
|
+
wasm.__wbg_set_point_x(this.__wbg_ptr, arg0);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @param {number} arg0
|
|
52
|
+
*/
|
|
53
|
+
set y(arg0) {
|
|
54
|
+
wasm.__wbg_set_point_y(this.__wbg_ptr, arg0);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @param {number} arg0
|
|
58
|
+
*/
|
|
59
|
+
set z(arg0) {
|
|
60
|
+
wasm.__wbg_set_point_z(this.__wbg_ptr, arg0);
|
|
61
|
+
}
|
|
207
62
|
}
|
|
208
|
-
|
|
209
|
-
const ProjectionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
210
|
-
? { register: () => {}, unregister: () => {} }
|
|
211
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_projection_free(ptr >>> 0, 1));
|
|
63
|
+
if (Symbol.dispose) Point.prototype[Symbol.dispose] = Point.prototype.free;
|
|
212
64
|
|
|
213
65
|
export class Projection {
|
|
214
|
-
|
|
215
66
|
__destroy_into_raw() {
|
|
216
67
|
const ptr = this.__wbg_ptr;
|
|
217
68
|
this.__wbg_ptr = 0;
|
|
218
69
|
ProjectionFinalization.unregister(this);
|
|
219
70
|
return ptr;
|
|
220
71
|
}
|
|
221
|
-
|
|
222
72
|
free() {
|
|
223
73
|
const ptr = this.__destroy_into_raw();
|
|
224
74
|
wasm.__wbg_projection_free(ptr, 0);
|
|
225
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* @returns {string}
|
|
78
|
+
*/
|
|
79
|
+
get axis() {
|
|
80
|
+
let deferred1_0;
|
|
81
|
+
let deferred1_1;
|
|
82
|
+
try {
|
|
83
|
+
const ret = wasm.projection_axis(this.__wbg_ptr);
|
|
84
|
+
deferred1_0 = ret[0];
|
|
85
|
+
deferred1_1 = ret[1];
|
|
86
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
87
|
+
} finally {
|
|
88
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
226
91
|
/**
|
|
227
92
|
* @returns {boolean}
|
|
228
93
|
*/
|
|
@@ -254,18 +119,18 @@ export class Projection {
|
|
|
254
119
|
if (ret[2]) {
|
|
255
120
|
throw takeFromExternrefTable0(ret[1]);
|
|
256
121
|
}
|
|
257
|
-
this.__wbg_ptr = ret[0]
|
|
122
|
+
this.__wbg_ptr = ret[0];
|
|
258
123
|
ProjectionFinalization.register(this, this.__wbg_ptr, this);
|
|
259
124
|
return this;
|
|
260
125
|
}
|
|
261
126
|
/**
|
|
262
127
|
* @returns {string}
|
|
263
128
|
*/
|
|
264
|
-
get
|
|
129
|
+
get projName() {
|
|
265
130
|
let deferred1_0;
|
|
266
131
|
let deferred1_1;
|
|
267
132
|
try {
|
|
268
|
-
const ret = wasm.
|
|
133
|
+
const ret = wasm.projection_projName(this.__wbg_ptr);
|
|
269
134
|
deferred1_0 = ret[0];
|
|
270
135
|
deferred1_1 = ret[1];
|
|
271
136
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
@@ -274,28 +139,20 @@ export class Projection {
|
|
|
274
139
|
}
|
|
275
140
|
}
|
|
276
141
|
/**
|
|
277
|
-
* @returns {
|
|
142
|
+
* @returns {number}
|
|
278
143
|
*/
|
|
279
|
-
get
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
try {
|
|
283
|
-
const ret = wasm.projection_units(this.__wbg_ptr);
|
|
284
|
-
deferred1_0 = ret[0];
|
|
285
|
-
deferred1_1 = ret[1];
|
|
286
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
287
|
-
} finally {
|
|
288
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
289
|
-
}
|
|
144
|
+
get to_meter() {
|
|
145
|
+
const ret = wasm.projection_to_meter(this.__wbg_ptr);
|
|
146
|
+
return ret;
|
|
290
147
|
}
|
|
291
148
|
/**
|
|
292
149
|
* @returns {string}
|
|
293
150
|
*/
|
|
294
|
-
get
|
|
151
|
+
get units() {
|
|
295
152
|
let deferred1_0;
|
|
296
153
|
let deferred1_1;
|
|
297
154
|
try {
|
|
298
|
-
const ret = wasm.
|
|
155
|
+
const ret = wasm.projection_units(this.__wbg_ptr);
|
|
299
156
|
deferred1_0 = ret[0];
|
|
300
157
|
deferred1_1 = ret[1];
|
|
301
158
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
@@ -303,81 +160,199 @@ export class Projection {
|
|
|
303
160
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
304
161
|
}
|
|
305
162
|
}
|
|
306
|
-
/**
|
|
307
|
-
* @returns {number}
|
|
308
|
-
*/
|
|
309
|
-
get to_meter() {
|
|
310
|
-
const ret = wasm.projection_to_meter(this.__wbg_ptr);
|
|
311
|
-
return ret;
|
|
312
|
-
}
|
|
313
163
|
}
|
|
164
|
+
if (Symbol.dispose) Projection.prototype[Symbol.dispose] = Projection.prototype.free;
|
|
314
165
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
166
|
+
/**
|
|
167
|
+
* @param {string} key
|
|
168
|
+
* @param {Uint8Array} array
|
|
169
|
+
*/
|
|
170
|
+
export function add_nadgrid(key, array) {
|
|
171
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
172
|
+
const len0 = WASM_VECTOR_LEN;
|
|
173
|
+
const ret = wasm.add_nadgrid(ptr0, len0, array);
|
|
174
|
+
if (ret[1]) {
|
|
175
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
324
178
|
|
|
325
|
-
export function
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
};
|
|
179
|
+
export function main() {
|
|
180
|
+
wasm.main();
|
|
181
|
+
}
|
|
329
182
|
|
|
330
|
-
|
|
331
|
-
|
|
183
|
+
/**
|
|
184
|
+
* @param {Projection} src
|
|
185
|
+
* @param {Projection} dst
|
|
186
|
+
* @param {Point} point
|
|
187
|
+
*/
|
|
188
|
+
export function transform(src, dst, point) {
|
|
189
|
+
_assertClass(src, Projection);
|
|
190
|
+
_assertClass(dst, Projection);
|
|
191
|
+
_assertClass(point, Point);
|
|
192
|
+
const ret = wasm.transform(src.__wbg_ptr, dst.__wbg_ptr, point.__wbg_ptr);
|
|
193
|
+
if (ret[1]) {
|
|
194
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
export function __wbg_Error_30c8987f7c2ed4e2(arg0, arg1) {
|
|
198
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
332
199
|
return ret;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
200
|
+
}
|
|
201
|
+
export function __wbg___wbindgen_throw_41e9ee4f547fc59a(arg0, arg1) {
|
|
202
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
203
|
+
}
|
|
204
|
+
export function __wbg_debug_52bda05ddf50b736(arg0) {
|
|
205
|
+
console.debug(arg0);
|
|
206
|
+
}
|
|
207
|
+
export function __wbg_error_c9cf3fc2064683a9(arg0) {
|
|
208
|
+
console.error(arg0);
|
|
209
|
+
}
|
|
210
|
+
export function __wbg_info_26925f73a2eee895(arg0) {
|
|
211
|
+
console.info(arg0);
|
|
212
|
+
}
|
|
213
|
+
export function __wbg_length_7f3c00c40364105e(arg0) {
|
|
214
|
+
const ret = arg0.length;
|
|
337
215
|
return ret;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
216
|
+
}
|
|
217
|
+
export function __wbg_log_17c30ef363c61cf4(arg0) {
|
|
218
|
+
console.log(arg0);
|
|
219
|
+
}
|
|
220
|
+
export function __wbg_parseFloat_a9cb882d5665c6cb(arg0, arg1) {
|
|
341
221
|
const ret = parseFloat(getStringFromWasm0(arg0, arg1));
|
|
342
222
|
return ret;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export function __wbg_parseInt_7deceafc75400ae4(arg0, arg1, arg2) {
|
|
223
|
+
}
|
|
224
|
+
export function __wbg_parseInt_9756a56948abd94c(arg0, arg1, arg2) {
|
|
346
225
|
const ret = parseInt(getStringFromWasm0(arg0, arg1), arg2);
|
|
347
226
|
return ret;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
227
|
+
}
|
|
228
|
+
export function __wbg_prototypesetcall_bc27214492979395(arg0, arg1, arg2) {
|
|
229
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
230
|
+
}
|
|
231
|
+
export function __wbg_subarray_002b94d5e13d1411(arg0, arg1, arg2) {
|
|
232
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
352
233
|
return ret;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
234
|
+
}
|
|
235
|
+
export function __wbg_warn_13abc63e0d4b3527(arg0) {
|
|
236
|
+
console.warn(arg0);
|
|
237
|
+
}
|
|
238
|
+
export function __wbindgen_generic_0000000000000001(arg0, arg1) {
|
|
239
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
240
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
357
241
|
return ret;
|
|
358
|
-
}
|
|
359
|
-
|
|
242
|
+
}
|
|
360
243
|
export function __wbindgen_init_externref_table() {
|
|
361
|
-
const table = wasm.
|
|
244
|
+
const table = wasm.__wbindgen_externrefs;
|
|
362
245
|
const offset = table.grow(4);
|
|
363
246
|
table.set(0, undefined);
|
|
364
247
|
table.set(offset + 0, undefined);
|
|
365
248
|
table.set(offset + 1, null);
|
|
366
249
|
table.set(offset + 2, true);
|
|
367
250
|
table.set(offset + 3, false);
|
|
368
|
-
|
|
369
|
-
|
|
251
|
+
}
|
|
252
|
+
const PointFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
253
|
+
? { register: () => {}, unregister: () => {} }
|
|
254
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_point_free(ptr, 1));
|
|
255
|
+
const ProjectionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
256
|
+
? { register: () => {}, unregister: () => {} }
|
|
257
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_projection_free(ptr, 1));
|
|
370
258
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
377
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
378
|
-
};
|
|
259
|
+
function _assertClass(instance, klass) {
|
|
260
|
+
if (!(instance instanceof klass)) {
|
|
261
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
379
264
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
265
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
266
|
+
ptr = ptr >>> 0;
|
|
267
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function getStringFromWasm0(ptr, len) {
|
|
271
|
+
return decodeText(ptr >>> 0, len);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
let cachedUint8ArrayMemory0 = null;
|
|
275
|
+
function getUint8ArrayMemory0() {
|
|
276
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
277
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
278
|
+
}
|
|
279
|
+
return cachedUint8ArrayMemory0;
|
|
280
|
+
}
|
|
383
281
|
|
|
282
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
283
|
+
if (realloc === undefined) {
|
|
284
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
285
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
286
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
287
|
+
WASM_VECTOR_LEN = buf.length;
|
|
288
|
+
return ptr;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
let len = arg.length;
|
|
292
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
293
|
+
|
|
294
|
+
const mem = getUint8ArrayMemory0();
|
|
295
|
+
|
|
296
|
+
let offset = 0;
|
|
297
|
+
|
|
298
|
+
for (; offset < len; offset++) {
|
|
299
|
+
const code = arg.charCodeAt(offset);
|
|
300
|
+
if (code > 0x7F) break;
|
|
301
|
+
mem[ptr + offset] = code;
|
|
302
|
+
}
|
|
303
|
+
if (offset !== len) {
|
|
304
|
+
if (offset !== 0) {
|
|
305
|
+
arg = arg.slice(offset);
|
|
306
|
+
}
|
|
307
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
308
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
309
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
310
|
+
|
|
311
|
+
offset += ret.written;
|
|
312
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
WASM_VECTOR_LEN = offset;
|
|
316
|
+
return ptr;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function takeFromExternrefTable0(idx) {
|
|
320
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
321
|
+
wasm.__externref_table_dealloc(idx);
|
|
322
|
+
return value;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
326
|
+
cachedTextDecoder.decode();
|
|
327
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
328
|
+
let numBytesDecoded = 0;
|
|
329
|
+
function decodeText(ptr, len) {
|
|
330
|
+
numBytesDecoded += len;
|
|
331
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
332
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
333
|
+
cachedTextDecoder.decode();
|
|
334
|
+
numBytesDecoded = len;
|
|
335
|
+
}
|
|
336
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const cachedTextEncoder = new TextEncoder();
|
|
340
|
+
|
|
341
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
342
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
343
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
344
|
+
view.set(buf);
|
|
345
|
+
return {
|
|
346
|
+
read: arg.length,
|
|
347
|
+
written: buf.length
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
let WASM_VECTOR_LEN = 0;
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
let wasm;
|
|
356
|
+
export function __wbg_set_wasm(val) {
|
|
357
|
+
wasm = val;
|
|
358
|
+
}
|
package/proj4rs_bg.wasm
CHANGED
|
Binary file
|
package/proj4rs_bg.wasm.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export const __wbg_set_point_x: (a: number, b: number) => void;
|
|
|
10
10
|
export const __wbg_set_point_y: (a: number, b: number) => void;
|
|
11
11
|
export const __wbg_set_point_z: (a: number, b: number) => void;
|
|
12
12
|
export const add_nadgrid: (a: number, b: number, c: any) => [number, number];
|
|
13
|
+
export const main: () => void;
|
|
13
14
|
export const point_new: (a: number, b: number, c: number) => number;
|
|
14
15
|
export const projection_axis: (a: number) => [number, number];
|
|
15
16
|
export const projection_isGeocentric: (a: number) => number;
|
|
@@ -20,7 +21,7 @@ export const projection_projName: (a: number) => [number, number];
|
|
|
20
21
|
export const projection_to_meter: (a: number) => number;
|
|
21
22
|
export const projection_units: (a: number) => [number, number];
|
|
22
23
|
export const transform: (a: number, b: number, c: number) => [number, number];
|
|
23
|
-
export const
|
|
24
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
24
25
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
25
26
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
26
27
|
export const __externref_table_dealloc: (a: number) => void;
|