Files
secondo/Algebras/OSM/Scripts/TuImportOsmDataFromShpFiles.sec
2026-01-23 17:03:45 +08:00

69 lines
2.8 KiB
Plaintext

################################################################################
### Importing OSM data from shape files (2 / 11)
################################################################################
### Description:
### - Reads data on Streets and points of interest from shape files.
### In shape-files matching the free standard Geofabrik-format some data e.g.
### on Tunnels and Layers are missing. Self-made shape-files, however, provide
### this data. To retrieve this data these files have to be treated specially
### which is done in a follow-up Secondo-script.
### Please, see tu_osm_import.sh for further details.
###
### Preconditions:
### - existing open database
###
### Postconditions:
### - StreetsTmp-relation
### either self-made shape-files in a custom format:
### StreetsTmp: rel{GeoData: sline, ID: int, part: int, attrib: string}
### or shape-files in the free standard geofabrik-format:
### StreetsTmp: rel{GeoData: sline, osm_id: int, name: string, ref: string,
### type: string, oneway: int, bridge: int, maxspeed: int,
### Tunnel: bool, Layer: int}
### - PointsTmp-relation
### PointsTmp: rel{osm_id: int, timestamp: int, name: string, GeoData: point,
### type: string}
### - restrictionsTmp-relation
### restrictionsTmp: rel{osm_id: int, from: int, via: int, to: int,
### restriction: text}
###
### Author:
### - Thomas Uchdorf, thomas.uchdorf(at)fernuni-hagen.de
################################################################################
# Importing the street data (Here attributes Tunnel and Layer are added with
# dummy data. Their real data is derived from the attrib-attribute later. Be
# aware that this is NOT an option if the standard geofabrik format is used!
# In this case the values in the additional attributes are worthless and just
# serve to save one more script-file.)
let StreetsTmp =
shpimport3(SRC_DIR_PATH + 'roads.shp') namedtransformstream[GeoData]
addcounter[JoinId_shp,1]
dbimport2(SRC_DIR_PATH + 'roads.dbf')
addcounter[JoinId_dbf,1]
mergejoin[JoinId_shp,JoinId_dbf]
remove[JoinId_shp,JoinId_dbf]
filter[isdefined(.GeoData)]
filter[bbox(.GeoData) intersects PartRect]
extend [Tunnel: FALSE, Layer: 0]
consume;
# Importing the POI data
let PointsTmp =
shpimport3(SRC_DIR_PATH + 'points.shp') namedtransformstream[GeoData]
addcounter[JoinId_shp,1]
dbimport2(SRC_DIR_PATH + 'points.dbf')
addcounter[JoinId_dbf,1]
mergejoin[JoinId_shp,JoinId_dbf]
remove[JoinId_shp,JoinId_dbf]
filter[isdefined(.GeoData)]
filter[bbox(.GeoData) intersects PartRect]
consume;
# Creating a dummy-relation for restrictions (data on restrictions is
# unavailable in shape-files)
let RestrictionsTmp = [const rel(tuple ([Osm_id: int, From: int, Via: int,
To: int, Restriction: text]))
value ()];