mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-04 17:04:53 +02:00
add computing from osm history
This commit is contained in:
parent
da60f964ab
commit
66bbce5e85
13 changed files with 3921 additions and 0 deletions
3
counting_osm_objects/osm_data/empty.osm
Normal file
3
counting_osm_objects/osm_data/empty.osm
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<osm version="0.6" generator="empty">
|
||||
</osm>
|
110
counting_osm_objects/osm_data/style.lua
Normal file
110
counting_osm_objects/osm_data/style.lua
Normal file
|
@ -0,0 +1,110 @@
|
|||
local tables = {}
|
||||
|
||||
-- Table pour les bornes incendie
|
||||
tables.fire_hydrants = osm2pgsql.define_node_table('fire_hydrants', {
|
||||
{ column = 'id_column', type = 'id_type' },
|
||||
{ column = 'geom', type = 'point', projection = 4326 },
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'ref', type = 'text' },
|
||||
{ column = 'color', type = 'text' },
|
||||
{ column = 'insee', type = 'text' },
|
||||
})
|
||||
|
||||
-- Table pour les arbres
|
||||
tables.trees = osm2pgsql.define_node_table('trees', {
|
||||
{ column = 'id_column', type = 'id_type' },
|
||||
{ column = 'geom', type = 'point', projection = 4326 },
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'species', type = 'text' },
|
||||
{ column = 'height', type = 'text' },
|
||||
{ column = 'insee', type = 'text' },
|
||||
})
|
||||
|
||||
-- Table pour les bornes de recharge (nodes)
|
||||
tables.charging_stations = osm2pgsql.define_node_table('charging_stations', {
|
||||
{ column = 'id_column', type = 'id_type' },
|
||||
{ column = 'geom', type = 'point', projection = 4326 },
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'operator', type = 'text' },
|
||||
{ column = 'capacity', type = 'text' },
|
||||
{ column = 'insee', type = 'text' },
|
||||
})
|
||||
|
||||
-- Table pour les bornes de recharge (ways)
|
||||
tables.charging_stations_ways = osm2pgsql.define_way_table('charging_stations_ways', {
|
||||
{ column = 'id_column', type = 'id_type' },
|
||||
{ column = 'geom', type = 'linestring', projection = 4326 },
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'operator', type = 'text' },
|
||||
{ column = 'capacity', type = 'text' },
|
||||
{ column = 'insee', type = 'text' },
|
||||
})
|
||||
|
||||
-- Function to determine the INSEE code from multiple possible sources
|
||||
function get_insee_code(tags)
|
||||
-- Try to get INSEE code from different tags
|
||||
if tags['ref:INSEE'] then
|
||||
return tags['ref:INSEE']
|
||||
elseif tags['addr:postcode'] then
|
||||
-- French postal codes often start with the department code
|
||||
-- For example, 91150 is in department 91, which can help identify the INSEE code
|
||||
return tags['addr:postcode'] and string.sub(tags['addr:postcode'], 1, 2) .. "111"
|
||||
elseif tags['addr:city'] and tags['addr:city'] == 'Étampes' then
|
||||
-- If the city is Étampes, use the INSEE code 91111
|
||||
return "91111"
|
||||
else
|
||||
-- Default to 91111 (Étampes) for this specific use case
|
||||
-- In a production environment, you would use a spatial query to determine the INSEE code
|
||||
return "91111"
|
||||
end
|
||||
end
|
||||
|
||||
function osm2pgsql.process_node(object)
|
||||
-- Check for fire hydrants with different tagging schemes
|
||||
if object.tags.emergency == 'fire_hydrant' or object.tags.amenity == 'fire_hydrant' then
|
||||
tables.fire_hydrants:insert({
|
||||
tags = object.tags,
|
||||
ref = object.tags.ref,
|
||||
color = object.tags.color,
|
||||
insee = get_insee_code(object.tags)
|
||||
})
|
||||
end
|
||||
|
||||
-- Check for trees
|
||||
if object.tags.natural == 'tree' then
|
||||
tables.trees:insert({
|
||||
tags = object.tags,
|
||||
species = object.tags.species,
|
||||
height = object.tags.height,
|
||||
insee = get_insee_code(object.tags)
|
||||
})
|
||||
end
|
||||
|
||||
-- Check for charging stations
|
||||
if object.tags.amenity == 'charging_station' then
|
||||
tables.charging_stations:insert({
|
||||
tags = object.tags,
|
||||
operator = object.tags.operator,
|
||||
capacity = object.tags.capacity,
|
||||
insee = get_insee_code(object.tags)
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function osm2pgsql.process_way(object)
|
||||
-- Check for charging stations that might be mapped as ways
|
||||
if object.tags.amenity == 'charging_station' then
|
||||
tables.charging_stations_ways:insert({
|
||||
tags = object.tags,
|
||||
operator = object.tags.operator,
|
||||
capacity = object.tags.capacity,
|
||||
insee = get_insee_code(object.tags)
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function osm2pgsql.process_relation(object)
|
||||
return
|
||||
end
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue