@osmix/geoparquet 0.1.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/CHANGELOG.md +21 -0
- package/README.md +47 -0
- package/dist/src/from-geoparquet.d.ts +68 -0
- package/dist/src/from-geoparquet.d.ts.map +1 -0
- package/dist/src/from-geoparquet.js +455 -0
- package/dist/src/from-geoparquet.js.map +1 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +27 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +47 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +6 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/wkb.d.ts +22 -0
- package/dist/src/wkb.d.ts.map +1 -0
- package/dist/src/wkb.js +181 -0
- package/dist/src/wkb.js.map +1 -0
- package/dist/test/from-geoparquet.test.d.ts +2 -0
- package/dist/test/from-geoparquet.test.d.ts.map +1 -0
- package/dist/test/from-geoparquet.test.js +445 -0
- package/dist/test/from-geoparquet.test.js.map +1 -0
- package/dist/test/monaco-parquet.test.d.ts +2 -0
- package/dist/test/monaco-parquet.test.d.ts.map +1 -0
- package/dist/test/monaco-parquet.test.js +200 -0
- package/dist/test/monaco-parquet.test.js.map +1 -0
- package/dist/test/wkb.test.d.ts +2 -0
- package/dist/test/wkb.test.d.ts.map +1 -0
- package/dist/test/wkb.test.js +234 -0
- package/dist/test/wkb.test.js.map +1 -0
- package/package.json +53 -0
- package/src/from-geoparquet.ts +565 -0
- package/src/index.ts +27 -0
- package/src/types.ts +51 -0
- package/src/wkb.ts +218 -0
- package/test/download-monaco-highways.sh +40 -0
- package/test/from-geoparquet.test.ts +520 -0
- package/test/monaco-parquet.test.ts +249 -0
- package/test/wkb.test.ts +296 -0
- package/tsconfig.json +9 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @osmix/geoparquet
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 31fa333: Add `@osmix/geoparquet` package for importing OSM data from OpenStreetMap US Layercake GeoParquet files.
|
|
8
|
+
|
|
9
|
+
Features:
|
|
10
|
+
|
|
11
|
+
- `fromGeoParquet()` function to create Osm indexes from GeoParquet files
|
|
12
|
+
- WKB geometry parsing for Point, LineString, Polygon, and MultiPolygon
|
|
13
|
+
- Support for file paths, URLs, and ArrayBuffer inputs
|
|
14
|
+
- Customizable column mapping for different parquet schemas
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 54fe002: Add fromGeoParquet to OsmixWorker and OsmixRemote
|
|
19
|
+
- 31fa333: Import GeoParquet
|
|
20
|
+
- Updated dependencies [d4f4b1f]
|
|
21
|
+
- @osmix/core@0.1.1
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @osmix/geoparquet
|
|
2
|
+
|
|
3
|
+
Import GeoParquet files into Osmix. OpenStreetMap US publishes GeoParquet extracts with .
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @osmix/geoparquet
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { fromGeoParquet } from "@osmix/geoparquet"
|
|
15
|
+
|
|
16
|
+
// From a local file buffer
|
|
17
|
+
const osm = await fromGeoParquet(await Bun.file('./monaco.parquet').arrayBuffer())
|
|
18
|
+
|
|
19
|
+
// Query imported data
|
|
20
|
+
const highways = osm.ways.search("highway")
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Layercake Format
|
|
24
|
+
|
|
25
|
+
[Layercake](https://openstreetmap.us/our-work/geoparquet/) is an OSM data distribution format created by OpenStreetMap US. It provides
|
|
26
|
+
OSM data as GeoParquet files with the following schema:
|
|
27
|
+
|
|
28
|
+
- `id`: OSM entity ID (bigint)
|
|
29
|
+
- `geometry`: WKB-encoded geometry
|
|
30
|
+
- `tags`: JSON object with OSM tags
|
|
31
|
+
|
|
32
|
+
This package reads these files using [hyparquet](https://github.com/hyparam/hyparquet)
|
|
33
|
+
and converts them to Osmix's in-memory format for spatial queries and analysis.
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
### `fromGeoParquet(source, options?, onProgress?)`
|
|
38
|
+
|
|
39
|
+
Create an Osm index from GeoParquet data.
|
|
40
|
+
|
|
41
|
+
**Parameters:**
|
|
42
|
+
- `source` - File path, URL, or ArrayBuffer containing parquet data
|
|
43
|
+
- `osmOptions` - Optional Osm configuration (id, header)
|
|
44
|
+
- `readOptions` - Optional GeoParquet read options
|
|
45
|
+
- `onProgress` - Optional callback for progress updates
|
|
46
|
+
|
|
47
|
+
**Returns:** Promise<Osm> - Populated Osm index with built indexes
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GeoParquet to OSM conversion utilities.
|
|
3
|
+
*
|
|
4
|
+
* Imports GeoParquet files into Osm indexes, mapping geometry
|
|
5
|
+
* types to appropriate OSM entity structures.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { Osm, type OsmOptions } from "@osmix/core";
|
|
10
|
+
import { type ProgressEvent } from "@osmix/shared/progress";
|
|
11
|
+
import type { GeoParquetReadOptions, GeoParquetSource } from "./types";
|
|
12
|
+
/**
|
|
13
|
+
* Create an Osm index from GeoParquet data.
|
|
14
|
+
*
|
|
15
|
+
* Accepts various input formats (file path, URL, or buffer) and converts
|
|
16
|
+
* features to OSM entities:
|
|
17
|
+
* - Point → Node
|
|
18
|
+
* - LineString → Way with nodes
|
|
19
|
+
* - Polygon → Way (simple) or Relation (with holes)
|
|
20
|
+
* - MultiPolygon → Relation
|
|
21
|
+
*
|
|
22
|
+
* Feature IDs are preserved if available; otherwise sequential negative IDs
|
|
23
|
+
* are assigned. Feature tags become OSM tags.
|
|
24
|
+
*
|
|
25
|
+
* @param source - GeoParquet data source (file path, URL, or buffer)
|
|
26
|
+
* @param options - Osm index options (id, header)
|
|
27
|
+
* @param readOptions - Options for reading the parquet file
|
|
28
|
+
* @param onProgress - Progress callback for UI feedback
|
|
29
|
+
* @returns Populated Osm index with built indexes
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { fromGeoParquet } from "@osmix/geoparquet"
|
|
34
|
+
*
|
|
35
|
+
* // From file
|
|
36
|
+
* const osm = await fromGeoParquet("./roads.parquet")
|
|
37
|
+
*
|
|
38
|
+
* // Query the imported data
|
|
39
|
+
* const highways = osm.ways.search("highway")
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function fromGeoParquet(source: GeoParquetSource, options?: Partial<OsmOptions>, readOptions?: GeoParquetReadOptions, onProgress?: (progress: ProgressEvent) => void): Promise<Osm>;
|
|
43
|
+
export declare class GeoParquetOsmBuilder {
|
|
44
|
+
private osm;
|
|
45
|
+
private readOptions;
|
|
46
|
+
private onProgress;
|
|
47
|
+
constructor(osmOptions?: Partial<OsmOptions>, readOptions?: GeoParquetReadOptions, onProgress?: (progress: ProgressEvent) => void);
|
|
48
|
+
readParquetRows(source: GeoParquetSource): Promise<Record<string, any>[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Converts GeoParquet rows to OSM entities.
|
|
51
|
+
*/
|
|
52
|
+
processGeoParquetRows(rows: Record<string, unknown>[]): void;
|
|
53
|
+
buildOsm(): Osm;
|
|
54
|
+
private nextNodeId;
|
|
55
|
+
private nextWayId;
|
|
56
|
+
private nextRelationId;
|
|
57
|
+
getNextRelationId(): number;
|
|
58
|
+
getNextWayId(): number;
|
|
59
|
+
getNextNodeId(): number;
|
|
60
|
+
private nodeMap;
|
|
61
|
+
private getOrCreateNode;
|
|
62
|
+
private processPoint;
|
|
63
|
+
private processLineString;
|
|
64
|
+
private processMultiLineString;
|
|
65
|
+
private processPolygon;
|
|
66
|
+
private processMultiPolygon;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=from-geoparquet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-geoparquet.d.ts","sourceRoot":"","sources":["../../src/from-geoparquet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAEN,KAAK,aAAa,EAElB,MAAM,wBAAwB,CAAA;AAiB/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,cAAc,CACnC,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,OAAO,CAAC,UAAU,CAAM,EACjC,WAAW,GAAE,qBAA0B,EACvC,UAAU,GAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAkB,GACzD,OAAO,CAAC,GAAG,CAAC,CAcd;AAED,qBAAa,oBAAoB;IAChC,OAAO,CAAC,GAAG,CAAK;IAChB,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,UAAU,CAAmC;gBAGpD,UAAU,GAAE,OAAO,CAAC,UAAU,CAAM,EACpC,WAAW,GAAE,qBAA0B,EACvC,UAAU,GAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAkB;IAOtD,eAAe,CAAC,MAAM,EAAE,gBAAgB;IAoC9C;;OAEG;IACH,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IA6FrD,QAAQ;IAWR,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,cAAc,CAAK;IAC3B,iBAAiB;IAGjB,YAAY;IAGZ,aAAa;IAKb,OAAO,CAAC,OAAO,CAA4B;IAG3C,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,iBAAiB;IA6BzB,OAAO,CAAC,sBAAsB;IA2B9B,OAAO,CAAC,cAAc;IAoFtB,OAAO,CAAC,mBAAmB;CA4E3B"}
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GeoParquet to OSM conversion utilities.
|
|
3
|
+
*
|
|
4
|
+
* Imports GeoParquet files into Osm indexes, mapping geometry
|
|
5
|
+
* types to appropriate OSM entity structures.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { Osm } from "@osmix/core";
|
|
10
|
+
import { logProgress, progressEvent, } from "@osmix/shared/progress";
|
|
11
|
+
import { rewindFeature } from "@placemarkio/geojson-rewind";
|
|
12
|
+
import { asyncBufferFromUrl, parquetReadObjects, } from "hyparquet";
|
|
13
|
+
import { parseWkb } from "./wkb";
|
|
14
|
+
/**
|
|
15
|
+
* Create an Osm index from GeoParquet data.
|
|
16
|
+
*
|
|
17
|
+
* Accepts various input formats (file path, URL, or buffer) and converts
|
|
18
|
+
* features to OSM entities:
|
|
19
|
+
* - Point → Node
|
|
20
|
+
* - LineString → Way with nodes
|
|
21
|
+
* - Polygon → Way (simple) or Relation (with holes)
|
|
22
|
+
* - MultiPolygon → Relation
|
|
23
|
+
*
|
|
24
|
+
* Feature IDs are preserved if available; otherwise sequential negative IDs
|
|
25
|
+
* are assigned. Feature tags become OSM tags.
|
|
26
|
+
*
|
|
27
|
+
* @param source - GeoParquet data source (file path, URL, or buffer)
|
|
28
|
+
* @param options - Osm index options (id, header)
|
|
29
|
+
* @param readOptions - Options for reading the parquet file
|
|
30
|
+
* @param onProgress - Progress callback for UI feedback
|
|
31
|
+
* @returns Populated Osm index with built indexes
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { fromGeoParquet } from "@osmix/geoparquet"
|
|
36
|
+
*
|
|
37
|
+
* // From file
|
|
38
|
+
* const osm = await fromGeoParquet("./roads.parquet")
|
|
39
|
+
*
|
|
40
|
+
* // Query the imported data
|
|
41
|
+
* const highways = osm.ways.search("highway")
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export async function fromGeoParquet(source, options = {}, readOptions = {}, onProgress = logProgress) {
|
|
45
|
+
const builder = new GeoParquetOsmBuilder(options, readOptions, onProgress);
|
|
46
|
+
onProgress(progressEvent("Loading GeoParquet file..."));
|
|
47
|
+
// Read rows from parquet file
|
|
48
|
+
const rows = await builder.readParquetRows(source);
|
|
49
|
+
onProgress(progressEvent(`Processing ${rows.length} features...`));
|
|
50
|
+
// Convert to OSM entities
|
|
51
|
+
builder.processGeoParquetRows(rows);
|
|
52
|
+
return builder.buildOsm();
|
|
53
|
+
}
|
|
54
|
+
export class GeoParquetOsmBuilder {
|
|
55
|
+
osm;
|
|
56
|
+
readOptions;
|
|
57
|
+
onProgress;
|
|
58
|
+
constructor(osmOptions = {}, readOptions = {}, onProgress = logProgress) {
|
|
59
|
+
this.osm = new Osm(osmOptions);
|
|
60
|
+
this.readOptions = readOptions;
|
|
61
|
+
this.onProgress = onProgress;
|
|
62
|
+
}
|
|
63
|
+
async readParquetRows(source) {
|
|
64
|
+
let file;
|
|
65
|
+
if (typeof source === "string") {
|
|
66
|
+
// String sources are treated as URLs
|
|
67
|
+
this.onProgress(progressEvent(`Fetching from URL: ${source}`));
|
|
68
|
+
file = await asyncBufferFromUrl({ url: source });
|
|
69
|
+
}
|
|
70
|
+
else if (source instanceof URL) {
|
|
71
|
+
this.onProgress(progressEvent(`Fetching from URL: ${source.href}`));
|
|
72
|
+
file = await asyncBufferFromUrl({ url: source.href });
|
|
73
|
+
}
|
|
74
|
+
else if (source instanceof ArrayBuffer) {
|
|
75
|
+
// Wrap ArrayBuffer as AsyncBuffer
|
|
76
|
+
file = {
|
|
77
|
+
byteLength: source.byteLength,
|
|
78
|
+
slice: (start, end) => source.slice(start, end),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Assume it's already an AsyncBuffer
|
|
83
|
+
file = source;
|
|
84
|
+
}
|
|
85
|
+
const readConfig = {
|
|
86
|
+
file,
|
|
87
|
+
...this.readOptions,
|
|
88
|
+
columns: [
|
|
89
|
+
this.readOptions.typeColumn ?? "type",
|
|
90
|
+
this.readOptions.idColumn ?? "id",
|
|
91
|
+
this.readOptions.geometryColumn ?? "geometry",
|
|
92
|
+
this.readOptions.tagsColumn ?? "tags",
|
|
93
|
+
this.readOptions.bboxColumn ?? "bbox",
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
this.onProgress(progressEvent("Reading parquet data..."));
|
|
97
|
+
return parquetReadObjects(readConfig);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Converts GeoParquet rows to OSM entities.
|
|
101
|
+
*/
|
|
102
|
+
processGeoParquetRows(rows) {
|
|
103
|
+
this.onProgress(progressEvent("Converting GeoParquet to Osmix..."));
|
|
104
|
+
const idColumn = this.readOptions.idColumn ?? "id";
|
|
105
|
+
const typeColumn = this.readOptions.typeColumn ?? "type";
|
|
106
|
+
const geometryColumn = this.readOptions.geometryColumn ?? "geometry";
|
|
107
|
+
const tagsColumn = this.readOptions.tagsColumn ?? "tags";
|
|
108
|
+
const bboxColumn = this.readOptions.bboxColumn ?? "bbox";
|
|
109
|
+
// Process each row
|
|
110
|
+
let count = 0;
|
|
111
|
+
for (const row of rows) {
|
|
112
|
+
// Extract values using column names
|
|
113
|
+
// biome-ignore lint/suspicious/noExplicitAny: dynamic column access
|
|
114
|
+
const rowAny = row;
|
|
115
|
+
const id = rowAny[idColumn];
|
|
116
|
+
const type = rowAny[typeColumn];
|
|
117
|
+
const geometryData = rowAny[geometryColumn];
|
|
118
|
+
const tagsData = rowAny[tagsColumn];
|
|
119
|
+
// bboxData is read but currently unused - reserved for future optimization
|
|
120
|
+
void rowAny[bboxColumn];
|
|
121
|
+
if (!geometryData) {
|
|
122
|
+
count++;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
// Parse WKB geometry
|
|
126
|
+
let geometry;
|
|
127
|
+
try {
|
|
128
|
+
if (geometryData instanceof Uint8Array) {
|
|
129
|
+
geometry = parseWkb(geometryData);
|
|
130
|
+
}
|
|
131
|
+
else if (typeof geometryData === "string") {
|
|
132
|
+
geometry = JSON.parse(geometryData);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
geometry = geometryData;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (_e) {
|
|
139
|
+
// Skip invalid geometries
|
|
140
|
+
count++;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
// Parse tags
|
|
144
|
+
const tags = parseTags(tagsData);
|
|
145
|
+
// Get numeric ID from bigint or generate one
|
|
146
|
+
const numericId = id !== undefined
|
|
147
|
+
? typeof id === "bigint"
|
|
148
|
+
? Number(id)
|
|
149
|
+
: id
|
|
150
|
+
: undefined;
|
|
151
|
+
// Normalize geometry winding order
|
|
152
|
+
const normalizedGeometry = normalizeGeometry(geometry);
|
|
153
|
+
if (normalizedGeometry.type === "Point") {
|
|
154
|
+
this.processPoint(normalizedGeometry, numericId, tags);
|
|
155
|
+
}
|
|
156
|
+
else if (normalizedGeometry.type === "LineString") {
|
|
157
|
+
this.processLineString(normalizedGeometry, numericId, tags);
|
|
158
|
+
}
|
|
159
|
+
else if (normalizedGeometry.type === "Polygon") {
|
|
160
|
+
if (type === "node")
|
|
161
|
+
throw Error(`ID: ${numericId} has type 'node' but geometry is a polygon`);
|
|
162
|
+
// Infer type from geometry if missing: relation if has holes, way otherwise
|
|
163
|
+
const polygonType = type ??
|
|
164
|
+
(normalizedGeometry.coordinates.length > 1 ? "relation" : "way");
|
|
165
|
+
this.processPolygon(normalizedGeometry, polygonType, numericId, tags);
|
|
166
|
+
}
|
|
167
|
+
else if (normalizedGeometry.type === "MultiPolygon") {
|
|
168
|
+
this.processMultiPolygon(normalizedGeometry, numericId, tags);
|
|
169
|
+
}
|
|
170
|
+
else if (normalizedGeometry.type === "MultiLineString") {
|
|
171
|
+
this.processMultiLineString(normalizedGeometry, numericId, tags);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
throw Error(`Unsupported geometry type: ${normalizedGeometry.type}`);
|
|
175
|
+
}
|
|
176
|
+
count++;
|
|
177
|
+
if (count % 10000 === 0) {
|
|
178
|
+
this.onProgress(progressEvent(`Processed ${count} features...`));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
this.onProgress(progressEvent(`Imported ${count} features`));
|
|
182
|
+
}
|
|
183
|
+
buildOsm() {
|
|
184
|
+
this.onProgress(progressEvent("Finished converting GeoParquet to Osmix, building indexes..."));
|
|
185
|
+
this.osm.buildIndexes();
|
|
186
|
+
this.osm.buildSpatialIndexes();
|
|
187
|
+
return this.osm;
|
|
188
|
+
}
|
|
189
|
+
nextNodeId = -1;
|
|
190
|
+
nextWayId = -1;
|
|
191
|
+
nextRelationId = -1;
|
|
192
|
+
getNextRelationId() {
|
|
193
|
+
return this.nextRelationId--;
|
|
194
|
+
}
|
|
195
|
+
getNextWayId() {
|
|
196
|
+
return this.nextWayId--;
|
|
197
|
+
}
|
|
198
|
+
getNextNodeId() {
|
|
199
|
+
return this.nextNodeId--;
|
|
200
|
+
}
|
|
201
|
+
// Map to track nodes by coordinate string for reuse when creating ways
|
|
202
|
+
nodeMap = new Map();
|
|
203
|
+
// Helper to get or create a node for a coordinate
|
|
204
|
+
getOrCreateNode(lon, lat) {
|
|
205
|
+
const coordKey = `${lon},${lat}`;
|
|
206
|
+
const existingNodeId = this.nodeMap.get(coordKey);
|
|
207
|
+
if (existingNodeId !== undefined) {
|
|
208
|
+
return existingNodeId;
|
|
209
|
+
}
|
|
210
|
+
const nodeId = this.getNextNodeId();
|
|
211
|
+
this.nodeMap.set(coordKey, nodeId);
|
|
212
|
+
this.osm.nodes.addNode({
|
|
213
|
+
id: nodeId,
|
|
214
|
+
lon,
|
|
215
|
+
lat,
|
|
216
|
+
});
|
|
217
|
+
return nodeId;
|
|
218
|
+
}
|
|
219
|
+
processPoint(geometry, featureId, tags) {
|
|
220
|
+
const [lon, lat] = geometry.coordinates;
|
|
221
|
+
if (lon === undefined || lat === undefined)
|
|
222
|
+
throw Error("Point must have lon and lat coordinates");
|
|
223
|
+
const nodeId = featureId ?? this.getNextNodeId();
|
|
224
|
+
this.osm.nodes.addNode({
|
|
225
|
+
id: nodeId,
|
|
226
|
+
lon,
|
|
227
|
+
lat,
|
|
228
|
+
tags,
|
|
229
|
+
});
|
|
230
|
+
this.nodeMap.set(`${lon},${lat}`, nodeId);
|
|
231
|
+
return nodeId;
|
|
232
|
+
}
|
|
233
|
+
processLineString(geometry, featureId, tags) {
|
|
234
|
+
const coordinates = geometry.coordinates;
|
|
235
|
+
if (coordinates.length < 2)
|
|
236
|
+
throw Error("LineString must have at least 2 coordinates");
|
|
237
|
+
const nodeRefs = [];
|
|
238
|
+
for (const [lon, lat] of coordinates) {
|
|
239
|
+
if (lon === undefined || lat === undefined)
|
|
240
|
+
throw Error("LineString coordinates must have lon and lat");
|
|
241
|
+
nodeRefs.push(this.getOrCreateNode(lon, lat));
|
|
242
|
+
}
|
|
243
|
+
if (nodeRefs.length < 2)
|
|
244
|
+
throw Error("LineString must have at least 2 coordinates");
|
|
245
|
+
const wayId = featureId ?? this.getNextWayId();
|
|
246
|
+
this.osm.ways.addWay({
|
|
247
|
+
id: wayId,
|
|
248
|
+
refs: nodeRefs,
|
|
249
|
+
tags,
|
|
250
|
+
});
|
|
251
|
+
return wayId;
|
|
252
|
+
}
|
|
253
|
+
processMultiLineString(geometry, featureId, tags) {
|
|
254
|
+
const coordinates = geometry.coordinates;
|
|
255
|
+
if (coordinates.length === 0)
|
|
256
|
+
throw Error("MultiLineString must have at least one LineString");
|
|
257
|
+
const wayIds = [];
|
|
258
|
+
for (const line of coordinates) {
|
|
259
|
+
if (line.length < 2)
|
|
260
|
+
throw Error("LineString must have at least 2 coordinates");
|
|
261
|
+
const wayId = this.processLineString({ type: "LineString", coordinates: line }, this.getNextWayId());
|
|
262
|
+
wayIds.push(wayId);
|
|
263
|
+
}
|
|
264
|
+
this.osm.relations.addRelation({
|
|
265
|
+
id: featureId ?? this.getNextRelationId(),
|
|
266
|
+
members: wayIds.map((id) => ({ type: "way", ref: id })),
|
|
267
|
+
tags: { type: "multilinestring", ...tags },
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
processPolygon(geometry, type, featureId, tags) {
|
|
271
|
+
const coordinates = geometry.coordinates;
|
|
272
|
+
if (coordinates.length === 0)
|
|
273
|
+
return;
|
|
274
|
+
const outerRing = coordinates[0];
|
|
275
|
+
if (!outerRing || outerRing.length < 3)
|
|
276
|
+
return;
|
|
277
|
+
// Create nodes for outer ring
|
|
278
|
+
const outerNodeRefs = [];
|
|
279
|
+
for (const [lon, lat] of outerRing) {
|
|
280
|
+
if (lon === undefined || lat === undefined)
|
|
281
|
+
continue;
|
|
282
|
+
const nodeId = this.getOrCreateNode(lon, lat);
|
|
283
|
+
outerNodeRefs.push(nodeId);
|
|
284
|
+
}
|
|
285
|
+
if (outerNodeRefs.length < 3)
|
|
286
|
+
return;
|
|
287
|
+
// Ensure the outer ring is closed
|
|
288
|
+
if (outerNodeRefs[0] !== outerNodeRefs[outerNodeRefs.length - 1]) {
|
|
289
|
+
outerNodeRefs.push(outerNodeRefs[0]);
|
|
290
|
+
}
|
|
291
|
+
const outerWayId = type === "relation"
|
|
292
|
+
? this.getNextWayId()
|
|
293
|
+
: (featureId ?? this.getNextWayId());
|
|
294
|
+
this.osm.ways.addWay({
|
|
295
|
+
id: outerWayId,
|
|
296
|
+
refs: outerNodeRefs,
|
|
297
|
+
tags: type === "relation" ? { area: "yes" } : { area: "yes", ...tags },
|
|
298
|
+
});
|
|
299
|
+
if (type === "way")
|
|
300
|
+
return;
|
|
301
|
+
// Create separate ways for holes
|
|
302
|
+
const holeWayIds = [];
|
|
303
|
+
for (let i = 1; i < coordinates.length; i++) {
|
|
304
|
+
const holeRing = coordinates[i];
|
|
305
|
+
if (!holeRing || holeRing.length < 3)
|
|
306
|
+
continue;
|
|
307
|
+
const holeNodeRefs = [];
|
|
308
|
+
for (const [lon, lat] of holeRing) {
|
|
309
|
+
if (lon === undefined || lat === undefined)
|
|
310
|
+
continue;
|
|
311
|
+
const nodeId = this.getOrCreateNode(lon, lat);
|
|
312
|
+
holeNodeRefs.push(nodeId);
|
|
313
|
+
}
|
|
314
|
+
if (holeNodeRefs.length < 3)
|
|
315
|
+
continue;
|
|
316
|
+
// Ensure the ring is closed
|
|
317
|
+
if (holeNodeRefs[0] !== holeNodeRefs[holeNodeRefs.length - 1]) {
|
|
318
|
+
holeNodeRefs.push(holeNodeRefs[0]);
|
|
319
|
+
}
|
|
320
|
+
const holeWayId = this.getNextWayId();
|
|
321
|
+
this.osm.ways.addWay({
|
|
322
|
+
id: holeWayId,
|
|
323
|
+
refs: holeNodeRefs,
|
|
324
|
+
tags: { area: "yes" },
|
|
325
|
+
});
|
|
326
|
+
holeWayIds.push(holeWayId);
|
|
327
|
+
}
|
|
328
|
+
this.osm.relations.addRelation({
|
|
329
|
+
id: featureId ?? this.getNextRelationId(),
|
|
330
|
+
members: [
|
|
331
|
+
{ type: "way", ref: outerWayId, role: "outer" },
|
|
332
|
+
...holeWayIds.map((id) => ({ type: "way", ref: id, role: "inner" })),
|
|
333
|
+
],
|
|
334
|
+
tags: {
|
|
335
|
+
type: "multipolygon",
|
|
336
|
+
...tags,
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
processMultiPolygon(geometry, featureId, tags) {
|
|
341
|
+
const coordinates = geometry.coordinates;
|
|
342
|
+
if (coordinates.length === 0)
|
|
343
|
+
return;
|
|
344
|
+
const relationMembers = [];
|
|
345
|
+
for (const polygon of coordinates) {
|
|
346
|
+
if (polygon.length === 0)
|
|
347
|
+
continue;
|
|
348
|
+
const outerRing = polygon[0];
|
|
349
|
+
if (!outerRing || outerRing.length < 3)
|
|
350
|
+
continue;
|
|
351
|
+
// Create nodes for outer ring
|
|
352
|
+
const outerNodeRefs = [];
|
|
353
|
+
for (const [lon, lat] of outerRing) {
|
|
354
|
+
if (lon === undefined || lat === undefined)
|
|
355
|
+
continue;
|
|
356
|
+
const nodeId = this.getOrCreateNode(lon, lat);
|
|
357
|
+
outerNodeRefs.push(nodeId);
|
|
358
|
+
}
|
|
359
|
+
if (outerNodeRefs.length < 3)
|
|
360
|
+
continue;
|
|
361
|
+
// Ensure the ring is closed
|
|
362
|
+
if (outerNodeRefs[0] !== outerNodeRefs[outerNodeRefs.length - 1]) {
|
|
363
|
+
outerNodeRefs.push(outerNodeRefs[0]);
|
|
364
|
+
}
|
|
365
|
+
const outerWayId = this.getNextWayId();
|
|
366
|
+
this.osm.ways.addWay({
|
|
367
|
+
id: outerWayId,
|
|
368
|
+
refs: outerNodeRefs,
|
|
369
|
+
tags: { area: "yes" },
|
|
370
|
+
});
|
|
371
|
+
relationMembers.push({ type: "way", ref: outerWayId, role: "outer" });
|
|
372
|
+
// Create separate ways for holes
|
|
373
|
+
for (let i = 1; i < polygon.length; i++) {
|
|
374
|
+
const holeRing = polygon[i];
|
|
375
|
+
if (!holeRing || holeRing.length < 3)
|
|
376
|
+
continue;
|
|
377
|
+
const holeNodeRefs = [];
|
|
378
|
+
for (const [lon, lat] of holeRing) {
|
|
379
|
+
if (lon === undefined || lat === undefined)
|
|
380
|
+
continue;
|
|
381
|
+
const nodeId = this.getOrCreateNode(lon, lat);
|
|
382
|
+
holeNodeRefs.push(nodeId);
|
|
383
|
+
}
|
|
384
|
+
if (holeNodeRefs.length < 3)
|
|
385
|
+
continue;
|
|
386
|
+
// Ensure the ring is closed
|
|
387
|
+
if (holeNodeRefs[0] !== holeNodeRefs[holeNodeRefs.length - 1]) {
|
|
388
|
+
holeNodeRefs.push(holeNodeRefs[0]);
|
|
389
|
+
}
|
|
390
|
+
const holeWayId = this.getNextWayId();
|
|
391
|
+
this.osm.ways.addWay({
|
|
392
|
+
id: holeWayId,
|
|
393
|
+
refs: holeNodeRefs,
|
|
394
|
+
tags: { area: "yes" },
|
|
395
|
+
});
|
|
396
|
+
relationMembers.push({ type: "way", ref: holeWayId, role: "inner" });
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (relationMembers.length > 0) {
|
|
400
|
+
this.osm.relations.addRelation({
|
|
401
|
+
id: featureId ?? this.getNextRelationId(),
|
|
402
|
+
members: relationMembers,
|
|
403
|
+
tags: { type: "multipolygon", ...tags },
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Parse tags from various formats.
|
|
410
|
+
*/
|
|
411
|
+
function parseTags(tagsData) {
|
|
412
|
+
if (!tagsData)
|
|
413
|
+
return undefined;
|
|
414
|
+
if (typeof tagsData === "string") {
|
|
415
|
+
try {
|
|
416
|
+
const parsed = JSON.parse(tagsData);
|
|
417
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
418
|
+
return parsed;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
catch {
|
|
422
|
+
return undefined;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (typeof tagsData === "object") {
|
|
426
|
+
const tags = {};
|
|
427
|
+
for (const [key, value] of Object.entries(tagsData)) {
|
|
428
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
429
|
+
tags[key] = value;
|
|
430
|
+
}
|
|
431
|
+
else if (value != null) {
|
|
432
|
+
tags[key] = String(value);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return Object.keys(tags).length > 0 ? tags : undefined;
|
|
436
|
+
}
|
|
437
|
+
return undefined;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Normalize geometry winding order for OSM conventions.
|
|
441
|
+
*/
|
|
442
|
+
function normalizeGeometry(geometry) {
|
|
443
|
+
if (geometry.type === "Polygon" || geometry.type === "MultiPolygon") {
|
|
444
|
+
// Use rewind to ensure correct winding order
|
|
445
|
+
const feature = {
|
|
446
|
+
type: "Feature",
|
|
447
|
+
geometry,
|
|
448
|
+
properties: {},
|
|
449
|
+
};
|
|
450
|
+
const rewound = rewindFeature(feature);
|
|
451
|
+
return rewound.geometry ?? geometry;
|
|
452
|
+
}
|
|
453
|
+
return geometry;
|
|
454
|
+
}
|
|
455
|
+
//# sourceMappingURL=from-geoparquet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-geoparquet.js","sourceRoot":"","sources":["../../src/from-geoparquet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,GAAG,EAAmB,MAAM,aAAa,CAAA;AAClD,OAAO,EACN,WAAW,EAEX,aAAa,GACb,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAS3D,OAAO,EAEN,kBAAkB,EAElB,kBAAkB,GAClB,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,MAAwB,EACxB,UAA+B,EAAE,EACjC,cAAqC,EAAE,EACvC,aAAgD,WAAW;IAE3D,MAAM,OAAO,GAAG,IAAI,oBAAoB,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAA;IAE1E,UAAU,CAAC,aAAa,CAAC,4BAA4B,CAAC,CAAC,CAAA;IAEvD,8BAA8B;IAC9B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;IAElD,UAAU,CAAC,aAAa,CAAC,cAAc,IAAI,CAAC,MAAM,cAAc,CAAC,CAAC,CAAA;IAElE,0BAA0B;IAC1B,OAAO,CAAC,q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AAE,CAAC;YACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC5D,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;YAClB,CAAC;iBAAM,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;YAC1B,CAAC;QACF,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;IACvD,CAAC;IAED,OAAO,SAAS,CAAA;AACjB,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,QAAkB;IAC5C,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QACrE,6CAA6C;QAC7C,MAAM,OAAO,GAAG;YACf,IAAI,EAAE,SAAkB;YACxB,QAAQ;YACR,UAAU,EAAE,EAAE;SACd,CAAA;QACD,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;QACtC,OAAO,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAA;IACpC,CAAC;IACD,OAAO,QAAQ,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @osmix/geoparquet - Import OSM data from GeoParquet files.
|
|
3
|
+
*
|
|
4
|
+
* Provides import functionality for GeoParquet files including OpenStreetMap US Layercake,
|
|
5
|
+
* converting geometry data to Osmix's in-memory format.
|
|
6
|
+
*
|
|
7
|
+
* Handles geometry mapping:
|
|
8
|
+
* - Point → Node
|
|
9
|
+
* - LineString → Way with nodes
|
|
10
|
+
* - Polygon → Way (simple) or Relation (with holes)
|
|
11
|
+
* - MultiPolygon → Multipolygon relation
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Import GeoParquet data to Osm index
|
|
16
|
+
* import { fromGeoParquet } from "@osmix/geoparquet"
|
|
17
|
+
*
|
|
18
|
+
* const osm = await fromGeoParquet("./data.parquet")
|
|
19
|
+
* const highways = osm.ways.search("highway")
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @module @osmix/geoparquet
|
|
23
|
+
*/
|
|
24
|
+
export * from "./from-geoparquet";
|
|
25
|
+
export * from "./types";
|
|
26
|
+
export { parseWkb } from "./wkb";
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA"}
|