2023-xx-xx TO DO
----------
Test whether it makes sense to add "hard-coded" bbox filter also to views.
Test whether it makes sense to add an update statement to delete trigger functions to reduce number of features in table layer metadata

2025-01-23
----------
Version 0.10.6
Fixed functions to work with PostgreSQL 17
Fixed bug in function [qgis_pkg.generate_sql_layers_bridge(...)]

2024-12-23
----------
Version 0.10.5
Fixed bug in function [qgis_pkg.generate_sql_layers_vegetation(...)]
Fixed bugs in function [qgis_pkg.generate_sql_layers_transportation(...)]

2023-11-19
----------
Version 0.10.4
Function [qgis_pkg.compute_bbox_extents(...)] no more rounds coordinates
Fixed bug in delete trigger functions for Solitary Vegetation Object and Plant Cover
Fixed bugs in delete and update trigger functions for WaterSurface

2023-10-31
----------
Version 0.10.3
Fixed minor bugs in function [qgis_pkg.grant_qgis_usr_privileges(...)]

2023-08-28
----------
Version 0.10.2
Some code restructuring
Waterdoby module:
	- Added support for MultiCurve LoD0-1 layers
	- Added codelist values
Fixed minor bugs in Vegetation and Transportation modules
Fixed a bug in function [qgis_pkg.list_feature_types(...)]

2023-03-29
----------
Version 0.10.1
Fixed bug in function [qgis_pkg.grant_qgis_usr_privileges(...)]
Slightly reworked table qgis_pkg.enum_lookup_config

2023-03-20
----------
Version 0.10
Improved support for bboxes with geographic coordinates
Improved speed of some functions dealing with bboxes and count()
Added support for Detail Views
	- Create Detail Views as updatable views
	- Add triggers and trigger functions accordingly
Extended/restructured table layer_extents
Added tables for enum and codelist configuration
Changed layer generation functions to add metadata for enums and codelists
Added functions
	- [qgis_pkg.list_ades()]
	- [qgis_pkg.drop_ga_indices(...)]
	- [qgis_pkg.compute_schemas_disk_size()]
	- [qgis_pkg.list_cdb_schemas_n_feats()]
	- [qgis_pkg.list_cdb_schemas_privs_n_feats()]
Updated functions:
	- [qgis_pkg.list_cdb_schemas()]
	- [qgis_pkg.list_cdb_schemas_privs()]
	- [qgis_pkg.add_ga_indices(...)]
	- [qgis_pkg.create_qgis_user_schema(...)]
	- [qgis_pkg.compute_cdb_schema_extents(...)]
	- [qgis_pkg.root_class_checker(...)]
	- [qgis_pkg.root_class_counter(...)]
	- [qgis_pkg.feature_type_checker(...)]
	- [qgis_pkg.feature_type_counter(...)]
	- [qgis_pkg.has_layer_support(...)]

2023-02-20
----------
Version 0.9.1
Solved bug: Function qgis_pkg.cleanup_schema() now really resets sequences

2023-02-10
----------
Version 0.9.0
Reordered order of sql files to install
Enhanced functions to deal with user privileges
Added functions to allow for selection of features types and root-class features
Minor code clean-up and bug fixes

2022-11-13
----------
Version 0.8.0
Fixed bug in trigger functions to extract the name of the cdb_schema
Script 030:
	- Updated/rewritten functions
		[qgis_pkg.list_cdb_schemas(...)]
		[qgis_pkg.compute_cdb_schema_extents(...)]
		[qgis_pkg.upsert_extents(...)]		
	- Renamed function [qgis_pkg.support_for_schema(...)] to  [qgis_pkg.has_layers_for_cdb_schema(...)]
Scripts 080-170:
	- Renamed some attribute forms and added news for new features
	- Added layer support for
		Terrain Intersection Curve (bridge, building, tunnel, generics, city_furniture)
		Multi_Curve geometries (bridge, building, tunnel)
		MasspointRelief (multipoint), BreaklinesRelief (multilinestring)
Minor code clean-up and bug fixes

2022-06-02
----------
Version 0.7.0
Fixed bug in function to upsert extents
Updated layer generator functions with new qlm form names

2022-05-27
----------
Version 0.6.5
Added Foreing Key constraints to enumeration and codelists tables
Added codelists values for Dutch BAG (building functions)

2022-05-25
----------
Version 0.6.4
Minor improvements to functions to grant and revoke privileges to users

2022-05-18
----------
Version 0.6.3
Readded REVOKE statements to all functions
Read SRID from selected cdb_schema instead of default citydb
Script 030:
	- Added function [qgis_pkg.is_superuser()]
	- Improved function [qgis_pkg.view_counter()]
Minor bug fixes

2022-05-10
----------
Version 0.6.2
Script 030:
	Function [qgis_pkg.list_cdb_schemas()]: added argument to optionally output only non-empty cdb_schemas
	Function [qgis_pkg.create_qgis_user_schema()] solved problem with sequences not being updated to currval

2022-04-16
----------
Version 0.6.1
Added "DELETE FROM LAYER_MEDATADA ..." for functions that drop layers
Improved function [qgis_pkg.qgis_pkg_version()] with codename and release_date
Inverted order of input parameters of function [qgis_pkg.support_for_schema()]

2022-04-14
----------
Version 0.6.0
Made functions to drop and refresh layers compatible with usr_schema names with "_"
Cleaned up a bit some code

2022-04-11
----------
MAJOR UPDATE -> Version 0.5.0
Major code restructuring with some bug fixes.
Added header and copyright notice to each file.
Renumbered sql files.
Renamed all [sql_generator_xx()] [functions to generate_sql_xx()]
Script: 
Script 070: Added scripts to create/refresh/drop layer functions
	- Drop functions can handle up to one cdb_schema at once (circa max 520 layers)
Scripts 080-170: Cleaned up code of layer generation functions
	- Switched order of first 2 input parameters
	- Added controls for usr_name, cdb_schema validity
Script 180:
	- Finalise install, add default users

2022-04-06
----------
MAJOR UPDATE -> Version 0.4.0
Merged script 015 back into 010
Script 010 Renamed "template" objects in qgis_pkg to *_template
Script 020
	- Added/updated functions to activate multi-user, with different privileges
	- Added  functions:
		[qgis_pkg.list_cdb_schemas()]
		[qgis_pkg.list_qgis_pkg_usrgroup_members()]
		[qgis_pkg.grant_qgis_usr_privileges()]
		[qgis_pkg.revoke_qgis_usr_privileges()]
	- Added some [qgis_pkg.sql_generator_xx()] functions
Scripts 2xx
	- Code restructuring
	- Functions renamed to qgis_pkg.sql_generator_layer_xx
	- Function made safe for SQL identifiers that need to be quoted
Minor updates and buxfixes

2022-03-29
----------
Added script 210 for layer generation of bridge module
Added script 250 for layer generation of tunnel module
Minor updates and buxfixes for remaining layer generation functions

2022-03-28
----------
Added script 220 for layer generation of building module

2022-03-25
----------
Script 020:
	- Added function [qgis_pkg.generate_mview_bbox_poly()]
Scripts 2xx
	- Updated existing scripts to handle bbox as array for corner coordinates

2022-03-19
----------
Script 020:
	- Drop unused functions.
	In functions 'upsert_extents' and 'compute_schema_extents':
	- Set checking constraint name to 'extents_cdb_schema_bbox_type_key'.
	In function 'view_counter':
	- Replace 'view' input param to 'mview'. 

2022-03-18
----------
Script 010:
	- Dropped column "schema_name" from all tables, now it is "cdb_schema"
	- All functions use the new column
Script 020:
	- Made functions in script 020 user_schema-aware
	- Renamed some parameters for consistency
	- Integrated functions from script 200
Script 200: dropped
Scripts for layer generation:
	- Small updates and debugging

2022-03-10
----------
All scripts are now prefixed with 3 digits
New names for variables: cty_schema, usr_name and usr_schema. schema_name mostly dropped everywhere.
For compatibility reasons, schema_name column is temporarily still in table layer_metadata
Fixed/improved generation of implicit geometries in m_views.
Added support for user-defined schemas. At the moment only "qgis_user"
	- Tables [layer_metadata], [extents], and for [enumerations] and [codelists] 
		are created	for each user schema
	- Added function [qgis_pkg.create_qgis_user_schema()]
Script 010-015
	- Dropped "old" way of defining serial types in tables
	- Fixed views for enumerations and codelists
Scripts 070 and 080 are now obsolete
Script 200 contains additional functions (to be merged into script 020)
Scripts 210...340 contain new [qgis_pkg.create_layers_xx()] functions
	- Functions correspond to CityGML modules
	- They are cdb_schema- and usr_schema-aware
	- Currently: CityFurniture, Generics, LandUse, Vegetation, Relief are done

2022-03-08
----------
Script 20: 
	- Renamed function [qgis_pkg.snap_poly_to_grid()] to [qgis_pkg.ST_Snap_poly_to_grid()]
	- Script 70 adapted accordingly
	- Added function [qgis_pkg.drop_layers()]
Script 70: Added mviews for remaining modules (Bridge, Tunnel, Transportation)
Script 80: Added mviews for remaining modules (Bridge, Tunnel, Transportation)
Corrected some bugs in update trigger functions (bdg thematic surfaces, tin relief)
Added (for now empty) columns for usr_name and usr_schema to tables [layer_metadata] and [extents]

2022-02-24
----------
Added script 15 (Look-up tables revised):
	Created tables [gis_pkg.codelist,gis_pkg.codelist_value,gis_pkg.enumeration, gis_pkg.enumeration_value]
	Created views [gis_pkg.v_codelist_value, gis_pkg.v_enumeration_value]
	Work in progress to reduce the number of look-up tables, lu_tables are still loaded in parallel
Script 20: Merged and harmonises Kostantinos' functions.

2022-02-22
----------
Script 30: Added remaining types. Now COMPLETE. Some unnecessary commented out.
Script 40: Added remaining upd_t-functions. Now COMPLETE, some unnecessary left out.
Script 50:
	DDL generation is now dynamic.
	Added remaining upd_v-functions. Now COMPLETE, some unnecessary left out.
Script 60:
	DDL generation is now dynamic.
	Added remaining trigger functions. Now COMPLETE, some unnecessary left out.
Script 80: Added more triggers

2022-02-18
----------
Script 10: Added table [qgis_pkg.extents]
Script 20: 
	Added function [qgis_pkg.compute_schema_extents()]
		Computes the extents of the whole city model in the chosed citydb schema
	Added function [qgis_pkg.upsert_extents()]
		Perform upsert operation on table [qgis_pkg.extents] to store the envelope values
	Added functions [qgis_pkg.create_mviews()] and [qgis_pkg.create_updatable_views()]
Script 70:
	Added mviews for WaterBody module
	Added code stubs for Transportation module (currently deactivated)
Script 80:
	Added views for WaterBody module
Script 90: Reworked and added more examples to install (m)views dynamically

2022-02-17
----------
Restructured file contents:
	10: Create schema qgis_pkg, create tables and look-up tables
	20: Create functions to be stored in schema qgis_pkg
	30: Create types corresponding to the 3DCityDB tables
	40: Update t(able) functions
	50: Update v(view) functions
	60: Trigger functions (insert, update, delete)
	70: DDL generation for materialized views
	80: DDL generation for views and triggers
	90: Miscellaneous (e.g. run function to refresh materialised views)
Reworked and improved metadata table for materialised views [qgis_pkg.layer_metadata]
Renamed and improved function [qgis_pkg.refresh_mview()]
	Improvements to better show partial and total elapsed time to refresh materialised views
	Count features for each materialised view and updates table [qgis_pkg.layer_metadata] 
Added function [qgis_pkg.ST_Area3d_poly()] to compute 3D area of polygons, independent from SFCGDAL 
Upgraded PostGIS' [ST_SnapToGrid()] function with own [qgis_pkg.snap_poly_to_grid()]
	Option to "do nothing"
	Option to set number of significant digits to round coordinates
	Option to set minimum area of polygons to be ignored
Upgraded scripts in 07 & 08 to generate DDL dynamically based on the chosen citydb schema
Upgraded scripts in 07: Major rework of the whole script structure
	Rewritten and added more queries to allow for automatic "smart" selection of geometries (XOR)
	Renamed layers: _geom_ to _g_, _building_ to _bdg_ etc. to shorten names
	Added (optional) "hard-coded" bbox selection
	Added (optional) parameters to be passed to [qgis_pkg.snap_poly_to_grid()]
	Currently generating 156 materialised views
		Building module complete
		Vegetation module complete
		Land use module complete
		City Furniture module complete
		Generic CityObject module complete
		Relief module: Relief Feature and TIN Relief
Upgraded scripts in 08: Major rework of the whole script structure
	Rewritten and added more queries
	Renamed layers according to the new naming schema for materialised views	
	Added dynamic generation of triggers
	Currently generating 156 views
		Not all are already updatable

2022-01-31
----------
Started restructuring materialized views (and views) according to new hierarchy after discussion with VCS
Renamed all names with *_bdg_* to *_building_*
Added ST_SnapToGrid function (and precision of 0.001) to geometries in materialised views.
	Details: https://postgis.net/docs/ST_SnapToGrid.html
WARNING: the actual queries for geometries in the materialized views need further updates
Slightly improved [qgis_pkg.refresh_materialized_view()] to show time needed to update materialized view(s)

2022-01-19:
----------
Renamed views for thematic surfaces adding "themsurf" to the name
Corrected some errors in triggers
Extended table qgis_pkg.materialized_views with columns "hierarchy" and "schema_name" 
TEMPORARY WORKAROUND: added hard-coded SRID to geometry columns of materialized views and views (any difference?)

2022-01-18:
----------
Added updatable views for relief feature, TIN relief and solitary vegetation object
Restructured update functions for tables and views
T- and V- and trigger functions made dynamic to be used with multiple citydb schemas
Rewritten function [qgis_pkg.refresh_materialized_view()] to work with schema_name and mat_view_name parameters
Code clean-up and some bugs removed

2022-01-04:
----------
Added materialized views for relief feature, TIN relief and solitary vegetation object geometries
Code restructured and cleaned up
Added function [qgis_pkg.refresh_materialized_view()]

2021-12-29
----------
Initial release
Materialized views for buildings, building installations geometries
Updatable views for buildings, building installations

-- END OF DOCUMENT --