Skip to content

Commit

Permalink
updated 3dcitydb schema files
Browse files Browse the repository at this point in the history
  • Loading branch information
clausnagel committed Nov 30, 2023
1 parent 7f1b1f9 commit 076c0a8
Show file tree
Hide file tree
Showing 17 changed files with 345 additions and 190 deletions.
45 changes: 45 additions & 0 deletions resources/3dcitydb/json-schema/geometryProperties.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://3dcitydb.org/json-schema/5.0/geometryProperties.schema.json",
"title": "3DCityDB 5.0 geometry properties schema",
"description": "Schema for the JSON column geometry_properties of the geometry_data table.",
"type": "object",
"properties": {
"objectId": {
"type": "string"
},
"is2D": {
"type": "boolean",
"default": false
},
"hierarchy": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "number",
"minimum": 1,
"maximum": 11
},
"objectId": {
"type": "string"
},
"parent": {
"type": "number"
},
"geometryIndex": {
"type": "number"
},
"isReversed": {
"type": "boolean",
"default": false
}
},
"additionalProperties": false
},
"additionalItems": false
}
},
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://3dcitydb.org/json-schema/5.0/georeferencedTextureMapping.schema.json",
"title": "3DCityDB 5.0 geo-referenced texture mapping schema",
"description": "Schema for the JSON column georeferenced_texture_mapping of the surface_data_mapping table.",
"type": "object",
"additionalProperties": {
"type": "boolean"
}
}
13 changes: 13 additions & 0 deletions resources/3dcitydb/json-schema/gtOrientation.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://3dcitydb.org/json-schema/5.0/gtOrientation.schema.json",
"title": "3DCityDB 5.0 geo-referenced texture orientation schema",
"description": "Schema for the JSON column gt_orientation of the surface_data table.",
"type": "array",
"items": {
"type": "number"
},
"minItems": 4,
"maxItems": 4,
"additionalItems": false
}
10 changes: 10 additions & 0 deletions resources/3dcitydb/json-schema/materialMapping.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://3dcitydb.org/json-schema/5.0/materialMapping.schema.json",
"title": "3DCityDB 5.0 material mapping schema",
"description": "Schema for the JSON column material_mapping of the surface_data_mapping table.",
"type": "object",
"additionalProperties": {
"type": "boolean"
}
}
24 changes: 24 additions & 0 deletions resources/3dcitydb/json-schema/textureMapping.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://3dcitydb.org/json-schema/5.0/textureMapping.schema.json",
"title": "3DCityDB 5.0 texture mapping schema",
"description": "Schema for the JSON column texture_mapping of the surface_data_mapping table.",
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
},
"minItems": 2,
"maxItems": 2,
"additionalItems": false
},
"additionalItems": false
},
"additionalItems": false
}
}
24 changes: 24 additions & 0 deletions resources/3dcitydb/json-schema/valArray.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://3dcitydb.org/json-schema/5.0/valArray.schema.json",
"title": "3DCityDB 5.0 array value schema",
"description": "Schema for the JSON column val_array of the property table.",
"type": "array",
"items": {
"anyOf": [
{
"type": "integer"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"additionalItems": false
}
16 changes: 16 additions & 0 deletions resources/3dcitydb/json-schema/worldToTextureMapping.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://3dcitydb.org/json-schema/5.0/worldToTextureMapping.schema.json",
"title": "3DCityDB 5.0 world-to-texture mapping schema",
"description": "Schema for the JSON column world_to_texture_mapping of the surface_data_mapping table.",
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "number"
},
"minItems": 12,
"maxItems": 12,
"additionalItems": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* delete_feature(pid_array bigint[]) RETURNS SETOF BIGINT
* delete_feature(pid_array bigint[], schema_name TEXT) RETURNS SETOF BIGINT
* delete_feature(pid bigint, schema_name TEXT) RETURNS BIGINT
* delete_property_row(pid_array bigint[]) RETURNS SETOF BIGINT
* delete_property(pid_array bigint[]) RETURNS SETOF BIGINT
* delete_property(pid_array bigint[], schema_name TEXT) RETURNS SETOF BIGINT
* delete_property(pid bigint, schema_name TEXT) RETURNS BIGINT
Expand Down Expand Up @@ -70,7 +71,7 @@ DECLARE
deleted_ids bigint[] := '{}';
BEGIN
PERFORM
citydb_pkg.delete_property(array_agg(p.id))
citydb_pkg.delete_property_row(array_agg(p.id))
FROM
property p,
unnest($1) a(a_id)
Expand Down Expand Up @@ -131,9 +132,9 @@ $body$
LANGUAGE plpgsql STRICT;

/******************************************************************
* delete from PROPERTY table based on an id array
* delete single row from PROPERTY table based on an id array
******************************************************************/
CREATE OR REPLACE FUNCTION citydb_pkg.delete_property(bigint[]) RETURNS SETOF BIGINT AS
CREATE OR REPLACE FUNCTION citydb_pkg.delete_property_row(bigint[]) RETURNS SETOF BIGINT AS
$body$
DECLARE
deleted_ids bigint[] := '{}';
Expand All @@ -143,13 +144,13 @@ DECLARE
appearance_ids bigint[] := '{}';
address_ids bigint[] := '{}';
BEGIN
WITH child_refs AS (
WITH property_ids AS (
DELETE FROM
property p
USING
unnest($1) a(a_id)
WHERE
p.root_id = a.a_id
p.id = a.a_id
RETURNING
p.id,
p.val_feature_id,
Expand All @@ -174,7 +175,7 @@ BEGIN
appearance_ids,
address_ids
FROM
child_refs
property_ids
WHERE
val_feature_id IS NULL OR val_reference_type IS NULL OR val_reference_type = 1;

Expand Down Expand Up @@ -223,6 +224,46 @@ END;
$body$
LANGUAGE plpgsql STRICT;

/******************************************************************
* delete from PROPERTY table based on an id array
******************************************************************/
CREATE OR REPLACE FUNCTION citydb_pkg.delete_property(bigint[]) RETURNS SETOF BIGINT AS
$body$
DECLARE
property_ids bigint[] := '{}';
BEGIN
WITH RECURSIVE child_refs AS (
SELECT
p.id
FROM
property p,
unnest($1) a(a_id)
WHERE
p.id = a.a_id
UNION ALL
SELECT
p.id
FROM
property p,
child_refs c
WHERE
p.parent_id = c.id
)
SELECT
array_agg(id)
INTO
property_ids
FROM
child_refs;

RETURN QUERY
SELECT citydb_pkg.delete_property_row(property_ids)
INTERSECT
SELECT unnest($1);
END;
$body$
LANGUAGE plpgsql STRICT;

/******************************************************************
* delete from PROPERTY table based on an id array and schema name
******************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* FUNCTIONS:
* change_column_srid(table_name TEXT, column_name TEXT, dim INTEGER, schema_srid INTEGER,
* transform INTEGER DEFAULT 0, geom_type TEXT DEFAULT 'GEOMETRY', schema_name TEXT DEFAULT 'citydb') RETURNS SETOF VOID
* change_schema_srid(schema_srid INTEGER, schema_gml_srs_name TEXT,
* change_schema_srid(schema_srid INTEGER, schema_srs_name TEXT,
* transform INTEGER DEFAULT 0, schema_name TEXT DEFAULT 'citydb') RETURNS SETOF VOID
* check_srid(srsno INTEGER DEFAULT 0) RETURNS TEXT
* is_coord_ref_sys_3d(schema_srid INTEGER) RETURNS INTEGER
Expand Down Expand Up @@ -184,14 +184,14 @@ LANGUAGE plpgsql STRICT;
*
* @param schema_srid the SRID of the coordinate system to be
* further used in the database
* @param db_gml_srs_name the SRS_NAME of the coordinate system
* @param schema_srs_name the SRS_NAME of the coordinate system
* to be further used in the database
* @param transform 1 if existing data shall be transformed, 0 if not
* @param schema name name of schema
* @param schema_name name of schema
*******************************************************************/
CREATE OR REPLACE FUNCTION citydb_pkg.change_schema_srid(
schema_srid INTEGER,
schema_gml_srs_name TEXT,
schema_srs_name TEXT,
transform INTEGER DEFAULT 0,
schema_name TEXT DEFAULT 'citydb'
) RETURNS SETOF VOID AS $$
Expand Down
23 changes: 3 additions & 20 deletions resources/3dcitydb/postgresql/SQLScripts/CITYDB_PKG/UTIL/UTIL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* OUT wktext TEXT,
* OUT versioning TEXT
* ) RETURNS RECORD
* versioning_db(schema_name TEXT DEFAULT 'citydb') RETURNS TEXT
* get_seq_values(seq_name TEXT, seq_count BIGINT) RETURNS SETOF BIGINT
* drop_tmp_tables(schema_name TEXT DEFAULT 'citydb') RETURNS SETOF VOID
******************************************************************/
Expand Down Expand Up @@ -62,8 +61,7 @@ CREATE OR REPLACE FUNCTION citydb_pkg.db_metadata(
OUT srs_name TEXT,
OUT coord_ref_sys_name TEXT,
OUT coord_ref_sys_kind TEXT,
OUT wktext TEXT,
OUT versioning TEXT
OUT wktext TEXT
) RETURNS RECORD AS
$$
BEGIN
Expand All @@ -73,34 +71,19 @@ BEGIN
d.srs_name,
split_part(s.srtext, ''"'', 2),
split_part(s.srtext, ''['', 1),
s.srtext,
citydb_pkg.versioning_db($1) AS versioning
s.srtext
FROM
%I.database_srs d,
spatial_ref_sys s
WHERE
d.srid = s.srid', schema_name)
USING schema_name
INTO srid, srs_name, coord_ref_sys_name, coord_ref_sys_kind, wktext, versioning;
INTO srid, srs_name, coord_ref_sys_name, coord_ref_sys_kind, wktext;
END;
$$
LANGUAGE plpgsql STABLE;


/*****************************************************************
* versioning_db
*
* @param schema_name name of schema
*
* @RETURN TEXT 'ON' for version-enabled, 'OFF' for version-disabled
******************************************************************/
CREATE OR REPLACE FUNCTION citydb_pkg.versioning_db(schema_name TEXT DEFAULT 'citydb') RETURNS TEXT AS
$$
SELECT 'OFF'::text;
$$
LANGUAGE sql IMMUTABLE;


/*****************************************************************
* get_sequence_values
*
Expand Down
8 changes: 4 additions & 4 deletions resources/3dcitydb/postgresql/SQLScripts/CREATE_DB.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
SET client_min_messages TO WARNING;
\set ON_ERROR_STOP ON

\set SRSNO :srsno
\set GMLSRSNAME :gmlsrsname
\set SRID :srid
\set SRS_NAME :srs_name

--// check if the PostGIS extension is available
SELECT postgis_lib_version() AS postgis_version;
Expand Down Expand Up @@ -79,8 +79,8 @@ ALTER DATABASE :"DBNAME" SET search_path TO citydb, citydb_pkg, :current_path;
--// checks if the chosen SRID is provided by the spatial_ref_sys table
\echo
\echo 'Checking spatial reference system ...'
SELECT citydb_pkg.check_srid(:SRSNO);
SELECT citydb_pkg.check_srid(:SRID);

\echo 'Setting spatial reference system of 3DCityDB instance ...'
SELECT citydb_pkg.change_schema_srid(:SRSNO,:'GMLSRSNAME');
SELECT citydb_pkg.change_schema_srid(:SRID,:'SRS_NAME');
\echo 'Done'
Loading

0 comments on commit 076c0a8

Please sign in to comment.