auto-sync: 2026-05-02 17:10:01
This commit is contained in:
@@ -78,10 +78,15 @@ def init_db(conn, has_spatialite):
|
||||
smoothness TEXT,
|
||||
access TEXT,
|
||||
tags TEXT,
|
||||
geom BLOB
|
||||
geom BLOB,
|
||||
min_lon REAL,
|
||||
max_lon REAL,
|
||||
min_lat REAL,
|
||||
max_lat REAL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_trails_highway ON trails(highway_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_trails_surface ON trails(surface);
|
||||
CREATE INDEX IF NOT EXISTS idx_trails_bbox ON trails(min_lon, max_lon, min_lat, max_lat);
|
||||
|
||||
DROP TABLE IF EXISTS poi;
|
||||
CREATE TABLE poi (
|
||||
@@ -89,9 +94,12 @@ def init_db(conn, has_spatialite):
|
||||
osm_id INTEGER NOT NULL,
|
||||
poi_type TEXT,
|
||||
name TEXT,
|
||||
geom BLOB
|
||||
geom BLOB,
|
||||
lon REAL,
|
||||
lat REAL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_poi_type ON poi(poi_type);
|
||||
CREATE INDEX IF NOT EXISTS idx_poi_coords ON poi(lon, lat);
|
||||
""")
|
||||
conn.commit()
|
||||
|
||||
@@ -153,8 +161,9 @@ def parse_geojsonseq(geojson_path, conn):
|
||||
cur.executemany("""
|
||||
INSERT INTO trails
|
||||
(osm_id, highway_type, track_type, surface, name, length_m,
|
||||
mtb_scale, visibility, smoothness, access, tags, geom)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
mtb_scale, visibility, smoothness, access, tags, geom,
|
||||
min_lon, max_lon, min_lat, max_lat)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
""", batch_trails)
|
||||
conn.commit()
|
||||
trails_count += len(batch_trails)
|
||||
@@ -165,8 +174,8 @@ def parse_geojsonseq(geojson_path, conn):
|
||||
nonlocal poi_count
|
||||
if batch_poi:
|
||||
cur.executemany("""
|
||||
INSERT INTO poi (osm_id, poi_type, name, geom)
|
||||
VALUES (?,?,?,?)
|
||||
INSERT INTO poi (osm_id, poi_type, name, geom, lon, lat)
|
||||
VALUES (?,?,?,?,?,?)
|
||||
""", batch_poi)
|
||||
conn.commit()
|
||||
poi_count += len(batch_poi)
|
||||
@@ -202,6 +211,10 @@ def parse_geojsonseq(geojson_path, conn):
|
||||
continue
|
||||
length_m = haversine_length(coords)
|
||||
wkb = coords_to_wkb_linestring(coords)
|
||||
lons = [c[0] for c in coords]
|
||||
lats = [c[1] for c in coords]
|
||||
min_lon, max_lon = min(lons), max(lons)
|
||||
min_lat, max_lat = min(lats), max(lats)
|
||||
extra = {k: v for k, v in props.items()
|
||||
if k not in ("highway", "tracktype", "surface", "name",
|
||||
"mtb:scale", "trail_visibility", "smoothness", "access")}
|
||||
@@ -218,6 +231,7 @@ def parse_geojsonseq(geojson_path, conn):
|
||||
props.get("access"),
|
||||
json.dumps(extra, ensure_ascii=False),
|
||||
wkb,
|
||||
min_lon, max_lon, min_lat, max_lat,
|
||||
))
|
||||
if len(batch_trails) >= BATCH_SIZE:
|
||||
flush_trails()
|
||||
@@ -242,12 +256,15 @@ def parse_geojsonseq(geojson_path, conn):
|
||||
coords = geom.get("coordinates", [])
|
||||
if len(coords) < 2:
|
||||
continue
|
||||
wkb = coords_to_wkb_point(coords[0], coords[1])
|
||||
lon, lat = coords[0], coords[1]
|
||||
wkb = coords_to_wkb_point(lon, lat)
|
||||
batch_poi.append((
|
||||
osm_id,
|
||||
poi_type,
|
||||
props.get("name"),
|
||||
wkb,
|
||||
lon,
|
||||
lat,
|
||||
))
|
||||
if len(batch_poi) >= BATCH_SIZE:
|
||||
flush_poi()
|
||||
|
||||
Reference in New Issue
Block a user