mirror of
https://github.com/osm2pgsql-dev/osm2pgsql.git
synced 2025-08-19 16:28:16 +00:00
@ -11,7 +11,7 @@ local srid = 4326
|
||||
local tables = {}
|
||||
|
||||
tables.points = osm2pgsql.define_node_table('points', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'point', projection = srid },
|
||||
{ column = 'version', type = 'int' },
|
||||
{ column = 'changeset', type = 'int' },
|
||||
@ -21,7 +21,7 @@ tables.points = osm2pgsql.define_node_table('points', {
|
||||
})
|
||||
|
||||
tables.lines = osm2pgsql.define_way_table('lines', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'linestring', projection = srid },
|
||||
{ column = 'version', type = 'int' },
|
||||
{ column = 'changeset', type = 'int' },
|
||||
@ -31,7 +31,7 @@ tables.lines = osm2pgsql.define_way_table('lines', {
|
||||
})
|
||||
|
||||
tables.relations = osm2pgsql.define_relation_table('relations', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'version', type = 'int' },
|
||||
{ column = 'changeset', type = 'int' },
|
||||
{ column = 'created', type = 'timestamp' },
|
||||
@ -48,7 +48,7 @@ function osm2pgsql.process_node(object)
|
||||
tags = object.tags,
|
||||
version = object.version,
|
||||
changeset = object.changeset,
|
||||
created = os.date('!%Y-%m-%dT%TZ', object.timestamp),
|
||||
created = os.date('!%Y-%m-%dT%H:%M:%SZ', object.timestamp),
|
||||
uid = object.uid,
|
||||
user = object.user
|
||||
})
|
||||
@ -59,7 +59,7 @@ function osm2pgsql.process_way(object)
|
||||
tags = object.tags,
|
||||
version = object.version,
|
||||
changeset = object.changeset,
|
||||
created = os.date('!%Y-%m-%dT%TZ', object.timestamp),
|
||||
created = os.date('!%Y-%m-%dT%H:%M:%SZ', object.timestamp),
|
||||
uid = object.uid,
|
||||
user = object.user
|
||||
})
|
||||
@ -70,7 +70,7 @@ function osm2pgsql.process_relation(object)
|
||||
tags = object.tags,
|
||||
version = object.version,
|
||||
changeset = object.changeset,
|
||||
created = os.date('!%Y-%m-%dT%TZ', object.timestamp),
|
||||
created = os.date('!%Y-%m-%dT%H:%M:%SZ', object.timestamp),
|
||||
uid = object.uid,
|
||||
user = object.user
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- This config example file is released into the Public Domain.
|
||||
|
||||
-- This is a very simple Lua config for the Flex Backend not intended for
|
||||
-- This is a very simple Lua config for the Flex output not intended for
|
||||
-- real-world use. Look at and understand "simple.lua" first, before looking
|
||||
-- at this file. This file demonstrates some column data type options.
|
||||
|
||||
@ -19,7 +19,7 @@ local highways = osm2pgsql.define_way_table('highways', {
|
||||
|
||||
-- type "bool" is special, see below
|
||||
{ column = 'lit', type = 'bool' },
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' }, -- also available: 'json', 'hstore'
|
||||
|
||||
-- an PostgreSQL array type, not specially handled by osm2pgsql, see below
|
||||
{ column = 'nodes', type = 'int8[]' },
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
-- This is a generic configuration that is a good starting point for
|
||||
-- real-world projects. Data is split into tables according to geometry type
|
||||
-- and most tags are stored in hstore columns.
|
||||
-- and most tags are stored in jsonb columns.
|
||||
|
||||
-- Set this to the projection you want to use
|
||||
local srid = 3857
|
||||
@ -10,28 +10,28 @@ local srid = 3857
|
||||
local tables = {}
|
||||
|
||||
tables.points = osm2pgsql.define_node_table('points', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'point', projection = srid },
|
||||
})
|
||||
|
||||
tables.lines = osm2pgsql.define_way_table('lines', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'linestring', projection = srid },
|
||||
})
|
||||
|
||||
tables.polygons = osm2pgsql.define_area_table('polygons', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'geometry', projection = srid },
|
||||
{ column = 'area', type = 'area' },
|
||||
})
|
||||
|
||||
tables.routes = osm2pgsql.define_relation_table('routes', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'multilinestring', projection = srid },
|
||||
})
|
||||
|
||||
tables.boundaries = osm2pgsql.define_relation_table('boundaries', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'multilinestring', projection = srid },
|
||||
})
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- This config example file is released into the Public Domain.
|
||||
|
||||
-- This is a very simple Lua config for the Flex Backend not intended for
|
||||
-- This is a very simple Lua config for the Flex output not intended for
|
||||
-- real-world use. Look at and understand "simple.lua" first, before looking
|
||||
-- at this file. This file will show some options around geometry processing.
|
||||
-- After you have understood this file, go on to "data-types.lua".
|
||||
@ -8,21 +8,21 @@
|
||||
local tables = {}
|
||||
|
||||
tables.pois = osm2pgsql.define_node_table('pois', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
-- Create a geometry column for point geometries. The geometry will be
|
||||
-- in web mercator, EPSG 3857.
|
||||
{ column = 'geom', type = 'point' },
|
||||
})
|
||||
|
||||
tables.ways = osm2pgsql.define_way_table('ways', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
-- Create a geometry column for linestring geometries. The geometry will
|
||||
-- be in latlong (WGS84), EPSG 4326.
|
||||
{ column = 'geom', type = 'linestring', projection = 4326 },
|
||||
})
|
||||
|
||||
tables.polygons = osm2pgsql.define_area_table('polygons', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'geometry' },
|
||||
-- The 'area' type is used to store the calculated area of a polygon
|
||||
-- feature. This can be used in style sheets to only render larger polygons
|
||||
@ -34,7 +34,7 @@ tables.polygons = osm2pgsql.define_area_table('polygons', {
|
||||
|
||||
tables.boundaries = osm2pgsql.define_relation_table('boundaries', {
|
||||
{ column = 'type', type = 'text' },
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
-- Boundaries will be stitched together from relation members into long
|
||||
-- linestrings. This is a multilinestring column because sometimes the
|
||||
-- boundaries are not contiguous.
|
||||
|
@ -12,7 +12,7 @@
|
||||
local tables = {}
|
||||
|
||||
tables.highways = osm2pgsql.define_way_table('highways', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'rel_refs', type = 'text' }, -- for the refs from the relations
|
||||
{ column = 'rel_ids', type = 'int8[]' }, -- array with integers (for relation IDs)
|
||||
{ column = 'geom', type = 'linestring' },
|
||||
@ -20,7 +20,7 @@ tables.highways = osm2pgsql.define_way_table('highways', {
|
||||
|
||||
-- Tables don't have to have a geometry column
|
||||
tables.routes = osm2pgsql.define_relation_table('routes', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
})
|
||||
|
||||
-- This will be used to store information about relations queryable by member
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- This config example file is released into the Public Domain.
|
||||
|
||||
-- This is a very simple Lua config for the Flex Backend not intended for
|
||||
-- This is a very simple Lua config for the Flex output not intended for
|
||||
-- real-world use. Use it do understand the basic principles of the
|
||||
-- configuration. After reading and understanding this, have a look at
|
||||
-- "geometries.lua".
|
||||
@ -24,7 +24,7 @@ local tables = {}
|
||||
-- "append" mode, osm2pgsql will automatically update this table using the node
|
||||
-- ids.
|
||||
tables.pois = osm2pgsql.define_node_table('pois', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'point' }, -- will be something like `GEOMETRY(Point, 4326)` in SQL
|
||||
})
|
||||
|
||||
@ -40,7 +40,7 @@ tables.restaurants = osm2pgsql.define_node_table('restaurants', {
|
||||
-- contain a "way_id" column. When running in "append" mode, osm2pgsql will
|
||||
-- automatically update this table using the way ids.
|
||||
tables.ways = osm2pgsql.define_way_table('ways', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'linestring' },
|
||||
})
|
||||
|
||||
@ -50,7 +50,7 @@ tables.ways = osm2pgsql.define_way_table('ways', {
|
||||
-- running in "append" mode, osm2pgsql will automatically update this table
|
||||
-- using the way/relation ids.
|
||||
tables.polygons = osm2pgsql.define_area_table('polygons', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
-- The type of the `geom` column is `geometry`, because we need to store
|
||||
-- polygons AND multipolygons
|
||||
{ column = 'geom', type = 'geometry' },
|
||||
@ -95,7 +95,7 @@ function osm2pgsql.process_node(object)
|
||||
})
|
||||
else
|
||||
tables.pois:add_row({
|
||||
-- We know `tags` is of type `hstore` so this will do the
|
||||
-- We know `tags` is of type `jsonb` so this will do the
|
||||
-- right thing.
|
||||
tags = object.tags
|
||||
})
|
||||
|
@ -12,8 +12,8 @@ local dtable = osm2pgsql.define_table{
|
||||
-- "osm_type CHAR(1)" for the type of object: N(ode), W(way), R(relation)
|
||||
ids = { type = 'any', id_column = 'osm_id', type_column = 'osm_type' },
|
||||
columns = {
|
||||
{ column = 'attrs', type = 'hstore' },
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'attrs', type = 'jsonb' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'geometry' },
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
-- This configuration for the flex output shows how to define a table in
|
||||
-- a PostgreSQL schema.
|
||||
--
|
||||
-- This config file expects that you have a schema called `myschema` in
|
||||
-- your database (created with something like `CREATE SCHEMA myschema;`).
|
||||
|
||||
local dtable = osm2pgsql.define_way_table('data', {
|
||||
{ column = 'tags', type = 'hstore' },
|
||||
{ column = 'tags', type = 'jsonb' },
|
||||
{ column = 'geom', type = 'geometry' },
|
||||
}, { schema = 'myschema' })
|
||||
|
||||
|
@ -98,8 +98,8 @@ if (HAVE_LUA)
|
||||
set_test(test-output-flex-way-relation-del)
|
||||
|
||||
set_test(test-output-flex-example-configs)
|
||||
set(FLEX_EXAMPLE_CONFIGS "compatible,data-types,generic,geometries,route-relations,simple,unitable")
|
||||
# places.lua not tested because it needs dkjson package
|
||||
set(FLEX_EXAMPLE_CONFIGS "attributes,compatible,data-types,generic,geometries,places,route-relations,simple,unitable")
|
||||
# with-schema.lua is not tested because it needs the schema created in the database
|
||||
set_tests_properties(test-output-flex-example-configs PROPERTIES ENVIRONMENT "EXAMPLE_FILES=${FLEX_EXAMPLE_CONFIGS}")
|
||||
endif()
|
||||
|
||||
|
Reference in New Issue
Block a user