@maplat/transform 0.3.0 → 0.4.0

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,143 +1,143 @@
1
- # Maplat Transform
2
-
3
- A JavaScript library that performs coordinate transformation between two plane coordinate systems using transformation definitions generated by Maplat.
4
- This is part of the [Maplat](https://github.com/code4history/Maplat/) project.
5
-
6
- 日本語のREADMEは[こちら](./README.ja.md)
7
-
8
- ## Key Features
9
-
10
- - **Import Transformation Definitions:** Import and build internal structures from transformation definitions generated by Maplat
11
- - **Bidirectional Coordinate Transformation:** Convert coordinates between two planes in both directions
12
- - **Topology Preservation:** Maintains homeomorphic properties during transformation
13
- - **Multiple Coordinate System Support:** Handles transformations between various coordinate systems including standard orthogonal coordinates, Y-axis inverted coordinates, and distorted coordinates like bird's-eye views
14
- - **State Management:** Save and restore transformation states
15
-
16
- ## Installation
17
-
18
- ### npm
19
-
20
- ```sh
21
- npm install @maplat/transform
22
- ```
23
-
24
- ### JSR (JavaScript Registry)
25
-
26
- ```sh
27
- # For Deno
28
- deno add @maplat/transform
29
-
30
- # For npm/Node.js
31
- npx jsr add @maplat/transform
32
- ```
33
-
34
- ### Deno
35
-
36
- ```typescript
37
- // Using JSR (recommended)
38
- import { Transform } from "jsr:@maplat/transform";
39
-
40
- // Using deno.json import map
41
- import { Transform } from "@maplat/transform";
42
-
43
- // Or directly from npm
44
- import { Transform } from "npm:@maplat/transform";
45
- ```
46
-
47
- ### Browser
48
-
49
- ```html
50
- <script src="https://unpkg.com/@maplat/transform/dist/maplat_transform.umd.js"></script>
51
- ```
52
-
53
- ## Basic Usage
54
-
55
- ### Node.js/npm
56
-
57
- ```javascript
58
- import { Transform } from '@maplat/transform';
59
-
60
- // Import transformation definition
61
- const transform = new Transform();
62
- transform.setCompiled(compiledData); // Apply transformation definition generated by Maplat
63
-
64
- // Forward transformation (source → target coordinate system)
65
- const transformed = transform.transform([100, 100], false);
66
-
67
- // Backward transformation (target → source coordinate system)
68
- const restored = transform.transform(transformed, true);
69
- ```
70
-
71
- ### Deno
72
-
73
- ```typescript
74
- import { Transform } from "../src/index.ts";
75
-
76
- // Load compiled data from file
77
- const compiledJson = await Deno.readTextFile('./compiled.json');
78
- const compiledData = JSON.parse(compiledJson);
79
-
80
- // Create and configure transform
81
- const transform = new Transform();
82
- transform.setCompiled(compiledData);
83
-
84
- // Use the same API as Node.js
85
- const transformed = transform.transform([100, 100], false);
86
- const restored = transform.transform(transformed, true);
87
- ```
88
-
89
- ### Error Handling
90
-
91
- The library may throw errors in the following cases:
92
-
93
- - Transformation errors in strict mode
94
- - Attempting backward transformation when not allowed
95
- - Invalid data structure during transformation
96
-
97
- If errors occur, the transformation definition data needs to be modified. Please use editor tools that incorporate [@maplat/tin](https://github.com/code4history/MaplatTin/) to modify transformation definitions.
98
-
99
- ## Development
100
-
101
- ### Running Tests
102
-
103
- #### Node.js
104
- ```sh
105
- npm test
106
- ```
107
-
108
- #### Deno
109
- ```sh
110
- deno task test
111
- ```
112
-
113
- ### Running Examples
114
-
115
- #### Deno
116
- ```sh
117
- # Run the example
118
- deno run --allow-read examples/deno-example.ts
119
-
120
- # Or using deno task
121
- cd examples && deno run --allow-read deno-example.ts
122
- ```
123
-
124
- ## Important Note
125
-
126
- This library specializes in executing coordinate transformations and does not include functionality for generating or editing transformation definitions. If you need to create or edit transformation definitions, please use the [@maplat/tin](https://github.com/code4history/MaplatTin/) package.
127
-
128
- ## Deno Support
129
-
130
- This library fully supports Deno. See the [Deno Usage Guide](./docs/DENO_USAGE.md) for detailed instructions on using MaplatTransform with Deno.
131
-
132
- ## License
133
-
134
- Maplat Limited License 1.1
135
-
136
- Copyright (c) 2024 Code for History
137
-
138
- ### Developers
139
-
140
- - Kohei Otsuka
141
- - Code for History
142
-
143
- We welcome your contributions! Feel free to submit [issues and pull requests](https://github.com/code4history/MaplatTransform/issues).
1
+ # Maplat Transform
2
+
3
+ A JavaScript library that performs coordinate transformation between two plane coordinate systems using transformation definitions generated by Maplat.
4
+ This is part of the [Maplat](https://github.com/code4history/Maplat/) project.
5
+
6
+ 日本語のREADMEは[こちら](./README.ja.md)
7
+
8
+ ## Key Features
9
+
10
+ - **Import Transformation Definitions:** Import and build internal structures from transformation definitions generated by Maplat
11
+ - **Bidirectional Coordinate Transformation:** Convert coordinates between two planes in both directions
12
+ - **Topology Preservation:** Maintains homeomorphic properties during transformation
13
+ - **Multiple Coordinate System Support:** Handles transformations between various coordinate systems including standard orthogonal coordinates, Y-axis inverted coordinates, and distorted coordinates like bird's-eye views
14
+ - **State Management:** Save and restore transformation states
15
+
16
+ ## Installation
17
+
18
+ ### npm
19
+
20
+ ```sh
21
+ npm install @maplat/transform
22
+ ```
23
+
24
+ ### JSR (JavaScript Registry)
25
+
26
+ ```sh
27
+ # For Deno
28
+ deno add @maplat/transform
29
+
30
+ # For npm/Node.js
31
+ npx jsr add @maplat/transform
32
+ ```
33
+
34
+ ### Deno
35
+
36
+ ```typescript
37
+ // Using JSR (recommended)
38
+ import { Transform } from "jsr:@maplat/transform";
39
+
40
+ // Using deno.json import map
41
+ import { Transform } from "@maplat/transform";
42
+
43
+ // Or directly from npm
44
+ import { Transform } from "npm:@maplat/transform";
45
+ ```
46
+
47
+ ### Browser
48
+
49
+ ```html
50
+ <script src="https://unpkg.com/@maplat/transform/dist/maplat_transform.umd.js"></script>
51
+ ```
52
+
53
+ ## Basic Usage
54
+
55
+ ### Node.js/npm
56
+
57
+ ```javascript
58
+ import { Transform } from '@maplat/transform';
59
+
60
+ // Import transformation definition
61
+ const transform = new Transform();
62
+ transform.setCompiled(compiledData); // Apply transformation definition generated by Maplat
63
+
64
+ // Forward transformation (source → target coordinate system)
65
+ const transformed = transform.transform([100, 100], false);
66
+
67
+ // Backward transformation (target → source coordinate system)
68
+ const restored = transform.transform(transformed, true);
69
+ ```
70
+
71
+ ### Deno
72
+
73
+ ```typescript
74
+ import { Transform } from "../src/index.ts";
75
+
76
+ // Load compiled data from file
77
+ const compiledJson = await Deno.readTextFile('./compiled.json');
78
+ const compiledData = JSON.parse(compiledJson);
79
+
80
+ // Create and configure transform
81
+ const transform = new Transform();
82
+ transform.setCompiled(compiledData);
83
+
84
+ // Use the same API as Node.js
85
+ const transformed = transform.transform([100, 100], false);
86
+ const restored = transform.transform(transformed, true);
87
+ ```
88
+
89
+ ### Error Handling
90
+
91
+ The library may throw errors in the following cases:
92
+
93
+ - Transformation errors in strict mode
94
+ - Attempting backward transformation when not allowed
95
+ - Invalid data structure during transformation
96
+
97
+ If errors occur, the transformation definition data needs to be modified. Please use editor tools that incorporate [@maplat/tin](https://github.com/code4history/MaplatTin/) to modify transformation definitions.
98
+
99
+ ## Development
100
+
101
+ ### Running Tests
102
+
103
+ #### Node.js
104
+ ```sh
105
+ npm test
106
+ ```
107
+
108
+ #### Deno
109
+ ```sh
110
+ deno task test
111
+ ```
112
+
113
+ ### Running Examples
114
+
115
+ #### Deno
116
+ ```sh
117
+ # Run the example
118
+ deno run --allow-read examples/deno-example.ts
119
+
120
+ # Or using deno task
121
+ cd examples && deno run --allow-read deno-example.ts
122
+ ```
123
+
124
+ ## Important Note
125
+
126
+ This library specializes in executing coordinate transformations and does not include functionality for generating or editing transformation definitions. If you need to create or edit transformation definitions, please use the [@maplat/tin](https://github.com/code4history/MaplatTin/) package.
127
+
128
+ ## Deno Support
129
+
130
+ This library fully supports Deno. See the [Deno Usage Guide](./docs/DENO_USAGE.md) for detailed instructions on using MaplatTransform with Deno.
131
+
132
+ ## License
133
+
134
+ Maplat Limited License 1.1
135
+
136
+ Copyright (c) 2024 Code for History
137
+
138
+ ### Developers
139
+
140
+ - Kohei Otsuka
141
+ - Code for History
142
+
143
+ We welcome your contributions! Feel free to submit [issues and pull requests](https://github.com/code4history/MaplatTransform/issues).
package/dist/index.d.ts CHANGED
@@ -194,6 +194,19 @@ export declare class Transform {
194
194
  stateFull: boolean;
195
195
  stateTriangle?: Tri;
196
196
  stateBackward?: boolean;
197
+ /**
198
+ * Optional properties for MaplatCore extension
199
+ * These properties allow consuming applications to extend Transform instances
200
+ * with additional metadata without requiring Module Augmentation
201
+ */
202
+ /** Layer priority for rendering order */
203
+ priority?: number;
204
+ /** Layer importance for display decisions */
205
+ importance?: number;
206
+ /** Bounds in XY (source) coordinate system */
207
+ xyBounds?: Feature<Polygon>;
208
+ /** Bounds in Mercator (Web Mercator) coordinate system */
209
+ mercBounds?: Feature<Polygon>;
197
210
  constructor();
198
211
  /**
199
212
  * コンパイルされた設定を適用します