| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- -- Defineerime tabeli teede jaoks
- local tables = {}
- -- Määrame skeemi keskkonnamuutujast või vaikimisi 'public'
- local schema = os.getenv("PGSCHEMA") or "public"
- -- Lubatud teede tüübid
- local allowed_types = {
- residential = true,
- primary = true,
- secondary = true,
- tertiary = true,
- secondary_link = true,
- primary_link = true,
- track = true,
- service = true,
- unclassified = true
- }
- tables.roads = osm2pgsql.define_way_table('roads', {
- { column = 'name', type = 'text' },
- { column = 'highway', type = 'text' },
- { column = 'surface', type = 'text' },
- { column = 'geom', type = 'linestring' }
- }, {
- schema = schema,
- proj = 3301
- })
- -- Töötleme teed (ways)
- function osm2pgsql.process_way(object)
- local highway = object.tags.highway
- -- Lisa ainult lubatud tüübid, millel on korrektne geomeetria
- if highway and highway ~= '' and allowed_types[highway] then
- local geom = object:as_linestring()
- if geom then
- tables.roads:insert({
- name = object.tags.name,
- highway = highway,
- surface = object.tags.surface,
- geom = geom
- })
- end
- end
- end
|