Initial commit.
This commit is contained in:
51
script/contrib/CreateGeometryForWays.sql
Normal file
51
script/contrib/CreateGeometryForWays.sql
Normal file
@@ -0,0 +1,51 @@
|
||||
-------------------------------------------------------------------------------
|
||||
-- The following script creates a new table for the pgsql simple schema for
|
||||
-- storing full way geometries.
|
||||
--
|
||||
-- Author: Ralf
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
-- drop table if it exists
|
||||
DROP TABLE IF EXISTS way_geometry;
|
||||
|
||||
-- create table
|
||||
CREATE TABLE way_geometry(
|
||||
way_id bigint NOT NULL
|
||||
);
|
||||
-- add PostGIS geometry column
|
||||
SELECT AddGeometryColumn('', 'way_geometry', 'geom', 4326, 'GEOMETRY', 2);
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- the following might go into the POST_LOAD_SQL-array in the class "PostgreSqlWriter"??
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
-- add a linestring for every way (create a polyline)
|
||||
INSERT INTO way_geometry select id, ( select ST_LineFromMultiPoint( Collect(nodes.geom) ) from nodes
|
||||
left join way_nodes on nodes.id=way_nodes.node_id where way_nodes.way_id=ways.id ) FROM ways;
|
||||
|
||||
-- after creating a line for every way (polyline), we want closed ways to be stored as polygones.
|
||||
-- So we need to delete the previously created polylines for these ways first.
|
||||
DELETE FROM way_geometry WHERE way_id IN
|
||||
( SELECT ways.id FROM ways
|
||||
WHERE ST_IsClosed( (SELECT ST_LineFromMultiPoint( Collect(n.geom) ) FROM nodes n LEFT JOIN way_nodes wn ON n.id=wn.node_id WHERE ways.id=wn.way_id) )
|
||||
AND ST_NumPoints( (SELECT ST_LineFromMultiPoint( Collect(n.geom) ) FROM nodes n LEFT JOIN way_nodes wn ON n.id=wn.node_id WHERE ways.id=wn.way_id) ) >= 3
|
||||
)
|
||||
;
|
||||
|
||||
-- now we need to add the polyline geometry for every closed way
|
||||
INSERT INTO way_geometry SELECT ways.id,
|
||||
( SELECT ST_MakePolygon( ST_LineFromMultiPoint(Collect(nodes.geom)) ) FROM nodes
|
||||
LEFT JOIN way_nodes ON nodes.id=way_nodes.node_id WHERE way_nodes.way_id=ways.id
|
||||
)
|
||||
FROM ways
|
||||
WHERE ST_IsClosed( (SELECT ST_LineFromMultiPoint( Collect(n.geom) ) FROM nodes n LEFT JOIN way_nodes wn ON n.id=wn.node_id WHERE ways.id=wn.way_id) )
|
||||
AND ST_NumPoints( (SELECT ST_LineFromMultiPoint( Collect(n.geom) ) FROM nodes n LEFT JOIN way_nodes wn ON n.id=wn.node_id WHERE ways.id=wn.way_id) ) >= 3
|
||||
;
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
-- create index on way_geometry
|
||||
CREATE INDEX idx_way_geometry_way_id ON way_geometry USING btree (way_id);
|
||||
CREATE INDEX idx_way_geometry_geom ON way_geometry USING gist (geom);
|
4096
script/contrib/apidb_0.6.sql
Normal file
4096
script/contrib/apidb_0.6.sql
Normal file
File diff suppressed because it is too large
Load Diff
28
script/contrib/apidb_0.6_osmosis_xid_indexing.sql
Normal file
28
script/contrib/apidb_0.6_osmosis_xid_indexing.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- This script creates a function and indexes that allow osmosis to efficiently query based on transaction ids.
|
||||
CREATE OR REPLACE FUNCTION xid_to_int4(t xid)
|
||||
RETURNS integer AS
|
||||
$BODY$
|
||||
DECLARE
|
||||
tl bigint;
|
||||
ti int;
|
||||
BEGIN
|
||||
tl := t;
|
||||
|
||||
IF tl >= 2147483648 THEN
|
||||
tl := tl - 4294967296;
|
||||
END IF;
|
||||
|
||||
ti := tl;
|
||||
|
||||
RETURN ti;
|
||||
END;
|
||||
$BODY$
|
||||
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
|
||||
|
||||
|
||||
DROP INDEX IF EXISTS nodes_xmin_idx;
|
||||
DROP INDEX IF EXISTS ways_xmin_idx;
|
||||
DROP INDEX IF EXISTS relations_xmin_idx;
|
||||
CREATE INDEX nodes_xmin_idx ON nodes USING btree ((xid_to_int4(xmin)));
|
||||
CREATE INDEX ways_xmin_idx ON ways USING btree ((xid_to_int4(xmin)));
|
||||
CREATE INDEX relations_xmin_idx ON relations USING btree ((xid_to_int4(xmin)));
|
2
script/contrib/dump_apidb.sh
Executable file
2
script/contrib/dump_apidb.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
/usr/bin/pg_dump -O -v -f "apidb_0.6.sql" api06
|
37
script/contrib/replicate_osm_file.sh
Executable file
37
script/contrib/replicate_osm_file.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script automates the replication of changes into an offline osm file for a specific area of interest. This allows an up-to-date local snapshot of an area to be maintained.
|
||||
|
||||
# The name of the replicated file.
|
||||
OSM_FILE=myfile.osm.gz
|
||||
|
||||
# The name of the temp file to create during processing (Note: must have the same extension as OSM_FILE to ensure the same compression method is used.
|
||||
TEMP_OSM_FILE=tmp.osm.gz
|
||||
|
||||
# The directory containing the state associated with the --read-change-interval task previously initiated with the --read-change-interval-init task.
|
||||
WORKING_DIRECTORY=./
|
||||
|
||||
# The bounding box to maintain.
|
||||
LEFT=-180
|
||||
BOTTOM=-90
|
||||
RIGHT=180
|
||||
TOP=90
|
||||
|
||||
# The osmosis command.
|
||||
CMD="osmosis -q"
|
||||
|
||||
# Launch the osmosis process.
|
||||
$CMD --read-change-interval $WORKING_DIRECTORY --read-xml $OSM_FILE --apply-change --bounding-box left=$LEFT bottom=$BOTTOM right=$RIGHT top=$TOP --write-xml $TEMP_OSM_FILE
|
||||
|
||||
STATUS=$?
|
||||
|
||||
# Verify that osmosis ran successfully.
|
||||
if [ "$STATUS" -ne "0" ]; then
|
||||
|
||||
echo "Osmosis failed, aborting."
|
||||
exit $STATUS
|
||||
|
||||
fi
|
||||
|
||||
mv $TEMP_OSM_FILE $OSM_FILE
|
||||
|
Reference in New Issue
Block a user