proj4rs 0.0.1 → 0.1.11

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 CHANGED
@@ -1,7 +1,13 @@
1
+ [![Crates.io](https://img.shields.io/crates/v/proj4rs)](https://crates.io/crates/proj4rs)
1
2
  [![Crates.io](https://img.shields.io/crates/d/proj4rs)](https://crates.io/crates/proj4rs)
3
+ [![License](https://img.shields.io/badge/license-MIT_OR_Apache_2.0-blue.svg)](https://github.com/image-rs/imageproc/blob/master/LICENSE)
2
4
  [![Documentation](https://img.shields.io/badge/Documentation-Published-green)](https://docs.rs/proj4rs/latest/proj4rs/)
3
5
  [![Demo](https://img.shields.io/badge/Demo-Published-green)](https://docs.3liz.org/proj4rs/)
4
6
 
7
+
8
+
9
+
10
+
5
11
  ---
6
12
 
7
13
  Rust library for transforming geographic point coordinates
@@ -100,4 +106,5 @@ Proj.transform(from, to, point);
100
106
  ```
101
107
 
102
108
  ## Contributing
103
- You can contribute to this library by going on the [proj4rs](https://github.com/3liz/proj4rs/) repository
109
+
110
+ You can contribute to this library by going on the [proj4rs](./CONTRIBUTING.md) repository
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "David Marteau <dmarteau@3liz.com>"
6
6
  ],
7
7
  "description": "Rust adaptation of Proj4",
8
- "version": "0.0.1",
8
+ "version": "0.1.11",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",
package/proj4.js CHANGED
@@ -6,7 +6,8 @@
6
6
  //
7
7
 
8
8
  // Initialize the proj4rs module
9
- import * as Proj from "./proj4rs.js";
9
+ import init, * as Proj from "./pkg/proj4rs.js";
10
+ await init();
10
11
 
11
12
  /// Used as factory for creating projection alias
12
13
  function defs(name) {
@@ -52,7 +53,7 @@ function defs(name) {
52
53
 
53
54
  // Transform array or object to Proj point
54
55
  function toPoint(coords) {
55
- console.debug(coords);
56
+ //console.debug(coords);
56
57
  if (Array.isArray(coords) && coords.length>1) {
57
58
  return new Proj.Point(coords[0], coords[1], (coords.length > 2 ? coords[2] : 0.0));
58
59
  } else if (typeof coords === 'object' && coords.x !== undefined && coords.y !== undefined) {
@@ -107,7 +108,7 @@ function transformer(from, to, coords) {
107
108
  return [transformed.x, transformed.y];
108
109
  }
109
110
  } else {
110
- keys = Object.keys(coords);
111
+ let keys = Object.keys(coords);
111
112
  if (keys.length > 2) {
112
113
  keys.forEach(function (key) {
113
114
  if (key !== 'x' && key !== 'y' && (key !== 'z' || geocent)) {
@@ -179,13 +180,13 @@ function proj4(fromProj, toProj, coords) {
179
180
  obj = {
180
181
  forward: function (coords) {
181
182
  let rv = transformer(fromProj, toProj, coords);
182
- console.debug("forward", rv);
183
+ //console.debug("forward", rv);
183
184
  //return transformer(fromProj, toProj, coords);
184
185
  return rv;
185
186
  },
186
187
  inverse: function (coords) {
187
188
  let rv = transformer(toProj, fromProj, coords);
188
- console.debug("inverse", rv);
189
+ //console.debug("inverse", rv);
189
190
  //return transformer(toProj, fromProj, coords);
190
191
  return rv;
191
192
  }
package/proj4rs.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function transform(src: Projection, dst: Projection, point: Point): void;
3
4
  /**
4
5
  * Read a binary NTv2 from Dataview.
5
6
  *
6
7
  * Note: only NTv2 file format are supported.
7
8
  */
8
9
  export function add_nadgrid(key: string, view: DataView): void;
9
- export function transform(src: Projection, dst: Projection, point: Point): void;
10
10
  export class Point {
11
11
  free(): void;
12
12
  constructor(x: number, y: number, z: number);
@@ -17,11 +17,11 @@ export class Point {
17
17
  export class Projection {
18
18
  free(): void;
19
19
  constructor(defn: string);
20
- readonly projName: string;
21
- readonly isLatlon: boolean;
22
20
  readonly isGeocentric: boolean;
23
- readonly axis: string;
21
+ readonly isLatlon: boolean;
24
22
  readonly isNormalizedAxis: boolean;
25
- readonly to_meter: number;
23
+ readonly axis: string;
26
24
  readonly units: string;
25
+ readonly projName: string;
26
+ readonly to_meter: number;
27
27
  }
package/proj4rs_bg.js CHANGED
@@ -100,21 +100,6 @@ function takeFromExternrefTable0(idx) {
100
100
  wasm.__externref_table_dealloc(idx);
101
101
  return value;
102
102
  }
103
- /**
104
- * Read a binary NTv2 from Dataview.
105
- *
106
- * Note: only NTv2 file format are supported.
107
- * @param {string} key
108
- * @param {DataView} view
109
- */
110
- export function add_nadgrid(key, view) {
111
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
112
- const len0 = WASM_VECTOR_LEN;
113
- const ret = wasm.add_nadgrid(ptr0, len0, view);
114
- if (ret[1]) {
115
- throw takeFromExternrefTable0(ret[0]);
116
- }
117
- }
118
103
 
119
104
  function _assertClass(instance, klass) {
120
105
  if (!(instance instanceof klass)) {
@@ -136,6 +121,22 @@ export function transform(src, dst, point) {
136
121
  }
137
122
  }
138
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
+
139
140
  const PointFinalization = (typeof FinalizationRegistry === 'undefined')
140
141
  ? { register: () => {}, unregister: () => {} }
141
142
  : new FinalizationRegistry(ptr => wasm.__wbg_point_free(ptr >>> 0, 1));
@@ -153,55 +154,55 @@ export class Point {
153
154
  const ptr = this.__destroy_into_raw();
154
155
  wasm.__wbg_point_free(ptr, 0);
155
156
  }
156
- /**
157
- * @param {number} x
158
- * @param {number} y
159
- * @param {number} z
160
- */
161
- constructor(x, y, z) {
162
- const ret = wasm.point_new(x, y, z);
163
- this.__wbg_ptr = ret >>> 0;
164
- PointFinalization.register(this, this.__wbg_ptr, this);
165
- return this;
166
- }
167
157
  /**
168
158
  * @returns {number}
169
159
  */
170
160
  get x() {
171
- const ret = wasm.point_x(this.__wbg_ptr);
161
+ const ret = wasm.__wbg_get_point_x(this.__wbg_ptr);
172
162
  return ret;
173
163
  }
174
164
  /**
175
- * @param {number} x
165
+ * @param {number} arg0
176
166
  */
177
- set x(x) {
178
- wasm.point_set_x(this.__wbg_ptr, x);
167
+ set x(arg0) {
168
+ wasm.__wbg_set_point_x(this.__wbg_ptr, arg0);
179
169
  }
180
170
  /**
181
171
  * @returns {number}
182
172
  */
183
173
  get y() {
184
- const ret = wasm.point_y(this.__wbg_ptr);
174
+ const ret = wasm.__wbg_get_point_y(this.__wbg_ptr);
185
175
  return ret;
186
176
  }
187
177
  /**
188
- * @param {number} y
178
+ * @param {number} arg0
189
179
  */
190
- set y(y) {
191
- wasm.point_set_y(this.__wbg_ptr, y);
180
+ set y(arg0) {
181
+ wasm.__wbg_set_point_y(this.__wbg_ptr, arg0);
192
182
  }
193
183
  /**
194
184
  * @returns {number}
195
185
  */
196
186
  get z() {
197
- const ret = wasm.point_z(this.__wbg_ptr);
187
+ const ret = wasm.__wbg_get_point_z(this.__wbg_ptr);
198
188
  return ret;
199
189
  }
200
190
  /**
191
+ * @param {number} arg0
192
+ */
193
+ set z(arg0) {
194
+ wasm.__wbg_set_point_z(this.__wbg_ptr, arg0);
195
+ }
196
+ /**
197
+ * @param {number} x
198
+ * @param {number} y
201
199
  * @param {number} z
202
200
  */
203
- set z(z) {
204
- wasm.point_set_z(this.__wbg_ptr, z);
201
+ constructor(x, y, z) {
202
+ const ret = wasm.point_new(x, y, z);
203
+ this.__wbg_ptr = ret >>> 0;
204
+ PointFinalization.register(this, this.__wbg_ptr, this);
205
+ return this;
205
206
  }
206
207
  }
207
208
 
@@ -222,6 +223,27 @@ export class Projection {
222
223
  const ptr = this.__destroy_into_raw();
223
224
  wasm.__wbg_projection_free(ptr, 0);
224
225
  }
226
+ /**
227
+ * @returns {boolean}
228
+ */
229
+ get isGeocentric() {
230
+ const ret = wasm.projection_isGeocentric(this.__wbg_ptr);
231
+ return ret !== 0;
232
+ }
233
+ /**
234
+ * @returns {boolean}
235
+ */
236
+ get isLatlon() {
237
+ const ret = wasm.projection_isLatlon(this.__wbg_ptr);
238
+ return ret !== 0;
239
+ }
240
+ /**
241
+ * @returns {boolean}
242
+ */
243
+ get isNormalizedAxis() {
244
+ const ret = wasm.projection_isNormalizedAxis(this.__wbg_ptr);
245
+ return ret !== 0;
246
+ }
225
247
  /**
226
248
  * @param {string} defn
227
249
  */
@@ -239,11 +261,11 @@ export class Projection {
239
261
  /**
240
262
  * @returns {string}
241
263
  */
242
- get projName() {
264
+ get axis() {
243
265
  let deferred1_0;
244
266
  let deferred1_1;
245
267
  try {
246
- const ret = wasm.projection_projName(this.__wbg_ptr);
268
+ const ret = wasm.projection_axis(this.__wbg_ptr);
247
269
  deferred1_0 = ret[0];
248
270
  deferred1_1 = ret[1];
249
271
  return getStringFromWasm0(ret[0], ret[1]);
@@ -251,28 +273,14 @@ export class Projection {
251
273
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
252
274
  }
253
275
  }
254
- /**
255
- * @returns {boolean}
256
- */
257
- get isLatlon() {
258
- const ret = wasm.projection_isLatlon(this.__wbg_ptr);
259
- return ret !== 0;
260
- }
261
- /**
262
- * @returns {boolean}
263
- */
264
- get isGeocentric() {
265
- const ret = wasm.projection_isGeocentric(this.__wbg_ptr);
266
- return ret !== 0;
267
- }
268
276
  /**
269
277
  * @returns {string}
270
278
  */
271
- get axis() {
279
+ get units() {
272
280
  let deferred1_0;
273
281
  let deferred1_1;
274
282
  try {
275
- const ret = wasm.projection_axis(this.__wbg_ptr);
283
+ const ret = wasm.projection_units(this.__wbg_ptr);
276
284
  deferred1_0 = ret[0];
277
285
  deferred1_1 = ret[1];
278
286
  return getStringFromWasm0(ret[0], ret[1]);
@@ -280,28 +288,14 @@ export class Projection {
280
288
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
281
289
  }
282
290
  }
283
- /**
284
- * @returns {boolean}
285
- */
286
- get isNormalizedAxis() {
287
- const ret = wasm.projection_isNormalizedAxis(this.__wbg_ptr);
288
- return ret !== 0;
289
- }
290
- /**
291
- * @returns {number}
292
- */
293
- get to_meter() {
294
- const ret = wasm.projection_to_meter(this.__wbg_ptr);
295
- return ret;
296
- }
297
291
  /**
298
292
  * @returns {string}
299
293
  */
300
- get units() {
294
+ get projName() {
301
295
  let deferred1_0;
302
296
  let deferred1_1;
303
297
  try {
304
- const ret = wasm.projection_units(this.__wbg_ptr);
298
+ const ret = wasm.projection_projName(this.__wbg_ptr);
305
299
  deferred1_0 = ret[0];
306
300
  deferred1_1 = ret[1];
307
301
  return getStringFromWasm0(ret[0], ret[1]);
@@ -309,6 +303,13 @@ export class Projection {
309
303
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
310
304
  }
311
305
  }
306
+ /**
307
+ * @returns {number}
308
+ */
309
+ get to_meter() {
310
+ const ret = wasm.projection_to_meter(this.__wbg_ptr);
311
+ return ret;
312
+ }
312
313
  }
313
314
 
314
315
  export function __wbg_buffer_e6c6daaa78528d53(arg0) {
package/proj4rs_bg.wasm CHANGED
Binary file
@@ -1,24 +1,24 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const add_nadgrid: (a: number, b: number, c: any) => [number, number];
4
+ export const __wbg_get_point_x: (a: number) => number;
5
+ export const __wbg_get_point_y: (a: number) => number;
6
+ export const __wbg_get_point_z: (a: number) => number;
7
+ export const __wbg_point_free: (a: number, b: number) => void;
5
8
  export const __wbg_projection_free: (a: number, b: number) => void;
6
- export const projection_new: (a: number, b: number) => [number, number, number];
7
- export const projection_projName: (a: number) => [number, number];
8
- export const projection_isLatlon: (a: number) => number;
9
- export const projection_isGeocentric: (a: number) => number;
9
+ export const __wbg_set_point_x: (a: number, b: number) => void;
10
+ export const __wbg_set_point_y: (a: number, b: number) => void;
11
+ export const __wbg_set_point_z: (a: number, b: number) => void;
12
+ export const add_nadgrid: (a: number, b: number, c: any) => [number, number];
13
+ export const point_new: (a: number, b: number, c: number) => number;
10
14
  export const projection_axis: (a: number) => [number, number];
15
+ export const projection_isGeocentric: (a: number) => number;
16
+ export const projection_isLatlon: (a: number) => number;
11
17
  export const projection_isNormalizedAxis: (a: number) => number;
18
+ export const projection_new: (a: number, b: number) => [number, number, number];
19
+ export const projection_projName: (a: number) => [number, number];
12
20
  export const projection_to_meter: (a: number) => number;
13
21
  export const projection_units: (a: number) => [number, number];
14
- export const __wbg_point_free: (a: number, b: number) => void;
15
- export const point_new: (a: number, b: number, c: number) => number;
16
- export const point_x: (a: number) => number;
17
- export const point_set_x: (a: number, b: number) => void;
18
- export const point_y: (a: number) => number;
19
- export const point_set_y: (a: number, b: number) => void;
20
- export const point_z: (a: number) => number;
21
- export const point_set_z: (a: number, b: number) => void;
22
22
  export const transform: (a: number, b: number, c: number) => [number, number];
23
23
  export const __wbindgen_export_0: WebAssembly.Table;
24
24
  export const __wbindgen_malloc: (a: number, b: number) => number;