@dunguel/expo-geo-parser 0.4.0 → 0.5.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.
@@ -6,17 +6,42 @@ export type File = {
6
6
  type: GeoFileType;
7
7
  uti?: string | null;
8
8
  };
9
+ export type Position = number[];
10
+ export type Point = {
11
+ type: "Point";
12
+ coordinates: Position;
13
+ };
14
+ export type LineString = {
15
+ type: "LineString";
16
+ coordinates: Position[];
17
+ };
18
+ export type Polygon = {
19
+ type: "Polygon";
20
+ coordinates: Position[][];
21
+ };
22
+ export type MultiPoint = {
23
+ type: "MultiPoint";
24
+ coordinates: Position[];
25
+ };
26
+ export type MultiLineString = {
27
+ type: "MultiLineString";
28
+ coordinates: Position[][];
29
+ };
30
+ export type MultiPolygon = {
31
+ type: "MultiPolygon";
32
+ coordinates: Position[][][];
33
+ };
34
+ export type GeometryCollection = {
35
+ type: "GeometryCollection";
36
+ geometries: Geometry[];
37
+ };
38
+ export type Geometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon | GeometryCollection;
9
39
  export type Feature = {
10
40
  type: "Feature";
11
- id?: string | number;
41
+ id?: string;
12
42
  geometry: Geometry;
13
43
  properties: Record<string, unknown>;
14
44
  };
15
- export type Geometry = {
16
- type: string;
17
- coordinates?: number[][];
18
- geometries?: Geometry[];
19
- };
20
45
  export type FeatureCollection = {
21
46
  type: "FeatureCollection";
22
47
  name?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGeoParser.types.d.ts","sourceRoot":"","sources":["../src/ExpoGeoParser.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjF,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CA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BAAiB,GAAG;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGeoParser.types.js","sourceRoot":"","sources":["../src/ExpoGeoParser.types.ts"],"names":[],"mappings":"","sourcesContent":["export type GeoFileType = \"kml\" | \"kmz\" | \"zip\" | \"geojson\" | \"json\" | \"unknown\";\n\nexport type File = {\n uri: string;\n fileName?: string | null;\n extension?: string | null;\n type: GeoFileType;\n uti?: string | null;\n};\n\nexport type Feature = {\n type: \"Feature\";\n id?: string | number;\n geometry: Geometry;\n properties: Record<string, unknown>;\n};\n\nexport type Geometry = {\n type: string;\n coordinates?: number[][];\n geometries?: Geometry[];\n};\n\nexport type FeatureCollection = {\n type: \"FeatureCollection\";\n name?: string;\n description?: string;\n sourceType?: GeoFileType;\n features: Feature[];\n};\n\nexport type ParseFeaturesEvent = {\n features: Feature[];\n isLast: boolean;\n};\n"]}
1
+ {"version":3,"file":"ExpoGeoParser.types.js","sourceRoot":"","sources":["../src/ExpoGeoParser.types.ts"],"names":[],"mappings":"","sourcesContent":["export type GeoFileType = \"kml\" | \"kmz\" | \"zip\" | \"geojson\" | \"json\" | \"unknown\";\n\nexport type File = {\n uri: string;\n fileName?: string | null;\n extension?: string | null;\n type: GeoFileType;\n uti?: string | null;\n};\n\n// GeoJSON-compliant geometry types (RFC 7946)\n\nexport type Position = number[]; // [longitude, latitude, ?altitude]\n\nexport type Point = {\n type: \"Point\";\n coordinates: Position;\n};\n\nexport type LineString = {\n type: \"LineString\";\n coordinates: Position[];\n};\n\nexport type Polygon = {\n type: \"Polygon\";\n coordinates: Position[][];\n};\n\nexport type MultiPoint = {\n type: \"MultiPoint\";\n coordinates: Position[];\n};\n\nexport type MultiLineString = {\n type: \"MultiLineString\";\n coordinates: Position[][];\n};\n\nexport type MultiPolygon = {\n type: \"MultiPolygon\";\n coordinates: Position[][][];\n};\n\nexport type GeometryCollection = {\n type: \"GeometryCollection\";\n geometries: Geometry[];\n};\n\nexport type Geometry =\n | Point\n | LineString\n | Polygon\n | MultiPoint\n | MultiLineString\n | MultiPolygon\n | GeometryCollection;\n\nexport type Feature = {\n type: \"Feature\";\n id?: string;\n geometry: Geometry;\n properties: Record<string, unknown>;\n};\n\nexport type FeatureCollection = {\n type: \"FeatureCollection\";\n name?: string;\n description?: string;\n sourceType?: GeoFileType;\n features: Feature[];\n};\n\nexport type ParseFeaturesEvent = {\n features: Feature[];\n isLast: boolean;\n};\n"]}
@@ -84,6 +84,9 @@ private extension ExpoGeoParserModule {
84
84
  throw GeoParserError.invalidURI(uri)
85
85
  }
86
86
 
87
+ let accessing = url.startAccessingSecurityScopedResource()
88
+ defer { if accessing { url.stopAccessingSecurityScopedResource() } }
89
+
87
90
  let info = detectFileType(from: url)
88
91
 
89
92
  if info.type == "kmz" || info.type == "zip" {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dunguel/expo-geo-parser",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "A high-performance Expo native module for parsing geospatial files like KML, KMZ, and other formats, extracting polygons, markers, and spatial data efficiently on iOS and Android.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -8,19 +8,61 @@ export type File = {
8
8
  uti?: string | null;
9
9
  };
10
10
 
11
+ // GeoJSON-compliant geometry types (RFC 7946)
12
+
13
+ export type Position = number[]; // [longitude, latitude, ?altitude]
14
+
15
+ export type Point = {
16
+ type: "Point";
17
+ coordinates: Position;
18
+ };
19
+
20
+ export type LineString = {
21
+ type: "LineString";
22
+ coordinates: Position[];
23
+ };
24
+
25
+ export type Polygon = {
26
+ type: "Polygon";
27
+ coordinates: Position[][];
28
+ };
29
+
30
+ export type MultiPoint = {
31
+ type: "MultiPoint";
32
+ coordinates: Position[];
33
+ };
34
+
35
+ export type MultiLineString = {
36
+ type: "MultiLineString";
37
+ coordinates: Position[][];
38
+ };
39
+
40
+ export type MultiPolygon = {
41
+ type: "MultiPolygon";
42
+ coordinates: Position[][][];
43
+ };
44
+
45
+ export type GeometryCollection = {
46
+ type: "GeometryCollection";
47
+ geometries: Geometry[];
48
+ };
49
+
50
+ export type Geometry =
51
+ | Point
52
+ | LineString
53
+ | Polygon
54
+ | MultiPoint
55
+ | MultiLineString
56
+ | MultiPolygon
57
+ | GeometryCollection;
58
+
11
59
  export type Feature = {
12
60
  type: "Feature";
13
- id?: string | number;
61
+ id?: string;
14
62
  geometry: Geometry;
15
63
  properties: Record<string, unknown>;
16
64
  };
17
65
 
18
- export type Geometry = {
19
- type: string;
20
- coordinates?: number[][];
21
- geometries?: Geometry[];
22
- };
23
-
24
66
  export type FeatureCollection = {
25
67
  type: "FeatureCollection";
26
68
  name?: string;