Cameras
Importer les données avec OSM2PGSQL
local cameras = osm2pgsql.define_node_table('cameras', {
{ column = 'id', sql_type = 'serial', create_only = true },
{ column = 'geom', type = 'point' },
})
local highways = osm2pgsql.define_way_table('highways', {
{ column = 'id', sql_type = 'serial', create_only = true },
{ column = 'geom', type = 'linestring' },
})
local buildings = osm2pgsql.define_area_table('buildings', {
{ column = 'id', sql_type = 'serial', create_only = true },
{ column = 'geom', type = 'polygon' },
})
function osm2pgsql.process_node(object)
if object.tags.man_made == 'surveillance' then
cameras:insert({
geom = object:as_point( )
})
end
end
function osm2pgsql.process_way(object)
if object.is_closed and object.tags.building then
buildings:insert({
geom = object:as_polygon()
})
end
if object.tags.highway then
highways:insert({
geom = object:as_linestring()
})
end
end
function osm2pgsql.process_relation(object)
if object.tags.type == 'multipolygon' and object.tags.building then
local geom = object:as_multipolygon()
for g in geom:geometries() do
buildings:insert({
geom = g,
})
end
end
end
osm2pgsql -d toto -U toto -W -H localhost -O flex -S extarct_features.lua st_quentin.osm.pbf
Utiliser postgis
Calculer une distance
with c1 as (select geom as g from cameras where id = 1), c2 as (select geom as g from cameras where id = 2) select ST_Distance(c1.g, c2.g) from c1, c2 ;
calculer les ways qui sont a moins de 100m d'une camera
select c.node_id, h.way_id from cameras c left join highways h on ST_DWithin(c.geom, h.geom, 100) where c.id = 1
Editer du pbf avec osmium
Convertis en format opl (format textuelle, éditable)
osmium cat st_quentin.osm.pbf -f opl > st_quentin.opl
L'inverse
osmium cat st_quentin.opl -f pbf > st_quentin.osm.pbf
Avoir un diff
osmium diff st_quentin.osm.pbf merge.osm.pbf -f opl > diff.txt
cat diff.txt | grep "^+" # ajout
cat diff.txt | grep "^-" # suppression
Appliquer un fichier de changeset (attention écrase toute la relation ou tout le noeud)
osmium apply-changes st_quentin.osm.pbf osmChange.xml -o new.osm.pbf