You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|**`get_feature_envelope`**<br/> `(fid BIGINT, compute_envelope INTEGER, set_envelope INTEGER, schema_name TEXT)`|`GEOMETRY`| Returns the envelope geometry of a given feature |
155
+
|**`get_feature_envelope`**<br/> `(fid BIGINT, schema_name TEXT, compute_envelope INTEGER, set_envelope INTEGER)`|`GEOMETRY`| Returns the envelope geometry of a given feature |
156
156
|**`get_implicit_geometry_envelope`**<br/> `(gid BIGINT, ref_pt GEOMETRY, matrix JSON, schema_name TEXT)`|`GEOMETRY`| Returns the envelope geometry of a given implicit geometry |
157
157
|**`get_envelope`**<br/> `(geom GEOMETRY, schema_name TEXT)`|`GEOMETRY`| Computes the envelope geometry for a given geometry |
158
-
|**`get_envelope`**<br/> `(box BOX3D, schema_name TEXT)`|`GEOMETRY`| Converts a BOX3D geometry to an envelope geometry |
159
-
|**`get_envelope`**<br/> `(geom1 GEOMETRY, geom2 GEOMETRY, schema_name TEXT)`|`GEOMETRY`| Computes the envelope geometry for two geometries |
160
158
161
159
The `get_feature_envelope` function returns the envelope of a feature. The feature's primary key `id` must be
162
160
provided as input. When the `compute_envelope` parameter is set to `0` (default), the envelope currently stored in the
@@ -167,30 +165,29 @@ encloses the feature, and it can be directly used as the value for the `envelope
167
165
168
166
The `get_feature_envelope` function offers two more optional parameters: The `set_envelope` parameter specifies whether the
169
167
computed envelopes should be used to update the `envelope` columns of the feature and its subfeatures (`1` for true, `0` for
170
-
false; default: `0`). The `schema_name` parameter defines the target database schema to operate in, as explained above
171
-
(default: `citydb`).
168
+
false; default: `0`). The `schema_name` parameter defines the target database schema to operate in, as explained
|**`change_schema_srid`**<br/>`(target_srid INTEGER, target_srs_name TEXT, transform INTEGER, schema_name TEXT)`|`SETOF VOID`| Updates the coordinate system for a database schema |
193
-
|**`change_column_srid`**<br/>`(table_name TEXT, column_name TEXT, dim INTEGER, target_srid INTEGER, transform INTEGER, geom_type TEXT, schema_name TEXT)`|`SETOF VOID`| Updates the coordinate system for a geometry column |
189
+
|**`change_schema_srid`**<br/>`(target_srid INTEGER, target_srs_name TEXT, schema_name TEXT, transform INTEGER)`|`SETOF VOID`| Updates the coordinate system for a database schema |
190
+
|**`change_column_srid`**<br/>`(table_name TEXT, column_name TEXT, dim INTEGER, target_srid INTEGER, schema_name TEXT, transform INTEGER, geom_type TEXT)`|`SETOF VOID`| Updates the coordinate system for a geometry column |
194
191
|**`check_srid`**<br/>`(srid INTEGER)`|`INTEGER`| Checks if a given `SRID` is valid |
195
192
|**`is_coord_ref_sys_3d`**<br/>`(srid INTEGER)`|`INTEGER`| Checks if a a CRS is a true 3D system |
196
193
|**`is_db_coord_ref_sys_3d`**<br/>`(schema_name TEXT)`|`INTEGER`| Checks if the CRS of the 3DCityDB is true 3D system |
@@ -220,9 +217,42 @@ table with the new values.
220
217
221
218
The `citydb_pkg` package also provides various utility functions as shown below.
|**`citydb_version`**<br/>`(OUT version TEXT, OUT major_version INTEGER, OUT minor_version INTEGER, OUT minor_revision INTEGER)`|`RECORD`| Returns the version of the 3DCityDB instance |
226
-
|**`db_metadata`**<br/>`(schema_name TEXT, OUT srid INTEGER, OUT srs_name TEXT, OUT coord_ref_sys_name TEXT, OUT coord_ref_sys_kind TEXT, OUT wktext TEXT, OUT versioning TEXT)`|`RECORD`| Returns meta information about the 3DCityDB instance |
227
-
|**`get_seq_values`**<br/>`(seq_name TEXT, seq_count BIGINT)`|`SETOF BIGINT`| Returns `n` sequence values from the given sequence |
228
-
|**`get_child_objectclass_ids`**<br/>`(class_id INTEGER, skip_abstract INTEGER, schema_name TEXT)`|`SETOF INTEGER`| Returns the `id` values of all transitive subclasses of the given object class |
|**`citydb_version`**<br/>`(OUT version TEXT, OUT major_version INTEGER, OUT minor_version INTEGER, OUT minor_revision INTEGER)`|`RECORD`| Returns the version of the 3DCityDB instance |
223
+
|**`db_metadata`**<br/>`(schema_name TEXT, OUT srid INTEGER, OUT srs_name TEXT, OUT coord_ref_sys_name TEXT, OUT coord_ref_sys_kind TEXT, OUT wktext TEXT, OUT versioning TEXT)`|`RECORD`| Returns meta information about the 3DCityDB instance |
224
+
|**`get_seq_values`**<br/>`(seq_name TEXT, seq_count BIGINT)`|`SETOF BIGINT`| Returns `n` sequence values from the given sequence |
225
+
|**`get_child_objectclass_ids`**<br/>`(class_id INTEGER, schema_name TEXT, skip_abstract INTEGER)`|`SETOF INTEGER`| Returns the `id` values of all transitive subclasses of the given object class |
226
+
|**`get_current_schema`**() |`TEXT`| Returns the name of the active 3DCityDB schema as determined by the current `search_path`|
227
+
|**`set_current_schema`**<br/>`(schema_name TEXT, local BOOLEAN)`|`SETOF VOID`| Sets the active 3DCityDB schema to the specified name by adjusting the `search_path`|
228
+
229
+
The functions `get_current_schema` and `set_current_schema` simplify managing the active 3DCityDB schema. While `get_current_schema`
230
+
returns the schema currently set in the `search_path`, `set_current_schema` updates it to the specified name. The
231
+
`local` parameter controls the scope of the change: when set to true (default), it applies the current transaction only;
232
+
when false, it applies to the entire session until explicitly changed. Additionally, `set_current_schema` automatically
233
+
includes required schemas like `citydb_pkg` and `public`.
234
+
235
+
## Applying functions to different schemas
236
+
237
+
The 3DCityDB supports using multiple data schemas within the same PostgreSQL database. The default schema
238
+
is named `citydb`, while additional schemas can be freely named by the user. A setup script to create additional data
239
+
schemas is included in the 3DCityDB software package and is documented [here](db-scripts.md#shell-scripts).
240
+
241
+
Most of the database functions described in this chapter accept an optional `schema_name` parameter to specify the
242
+
target schema. If this parameter is provided, the function temporarily sets the database `search_path` to the given
243
+
schema, making it the active schema for that operation. This change to the `search_path` applies only for the duration
244
+
of the current transaction — not the entire session. This ensures that any change to the `search_path` remains isolated
245
+
and does not affect other operations outside the transaction, helping to avoid unintended side effects.
246
+
247
+
If `schema_name` is omitted, the function uses the schema currently set in the `search_path`. This offers
248
+
flexibility, allowing users to configure the search path according to their needs before calling any 3DCityDB
249
+
database functions.
250
+
251
+
!!! note
252
+
When setting up a 3DCityDB instance, the default schema is always `citydb`. If you are not working with multiple schemas, you
253
+
can simply omit the `schema_name` parameter when calling functions — they will automatically operate on the `citydb` schema.
254
+
For most users, this is the default and recommended approach for invoking the database functions.
255
+
256
+
!!! tip
257
+
The utility functions `get_current_schema` and `set_current_schema` (see [above](#utility-functions)) are especially useful
258
+
for users who prefer not to manage the `search_path` manually.
0 commit comments