Skip to content

Commit 7c86a00

Browse files
committed
Fix postgres
1 parent b84fbfa commit 7c86a00

4 files changed

Lines changed: 120 additions & 108 deletions

File tree

backends/postgres_osmosis.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@ cat /usr/share/doc/osmosis/examples/pgsnapshot_schema_0.6_linestring.sql | psql
1212
osmosis \
1313
--read-pbf /data/landes-latest.osm.pbf \
1414
--write-pgsql host=postgres database=postgres user=postgres password=postgres
15+
cat /backends/postgres_osmosis_init.sql | psql $DATABASE_URL
1516
```
1617

1718
```sql
18-
CREATE INDEX nodes_idx_tags ON nodes USING gist(tags) WHERE tags != ''::hstore;
19-
CREATE INDEX ways_idx_tags ON ways USING gist(tags) WHERE tags != ''::hstore;
20-
CREATE INDEX relations_idx_tags ON relations USING gist(tags) WHERE tags != ''::hstore;
21-
22-
CREATE INDEX ways_idx_geom ON nodes USING gist(geom);
23-
CREATE INDEX ways_idx_linestring ON ways USING gist(linestring);
2419
```
2520

2621
## Run the server

backends/postgres_osmosis.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ def exec(query)
1414
request = OverpassParser.parse(query)
1515
sql = request.to_sql(@dialect)
1616
result = @@con.exec(sql)
17-
[sql, result.collect { |row| row['j'] }]
17+
[sql, result.collect { |row| row['j'].gsub('+00:00', 'Z') }]
1818
end
1919
end

backends/postgres_osmosis.sql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
CREATE OR REPLACE TEMP VIEW node AS
2-
SELECT id, version, tstamp AS created, tags, NULL::bigint[] AS nodes, NULL::jsonb AS members, geom, 'n' AS osm_type FROM nodes;
2+
SELECT id, version, tstamp::timestamp with time zone AS created, tags, NULL::bigint[] AS nodes, NULL::jsonb AS members, geom, 'n' AS osm_type FROM nodes;
33

44
CREATE OR REPLACE TEMP VIEW way AS
5-
SELECT id, version, tstamp AS created, tags, nodes, NULL::jsonb AS members, linestring AS geom, 'w' AS osm_type FROM ways;
5+
SELECT id, version, tstamp::timestamp with time zone AS created, tags, nodes, NULL::jsonb AS members, linestring AS geom, 'w' AS osm_type FROM ways;
66

77
CREATE OR REPLACE TEMP VIEW relation AS
88
SELECT
99
id,
1010
version,
11-
tstamp AS created,
11+
tstamp::timestamp with time zone AS created,
1212
tags,
1313
NULL::bigint[] AS nodes,
1414
jsonb_agg(jsonb_build_object(
@@ -35,3 +35,9 @@ SELECT * FROM way
3535
UNION ALL
3636
SELECT * FROM relation
3737
;
38+
39+
CREATE OR REPLACE TEMP VIEW area AS
40+
SELECT id, NULL::integer AS version, NULL::timestamp with time zone AS created, tags, NULL::bigint[] AS nodes, NULL::jsonb AS members, poly AS geom, 'a' AS osm_type FROM multipolygons WHERE id > 3600000000
41+
UNION ALL
42+
SELECT id, version, tstamp::timestamp with time zone AS created, tags, nodes AS nodes, NULL::jsonb AS members, ST_MakePolygon(linestring)::geometry(Geometry,4326) AS geom, 'w' AS osm_type FROM ways WHERE id < 3600000000 AND ST_IsClosed(linestring) AND ST_Dimension(ST_MakePolygon(linestring)) = 2
43+
;

0 commit comments

Comments
 (0)