@softwarity/geojson-editor 1.0.21 → 1.0.23
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 +4 -2
- package/dist/geojson-editor.js +2 -2
- package/package.json +1 -1
- package/src/geojson-editor.css +45 -0
- package/src/geojson-editor.template.ts +7 -0
- package/src/geojson-editor.ts +495 -96
- package/src/internal-types.ts +2 -2
- package/src/utils.ts +0 -21
package/src/internal-types.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface CollapseButtonMeta {
|
|
|
34
34
|
|
|
35
35
|
/** Visibility button metadata */
|
|
36
36
|
export interface VisibilityButtonMeta {
|
|
37
|
-
|
|
37
|
+
featureIndex: number;
|
|
38
38
|
isHidden: boolean;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -46,7 +46,7 @@ export interface LineMeta {
|
|
|
46
46
|
visibilityButton: VisibilityButtonMeta | null;
|
|
47
47
|
isHidden: boolean;
|
|
48
48
|
isCollapsed: boolean;
|
|
49
|
-
|
|
49
|
+
featureIndex: number | null;
|
|
50
50
|
hasError: boolean;
|
|
51
51
|
}
|
|
52
52
|
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Feature } from 'geojson';
|
|
2
1
|
import type { BracketCount } from './internal-types.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -6,26 +5,6 @@ import type { BracketCount } from './internal-types.js';
|
|
|
6
5
|
*/
|
|
7
6
|
export const createElement = (tag: string): HTMLElement => document.createElement(tag);
|
|
8
7
|
|
|
9
|
-
/**
|
|
10
|
-
* Generate a unique feature key from a feature object
|
|
11
|
-
* Uses id, properties.id, or a hash of geometry coordinates
|
|
12
|
-
*/
|
|
13
|
-
export function getFeatureKey(feature: Feature | null): string | null {
|
|
14
|
-
if (!feature) return null;
|
|
15
|
-
if (feature.id !== undefined) return `id:${feature.id}`;
|
|
16
|
-
if (feature.properties?.id !== undefined) return `prop:${feature.properties.id}`;
|
|
17
|
-
|
|
18
|
-
const geomType = feature.geometry?.type || 'null';
|
|
19
|
-
const geom = feature.geometry as { coordinates?: unknown } | null;
|
|
20
|
-
const coords = JSON.stringify(geom?.coordinates || []);
|
|
21
|
-
let hash = 0;
|
|
22
|
-
for (let i = 0; i < coords.length; i++) {
|
|
23
|
-
hash = ((hash << 5) - hash) + coords.charCodeAt(i);
|
|
24
|
-
hash = hash & hash;
|
|
25
|
-
}
|
|
26
|
-
return `hash:${geomType}:${hash.toString(36)}`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
8
|
/**
|
|
30
9
|
* Count open and close brackets in a line
|
|
31
10
|
* Handles string escaping properly
|