Skip to content

Instantly share code, notes, and snippets.

@avin
Last active August 29, 2015 14:13
Show Gist options
  • Save avin/cae23f68637a7d66ac05 to your computer and use it in GitHub Desktop.
Save avin/cae23f68637a7d66ac05 to your computer and use it in GitHub Desktop.
Export data from OSM Rails_Port DB to PostGIS DB and reload renderd
#!/bin/bash
osmosis="/usr/local/bin/osmosis"
log="/tmp/openstreetmap2drsk_gis.log"
var_dir="/var/gis_update"
osm_new="${var_dir}/osm_new.osm"
osm_prev="${var_dir}/osm_prev.osm"
diff_api_changes="${var_dir}/diff_api_changes.osc"
need_to_render="${var_dir}/tiles_to_render.list"
# export current OSM db
${osmosis} --read-apidb host="localhost" database="osm" user="www-data" validateSchemaVersion=no --write-xml file="${osm_new}" &>> ${log}
# make diff file of OSM exports
rm ${diff_api_changes}
${osmosis} --read-xml ${osm_new} --read-xml ${osm_prev} --derive-change --write-xml-change ${diff_api_changes} &>> ${log}
mv ${osm_new} ${osm_prev}
# move OSM data to tile DB
osm2pgsql --append --style /usr/share/osm2pgsql/default.style --database gis --username www-data --prefix planet_osm --slim --cache 2048 --hstore ${diff_api_changes} &>> ${log}
# generate need_to_render list
cat /dev/null > ${need_to_render}
/usr/bin/osm2pgsql --database gis --prefix planet_osm -a --slim -e 15:15 -o ${need_to_render} ${diff_api_changes}
# apply need to render
cat ${need_to_render} | /usr/bin/render_expired --verbose --min-zoom=10 --max-zoom=18 -m default --touch-from=10 -s /var/run/renderd/renderd.sock
rm ${need_to_render}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment