Skip to content

Commit 076c0a8

Browse files
committed
updated 3dcitydb schema files
1 parent 7f1b1f9 commit 076c0a8

17 files changed

+345
-190
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://3dcitydb.org/json-schema/5.0/geometryProperties.schema.json",
4+
"title": "3DCityDB 5.0 geometry properties schema",
5+
"description": "Schema for the JSON column geometry_properties of the geometry_data table.",
6+
"type": "object",
7+
"properties": {
8+
"objectId": {
9+
"type": "string"
10+
},
11+
"is2D": {
12+
"type": "boolean",
13+
"default": false
14+
},
15+
"hierarchy": {
16+
"type": "array",
17+
"items": {
18+
"type": "object",
19+
"properties": {
20+
"type": {
21+
"type": "number",
22+
"minimum": 1,
23+
"maximum": 11
24+
},
25+
"objectId": {
26+
"type": "string"
27+
},
28+
"parent": {
29+
"type": "number"
30+
},
31+
"geometryIndex": {
32+
"type": "number"
33+
},
34+
"isReversed": {
35+
"type": "boolean",
36+
"default": false
37+
}
38+
},
39+
"additionalProperties": false
40+
},
41+
"additionalItems": false
42+
}
43+
},
44+
"additionalProperties": false
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://3dcitydb.org/json-schema/5.0/georeferencedTextureMapping.schema.json",
4+
"title": "3DCityDB 5.0 geo-referenced texture mapping schema",
5+
"description": "Schema for the JSON column georeferenced_texture_mapping of the surface_data_mapping table.",
6+
"type": "object",
7+
"additionalProperties": {
8+
"type": "boolean"
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://3dcitydb.org/json-schema/5.0/gtOrientation.schema.json",
4+
"title": "3DCityDB 5.0 geo-referenced texture orientation schema",
5+
"description": "Schema for the JSON column gt_orientation of the surface_data table.",
6+
"type": "array",
7+
"items": {
8+
"type": "number"
9+
},
10+
"minItems": 4,
11+
"maxItems": 4,
12+
"additionalItems": false
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://3dcitydb.org/json-schema/5.0/materialMapping.schema.json",
4+
"title": "3DCityDB 5.0 material mapping schema",
5+
"description": "Schema for the JSON column material_mapping of the surface_data_mapping table.",
6+
"type": "object",
7+
"additionalProperties": {
8+
"type": "boolean"
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://3dcitydb.org/json-schema/5.0/textureMapping.schema.json",
4+
"title": "3DCityDB 5.0 texture mapping schema",
5+
"description": "Schema for the JSON column texture_mapping of the surface_data_mapping table.",
6+
"type": "object",
7+
"additionalProperties": {
8+
"type": "array",
9+
"items": {
10+
"type": "array",
11+
"items": {
12+
"type": "array",
13+
"items": {
14+
"type": "number"
15+
},
16+
"minItems": 2,
17+
"maxItems": 2,
18+
"additionalItems": false
19+
},
20+
"additionalItems": false
21+
},
22+
"additionalItems": false
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://3dcitydb.org/json-schema/5.0/valArray.schema.json",
4+
"title": "3DCityDB 5.0 array value schema",
5+
"description": "Schema for the JSON column val_array of the property table.",
6+
"type": "array",
7+
"items": {
8+
"anyOf": [
9+
{
10+
"type": "integer"
11+
},
12+
{
13+
"type": "number"
14+
},
15+
{
16+
"type": "string"
17+
},
18+
{
19+
"type": "boolean"
20+
}
21+
]
22+
},
23+
"additionalItems": false
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://3dcitydb.org/json-schema/5.0/worldToTextureMapping.schema.json",
4+
"title": "3DCityDB 5.0 world-to-texture mapping schema",
5+
"description": "Schema for the JSON column world_to_texture_mapping of the surface_data_mapping table.",
6+
"type": "object",
7+
"additionalProperties": {
8+
"type": "array",
9+
"items": {
10+
"type": "number"
11+
},
12+
"minItems": 12,
13+
"maxItems": 12,
14+
"additionalItems": false
15+
}
16+
}

resources/3dcitydb/postgresql/SQLScripts/CITYDB_PKG/DELETE/DELETE.sql

+47-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* delete_feature(pid_array bigint[]) RETURNS SETOF BIGINT
77
* delete_feature(pid_array bigint[], schema_name TEXT) RETURNS SETOF BIGINT
88
* delete_feature(pid bigint, schema_name TEXT) RETURNS BIGINT
9+
* delete_property_row(pid_array bigint[]) RETURNS SETOF BIGINT
910
* delete_property(pid_array bigint[]) RETURNS SETOF BIGINT
1011
* delete_property(pid_array bigint[], schema_name TEXT) RETURNS SETOF BIGINT
1112
* delete_property(pid bigint, schema_name TEXT) RETURNS BIGINT
@@ -70,7 +71,7 @@ DECLARE
7071
deleted_ids bigint[] := '{}';
7172
BEGIN
7273
PERFORM
73-
citydb_pkg.delete_property(array_agg(p.id))
74+
citydb_pkg.delete_property_row(array_agg(p.id))
7475
FROM
7576
property p,
7677
unnest($1) a(a_id)
@@ -131,9 +132,9 @@ $body$
131132
LANGUAGE plpgsql STRICT;
132133

133134
/******************************************************************
134-
* delete from PROPERTY table based on an id array
135+
* delete single row from PROPERTY table based on an id array
135136
******************************************************************/
136-
CREATE OR REPLACE FUNCTION citydb_pkg.delete_property(bigint[]) RETURNS SETOF BIGINT AS
137+
CREATE OR REPLACE FUNCTION citydb_pkg.delete_property_row(bigint[]) RETURNS SETOF BIGINT AS
137138
$body$
138139
DECLARE
139140
deleted_ids bigint[] := '{}';
@@ -143,13 +144,13 @@ DECLARE
143144
appearance_ids bigint[] := '{}';
144145
address_ids bigint[] := '{}';
145146
BEGIN
146-
WITH child_refs AS (
147+
WITH property_ids AS (
147148
DELETE FROM
148149
property p
149150
USING
150151
unnest($1) a(a_id)
151152
WHERE
152-
p.root_id = a.a_id
153+
p.id = a.a_id
153154
RETURNING
154155
p.id,
155156
p.val_feature_id,
@@ -174,7 +175,7 @@ BEGIN
174175
appearance_ids,
175176
address_ids
176177
FROM
177-
child_refs
178+
property_ids
178179
WHERE
179180
val_feature_id IS NULL OR val_reference_type IS NULL OR val_reference_type = 1;
180181

@@ -223,6 +224,46 @@ END;
223224
$body$
224225
LANGUAGE plpgsql STRICT;
225226

227+
/******************************************************************
228+
* delete from PROPERTY table based on an id array
229+
******************************************************************/
230+
CREATE OR REPLACE FUNCTION citydb_pkg.delete_property(bigint[]) RETURNS SETOF BIGINT AS
231+
$body$
232+
DECLARE
233+
property_ids bigint[] := '{}';
234+
BEGIN
235+
WITH RECURSIVE child_refs AS (
236+
SELECT
237+
p.id
238+
FROM
239+
property p,
240+
unnest($1) a(a_id)
241+
WHERE
242+
p.id = a.a_id
243+
UNION ALL
244+
SELECT
245+
p.id
246+
FROM
247+
property p,
248+
child_refs c
249+
WHERE
250+
p.parent_id = c.id
251+
)
252+
SELECT
253+
array_agg(id)
254+
INTO
255+
property_ids
256+
FROM
257+
child_refs;
258+
259+
RETURN QUERY
260+
SELECT citydb_pkg.delete_property_row(property_ids)
261+
INTERSECT
262+
SELECT unnest($1);
263+
END;
264+
$body$
265+
LANGUAGE plpgsql STRICT;
266+
226267
/******************************************************************
227268
* delete from PROPERTY table based on an id array and schema name
228269
******************************************************************/

resources/3dcitydb/postgresql/SQLScripts/CITYDB_PKG/SRS/SRS.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* FUNCTIONS:
55
* change_column_srid(table_name TEXT, column_name TEXT, dim INTEGER, schema_srid INTEGER,
66
* transform INTEGER DEFAULT 0, geom_type TEXT DEFAULT 'GEOMETRY', schema_name TEXT DEFAULT 'citydb') RETURNS SETOF VOID
7-
* change_schema_srid(schema_srid INTEGER, schema_gml_srs_name TEXT,
7+
* change_schema_srid(schema_srid INTEGER, schema_srs_name TEXT,
88
* transform INTEGER DEFAULT 0, schema_name TEXT DEFAULT 'citydb') RETURNS SETOF VOID
99
* check_srid(srsno INTEGER DEFAULT 0) RETURNS TEXT
1010
* is_coord_ref_sys_3d(schema_srid INTEGER) RETURNS INTEGER
@@ -184,14 +184,14 @@ LANGUAGE plpgsql STRICT;
184184
*
185185
* @param schema_srid the SRID of the coordinate system to be
186186
* further used in the database
187-
* @param db_gml_srs_name the SRS_NAME of the coordinate system
187+
* @param schema_srs_name the SRS_NAME of the coordinate system
188188
* to be further used in the database
189189
* @param transform 1 if existing data shall be transformed, 0 if not
190-
* @param schema name name of schema
190+
* @param schema_name name of schema
191191
*******************************************************************/
192192
CREATE OR REPLACE FUNCTION citydb_pkg.change_schema_srid(
193193
schema_srid INTEGER,
194-
schema_gml_srs_name TEXT,
194+
schema_srs_name TEXT,
195195
transform INTEGER DEFAULT 0,
196196
schema_name TEXT DEFAULT 'citydb'
197197
) RETURNS SETOF VOID AS $$

resources/3dcitydb/postgresql/SQLScripts/CITYDB_PKG/UTIL/UTIL.sql

+3-20
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* OUT wktext TEXT,
1818
* OUT versioning TEXT
1919
* ) RETURNS RECORD
20-
* versioning_db(schema_name TEXT DEFAULT 'citydb') RETURNS TEXT
2120
* get_seq_values(seq_name TEXT, seq_count BIGINT) RETURNS SETOF BIGINT
2221
* drop_tmp_tables(schema_name TEXT DEFAULT 'citydb') RETURNS SETOF VOID
2322
******************************************************************/
@@ -62,8 +61,7 @@ CREATE OR REPLACE FUNCTION citydb_pkg.db_metadata(
6261
OUT srs_name TEXT,
6362
OUT coord_ref_sys_name TEXT,
6463
OUT coord_ref_sys_kind TEXT,
65-
OUT wktext TEXT,
66-
OUT versioning TEXT
64+
OUT wktext TEXT
6765
) RETURNS RECORD AS
6866
$$
6967
BEGIN
@@ -73,34 +71,19 @@ BEGIN
7371
d.srs_name,
7472
split_part(s.srtext, ''"'', 2),
7573
split_part(s.srtext, ''['', 1),
76-
s.srtext,
77-
citydb_pkg.versioning_db($1) AS versioning
74+
s.srtext
7875
FROM
7976
%I.database_srs d,
8077
spatial_ref_sys s
8178
WHERE
8279
d.srid = s.srid', schema_name)
8380
USING schema_name
84-
INTO srid, srs_name, coord_ref_sys_name, coord_ref_sys_kind, wktext, versioning;
81+
INTO srid, srs_name, coord_ref_sys_name, coord_ref_sys_kind, wktext;
8582
END;
8683
$$
8784
LANGUAGE plpgsql STABLE;
8885

8986

90-
/*****************************************************************
91-
* versioning_db
92-
*
93-
* @param schema_name name of schema
94-
*
95-
* @RETURN TEXT 'ON' for version-enabled, 'OFF' for version-disabled
96-
******************************************************************/
97-
CREATE OR REPLACE FUNCTION citydb_pkg.versioning_db(schema_name TEXT DEFAULT 'citydb') RETURNS TEXT AS
98-
$$
99-
SELECT 'OFF'::text;
100-
$$
101-
LANGUAGE sql IMMUTABLE;
102-
103-
10487
/*****************************************************************
10588
* get_sequence_values
10689
*

resources/3dcitydb/postgresql/SQLScripts/CREATE_DB.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
SET client_min_messages TO WARNING;
3030
\set ON_ERROR_STOP ON
3131

32-
\set SRSNO :srsno
33-
\set GMLSRSNAME :gmlsrsname
32+
\set SRID :srid
33+
\set SRS_NAME :srs_name
3434

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

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

0 commit comments

Comments
 (0)