@motionscript/geo 0.0.0-stage → 0.1.0-alpha.3

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.
Files changed (108) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +201 -0
  3. package/dist/border/format.d.ts +73 -0
  4. package/dist/border/format.d.ts.map +1 -0
  5. package/dist/border/format.js +68 -0
  6. package/dist/border/format.js.map +1 -0
  7. package/dist/border/geo-border.d.ts +44 -0
  8. package/dist/border/geo-border.d.ts.map +1 -0
  9. package/dist/border/geo-border.js +234 -0
  10. package/dist/border/geo-border.js.map +1 -0
  11. package/dist/border/geometry.d.ts +40 -0
  12. package/dist/border/geometry.d.ts.map +1 -0
  13. package/dist/border/geometry.js +382 -0
  14. package/dist/border/geometry.js.map +1 -0
  15. package/dist/border/index.d.ts +15 -0
  16. package/dist/border/index.d.ts.map +1 -0
  17. package/dist/border/index.js +15 -0
  18. package/dist/border/index.js.map +1 -0
  19. package/dist/border/loader.d.ts +31 -0
  20. package/dist/border/loader.d.ts.map +1 -0
  21. package/dist/border/loader.js +87 -0
  22. package/dist/border/loader.js.map +1 -0
  23. package/dist/border/registry.d.ts +64 -0
  24. package/dist/border/registry.d.ts.map +1 -0
  25. package/dist/border/registry.js +152 -0
  26. package/dist/border/registry.js.map +1 -0
  27. package/dist/border/selection.d.ts +21 -0
  28. package/dist/border/selection.d.ts.map +1 -0
  29. package/dist/border/selection.js +86 -0
  30. package/dist/border/selection.js.map +1 -0
  31. package/dist/border/simplify.d.ts +12 -0
  32. package/dist/border/simplify.d.ts.map +1 -0
  33. package/dist/border/simplify.js +116 -0
  34. package/dist/border/simplify.js.map +1 -0
  35. package/dist/browser/index.js +25 -0
  36. package/dist/browser/index.js.map +7 -0
  37. package/dist/browser/manifest.json +11 -0
  38. package/dist/globe/atmosphere.d.ts +38 -0
  39. package/dist/globe/atmosphere.d.ts.map +1 -0
  40. package/dist/globe/atmosphere.js +91 -0
  41. package/dist/globe/atmosphere.js.map +1 -0
  42. package/dist/globe/borders.d.ts +39 -0
  43. package/dist/globe/borders.d.ts.map +1 -0
  44. package/dist/globe/borders.js +116 -0
  45. package/dist/globe/borders.js.map +1 -0
  46. package/dist/globe/data/ne-110m.d.ts +25 -0
  47. package/dist/globe/data/ne-110m.d.ts.map +1 -0
  48. package/dist/globe/data/ne-110m.js +198 -0
  49. package/dist/globe/data/ne-110m.js.map +1 -0
  50. package/dist/globe/globe-places.d.ts +140 -0
  51. package/dist/globe/globe-places.d.ts.map +1 -0
  52. package/dist/globe/globe-places.js +262 -0
  53. package/dist/globe/globe-places.js.map +1 -0
  54. package/dist/globe/globe.d.ts +193 -0
  55. package/dist/globe/globe.d.ts.map +1 -0
  56. package/dist/globe/globe.js +435 -0
  57. package/dist/globe/globe.js.map +1 -0
  58. package/dist/globe/index.d.ts +17 -0
  59. package/dist/globe/index.d.ts.map +1 -0
  60. package/dist/globe/index.js +17 -0
  61. package/dist/globe/index.js.map +1 -0
  62. package/dist/globe/places.d.ts +69 -0
  63. package/dist/globe/places.d.ts.map +1 -0
  64. package/dist/globe/places.js +94 -0
  65. package/dist/globe/places.js.map +1 -0
  66. package/dist/globe/projection.d.ts +182 -0
  67. package/dist/globe/projection.d.ts.map +1 -0
  68. package/dist/globe/projection.js +215 -0
  69. package/dist/globe/projection.js.map +1 -0
  70. package/dist/globe/world-map.d.ts +83 -0
  71. package/dist/globe/world-map.d.ts.map +1 -0
  72. package/dist/globe/world-map.js +169 -0
  73. package/dist/globe/world-map.js.map +1 -0
  74. package/dist/globe/world.d.ts +46 -0
  75. package/dist/globe/world.d.ts.map +1 -0
  76. package/dist/globe/world.js +71 -0
  77. package/dist/globe/world.js.map +1 -0
  78. package/dist/index.d.ts +5 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +6 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/nodes.d.ts +19 -0
  83. package/dist/nodes.d.ts.map +1 -0
  84. package/dist/nodes.js +19 -0
  85. package/dist/nodes.js.map +1 -0
  86. package/package.json +69 -3
  87. package/registry.json +31 -0
  88. package/src/border/format.ts +147 -0
  89. package/src/border/geo-border.ts +260 -0
  90. package/src/border/geometry.ts +463 -0
  91. package/src/border/index.ts +14 -0
  92. package/src/border/loader.ts +97 -0
  93. package/src/border/registry.ts +191 -0
  94. package/src/border/selection.ts +95 -0
  95. package/src/border/simplify.ts +110 -0
  96. package/src/globe/atmosphere.ts +98 -0
  97. package/src/globe/borders.ts +166 -0
  98. package/src/globe/data/ne-110m.ts +214 -0
  99. package/src/globe/globe-places.ts +352 -0
  100. package/src/globe/globe.ts +552 -0
  101. package/src/globe/index.ts +16 -0
  102. package/src/globe/places.ts +132 -0
  103. package/src/globe/projection.ts +261 -0
  104. package/src/globe/world-map.ts +227 -0
  105. package/src/globe/world.ts +111 -0
  106. package/src/index.ts +5 -0
  107. package/src/nodes.ts +19 -0
  108. package/README.md +0 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # @motionscript/geo
2
+
3
+ ## 0.1.0-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 59c9944: A subclass that redeclares a `@property` or a `@command()` its base already declares now overrides it. `getPropertyMeta` and `getCommandMeta` kept the base's declaration and dropped the subclass's, so a redeclared default, mapper, tween or editor option, or a command's `args` and `name`, never took effect. The most-derived declaration of each key now wins, whole, in the position the base gave it, and an inherited key the subclass does not redeclare is kept as declared. `Registry.describe`, a node type's command table and a new instance's values all read that one declaration.
8
+
9
+ A bare `Globe` now starts at its own camera and key light (orbit −10, elevation 25, zoom 2.8, ambient 0.55, key 1.9) rather than `Canvas3D`'s (35, 20, 12, 0.45, 2.4), which framed it as a small disc twelve radii away. A bare `Protein` likewise starts at elevation 18, zoom 2.6, ambient 0.55 and key 1.6. `describe("graph3d")` no longer reports `Canvas3D`'s defaults for `orbit`, `elevation` and `zoom`, which a graph derives from `camera.initialPosition`.
10
+
11
+ ## 0.1.0-alpha.2
12
+
13
+ ## 0.1.0-alpha.1
14
+
15
+ ### Minor Changes
16
+
17
+ - 59cecba: Build on `@motionscript/sdk` instead of `@motionscript/core`. The peer dependency is now `@motionscript/sdk`, every import goes through it (and `@motionscript/sdk/component` for the component machinery), and the browser build leaves `@motionscript/sdk` an import, so an import map names it once. A component copied with `ms add` imports the SDK too, and its registry item depends on `@motionscript/sdk` rather than `@motionscript/core`. `@motionscript/charts/kit` re-exports `@motionscript/sdk/component` where it re-exported `@motionscript/core/component`.
18
+
19
+ ## 0.1.0-alpha.0
20
+
21
+ Initial release.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,73 @@
1
+ /** The on-disk shape `@motionscript/geo-data` writes; see its `generate.mjs`. */
2
+ export declare const GEO_DATA_FORMAT = 1;
3
+ export interface GeoFileData {
4
+ format: number;
5
+ source?: string;
6
+ transform: {
7
+ scale: [number, number];
8
+ translate: [number, number];
9
+ };
10
+ /** Global arc id per local arc — identical across files for a shared border. */
11
+ arcIds: number[];
12
+ /** Per arc, flat `[x0, y0, w0, dx, dy, w, …]`: delta-encoded quantized lon/lat and a weight bucket. */
13
+ arcs: number[][];
14
+ features: GeoFeatureData[];
15
+ }
16
+ export interface GeoFeatureData {
17
+ code: string;
18
+ name: string;
19
+ nameNl?: string;
20
+ parent: string | null;
21
+ first: boolean;
22
+ listed: boolean;
23
+ remote?: boolean;
24
+ area: number;
25
+ mainland: number[] | null;
26
+ areas: number[];
27
+ /** Polygons → rings → arc refs (`~i` is arc `i` reversed). */
28
+ polygons: number[][][];
29
+ }
30
+ /** `[code, name, nameNl, parent, first]` per listed region. */
31
+ export type GeoIndexEntry = [string, string, string, string | null, 0 | 1];
32
+ export interface GeoIndex {
33
+ format: number;
34
+ source?: string;
35
+ regions: GeoIndexEntry[];
36
+ }
37
+ export interface GeoArc {
38
+ /** Identity for de-duplicating a border drawn by two regions, across files. */
39
+ key: number | string;
40
+ /** Interleaved lon/lat, in degrees. */
41
+ points: Float64Array;
42
+ /** Per point: 0 always survives, higher buckets are less significant; see `thresholdBucket`. */
43
+ buckets: Uint8Array;
44
+ }
45
+ export interface GeoRingRef {
46
+ arc: GeoArc;
47
+ reversed: boolean;
48
+ }
49
+ export interface GeoPolygon {
50
+ rings: GeoRingRef[][];
51
+ /** Per ring, in steradians — exterior first, then holes. */
52
+ ringAreas: number[];
53
+ area: number;
54
+ mainland: boolean;
55
+ }
56
+ export interface GeoFeature {
57
+ code: string;
58
+ name: string;
59
+ nameNl: string;
60
+ parent: string | null;
61
+ first: boolean;
62
+ listed: boolean;
63
+ remote: boolean;
64
+ polygons: GeoPolygon[];
65
+ }
66
+ export interface DecodedGeoFile {
67
+ features: Map<string, GeoFeature>;
68
+ }
69
+ export declare function ringCoordinates(ring: readonly GeoRingRef[]): [number, number][];
70
+ /** A ring's area in steradians, whichever way it winds. */
71
+ export declare function ringArea(ring: readonly GeoRingRef[]): number;
72
+ export declare function decodeGeoFile(data: GeoFileData): DecodedGeoFile;
73
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/border/format.ts"],"names":[],"mappings":"AAEA,iFAAiF;AACjF,eAAO,MAAM,eAAe,IAAI,CAAA;AAEhC,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,EAAE;QAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;IACnE,gFAAgF;IAChF,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,uGAAuG;IACvG,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;IAChB,QAAQ,EAAE,cAAc,EAAE,CAAA;CAC7B;AAED,MAAM,WAAW,cAAc;IAC3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AAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,UAAU,EAAE,CAAA;CACzB;AAED,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CACpC;AAkBD,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAU/E;AAED,2DAA2D;AAC3D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,MAAM,CAK5D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAiC/D"}
@@ -0,0 +1,68 @@
1
+ import { geoArea } from "d3-geo";
2
+ /** The on-disk shape `@motionscript/geo-data` writes; see its `generate.mjs`. */
3
+ export const GEO_DATA_FORMAT = 1;
4
+ function decodeArc(encoded, key, [kx, ky], [tx, ty]) {
5
+ const count = encoded.length / 3;
6
+ const points = new Float64Array(count * 2);
7
+ const buckets = new Uint8Array(count);
8
+ let x = 0;
9
+ let y = 0;
10
+ for (let i = 0; i < count; i++) {
11
+ x += encoded[i * 3];
12
+ y += encoded[i * 3 + 1];
13
+ points[i * 2] = x * kx + tx;
14
+ points[i * 2 + 1] = y * ky + ty;
15
+ buckets[i] = encoded[i * 3 + 2];
16
+ }
17
+ return { key, points, buckets };
18
+ }
19
+ export function ringCoordinates(ring) {
20
+ const out = [];
21
+ for (const { arc, reversed } of ring) {
22
+ const n = arc.buckets.length;
23
+ for (let j = out.length === 0 ? 0 : 1; j < n; j++) {
24
+ const i = reversed ? n - 1 - j : j;
25
+ out.push([arc.points[i * 2], arc.points[i * 2 + 1]]);
26
+ }
27
+ }
28
+ return out;
29
+ }
30
+ /** A ring's area in steradians, whichever way it winds. */
31
+ export function ringArea(ring) {
32
+ const coordinates = ringCoordinates(ring);
33
+ if (coordinates.length < 4)
34
+ return 0;
35
+ const area = geoArea({ type: "Polygon", coordinates: [coordinates] });
36
+ return area > 2 * Math.PI ? 4 * Math.PI - area : area;
37
+ }
38
+ export function decodeGeoFile(data) {
39
+ if (data.format !== GEO_DATA_FORMAT) {
40
+ throw new Error(`geo data format ${data.format} is not supported (expected ${GEO_DATA_FORMAT})`);
41
+ }
42
+ const arcs = data.arcs.map((encoded, i) => decodeArc(encoded, data.arcIds[i], data.transform.scale, data.transform.translate));
43
+ const ref = (index) => index < 0 ? { arc: arcs[~index], reversed: true } : { arc: arcs[index], reversed: false };
44
+ const features = new Map();
45
+ for (const f of data.features) {
46
+ const mainland = f.mainland ? new Set(f.mainland) : null;
47
+ features.set(f.code, {
48
+ code: f.code,
49
+ name: f.name,
50
+ nameNl: f.nameNl ?? f.name,
51
+ parent: f.parent,
52
+ first: f.first,
53
+ listed: f.listed,
54
+ remote: f.remote === true,
55
+ polygons: f.polygons.map((rings, i) => {
56
+ const resolved = rings.map((ring) => ring.map(ref));
57
+ return {
58
+ rings: resolved,
59
+ ringAreas: resolved.map((ring, r) => (r === 0 ? f.areas[i] : ringArea(ring))),
60
+ area: f.areas[i],
61
+ mainland: mainland === null || mainland.has(i),
62
+ };
63
+ }),
64
+ });
65
+ }
66
+ return { features };
67
+ }
68
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/border/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAA;AA0EhC,SAAS,SAAS,CAAC,OAAiB,EAAE,GAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAmB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAmB;IACrG,MAAM,KAAK,GAAG,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,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC7E,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;oBAChB,QAAQ,EAAE,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;iBACjD,CAAA;YACL,CAAC,CAAC;SACL,CAAC,CAAA;IACN,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,CAAA;AACvB,CAAC","sourcesContent":["import { geoArea } from \"d3-geo\"\n\n/** The on-disk shape `@motionscript/geo-data` writes; see its `generate.mjs`. */\nexport const GEO_DATA_FORMAT = 1\n\nexport interface GeoFileData {\n format: number\n source?: string\n transform: { scale: [number, number]; translate: [number, number] }\n /** Global arc id per local arc — identical across files for a shared border. */\n arcIds: number[]\n /** Per arc, flat `[x0, y0, w0, dx, dy, w, …]`: delta-encoded quantized lon/lat and a weight bucket. */\n arcs: number[][]\n features: GeoFeatureData[]\n}\n\nexport interface GeoFeatureData {\n code: string\n name: string\n nameNl?: string\n parent: string | null\n first: boolean\n listed: boolean\n remote?: boolean\n area: number\n mainland: number[] | null\n areas: number[]\n /** Polygons → rings → arc refs (`~i` is arc `i` reversed). */\n polygons: number[][][]\n}\n\n/** `[code, name, nameNl, parent, first]` per listed region. */\nexport type GeoIndexEntry = [string, string, string, string | null, 0 | 1]\n\nexport interface GeoIndex {\n format: number\n source?: string\n regions: GeoIndexEntry[]\n}\n\nexport interface GeoArc {\n /** Identity for de-duplicating a border drawn by two regions, across files. */\n key: number | string\n /** Interleaved lon/lat, in degrees. */\n points: Float64Array\n /** Per point: 0 always survives, higher buckets are less significant; see `thresholdBucket`. */\n buckets: Uint8Array\n}\n\nexport interface GeoRingRef {\n arc: GeoArc\n reversed: boolean\n}\n\nexport interface GeoPolygon {\n rings: GeoRingRef[][]\n /** Per ring, in steradians — exterior first, then holes. */\n ringAreas: number[]\n area: number\n mainland: boolean\n}\n\nexport interface GeoFeature {\n code: string\n name: string\n nameNl: string\n parent: string | null\n first: boolean\n listed: boolean\n remote: boolean\n polygons: GeoPolygon[]\n}\n\nexport interface DecodedGeoFile {\n features: Map<string, GeoFeature>\n}\n\nfunction decodeArc(encoded: number[], key: number, [kx, ky]: [number, number], [tx, ty]: [number, number]): GeoArc {\n const count = encoded.length / 3\n const points = new Float64Array(count * 2)\n const buckets = new Uint8Array(count)\n let x = 0\n let y = 0\n for (let i = 0; i < count; i++) {\n x += encoded[i * 3]\n y += encoded[i * 3 + 1]\n points[i * 2] = x * kx + tx\n points[i * 2 + 1] = y * ky + ty\n buckets[i] = encoded[i * 3 + 2]\n }\n return { key, points, buckets }\n}\n\nexport function ringCoordinates(ring: readonly GeoRingRef[]): [number, number][] {\n const out: [number, number][] = []\n for (const { arc, reversed } of ring) {\n const n = arc.buckets.length\n for (let j = out.length === 0 ? 0 : 1; j < n; j++) {\n const i = reversed ? n - 1 - j : j\n out.push([arc.points[i * 2], arc.points[i * 2 + 1]])\n }\n }\n return out\n}\n\n/** A ring's area in steradians, whichever way it winds. */\nexport function ringArea(ring: readonly GeoRingRef[]): number {\n const coordinates = ringCoordinates(ring)\n if (coordinates.length < 4) return 0\n const area = geoArea({ type: \"Polygon\", coordinates: [coordinates] })\n return area > 2 * Math.PI ? 4 * Math.PI - area : area\n}\n\nexport function decodeGeoFile(data: GeoFileData): DecodedGeoFile {\n if (data.format !== GEO_DATA_FORMAT) {\n throw new Error(`geo data format ${data.format} is not supported (expected ${GEO_DATA_FORMAT})`)\n }\n const arcs = data.arcs.map((encoded, i) =>\n decodeArc(encoded, data.arcIds[i], data.transform.scale, data.transform.translate)\n )\n const ref = (index: number): GeoRingRef =>\n index < 0 ? { arc: arcs[~index], reversed: true } : { arc: arcs[index], reversed: false }\n\n const features = new Map<string, GeoFeature>()\n for (const f of data.features) {\n const mainland = f.mainland ? new Set(f.mainland) : null\n features.set(f.code, {\n code: f.code,\n name: f.name,\n nameNl: f.nameNl ?? f.name,\n parent: f.parent,\n first: f.first,\n listed: f.listed,\n remote: f.remote === true,\n polygons: f.polygons.map((rings, i) => {\n const resolved = rings.map((ring) => ring.map(ref))\n return {\n rings: resolved,\n ringAreas: resolved.map((ring, r) => (r === 0 ? f.areas[i] : ringArea(ring))),\n area: f.areas[i],\n mainland: mainland === null || mainland.has(i),\n }\n }),\n })\n }\n return { features }\n}\n"]}
@@ -0,0 +1,44 @@
1
+ import { Clip, ShapeNode, type AssetScope, type NodeConfig, type RenderContext2D, type ShapeProps } from "@motionscript/sdk";
2
+ import { type GeoBorders, type GeoProjectionKind } from "./geometry.js";
3
+ import { type GeoFrame, type GeoLevel } from "./selection.js";
4
+ export interface GeoBorderProps extends ShapeProps {
5
+ /** ISO 3166-1 alpha-2 (`"FR"`) or ISO 3166-2 (`"US-CA"`) codes. */
6
+ iso: string | readonly string[];
7
+ level: GeoLevel;
8
+ /** 0–1: 1 is full resolution, lower is a more stylised outline. */
9
+ detail: number;
10
+ projection: GeoProjectionKind;
11
+ frame: GeoFrame;
12
+ borders: GeoBorders;
13
+ }
14
+ /**
15
+ * Country and subdivision outlines by ISO 3166 code, fitted into the node's box.
16
+ *
17
+ * <GeoBorder iso={["FR", "DE"]} detail={0.4} stroke={{ weight: 2, fill: "white" }} />
18
+ *
19
+ * Geometry comes from whatever `geoRegistry` has been given — a URL, a loader,
20
+ * or shapes defined by hand — and loads as a declared asset, so a frame never
21
+ * draws half a country. Fill and stroke are separate geometry: the fill is each
22
+ * region's polygons, the stroke is every border once, which is why a border two
23
+ * selected regions share is not drawn twice and why `stroke.align` does not
24
+ * apply.
25
+ */
26
+ export declare class GeoBorder extends ShapeNode<GeoBorderProps> {
27
+ iso: string | readonly string[];
28
+ level: GeoLevel;
29
+ detail: number;
30
+ projection: GeoProjectionKind;
31
+ frame: GeoFrame;
32
+ borders: GeoBorders;
33
+ constructor(props?: NodeConfig<GeoBorder, GeoBorderProps>);
34
+ declareAssets(assets: AssetScope): void;
35
+ protected renderSelf(ctx: RenderContext2D): void;
36
+ protected renderOverlay(ctx: RenderContext2D): void;
37
+ protected renderStroke(ctx: RenderContext2D): void;
38
+ protected clipSelf(): Clip;
39
+ private _drawnCache;
40
+ private readonly _warned;
41
+ private _pathOp;
42
+ private _drawn;
43
+ }
44
+ //# sourceMappingURL=geo-border.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo-border.d.ts","sourceRoot":"","sources":["../../src/border/geo-border.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,EAEJ,SAAS,EAGT,KAAK,UAAU,EAEf,KAAK,UAAU,EAEf,KAAK,eAAe,EAEpB,KAAK,UAAU,EAElB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAAe,KAAK,UAAU,EAAqC,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAGpH,OAAO,EAAgD,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAA;AAExG,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C,mEAAmE;IACnE,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAA;IAC/B,KAAK,EAAE,QAAQ,CAAA;IACf,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,iBAAiB,CAAA;IAC7B,KAAK,EAAE,QAAQ,CAAA;IACf,OAAO,EAAE,UAAU,CAAA;CACtB;AAyDD;;;;;;;;;;;GAWG;AACH,qBAYa,SAAU,SAAQ,SAAS,CAAC,cAAc,CAAC;IAE5C,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAA;IAG/B,KAAK,EAAE,QAAQ,CAAA;IAGf,MAAM,EAAE,MAAM,CAAA;IAOd,UAAU,EAAE,iBAAiB,CAAA;IAG7B,KAAK,EAAE,QAAQ,CAAA;IAGf,OAAO,EAAE,UAAU,CAAA;gBAEf,KAAK,CAAC,EAAE,UAAU,CAAC,SAAS,EAAE,cAAc,CAAC;IAIhD,aAAa,CAAC,MAAM,EAAE,UAA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