Update 'Dump OSM data to a postgis database'

Guillem Borrell Nogueras 2022-11-11 11:46:52 +01:00
parent b250fdcaf0
commit 328f276d07

@ -93,3 +93,20 @@ sudo -u postgres osm2pgsql --create --database pgsnapshot --cache 20000 --number
```
Then change the postgresql.conf and pg_hba.conf files to allow remote connections to the database.
## Interesting Postgis features
You can compute minimum distances with KNN as follows:
```
select
st_distance(st_transform(st_setsrid(st_point(-120, 12), 4326), 3857), way) as distance
from
public.planet_osm_roads
where
highway in ('motorway', 'trunk', 'primary', 'secondary')
order by
st_transform(st_setsrid(st_point(-120, 12), 4326), 3857) <-> way
limit
1
```