From cef31aed53fb3bbbaf7801eb9fc8349cb0bf7c9c Mon Sep 17 00:00:00 2001 From: Claus Nagel Date: Thu, 11 Feb 2021 11:59:01 +0100 Subject: [PATCH] moved to version 1.4 of the i-UR ADE --- README.md | 2 +- build.gradle | 10 +- .../ade-manager/UrbanRevitalizationADE.xsd | 9 +- .../ade-manager/schemas/publicTransit.xsd | 680 +++++++++ .../ade-manager/schemas/statisticalGrid.xsd | 186 ++- .../ade-manager/schemas/urbanFunction.xsd | 273 +--- resources/ade-manager/schemas/urbanObject.xsd | 44 +- .../3dcitydb/oracle/CREATE_ADE_DB.sql | 1031 +++++++++++++- .../oracle/DISABLE_ADE_VERSIONING.sql | 4 +- .../database/3dcitydb/oracle/DROP_ADE_DB.sql | 427 +++++- .../3dcitydb/oracle/ENABLE_ADE_VERSIONING.sql | 4 +- .../3dcitydb/postgreSQL/CREATE_ADE_DB.sql | 1225 ++++++++++++++++- .../3dcitydb/postgreSQL/DROP_ADE_DB.sql | 427 +++++- .../schema-mapping/schema-mapping.xml | 624 ++++++++- resources/templates/balloons/buildings.html | 94 +- resources/templates/balloons/genericGrid.html | 67 + resources/templates/balloons/population.html | 35 +- .../{areaClassification.html => shape.html} | 11 +- resources/templates/balloons/stop.html | 34 + resources/templates/balloons/trip.html | 33 + .../spreadsheets/areaClassification.txt | 5 - .../templates/spreadsheets/buildings.txt | 57 +- .../templates/spreadsheets/genericGrid.txt | 2 + .../templates/spreadsheets/population.txt | 35 +- resources/templates/spreadsheets/shape.txt | 4 + resources/templates/spreadsheets/stop.txt | 6 + resources/templates/spreadsheets/trip.txt | 5 + .../ade/iur/UrbanRevitalizationADE.java | 21 +- .../ade/iur/balloon/BalloonManager.java | 16 +- .../iur/balloon/BuildingBalloonHandler.java | 9 +- .../CityObjectGroupBalloonHandler.java | 22 +- .../iur/balloon/LandUseBalloonHandler.java | 2 +- .../balloon/PublicTransitBalloonHandler.java | 74 + .../StatisticalGridBalloonHandler.java | 13 +- .../balloon/TransportationBalloonHandler.java | 2 +- .../balloon/UrbanFunctionBalloonHandler.java | 4 +- .../ade/iur/exporter/ExportManager.java | 330 +++-- .../iur/exporter/urf/CensusBlockExporter.java | 76 +- .../CityObjectGroupPropertiesExporter.java | 92 ++ .../urf/DevelopmentProjectExporter.java | 186 ++- .../exporter/urf/DisasterDamageExporter.java | 120 +- .../urf/DisasterPreventionBaseExporter.java | 106 ++ .../iur/exporter/urf/PollutionExporter.java | 69 +- .../PublicTransportationFacilityExporter.java | 133 ++ .../iur/exporter/urf/RecreationsExporter.java | 63 +- .../exporter/urf/UrbanFunctionExporter.java | 509 ++++--- .../urf/UrbanFunctionModuleExporter.java | 6 + .../exporter/urf/UrbanizationExporter.java | 55 +- .../ade/iur/exporter/urf/ZoneExporter.java | 116 ++ .../CityObjectGroupPropertiesExporter.java | 92 ++ .../exporter/urg/GenericGridCellExporter.java | 137 ++ .../iur/exporter/urg/HouseholdsExporter.java | 27 +- .../iur/exporter/urg/LandPriceExporter.java | 69 +- .../urg/LandUseDiversionExporter.java | 98 +- .../urg/OfficesAndEmployeesExporter.java | 24 +- .../iur/exporter/urg/PopulationExporter.java | 70 +- .../PublicTransitAccessibilityExporter.java} | 47 +- .../exporter/urg/StatisticalGridExporter.java | 225 ++- .../urg/StatisticalGridModuleExporter.java | 6 + .../uro/BuildingPropertiesExporter.java | 81 +- .../CityObjectGroupPropertiesExporter.java | 11 +- .../uro/LandUsePropertiesExporter.java | 11 +- ...ansportationComplexPropertiesExporter.java | 16 +- .../uro/UrbanObjectModuleExporter.java | 6 + .../ade/iur/exporter/urt/AgencyExporter.java | 122 ++ .../iur/exporter/urt/AttributionExporter.java | 138 ++ .../exporter/urt/CalendarDateExporter.java | 86 ++ .../iur/exporter/urt/CalendarExporter.java | 75 + .../CityObjectGroupPropertiesExporter.java | 127 ++ .../exporter/urt/FareAttributeExporter.java | 108 ++ .../iur/exporter/urt/FareRuleExporter.java | 106 ++ .../iur/exporter/urt/FeedInfoExporter.java | 98 ++ .../iur/exporter/urt/FrequencyExporter.java | 98 ++ .../ade/iur/exporter/urt/LevelExporter.java | 53 + .../ade/iur/exporter/urt/OfficeExporter.java | 72 + .../ade/iur/exporter/urt/PathwayExporter.java | 148 ++ .../exporter/urt/PublicTransitExporter.java | 69 + .../urt/PublicTransitModuleExporter.java | 6 + .../ade/iur/exporter/urt/RouteExporter.java | 209 +++ .../ade/iur/exporter/urt/ShapeExporter.java | 102 ++ .../ade/iur/exporter/urt/StopExporter.java | 189 +++ .../iur/exporter/urt/StopTimeExporter.java | 141 ++ .../iur/exporter/urt/TransferExporter.java | 94 ++ .../iur/exporter/urt/TranslationExporter.java | 99 ++ .../exporter/urt/TranslationJPExporter.java | 67 + .../ade/iur/exporter/urt/TripExporter.java | 189 +++ .../ade/iur/importer/ImportManager.java | 360 +++-- .../iur/importer/urf/CensusBlockImporter.java | 7 +- .../CityObjectGroupPropertiesImporter.java | 95 ++ .../urf/DevelopmentProjectImporter.java | 9 +- .../importer/urf/DisasterDamageImporter.java | 7 +- .../importer/urf/LegalGroundsImporter.java | 5 +- .../urf/NumberOfHouseholdsImporter.java | 3 +- .../iur/importer/urf/PollutionImporter.java | 7 +- ...PublicTransportationFacilityImporter.java} | 15 +- .../iur/importer/urf/RecreationsImporter.java | 7 +- .../importer/urf/UrbanFunctionImporter.java | 301 ++-- .../urf/UrbanFunctionModuleImporter.java | 6 + .../UrbanFunctionToCityObjectImporter.java | 5 +- .../importer/urf/UrbanizationImporter.java | 3 +- .../ade/iur/importer/urf/ZoneImporter.java | 87 ++ .../urg/AreaOfAnnualDiversionsImporter.java | 92 ++ .../CityObjectGroupPropertiesImporter.java | 95 ++ .../iur/importer/urg/HouseholdsImporter.java | 7 +- .../importer/urg/KeyValuePairImporter.java | 102 ++ .../iur/importer/urg/LandPriceImporter.java | 94 ++ .../urg/LandPricePerLandUseImporter.java | 29 +- .../urg/LandUseDiversionImporter.java | 92 ++ .../urg/NumberOfAnnualDiversionsImporter.java | 25 +- .../urg/NumberOfHouseholdsImporter.java | 5 +- .../urg/OfficesAndEmployeesImporter.java | 7 +- .../urg/PopulationByAgeAndSexImporter.java | 23 +- .../iur/importer/urg/PopulationImporter.java | 7 +- .../importer/urg/StatisticalGridImporter.java | 101 +- .../urg/StatisticalGridModuleImporter.java | 6 + .../importer/uro/BuildingDetailsImporter.java | 5 +- .../uro/BuildingPropertiesImporter.java | 19 +- .../CityObjectGroupPropertiesImporter.java | 13 +- .../importer/uro/KeyValuePairImporter.java | 102 ++ .../uro/LandUsePropertiesImporter.java | 9 +- .../uro/LargeCustomerFacilitiesImporter.java | 5 +- .../importer/uro/TrafficVolumeImporter.java | 5 +- ...ansportationComplexPropertiesImporter.java | 11 +- .../uro/UrbanObjectModuleImporter.java | 6 + .../ade/iur/importer/urt/AgencyImporter.java | 85 ++ .../iur/importer/urt/AttributionImporter.java | 146 ++ .../importer/urt/CalendarDateImporter.java | 94 ++ .../iur/importer/urt/CalendarImporter.java | 74 + .../CityObjectGroupPropertiesImporter.java | 115 ++ .../iur/importer/urt/DescriptionImporter.java | 68 + .../importer/urt/FareAttributeImporter.java | 112 ++ .../iur/importer/urt/FareRuleImporter.java | 125 ++ .../iur/importer/urt/FeedInfoImporter.java | 94 ++ .../iur/importer/urt/FrequencyImporter.java | 104 ++ .../ade/iur/importer/urt/OfficeImporter.java | 58 + .../ade/iur/importer/urt/PathwayImporter.java | 150 ++ .../ade/iur/importer/urt/PointImporter.java | 90 ++ .../urt/PublicTransitDataTypeImporter.java | 60 + .../importer/urt/PublicTransitImporter.java | 100 ++ .../urt/PublicTransitModuleImporter.java | 6 + .../ade/iur/importer/urt/RouteImporter.java | 179 +++ .../ade/iur/importer/urt/StopImporter.java | 173 +++ .../iur/importer/urt/StopTimeImporter.java | 168 +++ .../iur/importer/urt/TransferImporter.java | 112 ++ .../iur/importer/urt/TranslationImporter.java | 102 ++ .../importer/urt/TranslationJPImporter.java | 65 + .../ade/iur/importer/urt/TripImporter.java | 216 +++ .../ade/iur/kmlExporter/KMLExportManager.java | 34 +- .../ade/iur/kmlExporter/RouteKmlExporter.java | 62 + .../ade/iur/kmlExporter/ShapeKmlExporter.java | 62 + .../StatisticalGridKmlExporter.java | 48 +- .../ade/iur/kmlExporter/StopKmlExporter.java | 59 + .../ade/iur/kmlExporter/TripKmlExporter.java | 62 + .../kmlExporter/UrbanFunctionKmlExporter.java | 95 +- .../citydb/ade/iur/schema/ADESequence.java | 8 +- .../org/citydb/ade/iur/schema/ADETable.java | 70 +- .../citydb/ade/iur/schema/ADETableMapper.java | 338 ++++- .../citydb/ade/iur/schema/ObjectMapper.java | 134 +- .../citydb/ade/iur/schema/SchemaMapper.java | 4 +- 159 files changed, 14042 insertions(+), 1881 deletions(-) create mode 100644 resources/ade-manager/schemas/publicTransit.xsd create mode 100644 resources/templates/balloons/genericGrid.html rename resources/templates/balloons/{areaClassification.html => shape.html} (59%) create mode 100644 resources/templates/balloons/stop.html create mode 100644 resources/templates/balloons/trip.html delete mode 100644 resources/templates/spreadsheets/areaClassification.txt create mode 100644 resources/templates/spreadsheets/genericGrid.txt create mode 100644 resources/templates/spreadsheets/shape.txt create mode 100644 resources/templates/spreadsheets/stop.txt create mode 100644 resources/templates/spreadsheets/trip.txt create mode 100644 src/main/java/org/citydb/ade/iur/balloon/PublicTransitBalloonHandler.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urf/CityObjectGroupPropertiesExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urf/DisasterPreventionBaseExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urf/PublicTransportationFacilityExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urf/UrbanFunctionModuleExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urf/ZoneExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urg/CityObjectGroupPropertiesExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urg/GenericGridCellExporter.java rename src/main/java/org/citydb/ade/iur/exporter/{urf/PublicTransitExporter.java => urg/PublicTransitAccessibilityExporter.java} (54%) create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urg/StatisticalGridModuleExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/uro/UrbanObjectModuleExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/AgencyExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/AttributionExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/CalendarDateExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/CalendarExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/CityObjectGroupPropertiesExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/FareAttributeExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/FareRuleExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/FeedInfoExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/FrequencyExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/LevelExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/OfficeExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/PathwayExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/PublicTransitExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/PublicTransitModuleExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/RouteExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/ShapeExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/StopExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/StopTimeExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/TransferExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/TranslationExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/TranslationJPExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/exporter/urt/TripExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urf/CityObjectGroupPropertiesImporter.java rename src/main/java/org/citydb/ade/iur/importer/urf/{PublicTransitImporter.java => PublicTransportationFacilityImporter.java} (83%) create mode 100644 src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionModuleImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urf/ZoneImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urg/AreaOfAnnualDiversionsImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urg/CityObjectGroupPropertiesImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urg/KeyValuePairImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urg/LandPriceImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urg/LandUseDiversionImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urg/StatisticalGridModuleImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/uro/KeyValuePairImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/uro/UrbanObjectModuleImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/AgencyImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/AttributionImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/CalendarDateImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/CalendarImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/CityObjectGroupPropertiesImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/DescriptionImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/FareAttributeImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/FareRuleImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/FeedInfoImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/FrequencyImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/OfficeImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/PathwayImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/PointImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitDataTypeImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitModuleImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/RouteImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/StopImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/StopTimeImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/TransferImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/TranslationImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/TranslationJPImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/importer/urt/TripImporter.java create mode 100644 src/main/java/org/citydb/ade/iur/kmlExporter/RouteKmlExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/kmlExporter/ShapeKmlExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/kmlExporter/StopKmlExporter.java create mode 100644 src/main/java/org/citydb/ade/iur/kmlExporter/TripKmlExporter.java diff --git a/README.md b/README.md index 1f3d678..9a91c56 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ The Java module for enabling the Importer/Exporter tool to store i-UR ADE data a has been manually implemented against the `ADEExtension` interface and plugin mechanism of the Importer/Exporter. The `ADEExtension` interface has been introduced with [version 4.0](https://github.com/3dcitydb/3dcitydb/releases/tag/v4.0.0) of the 3D City Database. The [TestADE repository](https://github.com/3dcitydb/extension-test-ade) demonstrates the -implementation of an artifical ADE and may serve as template for implementing extensions for your own ADEs. +implementation of an artificial ADE and may serve as template for implementing extensions for your own ADEs. The Java module for parsing and writing i-UR ADE enriched datasets is implemented as extension for the open source CityGML library citygml4j. More information can be found [here](https://github.com/citygml4j/iur-ade-citygml4j). diff --git a/build.gradle b/build.gradle index a3cf817..324031a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,11 +4,11 @@ plugins { } group 'org.citydb.ade' -version '1.0.0' +version '1.4.0' description 'i-Urban Revitalization ADE extension for the 3DCityDB' java { - sourceCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_11 } configurations { @@ -26,10 +26,10 @@ repositories { } dependencies { - implementation 'org.citydb:impexp-client:4.3.0-b20200807.1607' - implementation 'org.citygml4j.ade:iur-ade-citygml4j:1.0.0' + implementation 'org.citydb:impexp-client:4.3.0-b20210211-1117' + implementation 'org.citygml4j.ade:iur-ade-citygml4j:1.4.0' - citygml4j('org.citygml4j.ade:iur-ade-citygml4j:1.0.0') { + citygml4j('org.citygml4j.ade:iur-ade-citygml4j:1.4.0') { transitive = false } } diff --git a/resources/ade-manager/UrbanRevitalizationADE.xsd b/resources/ade-manager/UrbanRevitalizationADE.xsd index 26e935c..76f08f7 100644 --- a/resources/ade-manager/UrbanRevitalizationADE.xsd +++ b/resources/ade-manager/UrbanRevitalizationADE.xsd @@ -1,6 +1,7 @@ - - - - + + + + + diff --git a/resources/ade-manager/schemas/publicTransit.xsd b/resources/ade-manager/schemas/publicTransit.xsd new file mode 100644 index 0000000..9832834 --- /dev/null +++ b/resources/ade-manager/schemas/publicTransit.xsd @@ -0,0 +1,680 @@ + + + + XML Schema for Public Transit module + + + + + + + + + + + + + + id field of GTFS files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + extended field in GTFS-JP + + + + + extended field in GTFS-JP + + + + + extended field in GTFS-JP + + + + + extended field in GTFS-JP + + + + + + + + + extended field in GTFS-JP + + + + + geometric property added in this module + + + + + + + + + + true + + + + + + + + + + + + + + + route_desc + + + + + extended information defined in this modeule + + + + + extended information defined in this modeule + + + + + + + + + + + + + + + + + + + + + + + + + extended field in GTFS-JP + + + + + extended field in GTFS-JP + + + + + extended field in GTFS-JP + + + + + extended field in GTFS-JP + + + + + extended field in GTFS-JP + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + extended field in GTFS-JP + + + + + + + + extended field in GTFS-JP + + + + + + extended property defined in this module. The curve is composed of a sequence of points in a shape. + + + + + + + + + + true + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + extended file in GTFS-JP + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + extended file in GTFS-JP + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + extended information defined in this module + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/ade-manager/schemas/statisticalGrid.xsd b/resources/ade-manager/schemas/statisticalGrid.xsd index b21e7df..48648cd 100644 --- a/resources/ade-manager/schemas/statisticalGrid.xsd +++ b/resources/ade-manager/schemas/statisticalGrid.xsd @@ -1,20 +1,15 @@ - + XML Schema for Statistical Grid module - + - - The root type for statistical grid. As subclass of _CityObject, an - _StatisticalGrid inherits all attributes and relations, in particular a description, - an id and names. - @@ -25,24 +20,19 @@ - - - + + - - - - - This element is reserved for future use. - - true - - - + + + + + + @@ -64,12 +54,10 @@ - - @@ -84,20 +72,10 @@ - - - This element is reserved for future use. - - true - - - - - - + @@ -107,44 +85,32 @@ - + - grid cell to describe areas where the public transportation service is - available + grid cell to describe areas where the public transportation service is available - - - + true - + - + - - - This element is reserved for future use. - - true - - - - grid cell with land prices @@ -153,12 +119,11 @@ - + - @@ -173,21 +138,11 @@ - - - This element is reserved for future use. - - true - - - - - + - @@ -198,19 +153,17 @@ - grid cell with the number and area of land use - diversion + grid cell with the number and area of land use diversion - + - @@ -225,21 +178,11 @@ - - - This element is reserved for future use. - - true - - - - - + - @@ -248,6 +191,19 @@ + + + + + + + + + + + + + grid cell with the number of households @@ -259,12 +215,10 @@ - - @@ -279,15 +233,6 @@ - - - This element is reserved for future use. - - true - - - - @@ -307,12 +252,10 @@ - - @@ -327,11 +270,66 @@ - + + + grid cell for various use + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + - This element is reserved for future use. - true + 1 diff --git a/resources/ade-manager/schemas/urbanFunction.xsd b/resources/ade-manager/schemas/urbanFunction.xsd index ce32e35..e5b9d69 100644 --- a/resources/ade-manager/schemas/urbanFunction.xsd +++ b/resources/ade-manager/schemas/urbanFunction.xsd @@ -1,13 +1,13 @@ - + XML Schema for Urban Function module - - - + + + - + @@ -36,11 +36,16 @@ - - - + + + + + + + + + - @@ -48,15 +53,6 @@ - - - This element is reserved for future use. - - true - - - - @@ -81,11 +77,7 @@ - - - - - + @@ -97,15 +89,6 @@ - - - This element is reserved for future use. - - true - - - - zoning district @@ -115,7 +98,6 @@ - @@ -123,21 +105,9 @@ - - - - true - - - - - - - - - + @@ -155,24 +125,13 @@ - - - This element is reserved for future use. - - true - - - - Urban planning area - - - + @@ -191,15 +150,6 @@ - - - This element is reserved for future use. - - true - - - - Area specified area by the agreement between the parties agreed upon @@ -207,9 +157,7 @@ - - - + @@ -228,21 +176,10 @@ - - - This element is reserved for future use. - - true - - - - - - - + @@ -261,21 +198,10 @@ - - - This element is reserved for future use. - - true - - - - - - - + @@ -294,21 +220,10 @@ - - - This element is reserved for future use. - - true - - - - - - - + @@ -327,15 +242,6 @@ - - - This element is reserved for future use. - - true - - - - @@ -350,7 +256,6 @@ - @@ -370,15 +275,6 @@ - - - This element is reserved for future use. - - true - - - - Block for census survey @@ -392,7 +288,6 @@ - @@ -412,15 +307,6 @@ - - - This element is reserved for future use. - - true - - - - @@ -444,7 +330,6 @@ - @@ -464,15 +349,6 @@ - - - This element is reserved for future use. - - true - - - - Source of pollution @@ -482,7 +358,6 @@ - @@ -502,21 +377,11 @@ - - - This element is reserved for future use. - - true - - - - - @@ -536,22 +401,12 @@ - - - This element is reserved for future use. - - true - - - - - @@ -571,21 +426,10 @@ - - - This element is reserved for future use. - - true - - - - - - - + @@ -604,21 +448,10 @@ - - - This element is reserved for future use. - - true - - - - - - - + @@ -637,22 +470,12 @@ - - - This element is reserved for future use. - - true - - - - - @@ -672,26 +495,7 @@ - - - This element is reserved for future use. - - true - - - - - - - - true - - - - - - The root type for public transit. - + @@ -700,25 +504,38 @@ - - + + + + + true + + + + + - + - - + + - This element is reserved for future use. - true + 1 + + + + + + + 1 - diff --git a/resources/ade-manager/schemas/urbanObject.xsd b/resources/ade-manager/schemas/urbanObject.xsd index dec9c6e..a819a2c 100644 --- a/resources/ade-manager/schemas/urbanObject.xsd +++ b/resources/ade-manager/schemas/urbanObject.xsd @@ -1,18 +1,15 @@ - + XML Schema for Urban Object module - - - - - - - - - - + + + + + + + @@ -85,6 +82,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/database/3dcitydb/oracle/CREATE_ADE_DB.sql b/resources/database/3dcitydb/oracle/CREATE_ADE_DB.sql index a675917..4ba7dae 100644 --- a/resources/database/3dcitydb/oracle/CREATE_ADE_DB.sql +++ b/resources/database/3dcitydb/oracle/CREATE_ADE_DB.sql @@ -1,7 +1,62 @@ --- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-03-20 09:53:29 +-- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-08-25 11:09:20 -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Create tables ************************************** -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +-- -------------------------------------------------------------------- +-- ur_agency +-- -------------------------------------------------------------------- +CREATE TABLE ur_agency +( + id INTEGER NOT NULL, + address VARCHAR2(1000), + email VARCHAR2(1000), + fareurl VARCHAR2(1000), + language VARCHAR2(1000), + language_codespace VARCHAR2(1000), + name VARCHAR2(1000), + officialname VARCHAR2(1000), + phone VARCHAR2(1000), + presidentname VARCHAR2(1000), + presidentposition VARCHAR2(1000), + timezone VARCHAR2(1000), + timezone_codespace VARCHAR2(1000), + url VARCHAR2(1000), + zipnumber VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +CREATE TABLE ur_areaofannualdiversions +( + id INTEGER NOT NULL, + area NUMBER, + area_uom VARCHAR2(1000), + landusediver_areaofannual_id INTEGER, + year DATE, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +CREATE TABLE ur_attribution +( + id INTEGER NOT NULL, + agency_id INTEGER, + email VARCHAR2(1000), + isauthority NUMBER, + isoperator NUMBER, + isproducer NUMBER, + organizationname VARCHAR2(1000), + phonenumber VARCHAR2(1000), + route_id INTEGER, + trip_id INTEGER, + url VARCHAR2(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -53,6 +108,37 @@ CREATE TABLE ur_buildingdetails PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_calendar +-- -------------------------------------------------------------------- +CREATE TABLE ur_calendar +( + id INTEGER NOT NULL, + enddate TIMESTAMP, + friday NUMBER, + monday NUMBER, + saturday NUMBER, + startdate TIMESTAMP, + sunday NUMBER, + thursday NUMBER, + tuesday NUMBER, + wednesday NUMBER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +CREATE TABLE ur_calendardate +( + id INTEGER NOT NULL, + calendar_id INTEGER, + date_ TIMESTAMP, + exceptiontype VARCHAR2(1000), + exceptiontype_codespace VARCHAR2(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_censusblock -- -------------------------------------------------------------------- @@ -78,6 +164,51 @@ CREATE TABLE ur_cityobjectgroup PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_1 +-- -------------------------------------------------------------------- +CREATE TABLE ur_cityobjectgroup_1 +( + id INTEGER NOT NULL, + fiscalyearofpublication DATE, + language VARCHAR2(1000), + language_codespace VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_2 +-- -------------------------------------------------------------------- +CREATE TABLE ur_cityobjectgroup_2 +( + id INTEGER NOT NULL, + fiscalyearofpublication DATE, + language VARCHAR2(1000), + language_codespace VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_3 +-- -------------------------------------------------------------------- +CREATE TABLE ur_cityobjectgroup_3 +( + id INTEGER NOT NULL, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_description +-- -------------------------------------------------------------------- +CREATE TABLE ur_description +( + id INTEGER NOT NULL, + description VARCHAR2(1000), + frequencyofservice INTEGER, + numberofcustomers INTEGER, + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_developmentproject -- -------------------------------------------------------------------- @@ -119,6 +250,77 @@ CREATE TABLE ur_disasterdamage PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +CREATE TABLE ur_fareattribute +( + id INTEGER NOT NULL, + agency_id INTEGER, + currencytype VARCHAR2(1000), + currencytype_codespace VARCHAR2(1000), + paymentmethod VARCHAR2(1000), + paymentmethod_codespace VARCHAR2(1000), + price NUMBER, + transferduration INTEGER, + transfers VARCHAR2(1000), + transfers_codespace VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +CREATE TABLE ur_farerule +( + id INTEGER NOT NULL, + containsid VARCHAR2(1000), + containsid_codespace VARCHAR2(1000), + destinationid VARCHAR2(1000), + destinationid_codespace VARCHAR2(1000), + fare_id INTEGER, + originid VARCHAR2(1000), + originid_codespace VARCHAR2(1000), + route_id INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_feedinfo +-- -------------------------------------------------------------------- +CREATE TABLE ur_feedinfo +( + id INTEGER NOT NULL, + contactemail VARCHAR2(1000), + contacturl VARCHAR2(1000), + defaultlanguage VARCHAR2(1000), + defaultlanguage_codespace VARCHAR2(1000), + detailedinfo VARCHAR2(1000), + enddate TIMESTAMP, + language VARCHAR2(1000), + language_codespace VARCHAR2(1000), + publishername VARCHAR2(1000), + publisherurl VARCHAR2(1000), + startdate TIMESTAMP, + version VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +CREATE TABLE ur_frequency +( + id INTEGER NOT NULL, + endtime TIMESTAMP, + exacttimes VARCHAR2(1000), + exacttimes_codespace VARCHAR2(1000), + headwaysecs INTEGER, + starttime TIMESTAMP, + trip_id INTEGER, + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_households -- -------------------------------------------------------------------- @@ -130,6 +332,48 @@ CREATE TABLE ur_households PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +CREATE TABLE ur_keyvaluepair +( + id INTEGER NOT NULL, + codevalue VARCHAR2(1000), + codevalue_codespace VARCHAR2(1000), + datevalue TIMESTAMP, + doublevalue NUMBER, + intvalue INTEGER, + key VARCHAR2(1000), + key_codespace VARCHAR2(1000), + measuredvalue NUMBER, + measuredvalue_uom VARCHAR2(1000), + statisticalg_genericvalue_id INTEGER, + stringvalue VARCHAR2(1000), + urivalue VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +CREATE TABLE ur_keyvaluepair_1 +( + id INTEGER NOT NULL, + building_extendedattribut_id INTEGER, + codevalue VARCHAR2(1000), + codevalue_codespace VARCHAR2(1000), + datevalue TIMESTAMP, + doublevalue NUMBER, + intvalue INTEGER, + key VARCHAR2(1000), + key_codespace VARCHAR2(1000), + measuredvalue NUMBER, + measuredvalue_uom VARCHAR2(1000), + stringvalue VARCHAR2(1000), + urivalue VARCHAR2(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_land_use -- -------------------------------------------------------------------- @@ -164,17 +408,35 @@ CREATE TABLE ur_land_use ); -- -------------------------------------------------------------------- --- ur_landpriceperlanduse +-- ur_landprice -- -------------------------------------------------------------------- -CREATE TABLE ur_landpriceperlanduse +CREATE TABLE ur_landprice ( id INTEGER NOT NULL, currencyunit VARCHAR2(1000), currencyunit_codespace VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_landpriceperlanduse +-- -------------------------------------------------------------------- +CREATE TABLE ur_landpriceperlanduse +( + id INTEGER NOT NULL, landprice INTEGER, + landprice_landprice_id INTEGER, landuse VARCHAR2(1000), landuse_codespace VARCHAR2(1000), - statisticalgrid_landprice_id INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_landusediversion +-- -------------------------------------------------------------------- +CREATE TABLE ur_landusediversion +( + id INTEGER NOT NULL, PRIMARY KEY (id) ); @@ -234,10 +496,8 @@ CREATE TABLE ur_legalgrounds CREATE TABLE ur_numberofannualdiversio ( id INTEGER NOT NULL, - area NUMBER, - area_uom VARCHAR2(1000), count INTEGER, - statisticalg_numberofannu_id INTEGER, + landusediver_numberofannu_id INTEGER, year DATE, PRIMARY KEY (id) ); @@ -270,6 +530,18 @@ CREATE TABLE ur_numberofhouseholds_1 PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_office +-- -------------------------------------------------------------------- +CREATE TABLE ur_office +( + id INTEGER NOT NULL, + name VARCHAR2(1000), + phone VARCHAR2(1000), + url VARCHAR2(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_officesandemployees -- -------------------------------------------------------------------- @@ -281,6 +553,44 @@ CREATE TABLE ur_officesandemployees PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +CREATE TABLE ur_pathway +( + id INTEGER NOT NULL, + from_id INTEGER, + isbidirectional VARCHAR2(1000), + isbidirectional_codespace VARCHAR2(1000), + length NUMBER, + length_uom VARCHAR2(1000), + maxslope NUMBER, + minwidth NUMBER, + mode_ VARCHAR2(1000), + mode_codespace VARCHAR2(1000), + reversedsignpostedas VARCHAR2(1000), + signpostedas VARCHAR2(1000), + staircount INTEGER, + to_id INTEGER, + traversaltime INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +CREATE TABLE ur_point +( + id INTEGER NOT NULL, + latitude NUMBER, + longitude NUMBER, + point MDSYS.SDO_GEOMETRY, + pointdistancetraveled NUMBER, + pointsequence INTEGER, + publictransit_point_id INTEGER, + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_pollution -- -------------------------------------------------------------------- @@ -320,12 +630,10 @@ CREATE TABLE ur_population CREATE TABLE ur_populationbyageandsex ( id INTEGER NOT NULL, - age VARCHAR2(1000), - age_codespace VARCHAR2(1000), + ageandsex VARCHAR2(1000), + ageandsex_codespace VARCHAR2(1000), number_ INTEGER, population_populationbyag_id INTEGER, - sex VARCHAR2(1000), - sex_codespace VARCHAR2(1000), PRIMARY KEY (id) ); @@ -333,6 +641,30 @@ CREATE TABLE ur_populationbyageandsex -- ur_publictransit -- -------------------------------------------------------------------- CREATE TABLE ur_publictransit +( + id INTEGER NOT NULL, + index_ NUMBER, + objectclass_id INTEGER, + orgid VARCHAR2(1000), + target_id INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +CREATE TABLE ur_publictransitdatatype +( + id INTEGER NOT NULL, + cityobjectgroup_datatype_id INTEGER, + objectclass_id INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_publictransportationfa +-- -------------------------------------------------------------------- +CREATE TABLE ur_publictransportationfa ( id INTEGER NOT NULL, companyname VARCHAR2(1000), @@ -354,6 +686,35 @@ CREATE TABLE ur_recreations PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_route +-- -------------------------------------------------------------------- +CREATE TABLE ur_route +( + id INTEGER NOT NULL, + agency_id INTEGER, + color VARCHAR2(1000), + continuousdropoff VARCHAR2(1000), + continuousdropoff_codespace VARCHAR2(1000), + continuouspickup VARCHAR2(1000), + continuouspickup_codespace VARCHAR2(1000), + description_id INTEGER, + destinationstop VARCHAR2(1000), + lod0multicurve MDSYS.SDO_GEOMETRY, + longname VARCHAR2(1000), + originstop VARCHAR2(1000), + parentroute_id INTEGER, + routesortorder INTEGER, + shortname VARCHAR2(1000), + textcolor VARCHAR2(1000), + type VARCHAR2(1000), + type_codespace VARCHAR2(1000), + updatedate TIMESTAMP, + url VARCHAR2(1000), + viastop VARCHAR2(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_statisticalgrid -- -------------------------------------------------------------------- @@ -367,8 +728,8 @@ CREATE TABLE ur_statisticalgrid city_codespace VARCHAR2(1000), class VARCHAR2(1000), class_codespace VARCHAR2(1000), - lod_1multisurfacegeometry_id INTEGER, - lod_2multisurfacegeometry_id INTEGER, + lod_1multisurface_id INTEGER, + lod_2multisurface_id INTEGER, objectclass_id INTEGER, prefecture VARCHAR2(1000), prefecture_codespace VARCHAR2(1000), @@ -379,6 +740,59 @@ CREATE TABLE ur_statisticalgrid PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +CREATE TABLE ur_stop +( + id INTEGER NOT NULL, + code VARCHAR2(1000), + code_codespace VARCHAR2(1000), + latitude NUMBER, + level_id INTEGER, + locationtype VARCHAR2(1000), + locationtype_codespace VARCHAR2(1000), + longitude NUMBER, + parentstation_id INTEGER, + platformcode VARCHAR2(1000), + point MDSYS.SDO_GEOMETRY, + timezone VARCHAR2(1000), + timezone_codespace VARCHAR2(1000), + ttsname VARCHAR2(1000), + url VARCHAR2(1000), + wheelchairboarding VARCHAR2(1000), + wheelchairboarding_codespace VARCHAR2(1000), + zoneid VARCHAR2(1000), + zoneid_codespace VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +CREATE TABLE ur_stoptime +( + id INTEGER NOT NULL, + arrivaltime TIMESTAMP, + continuousdropofft_codespace VARCHAR2(1000), + continuousdropofftype VARCHAR2(1000), + continuouspickupty_codespace VARCHAR2(1000), + continuouspickuptype VARCHAR2(1000), + departuretime TIMESTAMP, + dropofftype VARCHAR2(1000), + dropofftype_codespace VARCHAR2(1000), + headsign VARCHAR2(1000), + pickuptype VARCHAR2(1000), + pickuptype_codespace VARCHAR2(1000), + shapedistancetraveled NUMBER, + stop_id INTEGER, + stopsequence INTEGER, + timepoint VARCHAR2(1000), + timepoint_codespace VARCHAR2(1000), + trip_id INTEGER, + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_trafficvolume -- -------------------------------------------------------------------- @@ -405,6 +819,50 @@ CREATE TABLE ur_trafficvolume PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +CREATE TABLE ur_transfer +( + id INTEGER NOT NULL, + from_id INTEGER, + mintransfertime INTEGER, + to_id INTEGER, + transfertype VARCHAR2(1000), + transfertype_codespace VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +CREATE TABLE ur_translation +( + id INTEGER NOT NULL, + fieldname VARCHAR2(1000), + fieldvalue VARCHAR2(1000), + language VARCHAR2(1000), + language_codespace VARCHAR2(1000), + recordid_id INTEGER, + recordsubid VARCHAR2(1000), + tablename VARCHAR2(1000), + tablename_codespace VARCHAR2(1000), + translation VARCHAR2(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_translationjp +-- -------------------------------------------------------------------- +CREATE TABLE ur_translationjp +( + id INTEGER NOT NULL, + language VARCHAR2(1000), + language_codespace VARCHAR2(1000), + translation VARCHAR2(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- @@ -419,6 +877,31 @@ CREATE TABLE ur_transportation_complex PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +CREATE TABLE ur_trip +( + id INTEGER NOT NULL, + bikeallowed VARCHAR2(1000), + bikeallowed_codespace VARCHAR2(1000), + blockid VARCHAR2(1000), + calendar_id INTEGER, + calendardate_id INTEGER, + directionid VARCHAR2(1000), + directionid_codespace VARCHAR2(1000), + headsign VARCHAR2(1000), + lod0multicurve MDSYS.SDO_GEOMETRY, + office_id INTEGER, + route_id INTEGER, + shape_id INTEGER, + shortname VARCHAR2(1000), + symbol VARCHAR2(1000), + wheelchairaccessib_codespace VARCHAR2(1000), + wheelchairaccessible VARCHAR2(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -436,10 +919,8 @@ CREATE TABLE ur_urbanfunction ( id INTEGER NOT NULL, abstract VARCHAR2(1000), - area_id INTEGER, areaclassification_codespace VARCHAR2(1000), areaclassificationtype VARCHAR2(1000), - boundary MDSYS.SDO_GEOMETRY, capacity INTEGER, city VARCHAR2(1000), city_codespace VARCHAR2(1000), @@ -453,7 +934,15 @@ CREATE TABLE ur_urbanfunction function VARCHAR2(1000), function_codespace VARCHAR2(1000), legalgrounds_id INTEGER, - location MDSYS.SDO_GEOMETRY, + lod0multicurve MDSYS.SDO_GEOMETRY, + lod0multipoint MDSYS.SDO_GEOMETRY, + lod0multisurface_id INTEGER, + lod_1multicurve MDSYS.SDO_GEOMETRY, + lod_1multipoint MDSYS.SDO_GEOMETRY, + lod_1multisurface_id INTEGER, + lod_2multicurve MDSYS.SDO_GEOMETRY, + lod_2multipoint MDSYS.SDO_GEOMETRY, + lod_2multisurface_id INTEGER, nominalarea NUMBER, nominalarea_uom VARCHAR2(1000), note VARCHAR2(1000), @@ -494,6 +983,36 @@ CREATE TABLE ur_zone -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Create foreign keys ******************************** -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +-- -------------------------------------------------------------------- +-- ur_agency +-- -------------------------------------------------------------------- +ALTER TABLE ur_agency ADD CONSTRAINT ur_agency_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +ALTER TABLE ur_areaofannualdiversions ADD CONSTRAINT ur_areaof_landus_areaof_fk FOREIGN KEY (landusediver_areaofannual_id) +REFERENCES ur_landusediversion (id); + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +ALTER TABLE ur_attribution ADD CONSTRAINT ur_attribution_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_attribution ADD CONSTRAINT ur_attribution_agency_fk FOREIGN KEY (agency_id) +REFERENCES ur_agency (id) +ON DELETE SET NULL; + +ALTER TABLE ur_attribution ADD CONSTRAINT ur_attribution_route_fk FOREIGN KEY (route_id) +REFERENCES ur_route (id) +ON DELETE SET NULL; + +ALTER TABLE ur_attribution ADD CONSTRAINT ur_attribution_trip_fk FOREIGN KEY (trip_id) +REFERENCES ur_trip (id) +ON DELETE SET NULL; + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -508,6 +1027,22 @@ ALTER TABLE ur_building ADD CONSTRAINT ur_building_largecustom_fk FOREIGN KEY (l REFERENCES ur_largecustomerfacilitie (id) ON DELETE SET NULL; +-- -------------------------------------------------------------------- +-- ur_calendar +-- -------------------------------------------------------------------- +ALTER TABLE ur_calendar ADD CONSTRAINT ur_calendar_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +ALTER TABLE ur_calendardate ADD CONSTRAINT ur_calendardate_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_calendardate ADD CONSTRAINT ur_calendardat_calendar_fk FOREIGN KEY (calendar_id) +REFERENCES ur_calendar (id) +ON DELETE SET NULL; + -- -------------------------------------------------------------------- -- ur_censusblock -- -------------------------------------------------------------------- @@ -520,6 +1055,24 @@ REFERENCES ur_urbanfunction (id); ALTER TABLE ur_cityobjectgroup ADD CONSTRAINT ur_cityobjectgroup_fk FOREIGN KEY (id) REFERENCES cityobjectgroup (id); +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_1 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_1 ADD CONSTRAINT ur_cityobjectgroup_fk_1 FOREIGN KEY (id) +REFERENCES cityobjectgroup (id); + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_2 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_2 ADD CONSTRAINT ur_cityobjectgroup_fk_2 FOREIGN KEY (id) +REFERENCES cityobjectgroup (id); + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_3 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_3 ADD CONSTRAINT ur_cityobjectgroup_fk_3 FOREIGN KEY (id) +REFERENCES cityobjectgroup (id); + -- -------------------------------------------------------------------- -- ur_developmentproject -- -------------------------------------------------------------------- @@ -532,29 +1085,93 @@ REFERENCES ur_zone (id); ALTER TABLE ur_disasterdamage ADD CONSTRAINT ur_disasterdamage_fk FOREIGN KEY (id) REFERENCES ur_urbanfunction (id); +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +ALTER TABLE ur_fareattribute ADD CONSTRAINT ur_fareattribute_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_fareattribute ADD CONSTRAINT ur_fareattribute_agency_fk FOREIGN KEY (agency_id) +REFERENCES ur_agency (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +ALTER TABLE ur_farerule ADD CONSTRAINT ur_farerule_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_farerule ADD CONSTRAINT ur_farerule_fare_fk FOREIGN KEY (fare_id) +REFERENCES ur_fareattribute (id) +ON DELETE SET NULL; + +ALTER TABLE ur_farerule ADD CONSTRAINT ur_farerule_route_fk FOREIGN KEY (route_id) +REFERENCES ur_route (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_feedinfo +-- -------------------------------------------------------------------- +ALTER TABLE ur_feedinfo ADD CONSTRAINT ur_feedinfo_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +ALTER TABLE ur_frequency ADD CONSTRAINT ur_frequency_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_frequency ADD CONSTRAINT ur_frequency_trip_fk FOREIGN KEY (trip_id) +REFERENCES ur_trip (id) +ON DELETE SET NULL; + -- -------------------------------------------------------------------- -- ur_households -- -------------------------------------------------------------------- ALTER TABLE ur_households ADD CONSTRAINT ur_households_fk FOREIGN KEY (id) REFERENCES ur_statisticalgrid (id); +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +ALTER TABLE ur_keyvaluepair ADD CONSTRAINT ur_keyval_statis_generi_fk FOREIGN KEY (statisticalg_genericvalue_id) +REFERENCES ur_statisticalgrid (id); + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +ALTER TABLE ur_keyvaluepair_1 ADD CONSTRAINT ur_keyval_buildi_extend_fk FOREIGN KEY (building_extendedattribut_id) +REFERENCES ur_building (id); + -- -------------------------------------------------------------------- -- ur_land_use -- -------------------------------------------------------------------- ALTER TABLE ur_land_use ADD CONSTRAINT ur_land_use_fk FOREIGN KEY (id) REFERENCES land_use (id); +-- -------------------------------------------------------------------- +-- ur_landprice +-- -------------------------------------------------------------------- +ALTER TABLE ur_landprice ADD CONSTRAINT ur_landprice_fk FOREIGN KEY (id) +REFERENCES ur_statisticalgrid (id); + -- -------------------------------------------------------------------- -- ur_landpriceperlanduse -- -------------------------------------------------------------------- -ALTER TABLE ur_landpriceperlanduse ADD CONSTRAINT ur_landpr_statis_landpr_fk FOREIGN KEY (statisticalgrid_landprice_id) +ALTER TABLE ur_landpriceperlanduse ADD CONSTRAINT ur_landpr_landpr_landpr_fk FOREIGN KEY (landprice_landprice_id) +REFERENCES ur_landprice (id); + +-- -------------------------------------------------------------------- +-- ur_landusediversion +-- -------------------------------------------------------------------- +ALTER TABLE ur_landusediversion ADD CONSTRAINT ur_landusediversion_fk FOREIGN KEY (id) REFERENCES ur_statisticalgrid (id); -- -------------------------------------------------------------------- -- ur_numberofannualdiversio -- -------------------------------------------------------------------- -ALTER TABLE ur_numberofannualdiversio ADD CONSTRAINT ur_number_statis_number_fk FOREIGN KEY (statisticalg_numberofannu_id) -REFERENCES ur_statisticalgrid (id); +ALTER TABLE ur_numberofannualdiversio ADD CONSTRAINT ur_number_landus_number_fk FOREIGN KEY (landusediver_numberofannu_id) +REFERENCES ur_landusediversion (id); -- -------------------------------------------------------------------- -- ur_numberofhouseholds @@ -574,12 +1191,38 @@ REFERENCES ur_censusblock (id); ALTER TABLE ur_numberofhouseholds_1 ADD CONSTRAINT ur_number_censu_numbe_fk_1 FOREIGN KEY (censusblock_numberofhou_id_1) REFERENCES ur_censusblock (id); +-- -------------------------------------------------------------------- +-- ur_office +-- -------------------------------------------------------------------- +ALTER TABLE ur_office ADD CONSTRAINT ur_office_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + -- -------------------------------------------------------------------- -- ur_officesandemployees -- -------------------------------------------------------------------- ALTER TABLE ur_officesandemployees ADD CONSTRAINT ur_officesandemployees_fk FOREIGN KEY (id) REFERENCES ur_statisticalgrid (id); +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +ALTER TABLE ur_pathway ADD CONSTRAINT ur_pathway_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_pathway ADD CONSTRAINT ur_pathway_from_fk FOREIGN KEY (from_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +ALTER TABLE ur_pathway ADD CONSTRAINT ur_pathway_to_fk FOREIGN KEY (to_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +ALTER TABLE ur_point ADD CONSTRAINT ur_point_publictr_point_fk FOREIGN KEY (publictransit_point_id) +REFERENCES ur_publictransit (id); + -- -------------------------------------------------------------------- -- ur_pollution -- -------------------------------------------------------------------- @@ -601,7 +1244,29 @@ REFERENCES ur_population (id); -- -------------------------------------------------------------------- -- ur_publictransit -- -------------------------------------------------------------------- +ALTER TABLE ur_publictransit ADD CONSTRAINT ur_publictran_objectcla_fk FOREIGN KEY (objectclass_id) +REFERENCES objectclass (id); + ALTER TABLE ur_publictransit ADD CONSTRAINT ur_publictransit_fk FOREIGN KEY (id) +REFERENCES cityobject (id); + +ALTER TABLE ur_publictransit ADD CONSTRAINT ur_publictransit_target_fk FOREIGN KEY (target_id) +REFERENCES cityobject (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +ALTER TABLE ur_publictransitdatatype ADD CONSTRAINT ur_publictra_objectcl_fk_1 FOREIGN KEY (objectclass_id) +REFERENCES objectclass (id); + +ALTER TABLE ur_publictransitdatatype ADD CONSTRAINT ur_public_cityob_dataty_fk FOREIGN KEY (cityobjectgroup_datatype_id) +REFERENCES ur_cityobjectgroup_3 (id); + +-- -------------------------------------------------------------------- +-- ur_publictransportationfa +-- -------------------------------------------------------------------- +ALTER TABLE ur_publictransportationfa ADD CONSTRAINT ur_publictransportation_fk FOREIGN KEY (id) REFERENCES ur_urbanfunction (id); -- -------------------------------------------------------------------- @@ -611,20 +1276,96 @@ ALTER TABLE ur_recreations ADD CONSTRAINT ur_recreations_fk FOREIGN KEY (id) REFERENCES ur_urbanfunction (id); -- -------------------------------------------------------------------- --- ur_statisticalgrid +-- ur_route -- -------------------------------------------------------------------- -ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisticalgrid_fk FOREIGN KEY (id) -REFERENCES cityobject (id); +ALTER TABLE ur_route ADD CONSTRAINT ur_route_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); +ALTER TABLE ur_route ADD CONSTRAINT ur_route_description_fk FOREIGN KEY (description_id) +REFERENCES ur_description (id) +ON DELETE SET NULL; + +ALTER TABLE ur_route ADD CONSTRAINT ur_route_parentroute_fk FOREIGN KEY (parentroute_id) +REFERENCES ur_route (id) +ON DELETE SET NULL; + +ALTER TABLE ur_route ADD CONSTRAINT ur_route_agency_fk FOREIGN KEY (agency_id) +REFERENCES ur_agency (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_statisticalgrid +-- -------------------------------------------------------------------- ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statistica_objectcla_fk FOREIGN KEY (objectclass_id) REFERENCES objectclass (id); -ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisti_lod_1multis_fk FOREIGN KEY (lod_1multisurfacegeometry_id) +ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisticalgrid_fk FOREIGN KEY (id) +REFERENCES cityobject (id); + +ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisti_lod_1multis_fk FOREIGN KEY (lod_1multisurface_id) REFERENCES surface_geometry (id); -ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisti_lod_2multis_fk FOREIGN KEY (lod_2multisurfacegeometry_id) +ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisti_lod_2multis_fk FOREIGN KEY (lod_2multisurface_id) REFERENCES surface_geometry (id); +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +ALTER TABLE ur_stop ADD CONSTRAINT ur_stop_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_stop ADD CONSTRAINT ur_stop_parentstation_fk FOREIGN KEY (parentstation_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +ALTER TABLE ur_stop ADD CONSTRAINT ur_stop_level_fk FOREIGN KEY (level_id) +REFERENCES ur_publictransit (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +ALTER TABLE ur_stoptime ADD CONSTRAINT ur_stoptime_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_stoptime ADD CONSTRAINT ur_stoptime_trip_fk FOREIGN KEY (trip_id) +REFERENCES ur_trip (id) +ON DELETE SET NULL; + +ALTER TABLE ur_stoptime ADD CONSTRAINT ur_stoptime_stop_fk FOREIGN KEY (stop_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +ALTER TABLE ur_transfer ADD CONSTRAINT ur_transfer_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_transfer ADD CONSTRAINT ur_transfer_from_fk FOREIGN KEY (from_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +ALTER TABLE ur_transfer ADD CONSTRAINT ur_transfer_to_fk FOREIGN KEY (to_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +ALTER TABLE ur_translation ADD CONSTRAINT ur_translation_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_translation ADD CONSTRAINT ur_translation_recordid_fk FOREIGN KEY (recordid_id) +REFERENCES ur_publictransit (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_translationjp +-- -------------------------------------------------------------------- +ALTER TABLE ur_translationjp ADD CONSTRAINT ur_translationjp_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- @@ -635,6 +1376,32 @@ ALTER TABLE ur_transportation_complex ADD CONSTRAINT ur_transp_comple_traffi_fk REFERENCES ur_trafficvolume (id) ON DELETE SET NULL; +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_route_fk FOREIGN KEY (route_id) +REFERENCES ur_route (id) +ON DELETE SET NULL; + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_calendar_fk FOREIGN KEY (calendar_id) +REFERENCES ur_calendar (id) +ON DELETE SET NULL; + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_calendardate_fk FOREIGN KEY (calendardate_id) +REFERENCES ur_calendardate (id) +ON DELETE SET NULL; + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_office_fk FOREIGN KEY (office_id) +REFERENCES ur_office (id) +ON DELETE SET NULL; + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_shape_fk FOREIGN KEY (shape_id) +REFERENCES ur_publictransit (id) +ON DELETE SET NULL; + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -659,7 +1426,13 @@ ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfunct_legalgrou_fk FOREIGN K REFERENCES ur_legalgrounds (id) ON DELETE SET NULL; -ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfunction_area_fk FOREIGN KEY (area_id) +ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfunct_lod0multi_fk FOREIGN KEY (lod0multisurface_id) +REFERENCES surface_geometry (id); + +ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfun_lod_1multis_fk FOREIGN KEY (lod_1multisurface_id) +REFERENCES surface_geometry (id); + +ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfun_lod_2multis_fk FOREIGN KEY (lod_2multisurface_id) REFERENCES surface_geometry (id); -- -------------------------------------------------------------------- @@ -695,6 +1468,20 @@ select :SRID mc from dual; prompt Used SRID for spatial indexes: &SRSNO; +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +CREATE INDEX ur_areaof_landus_areao_fkx ON ur_areaofannualdiversions (landusediver_areaofannual_id); + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +CREATE INDEX ur_attribution_agency_fkx ON ur_attribution (agency_id); + +CREATE INDEX ur_attribution_route_fkx ON ur_attribution (route_id); + +CREATE INDEX ur_attribution_trip_fkx ON ur_attribution (trip_id); + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -702,15 +1489,47 @@ CREATE INDEX ur_building_buildingde_fkx ON ur_building (buildingdetails_id); CREATE INDEX ur_building_largecusto_fkx ON ur_building (largecustomerfacilities_id); +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +CREATE INDEX ur_calendarda_calendar_fkx ON ur_calendardate (calendar_id); + +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +CREATE INDEX ur_fareattribut_agency_fkx ON ur_fareattribute (agency_id); + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +CREATE INDEX ur_farerule_fare_fkx ON ur_farerule (fare_id); + +CREATE INDEX ur_farerule_route_fkx ON ur_farerule (route_id); + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +CREATE INDEX ur_frequency_trip_fkx ON ur_frequency (trip_id); + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +CREATE INDEX ur_keyval_statis_gener_fkx ON ur_keyvaluepair (statisticalg_genericvalue_id); + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +CREATE INDEX ur_keyval_buildi_exten_fkx ON ur_keyvaluepair_1 (building_extendedattribut_id); + -- -------------------------------------------------------------------- -- ur_landpriceperlanduse -- -------------------------------------------------------------------- -CREATE INDEX ur_landpr_statis_landp_fkx ON ur_landpriceperlanduse (statisticalgrid_landprice_id); +CREATE INDEX ur_landpr_landpr_landp_fkx ON ur_landpriceperlanduse (landprice_landprice_id); -- -------------------------------------------------------------------- -- ur_numberofannualdiversio -- -------------------------------------------------------------------- -CREATE INDEX ur_number_statis_numbe_fkx ON ur_numberofannualdiversio (statisticalg_numberofannu_id); +CREATE INDEX ur_number_landus_numbe_fkx ON ur_numberofannualdiversio (landusediver_numberofannu_id); -- -------------------------------------------------------------------- -- ur_numberofhouseholds @@ -726,25 +1545,123 @@ CREATE INDEX ur_numbe_censu_numbe_fkx_1 ON ur_numberofhouseholds_1 (censusblock_ CREATE INDEX ur_number_census_numbe_fkx ON ur_numberofhouseholds_1 (censusblock_numberofhouse_id); +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +CREATE INDEX ur_pathway_from_fkx ON ur_pathway (from_id); + +CREATE INDEX ur_pathway_to_fkx ON ur_pathway (to_id); + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_POINT' AND COLUMN_NAME='POINT'; +INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) +VALUES ('UR_POINT','POINT', +MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); +CREATE INDEX ur_point_point_spx ON ur_point (point) INDEXTYPE IS MDSYS.SPATIAL_INDEX; + +CREATE INDEX ur_point_publict_point_fkx ON ur_point (publictransit_point_id); + -- -------------------------------------------------------------------- -- ur_populationbyageandsex -- -------------------------------------------------------------------- CREATE INDEX ur_popula_popula_popul_fkx ON ur_populationbyageandsex (population_populationbyag_id); +-- -------------------------------------------------------------------- +-- ur_publictransit +-- -------------------------------------------------------------------- +CREATE INDEX ur_publictra_objectcla_fkx ON ur_publictransit (objectclass_id); + +CREATE INDEX ur_publictransi_target_fkx ON ur_publictransit (target_id); + +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +CREATE INDEX ur_public_cityob_datat_fkx ON ur_publictransitdatatype (cityobjectgroup_datatype_id); + +CREATE INDEX ur_publictr_objectcl_fkx_1 ON ur_publictransitdatatype (objectclass_id); + +-- -------------------------------------------------------------------- +-- ur_route +-- -------------------------------------------------------------------- +CREATE INDEX ur_route_agency_fkx ON ur_route (agency_id); + +CREATE INDEX ur_route_description_fkx ON ur_route (description_id); + +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_ROUTE' AND COLUMN_NAME='LOD0MULTICURVE'; +INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) +VALUES ('UR_ROUTE','LOD0MULTICURVE', +MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); +CREATE INDEX ur_route_lod0multicurv_spx ON ur_route (lod0multicurve) INDEXTYPE IS MDSYS.SPATIAL_INDEX; + +CREATE INDEX ur_route_parentroute_fkx ON ur_route (parentroute_id); + -- -------------------------------------------------------------------- -- ur_statisticalgrid -- -------------------------------------------------------------------- -CREATE INDEX ur_statist_lod_1multis_fkx ON ur_statisticalgrid (lod_1multisurfacegeometry_id); +CREATE INDEX ur_statist_lod_1multis_fkx ON ur_statisticalgrid (lod_1multisurface_id); -CREATE INDEX ur_statist_lod_2multis_fkx ON ur_statisticalgrid (lod_2multisurfacegeometry_id); +CREATE INDEX ur_statist_lod_2multis_fkx ON ur_statisticalgrid (lod_2multisurface_id); CREATE INDEX ur_statistic_objectcla_fkx ON ur_statisticalgrid (objectclass_id); +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +CREATE INDEX ur_stop_level_fkx ON ur_stop (level_id); + +CREATE INDEX ur_stop_parentstation_fkx ON ur_stop (parentstation_id); + +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_STOP' AND COLUMN_NAME='POINT'; +INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) +VALUES ('UR_STOP','POINT', +MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); +CREATE INDEX ur_stop_point_spx ON ur_stop (point) INDEXTYPE IS MDSYS.SPATIAL_INDEX; + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +CREATE INDEX ur_stoptime_stop_fkx ON ur_stoptime (stop_id); + +CREATE INDEX ur_stoptime_trip_fkx ON ur_stoptime (trip_id); + +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +CREATE INDEX ur_transfer_from_fkx ON ur_transfer (from_id); + +CREATE INDEX ur_transfer_to_fkx ON ur_transfer (to_id); + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +CREATE INDEX ur_translatio_recordid_fkx ON ur_translation (recordid_id); + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- CREATE INDEX ur_transp_comple_traff_fkx ON ur_transportation_complex (trafficvolume_id); +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +CREATE INDEX ur_trip_calendar_fkx ON ur_trip (calendar_id); + +CREATE INDEX ur_trip_calendardate_fkx ON ur_trip (calendardate_id); + +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_TRIP' AND COLUMN_NAME='LOD0MULTICURVE'; +INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) +VALUES ('UR_TRIP','LOD0MULTICURVE', +MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); +CREATE INDEX ur_trip_lod0multicurve_spx ON ur_trip (lod0multicurve) INDEXTYPE IS MDSYS.SPATIAL_INDEX; + +CREATE INDEX ur_trip_office_fkx ON ur_trip (office_id); + +CREATE INDEX ur_trip_route_fkx ON ur_trip (route_id); + +CREATE INDEX ur_trip_shape_fkx ON ur_trip (shape_id); + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -755,21 +1672,49 @@ CREATE INDEX ur_urbanfu_to_cityobj_fk1x ON ur_urbanfunc_to_cityobjec (urbanfunct -- -------------------------------------------------------------------- -- ur_urbanfunction -- -------------------------------------------------------------------- -CREATE INDEX ur_urbanfunction_area_fkx ON ur_urbanfunction (area_id); +CREATE INDEX ur_urbanfunc_legalgrou_fkx ON ur_urbanfunction (legalgrounds_id); -DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_URBANFUNCTION' AND COLUMN_NAME='BOUNDARY'; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_URBANFUNCTION' AND COLUMN_NAME='LOD0MULTICURVE'; INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) -VALUES ('UR_URBANFUNCTION','BOUNDARY', +VALUES ('UR_URBANFUNCTION','LOD0MULTICURVE', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); -CREATE INDEX ur_urbanfunct_boundary_spx ON ur_urbanfunction (boundary) INDEXTYPE IS MDSYS.SPATIAL_INDEX; +CREATE INDEX ur_urbanfunc_lod0multi_spx ON ur_urbanfunction (lod0multicurve) INDEXTYPE IS MDSYS.SPATIAL_INDEX; -CREATE INDEX ur_urbanfunc_legalgrou_fkx ON ur_urbanfunction (legalgrounds_id); +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_URBANFUNCTION' AND COLUMN_NAME='LOD0MULTIPOINT'; +INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) +VALUES ('UR_URBANFUNCTION','LOD0MULTIPOINT', +MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); +CREATE INDEX ur_urbanfun_lod0mult_spx_1 ON ur_urbanfunction (lod0multipoint) INDEXTYPE IS MDSYS.SPATIAL_INDEX; + +CREATE INDEX ur_urbanfunc_lod0multi_fkx ON ur_urbanfunction (lod0multisurface_id); + +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_URBANFUNCTION' AND COLUMN_NAME='LOD_1MULTICURVE'; +INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) +VALUES ('UR_URBANFUNCTION','LOD_1MULTICURVE', +MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); +CREATE INDEX ur_urbanfu_lod_1multic_spx ON ur_urbanfunction (lod_1multicurve) INDEXTYPE IS MDSYS.SPATIAL_INDEX; + +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_URBANFUNCTION' AND COLUMN_NAME='LOD_1MULTIPOINT'; +INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) +VALUES ('UR_URBANFUNCTION','LOD_1MULTIPOINT', +MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); +CREATE INDEX ur_urbanfu_lod_1multip_spx ON ur_urbanfunction (lod_1multipoint) INDEXTYPE IS MDSYS.SPATIAL_INDEX; + +CREATE INDEX ur_urbanfu_lod_1multis_fkx ON ur_urbanfunction (lod_1multisurface_id); + +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_URBANFUNCTION' AND COLUMN_NAME='LOD_2MULTICURVE'; +INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) +VALUES ('UR_URBANFUNCTION','LOD_2MULTICURVE', +MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); +CREATE INDEX ur_urbanfu_lod_2multic_spx ON ur_urbanfunction (lod_2multicurve) INDEXTYPE IS MDSYS.SPATIAL_INDEX; -DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_URBANFUNCTION' AND COLUMN_NAME='LOCATION'; +DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME='UR_URBANFUNCTION' AND COLUMN_NAME='LOD_2MULTIPOINT'; INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) -VALUES ('UR_URBANFUNCTION','LOCATION', +VALUES ('UR_URBANFUNCTION','LOD_2MULTIPOINT', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', 0.000, 10000000.000, 0.0005), MDSYS.SDO_DIM_ELEMENT('Y', 0.000, 10000000.000, 0.0005),MDSYS.SDO_DIM_ELEMENT('Z', -1000, 10000, 0.0005)), &SRSNO); -CREATE INDEX ur_urbanfunct_location_spx ON ur_urbanfunction (location) INDEXTYPE IS MDSYS.SPATIAL_INDEX; +CREATE INDEX ur_urbanfu_lod_2multip_spx ON ur_urbanfunction (lod_2multipoint) INDEXTYPE IS MDSYS.SPATIAL_INDEX; + +CREATE INDEX ur_urbanfu_lod_2multis_fkx ON ur_urbanfunction (lod_2multisurface_id); CREATE INDEX ur_urbanfunc_objectcla_fkx ON ur_urbanfunction (objectclass_id); @@ -788,15 +1733,27 @@ CREATE SEQUENCE ur_landpriceperlandus_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CREATE SEQUENCE ur_numberofannualdive_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; +CREATE SEQUENCE ur_areaofannualdivers_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; + CREATE SEQUENCE ur_numberofhouseholds_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; +CREATE SEQUENCE ur_keyvaluepair_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; + CREATE SEQUENCE ur_buildingdetails_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; CREATE SEQUENCE ur_largecustomerfacil_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; +CREATE SEQUENCE ur_keyvaluepair_seq_1 INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; + CREATE SEQUENCE ur_trafficvolume_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; CREATE SEQUENCE ur_legalgrounds_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; CREATE SEQUENCE ur_numberofhousehol_seq_1 INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; +CREATE SEQUENCE ur_description_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; + +CREATE SEQUENCE ur_point_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; + +CREATE SEQUENCE ur_publictransitdatat_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 CACHE 10000; + diff --git a/resources/database/3dcitydb/oracle/DISABLE_ADE_VERSIONING.sql b/resources/database/3dcitydb/oracle/DISABLE_ADE_VERSIONING.sql index df275a6..dfc986a 100644 --- a/resources/database/3dcitydb/oracle/DISABLE_ADE_VERSIONING.sql +++ b/resources/database/3dcitydb/oracle/DISABLE_ADE_VERSIONING.sql @@ -1,6 +1,6 @@ --- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-03-20 09:53:29 +-- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-08-25 11:09:20 -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Disable Versioning ********************************* -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -exec DBMS_WM.DisableVersioning('ur_building,ur_buildingdetails,ur_censusblock,ur_cityobjectgroup,ur_developmentproject,ur_disasterdamage,ur_households,ur_land_use,ur_landpriceperlanduse,ur_largecustomerfacilitie,ur_legalgrounds,ur_numberofannualdiversio,ur_numberofhouseholds,ur_numberofhouseholds_1,ur_officesandemployees,ur_pollution,ur_population,ur_populationbyageandsex,ur_publictransit,ur_recreations,ur_statisticalgrid,ur_trafficvolume,ur_transportation_complex,ur_urbanfunc_to_cityobjec,ur_urbanfunction,ur_urbanization,ur_zone',true, true); +exec DBMS_WM.DisableVersioning('ur_agency,ur_areaofannualdiversions,ur_attribution,ur_building,ur_buildingdetails,ur_calendar,ur_calendardate,ur_censusblock,ur_cityobjectgroup,ur_cityobjectgroup_1,ur_cityobjectgroup_2,ur_cityobjectgroup_3,ur_description,ur_developmentproject,ur_disasterdamage,ur_fareattribute,ur_farerule,ur_feedinfo,ur_frequency,ur_households,ur_keyvaluepair,ur_keyvaluepair_1,ur_land_use,ur_landprice,ur_landpriceperlanduse,ur_landusediversion,ur_largecustomerfacilitie,ur_legalgrounds,ur_numberofannualdiversio,ur_numberofhouseholds,ur_numberofhouseholds_1,ur_office,ur_officesandemployees,ur_pathway,ur_point,ur_pollution,ur_population,ur_populationbyageandsex,ur_publictransit,ur_publictransitdatatype,ur_publictransportationfa,ur_recreations,ur_route,ur_statisticalgrid,ur_stop,ur_stoptime,ur_trafficvolume,ur_transfer,ur_translation,ur_translationjp,ur_transportation_complex,ur_trip,ur_urbanfunc_to_cityobjec,ur_urbanfunction,ur_urbanization,ur_zone',true, true); diff --git a/resources/database/3dcitydb/oracle/DROP_ADE_DB.sql b/resources/database/3dcitydb/oracle/DROP_ADE_DB.sql index 0b870e2..da3d85c 100644 --- a/resources/database/3dcitydb/oracle/DROP_ADE_DB.sql +++ b/resources/database/3dcitydb/oracle/DROP_ADE_DB.sql @@ -1,7 +1,34 @@ --- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-03-20 09:53:29 +-- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-08-25 11:09:20 -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Drop foreign keys ********************************** -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +-- -------------------------------------------------------------------- +-- ur_agency +-- -------------------------------------------------------------------- +ALTER TABLE ur_agency + DROP CONSTRAINT ur_agency_fk; + +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +ALTER TABLE ur_areaofannualdiversions + DROP CONSTRAINT ur_areaof_landus_areaof_fk; + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +ALTER TABLE ur_attribution + DROP CONSTRAINT ur_attribution_fk; + +ALTER TABLE ur_attribution + DROP CONSTRAINT ur_attribution_agency_fk; + +ALTER TABLE ur_attribution + DROP CONSTRAINT ur_attribution_route_fk; + +ALTER TABLE ur_attribution + DROP CONSTRAINT ur_attribution_trip_fk; + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -14,6 +41,21 @@ ALTER TABLE ur_building ALTER TABLE ur_building DROP CONSTRAINT ur_building_largecustom_fk; +-- -------------------------------------------------------------------- +-- ur_calendar +-- -------------------------------------------------------------------- +ALTER TABLE ur_calendar + DROP CONSTRAINT ur_calendar_fk; + +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +ALTER TABLE ur_calendardate + DROP CONSTRAINT ur_calendardate_fk; + +ALTER TABLE ur_calendardate + DROP CONSTRAINT ur_calendardat_calendar_fk; + -- -------------------------------------------------------------------- -- ur_censusblock -- -------------------------------------------------------------------- @@ -26,6 +68,24 @@ ALTER TABLE ur_censusblock ALTER TABLE ur_cityobjectgroup DROP CONSTRAINT ur_cityobjectgroup_fk; +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_1 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_1 + DROP CONSTRAINT ur_cityobjectgroup_fk_1; + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_2 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_2 + DROP CONSTRAINT ur_cityobjectgroup_fk_2; + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_3 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_3 + DROP CONSTRAINT ur_cityobjectgroup_fk_3; + -- -------------------------------------------------------------------- -- ur_developmentproject -- -------------------------------------------------------------------- @@ -38,29 +98,89 @@ ALTER TABLE ur_developmentproject ALTER TABLE ur_disasterdamage DROP CONSTRAINT ur_disasterdamage_fk; +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +ALTER TABLE ur_fareattribute + DROP CONSTRAINT ur_fareattribute_fk; + +ALTER TABLE ur_fareattribute + DROP CONSTRAINT ur_fareattribute_agency_fk; + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +ALTER TABLE ur_farerule + DROP CONSTRAINT ur_farerule_fk; + +ALTER TABLE ur_farerule + DROP CONSTRAINT ur_farerule_fare_fk; + +ALTER TABLE ur_farerule + DROP CONSTRAINT ur_farerule_route_fk; + +-- -------------------------------------------------------------------- +-- ur_feedinfo +-- -------------------------------------------------------------------- +ALTER TABLE ur_feedinfo + DROP CONSTRAINT ur_feedinfo_fk; + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +ALTER TABLE ur_frequency + DROP CONSTRAINT ur_frequency_fk; + +ALTER TABLE ur_frequency + DROP CONSTRAINT ur_frequency_trip_fk; + -- -------------------------------------------------------------------- -- ur_households -- -------------------------------------------------------------------- ALTER TABLE ur_households DROP CONSTRAINT ur_households_fk; +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +ALTER TABLE ur_keyvaluepair + DROP CONSTRAINT ur_keyval_statis_generi_fk; + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +ALTER TABLE ur_keyvaluepair_1 + DROP CONSTRAINT ur_keyval_buildi_extend_fk; + -- -------------------------------------------------------------------- -- ur_land_use -- -------------------------------------------------------------------- ALTER TABLE ur_land_use DROP CONSTRAINT ur_land_use_fk; +-- -------------------------------------------------------------------- +-- ur_landprice +-- -------------------------------------------------------------------- +ALTER TABLE ur_landprice + DROP CONSTRAINT ur_landprice_fk; + -- -------------------------------------------------------------------- -- ur_landpriceperlanduse -- -------------------------------------------------------------------- ALTER TABLE ur_landpriceperlanduse - DROP CONSTRAINT ur_landpr_statis_landpr_fk; + DROP CONSTRAINT ur_landpr_landpr_landpr_fk; + +-- -------------------------------------------------------------------- +-- ur_landusediversion +-- -------------------------------------------------------------------- +ALTER TABLE ur_landusediversion + DROP CONSTRAINT ur_landusediversion_fk; -- -------------------------------------------------------------------- -- ur_numberofannualdiversio -- -------------------------------------------------------------------- ALTER TABLE ur_numberofannualdiversio - DROP CONSTRAINT ur_number_statis_number_fk; + DROP CONSTRAINT ur_number_landus_number_fk; -- -------------------------------------------------------------------- -- ur_numberofhouseholds @@ -80,12 +200,36 @@ ALTER TABLE ur_numberofhouseholds_1 ALTER TABLE ur_numberofhouseholds_1 DROP CONSTRAINT ur_number_censu_numbe_fk_1; +-- -------------------------------------------------------------------- +-- ur_office +-- -------------------------------------------------------------------- +ALTER TABLE ur_office + DROP CONSTRAINT ur_office_fk; + -- -------------------------------------------------------------------- -- ur_officesandemployees -- -------------------------------------------------------------------- ALTER TABLE ur_officesandemployees DROP CONSTRAINT ur_officesandemployees_fk; +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +ALTER TABLE ur_pathway + DROP CONSTRAINT ur_pathway_fk; + +ALTER TABLE ur_pathway + DROP CONSTRAINT ur_pathway_from_fk; + +ALTER TABLE ur_pathway + DROP CONSTRAINT ur_pathway_to_fk; + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +ALTER TABLE ur_point + DROP CONSTRAINT ur_point_publictr_point_fk; + -- -------------------------------------------------------------------- -- ur_pollution -- -------------------------------------------------------------------- @@ -107,23 +251,59 @@ ALTER TABLE ur_populationbyageandsex -- -------------------------------------------------------------------- -- ur_publictransit -- -------------------------------------------------------------------- +ALTER TABLE ur_publictransit + DROP CONSTRAINT ur_publictran_objectcla_fk; + ALTER TABLE ur_publictransit DROP CONSTRAINT ur_publictransit_fk; +ALTER TABLE ur_publictransit + DROP CONSTRAINT ur_publictransit_target_fk; + +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +ALTER TABLE ur_publictransitdatatype + DROP CONSTRAINT ur_publictra_objectcl_fk_1; + +ALTER TABLE ur_publictransitdatatype + DROP CONSTRAINT ur_public_cityob_dataty_fk; + +-- -------------------------------------------------------------------- +-- ur_publictransportationfa +-- -------------------------------------------------------------------- +ALTER TABLE ur_publictransportationfa + DROP CONSTRAINT ur_publictransportation_fk; + -- -------------------------------------------------------------------- -- ur_recreations -- -------------------------------------------------------------------- ALTER TABLE ur_recreations DROP CONSTRAINT ur_recreations_fk; +-- -------------------------------------------------------------------- +-- ur_route +-- -------------------------------------------------------------------- +ALTER TABLE ur_route + DROP CONSTRAINT ur_route_fk; + +ALTER TABLE ur_route + DROP CONSTRAINT ur_route_description_fk; + +ALTER TABLE ur_route + DROP CONSTRAINT ur_route_parentroute_fk; + +ALTER TABLE ur_route + DROP CONSTRAINT ur_route_agency_fk; + -- -------------------------------------------------------------------- -- ur_statisticalgrid -- -------------------------------------------------------------------- ALTER TABLE ur_statisticalgrid - DROP CONSTRAINT ur_statisticalgrid_fk; + DROP CONSTRAINT ur_statistica_objectcla_fk; ALTER TABLE ur_statisticalgrid - DROP CONSTRAINT ur_statistica_objectcla_fk; + DROP CONSTRAINT ur_statisticalgrid_fk; ALTER TABLE ur_statisticalgrid DROP CONSTRAINT ur_statisti_lod_1multis_fk; @@ -131,6 +311,57 @@ ALTER TABLE ur_statisticalgrid ALTER TABLE ur_statisticalgrid DROP CONSTRAINT ur_statisti_lod_2multis_fk; +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +ALTER TABLE ur_stop + DROP CONSTRAINT ur_stop_fk; + +ALTER TABLE ur_stop + DROP CONSTRAINT ur_stop_parentstation_fk; + +ALTER TABLE ur_stop + DROP CONSTRAINT ur_stop_level_fk; + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +ALTER TABLE ur_stoptime + DROP CONSTRAINT ur_stoptime_fk; + +ALTER TABLE ur_stoptime + DROP CONSTRAINT ur_stoptime_trip_fk; + +ALTER TABLE ur_stoptime + DROP CONSTRAINT ur_stoptime_stop_fk; + +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +ALTER TABLE ur_transfer + DROP CONSTRAINT ur_transfer_fk; + +ALTER TABLE ur_transfer + DROP CONSTRAINT ur_transfer_from_fk; + +ALTER TABLE ur_transfer + DROP CONSTRAINT ur_transfer_to_fk; + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +ALTER TABLE ur_translation + DROP CONSTRAINT ur_translation_fk; + +ALTER TABLE ur_translation + DROP CONSTRAINT ur_translation_recordid_fk; + +-- -------------------------------------------------------------------- +-- ur_translationjp +-- -------------------------------------------------------------------- +ALTER TABLE ur_translationjp + DROP CONSTRAINT ur_translationjp_fk; + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- @@ -140,6 +371,27 @@ ALTER TABLE ur_transportation_complex ALTER TABLE ur_transportation_complex DROP CONSTRAINT ur_transp_comple_traffi_fk; +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_route_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_calendar_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_calendardate_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_office_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_shape_fk; + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -162,7 +414,13 @@ ALTER TABLE ur_urbanfunction DROP CONSTRAINT ur_urbanfunct_legalgrou_fk; ALTER TABLE ur_urbanfunction - DROP CONSTRAINT ur_urbanfunction_area_fk; + DROP CONSTRAINT ur_urbanfunct_lod0multi_fk; + +ALTER TABLE ur_urbanfunction + DROP CONSTRAINT ur_urbanfun_lod_1multis_fk; + +ALTER TABLE ur_urbanfunction + DROP CONSTRAINT ur_urbanfun_lod_2multis_fk; -- -------------------------------------------------------------------- -- ur_urbanization @@ -182,6 +440,21 @@ ALTER TABLE ur_zone -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Drop tables *************************************** -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +-- -------------------------------------------------------------------- +-- ur_agency +-- -------------------------------------------------------------------- +DROP TABLE ur_agency; + +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +DROP TABLE ur_areaofannualdiversions; + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +DROP TABLE ur_attribution; + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -192,6 +465,16 @@ DROP TABLE ur_building; -- -------------------------------------------------------------------- DROP TABLE ur_buildingdetails; +-- -------------------------------------------------------------------- +-- ur_calendar +-- -------------------------------------------------------------------- +DROP TABLE ur_calendar; + +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +DROP TABLE ur_calendardate; + -- -------------------------------------------------------------------- -- ur_censusblock -- -------------------------------------------------------------------- @@ -202,6 +485,26 @@ DROP TABLE ur_censusblock; -- -------------------------------------------------------------------- DROP TABLE ur_cityobjectgroup; +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_1 +-- -------------------------------------------------------------------- +DROP TABLE ur_cityobjectgroup_1; + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_2 +-- -------------------------------------------------------------------- +DROP TABLE ur_cityobjectgroup_2; + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_3 +-- -------------------------------------------------------------------- +DROP TABLE ur_cityobjectgroup_3; + +-- -------------------------------------------------------------------- +-- ur_description +-- -------------------------------------------------------------------- +DROP TABLE ur_description; + -- -------------------------------------------------------------------- -- ur_developmentproject -- -------------------------------------------------------------------- @@ -212,21 +515,61 @@ DROP TABLE ur_developmentproject; -- -------------------------------------------------------------------- DROP TABLE ur_disasterdamage; +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +DROP TABLE ur_fareattribute; + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +DROP TABLE ur_farerule; + +-- -------------------------------------------------------------------- +-- ur_feedinfo +-- -------------------------------------------------------------------- +DROP TABLE ur_feedinfo; + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +DROP TABLE ur_frequency; + -- -------------------------------------------------------------------- -- ur_households -- -------------------------------------------------------------------- DROP TABLE ur_households; +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +DROP TABLE ur_keyvaluepair; + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +DROP TABLE ur_keyvaluepair_1; + -- -------------------------------------------------------------------- -- ur_land_use -- -------------------------------------------------------------------- DROP TABLE ur_land_use; +-- -------------------------------------------------------------------- +-- ur_landprice +-- -------------------------------------------------------------------- +DROP TABLE ur_landprice; + -- -------------------------------------------------------------------- -- ur_landpriceperlanduse -- -------------------------------------------------------------------- DROP TABLE ur_landpriceperlanduse; +-- -------------------------------------------------------------------- +-- ur_landusediversion +-- -------------------------------------------------------------------- +DROP TABLE ur_landusediversion; + -- -------------------------------------------------------------------- -- ur_largecustomerfacilitie -- -------------------------------------------------------------------- @@ -252,11 +595,26 @@ DROP TABLE ur_numberofhouseholds; -- -------------------------------------------------------------------- DROP TABLE ur_numberofhouseholds_1; +-- -------------------------------------------------------------------- +-- ur_office +-- -------------------------------------------------------------------- +DROP TABLE ur_office; + -- -------------------------------------------------------------------- -- ur_officesandemployees -- -------------------------------------------------------------------- DROP TABLE ur_officesandemployees; +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +DROP TABLE ur_pathway; + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +DROP TABLE ur_point; + -- -------------------------------------------------------------------- -- ur_pollution -- -------------------------------------------------------------------- @@ -277,26 +635,71 @@ DROP TABLE ur_populationbyageandsex; -- -------------------------------------------------------------------- DROP TABLE ur_publictransit; +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +DROP TABLE ur_publictransitdatatype; + +-- -------------------------------------------------------------------- +-- ur_publictransportationfa +-- -------------------------------------------------------------------- +DROP TABLE ur_publictransportationfa; + -- -------------------------------------------------------------------- -- ur_recreations -- -------------------------------------------------------------------- DROP TABLE ur_recreations; +-- -------------------------------------------------------------------- +-- ur_route +-- -------------------------------------------------------------------- +DROP TABLE ur_route; + -- -------------------------------------------------------------------- -- ur_statisticalgrid -- -------------------------------------------------------------------- DROP TABLE ur_statisticalgrid; +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +DROP TABLE ur_stop; + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +DROP TABLE ur_stoptime; + -- -------------------------------------------------------------------- -- ur_trafficvolume -- -------------------------------------------------------------------- DROP TABLE ur_trafficvolume; +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +DROP TABLE ur_transfer; + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +DROP TABLE ur_translation; + +-- -------------------------------------------------------------------- +-- ur_translationjp +-- -------------------------------------------------------------------- +DROP TABLE ur_translationjp; + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- DROP TABLE ur_transportation_complex; +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +DROP TABLE ur_trip; + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -327,16 +730,28 @@ DROP SEQUENCE ur_landpriceperlandus_seq; DROP SEQUENCE ur_numberofannualdive_seq; +DROP SEQUENCE ur_areaofannualdivers_seq; + DROP SEQUENCE ur_numberofhouseholds_seq; +DROP SEQUENCE ur_keyvaluepair_seq; + DROP SEQUENCE ur_buildingdetails_seq; DROP SEQUENCE ur_largecustomerfacil_seq; +DROP SEQUENCE ur_keyvaluepair_seq_1; + DROP SEQUENCE ur_trafficvolume_seq; DROP SEQUENCE ur_legalgrounds_seq; DROP SEQUENCE ur_numberofhousehol_seq_1; +DROP SEQUENCE ur_description_seq; + +DROP SEQUENCE ur_point_seq; + +DROP SEQUENCE ur_publictransitdatat_seq; + PURGE RECYCLEBIN; diff --git a/resources/database/3dcitydb/oracle/ENABLE_ADE_VERSIONING.sql b/resources/database/3dcitydb/oracle/ENABLE_ADE_VERSIONING.sql index 67e02e1..ad49928 100644 --- a/resources/database/3dcitydb/oracle/ENABLE_ADE_VERSIONING.sql +++ b/resources/database/3dcitydb/oracle/ENABLE_ADE_VERSIONING.sql @@ -1,6 +1,6 @@ --- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-03-20 09:53:29 +-- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-08-25 11:09:20 -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Enable Versioning ********************************** -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -exec DBMS_WM.EnableVersioning('ur_building,ur_buildingdetails,ur_censusblock,ur_cityobjectgroup,ur_developmentproject,ur_disasterdamage,ur_households,ur_land_use,ur_landpriceperlanduse,ur_largecustomerfacilitie,ur_legalgrounds,ur_numberofannualdiversio,ur_numberofhouseholds,ur_numberofhouseholds_1,ur_officesandemployees,ur_pollution,ur_population,ur_populationbyageandsex,ur_publictransit,ur_recreations,ur_statisticalgrid,ur_trafficvolume,ur_transportation_complex,ur_urbanfunc_to_cityobjec,ur_urbanfunction,ur_urbanization,ur_zone','VIEW_WO_OVERWRITE'); +exec DBMS_WM.EnableVersioning('ur_agency,ur_areaofannualdiversions,ur_attribution,ur_building,ur_buildingdetails,ur_calendar,ur_calendardate,ur_censusblock,ur_cityobjectgroup,ur_cityobjectgroup_1,ur_cityobjectgroup_2,ur_cityobjectgroup_3,ur_description,ur_developmentproject,ur_disasterdamage,ur_fareattribute,ur_farerule,ur_feedinfo,ur_frequency,ur_households,ur_keyvaluepair,ur_keyvaluepair_1,ur_land_use,ur_landprice,ur_landpriceperlanduse,ur_landusediversion,ur_largecustomerfacilitie,ur_legalgrounds,ur_numberofannualdiversio,ur_numberofhouseholds,ur_numberofhouseholds_1,ur_office,ur_officesandemployees,ur_pathway,ur_point,ur_pollution,ur_population,ur_populationbyageandsex,ur_publictransit,ur_publictransitdatatype,ur_publictransportationfa,ur_recreations,ur_route,ur_statisticalgrid,ur_stop,ur_stoptime,ur_trafficvolume,ur_transfer,ur_translation,ur_translationjp,ur_transportation_complex,ur_trip,ur_urbanfunc_to_cityobjec,ur_urbanfunction,ur_urbanization,ur_zone','VIEW_WO_OVERWRITE'); diff --git a/resources/database/3dcitydb/postgreSQL/CREATE_ADE_DB.sql b/resources/database/3dcitydb/postgreSQL/CREATE_ADE_DB.sql index 20e872c..cbb4f24 100644 --- a/resources/database/3dcitydb/postgreSQL/CREATE_ADE_DB.sql +++ b/resources/database/3dcitydb/postgreSQL/CREATE_ADE_DB.sql @@ -1,7 +1,62 @@ --- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-03-20 09:53:29 +-- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-08-25 11:09:20 -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Create tables ************************************** -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +-- -------------------------------------------------------------------- +-- ur_agency +-- -------------------------------------------------------------------- +CREATE TABLE ur_agency +( + id INTEGER NOT NULL, + address VARCHAR(1000), + email VARCHAR(1000), + fareurl VARCHAR(1000), + language VARCHAR(1000), + language_codespace VARCHAR(1000), + name VARCHAR(1000), + officialname VARCHAR(1000), + phone VARCHAR(1000), + presidentname VARCHAR(1000), + presidentposition VARCHAR(1000), + timezone VARCHAR(1000), + timezone_codespace VARCHAR(1000), + url VARCHAR(1000), + zipnumber VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +CREATE TABLE ur_areaofannualdiversions +( + id INTEGER NOT NULL, + area NUMERIC, + area_uom VARCHAR(1000), + landusediver_areaofannual_id INTEGER, + year DATE, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +CREATE TABLE ur_attribution +( + id INTEGER NOT NULL, + agency_id INTEGER, + email VARCHAR(1000), + isauthority NUMERIC, + isoperator NUMERIC, + isproducer NUMERIC, + organizationname VARCHAR(1000), + phonenumber VARCHAR(1000), + route_id INTEGER, + trip_id INTEGER, + url VARCHAR(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -53,6 +108,37 @@ CREATE TABLE ur_buildingdetails PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_calendar +-- -------------------------------------------------------------------- +CREATE TABLE ur_calendar +( + id INTEGER NOT NULL, + enddate TIMESTAMP WITH TIME ZONE, + friday NUMERIC, + monday NUMERIC, + saturday NUMERIC, + startdate TIMESTAMP WITH TIME ZONE, + sunday NUMERIC, + thursday NUMERIC, + tuesday NUMERIC, + wednesday NUMERIC, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +CREATE TABLE ur_calendardate +( + id INTEGER NOT NULL, + calendar_id INTEGER, + date_ TIMESTAMP WITH TIME ZONE, + exceptiontype VARCHAR(1000), + exceptiontype_codespace VARCHAR(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_censusblock -- -------------------------------------------------------------------- @@ -78,6 +164,51 @@ CREATE TABLE ur_cityobjectgroup PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_1 +-- -------------------------------------------------------------------- +CREATE TABLE ur_cityobjectgroup_1 +( + id INTEGER NOT NULL, + fiscalyearofpublication DATE, + language VARCHAR(1000), + language_codespace VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_2 +-- -------------------------------------------------------------------- +CREATE TABLE ur_cityobjectgroup_2 +( + id INTEGER NOT NULL, + fiscalyearofpublication DATE, + language VARCHAR(1000), + language_codespace VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_3 +-- -------------------------------------------------------------------- +CREATE TABLE ur_cityobjectgroup_3 +( + id INTEGER NOT NULL, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_description +-- -------------------------------------------------------------------- +CREATE TABLE ur_description +( + id INTEGER NOT NULL, + description VARCHAR(1000), + frequencyofservice INTEGER, + numberofcustomers INTEGER, + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_developmentproject -- -------------------------------------------------------------------- @@ -119,6 +250,77 @@ CREATE TABLE ur_disasterdamage PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +CREATE TABLE ur_fareattribute +( + id INTEGER NOT NULL, + agency_id INTEGER, + currencytype VARCHAR(1000), + currencytype_codespace VARCHAR(1000), + paymentmethod VARCHAR(1000), + paymentmethod_codespace VARCHAR(1000), + price NUMERIC, + transferduration INTEGER, + transfers VARCHAR(1000), + transfers_codespace VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +CREATE TABLE ur_farerule +( + id INTEGER NOT NULL, + containsid VARCHAR(1000), + containsid_codespace VARCHAR(1000), + destinationid VARCHAR(1000), + destinationid_codespace VARCHAR(1000), + fare_id INTEGER, + originid VARCHAR(1000), + originid_codespace VARCHAR(1000), + route_id INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_feedinfo +-- -------------------------------------------------------------------- +CREATE TABLE ur_feedinfo +( + id INTEGER NOT NULL, + contactemail VARCHAR(1000), + contacturl VARCHAR(1000), + defaultlanguage VARCHAR(1000), + defaultlanguage_codespace VARCHAR(1000), + detailedinfo VARCHAR(1000), + enddate TIMESTAMP WITH TIME ZONE, + language VARCHAR(1000), + language_codespace VARCHAR(1000), + publishername VARCHAR(1000), + publisherurl VARCHAR(1000), + startdate TIMESTAMP WITH TIME ZONE, + version VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +CREATE TABLE ur_frequency +( + id INTEGER NOT NULL, + endtime TIMESTAMP WITH TIME ZONE, + exacttimes VARCHAR(1000), + exacttimes_codespace VARCHAR(1000), + headwaysecs INTEGER, + starttime TIMESTAMP WITH TIME ZONE, + trip_id INTEGER, + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_households -- -------------------------------------------------------------------- @@ -130,6 +332,48 @@ CREATE TABLE ur_households PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +CREATE TABLE ur_keyvaluepair +( + id INTEGER NOT NULL, + codevalue VARCHAR(1000), + codevalue_codespace VARCHAR(1000), + datevalue TIMESTAMP WITH TIME ZONE, + doublevalue NUMERIC, + intvalue INTEGER, + key VARCHAR(1000), + key_codespace VARCHAR(1000), + measuredvalue NUMERIC, + measuredvalue_uom VARCHAR(1000), + statisticalg_genericvalue_id INTEGER, + stringvalue VARCHAR(1000), + urivalue VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +CREATE TABLE ur_keyvaluepair_1 +( + id INTEGER NOT NULL, + building_extendedattribut_id INTEGER, + codevalue VARCHAR(1000), + codevalue_codespace VARCHAR(1000), + datevalue TIMESTAMP WITH TIME ZONE, + doublevalue NUMERIC, + intvalue INTEGER, + key VARCHAR(1000), + key_codespace VARCHAR(1000), + measuredvalue NUMERIC, + measuredvalue_uom VARCHAR(1000), + stringvalue VARCHAR(1000), + urivalue VARCHAR(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_land_use -- -------------------------------------------------------------------- @@ -164,17 +408,35 @@ CREATE TABLE ur_land_use ); -- -------------------------------------------------------------------- --- ur_landpriceperlanduse +-- ur_landprice -- -------------------------------------------------------------------- -CREATE TABLE ur_landpriceperlanduse +CREATE TABLE ur_landprice ( id INTEGER NOT NULL, currencyunit VARCHAR(1000), currencyunit_codespace VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_landpriceperlanduse +-- -------------------------------------------------------------------- +CREATE TABLE ur_landpriceperlanduse +( + id INTEGER NOT NULL, landprice INTEGER, + landprice_landprice_id INTEGER, landuse VARCHAR(1000), landuse_codespace VARCHAR(1000), - statisticalgrid_landprice_id INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_landusediversion +-- -------------------------------------------------------------------- +CREATE TABLE ur_landusediversion +( + id INTEGER NOT NULL, PRIMARY KEY (id) ); @@ -234,10 +496,8 @@ CREATE TABLE ur_legalgrounds CREATE TABLE ur_numberofannualdiversio ( id INTEGER NOT NULL, - area NUMERIC, - area_uom VARCHAR(1000), count INTEGER, - statisticalg_numberofannu_id INTEGER, + landusediver_numberofannu_id INTEGER, year DATE, PRIMARY KEY (id) ); @@ -270,6 +530,18 @@ CREATE TABLE ur_numberofhouseholds_1 PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_office +-- -------------------------------------------------------------------- +CREATE TABLE ur_office +( + id INTEGER NOT NULL, + name VARCHAR(1000), + phone VARCHAR(1000), + url VARCHAR(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_officesandemployees -- -------------------------------------------------------------------- @@ -281,6 +553,44 @@ CREATE TABLE ur_officesandemployees PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +CREATE TABLE ur_pathway +( + id INTEGER NOT NULL, + from_id INTEGER, + isbidirectional VARCHAR(1000), + isbidirectional_codespace VARCHAR(1000), + length NUMERIC, + length_uom VARCHAR(1000), + maxslope NUMERIC, + minwidth NUMERIC, + mode_ VARCHAR(1000), + mode_codespace VARCHAR(1000), + reversedsignpostedas VARCHAR(1000), + signpostedas VARCHAR(1000), + staircount INTEGER, + to_id INTEGER, + traversaltime INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +CREATE TABLE ur_point +( + id INTEGER NOT NULL, + latitude NUMERIC, + longitude NUMERIC, + point geometry(GEOMETRYZ), + pointdistancetraveled NUMERIC, + pointsequence INTEGER, + publictransit_point_id INTEGER, + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_pollution -- -------------------------------------------------------------------- @@ -320,12 +630,10 @@ CREATE TABLE ur_population CREATE TABLE ur_populationbyageandsex ( id INTEGER NOT NULL, - age VARCHAR(1000), - age_codespace VARCHAR(1000), + ageandsex VARCHAR(1000), + ageandsex_codespace VARCHAR(1000), number_ INTEGER, population_populationbyag_id INTEGER, - sex VARCHAR(1000), - sex_codespace VARCHAR(1000), PRIMARY KEY (id) ); @@ -333,6 +641,30 @@ CREATE TABLE ur_populationbyageandsex -- ur_publictransit -- -------------------------------------------------------------------- CREATE TABLE ur_publictransit +( + id INTEGER NOT NULL, + index_ NUMERIC, + objectclass_id INTEGER, + orgid VARCHAR(1000), + target_id INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +CREATE TABLE ur_publictransitdatatype +( + id INTEGER NOT NULL, + cityobjectgroup_datatype_id INTEGER, + objectclass_id INTEGER, + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_publictransportationfa +-- -------------------------------------------------------------------- +CREATE TABLE ur_publictransportationfa ( id INTEGER NOT NULL, companyname VARCHAR(1000), @@ -354,6 +686,35 @@ CREATE TABLE ur_recreations PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_route +-- -------------------------------------------------------------------- +CREATE TABLE ur_route +( + id INTEGER NOT NULL, + agency_id INTEGER, + color VARCHAR(1000), + continuousdropoff VARCHAR(1000), + continuousdropoff_codespace VARCHAR(1000), + continuouspickup VARCHAR(1000), + continuouspickup_codespace VARCHAR(1000), + description_id INTEGER, + destinationstop VARCHAR(1000), + lod0multicurve geometry(GEOMETRYZ), + longname VARCHAR(1000), + originstop VARCHAR(1000), + parentroute_id INTEGER, + routesortorder INTEGER, + shortname VARCHAR(1000), + textcolor VARCHAR(1000), + type VARCHAR(1000), + type_codespace VARCHAR(1000), + updatedate TIMESTAMP WITH TIME ZONE, + url VARCHAR(1000), + viastop VARCHAR(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_statisticalgrid -- -------------------------------------------------------------------- @@ -367,8 +728,8 @@ CREATE TABLE ur_statisticalgrid city_codespace VARCHAR(1000), class VARCHAR(1000), class_codespace VARCHAR(1000), - lod_1multisurfacegeometry_id INTEGER, - lod_2multisurfacegeometry_id INTEGER, + lod_1multisurface_id INTEGER, + lod_2multisurface_id INTEGER, objectclass_id INTEGER, prefecture VARCHAR(1000), prefecture_codespace VARCHAR(1000), @@ -379,6 +740,59 @@ CREATE TABLE ur_statisticalgrid PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +CREATE TABLE ur_stop +( + id INTEGER NOT NULL, + code VARCHAR(1000), + code_codespace VARCHAR(1000), + latitude NUMERIC, + level_id INTEGER, + locationtype VARCHAR(1000), + locationtype_codespace VARCHAR(1000), + longitude NUMERIC, + parentstation_id INTEGER, + platformcode VARCHAR(1000), + point geometry(GEOMETRYZ), + timezone VARCHAR(1000), + timezone_codespace VARCHAR(1000), + ttsname VARCHAR(1000), + url VARCHAR(1000), + wheelchairboarding VARCHAR(1000), + wheelchairboarding_codespace VARCHAR(1000), + zoneid VARCHAR(1000), + zoneid_codespace VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +CREATE TABLE ur_stoptime +( + id INTEGER NOT NULL, + arrivaltime TIMESTAMP WITH TIME ZONE, + continuousdropofft_codespace VARCHAR(1000), + continuousdropofftype VARCHAR(1000), + continuouspickupty_codespace VARCHAR(1000), + continuouspickuptype VARCHAR(1000), + departuretime TIMESTAMP WITH TIME ZONE, + dropofftype VARCHAR(1000), + dropofftype_codespace VARCHAR(1000), + headsign VARCHAR(1000), + pickuptype VARCHAR(1000), + pickuptype_codespace VARCHAR(1000), + shapedistancetraveled NUMERIC, + stop_id INTEGER, + stopsequence INTEGER, + timepoint VARCHAR(1000), + timepoint_codespace VARCHAR(1000), + trip_id INTEGER, + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_trafficvolume -- -------------------------------------------------------------------- @@ -405,6 +819,50 @@ CREATE TABLE ur_trafficvolume PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +CREATE TABLE ur_transfer +( + id INTEGER NOT NULL, + from_id INTEGER, + mintransfertime INTEGER, + to_id INTEGER, + transfertype VARCHAR(1000), + transfertype_codespace VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +CREATE TABLE ur_translation +( + id INTEGER NOT NULL, + fieldname VARCHAR(1000), + fieldvalue VARCHAR(1000), + language VARCHAR(1000), + language_codespace VARCHAR(1000), + recordid_id INTEGER, + recordsubid VARCHAR(1000), + tablename VARCHAR(1000), + tablename_codespace VARCHAR(1000), + translation VARCHAR(1000), + PRIMARY KEY (id) +); + +-- -------------------------------------------------------------------- +-- ur_translationjp +-- -------------------------------------------------------------------- +CREATE TABLE ur_translationjp +( + id INTEGER NOT NULL, + language VARCHAR(1000), + language_codespace VARCHAR(1000), + translation VARCHAR(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- @@ -419,6 +877,31 @@ CREATE TABLE ur_transportation_complex PRIMARY KEY (id) ); +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +CREATE TABLE ur_trip +( + id INTEGER NOT NULL, + bikeallowed VARCHAR(1000), + bikeallowed_codespace VARCHAR(1000), + blockid VARCHAR(1000), + calendar_id INTEGER, + calendardate_id INTEGER, + directionid VARCHAR(1000), + directionid_codespace VARCHAR(1000), + headsign VARCHAR(1000), + lod0multicurve geometry(GEOMETRYZ), + office_id INTEGER, + route_id INTEGER, + shape_id INTEGER, + shortname VARCHAR(1000), + symbol VARCHAR(1000), + wheelchairaccessib_codespace VARCHAR(1000), + wheelchairaccessible VARCHAR(1000), + PRIMARY KEY (id) +); + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -436,10 +919,8 @@ CREATE TABLE ur_urbanfunction ( id INTEGER NOT NULL, abstract VARCHAR(1000), - area_id INTEGER, areaclassification_codespace VARCHAR(1000), areaclassificationtype VARCHAR(1000), - boundary geometry(GEOMETRYZ), capacity INTEGER, city VARCHAR(1000), city_codespace VARCHAR(1000), @@ -453,7 +934,15 @@ CREATE TABLE ur_urbanfunction function VARCHAR(1000), function_codespace VARCHAR(1000), legalgrounds_id INTEGER, - location geometry(GEOMETRYZ), + lod0multicurve geometry(GEOMETRYZ), + lod0multipoint geometry(GEOMETRYZ), + lod0multisurface_id INTEGER, + lod_1multicurve geometry(GEOMETRYZ), + lod_1multipoint geometry(GEOMETRYZ), + lod_1multisurface_id INTEGER, + lod_2multicurve geometry(GEOMETRYZ), + lod_2multipoint geometry(GEOMETRYZ), + lod_2multisurface_id INTEGER, nominalarea NUMERIC, nominalarea_uom VARCHAR(1000), note VARCHAR(1000), @@ -494,6 +983,36 @@ CREATE TABLE ur_zone -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Create foreign keys ******************************** -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +-- -------------------------------------------------------------------- +-- ur_agency +-- -------------------------------------------------------------------- +ALTER TABLE ur_agency ADD CONSTRAINT ur_agency_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +ALTER TABLE ur_areaofannualdiversions ADD CONSTRAINT ur_areaof_landus_areaof_fk FOREIGN KEY (landusediver_areaofannual_id) +REFERENCES ur_landusediversion (id); + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +ALTER TABLE ur_attribution ADD CONSTRAINT ur_attribution_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_attribution ADD CONSTRAINT ur_attribution_agency_fk FOREIGN KEY (agency_id) +REFERENCES ur_agency (id) +ON DELETE SET NULL; + +ALTER TABLE ur_attribution ADD CONSTRAINT ur_attribution_route_fk FOREIGN KEY (route_id) +REFERENCES ur_route (id) +ON DELETE SET NULL; + +ALTER TABLE ur_attribution ADD CONSTRAINT ur_attribution_trip_fk FOREIGN KEY (trip_id) +REFERENCES ur_trip (id) +ON DELETE SET NULL; + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -508,6 +1027,22 @@ ALTER TABLE ur_building ADD CONSTRAINT ur_building_largecustom_fk FOREIGN KEY (l REFERENCES ur_largecustomerfacilitie (id) ON DELETE SET NULL; +-- -------------------------------------------------------------------- +-- ur_calendar +-- -------------------------------------------------------------------- +ALTER TABLE ur_calendar ADD CONSTRAINT ur_calendar_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +ALTER TABLE ur_calendardate ADD CONSTRAINT ur_calendardate_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_calendardate ADD CONSTRAINT ur_calendardat_calendar_fk FOREIGN KEY (calendar_id) +REFERENCES ur_calendar (id) +ON DELETE SET NULL; + -- -------------------------------------------------------------------- -- ur_censusblock -- -------------------------------------------------------------------- @@ -521,7 +1056,25 @@ ALTER TABLE ur_cityobjectgroup ADD CONSTRAINT ur_cityobjectgroup_fk FOREIGN KEY REFERENCES cityobjectgroup (id); -- -------------------------------------------------------------------- --- ur_developmentproject +-- ur_cityobjectgroup_1 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_1 ADD CONSTRAINT ur_cityobjectgroup_fk_1 FOREIGN KEY (id) +REFERENCES cityobjectgroup (id); + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_2 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_2 ADD CONSTRAINT ur_cityobjectgroup_fk_2 FOREIGN KEY (id) +REFERENCES cityobjectgroup (id); + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_3 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_3 ADD CONSTRAINT ur_cityobjectgroup_fk_3 FOREIGN KEY (id) +REFERENCES cityobjectgroup (id); + +-- -------------------------------------------------------------------- +-- ur_developmentproject -- -------------------------------------------------------------------- ALTER TABLE ur_developmentproject ADD CONSTRAINT ur_developmentproject_fk FOREIGN KEY (id) REFERENCES ur_zone (id); @@ -532,29 +1085,93 @@ REFERENCES ur_zone (id); ALTER TABLE ur_disasterdamage ADD CONSTRAINT ur_disasterdamage_fk FOREIGN KEY (id) REFERENCES ur_urbanfunction (id); +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +ALTER TABLE ur_fareattribute ADD CONSTRAINT ur_fareattribute_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_fareattribute ADD CONSTRAINT ur_fareattribute_agency_fk FOREIGN KEY (agency_id) +REFERENCES ur_agency (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +ALTER TABLE ur_farerule ADD CONSTRAINT ur_farerule_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_farerule ADD CONSTRAINT ur_farerule_fare_fk FOREIGN KEY (fare_id) +REFERENCES ur_fareattribute (id) +ON DELETE SET NULL; + +ALTER TABLE ur_farerule ADD CONSTRAINT ur_farerule_route_fk FOREIGN KEY (route_id) +REFERENCES ur_route (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_feedinfo +-- -------------------------------------------------------------------- +ALTER TABLE ur_feedinfo ADD CONSTRAINT ur_feedinfo_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +ALTER TABLE ur_frequency ADD CONSTRAINT ur_frequency_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_frequency ADD CONSTRAINT ur_frequency_trip_fk FOREIGN KEY (trip_id) +REFERENCES ur_trip (id) +ON DELETE SET NULL; + -- -------------------------------------------------------------------- -- ur_households -- -------------------------------------------------------------------- ALTER TABLE ur_households ADD CONSTRAINT ur_households_fk FOREIGN KEY (id) REFERENCES ur_statisticalgrid (id); +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +ALTER TABLE ur_keyvaluepair ADD CONSTRAINT ur_keyval_statis_generi_fk FOREIGN KEY (statisticalg_genericvalue_id) +REFERENCES ur_statisticalgrid (id); + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +ALTER TABLE ur_keyvaluepair_1 ADD CONSTRAINT ur_keyval_buildi_extend_fk FOREIGN KEY (building_extendedattribut_id) +REFERENCES ur_building (id); + -- -------------------------------------------------------------------- -- ur_land_use -- -------------------------------------------------------------------- ALTER TABLE ur_land_use ADD CONSTRAINT ur_land_use_fk FOREIGN KEY (id) REFERENCES land_use (id); +-- -------------------------------------------------------------------- +-- ur_landprice +-- -------------------------------------------------------------------- +ALTER TABLE ur_landprice ADD CONSTRAINT ur_landprice_fk FOREIGN KEY (id) +REFERENCES ur_statisticalgrid (id); + -- -------------------------------------------------------------------- -- ur_landpriceperlanduse -- -------------------------------------------------------------------- -ALTER TABLE ur_landpriceperlanduse ADD CONSTRAINT ur_landpr_statis_landpr_fk FOREIGN KEY (statisticalgrid_landprice_id) +ALTER TABLE ur_landpriceperlanduse ADD CONSTRAINT ur_landpr_landpr_landpr_fk FOREIGN KEY (landprice_landprice_id) +REFERENCES ur_landprice (id); + +-- -------------------------------------------------------------------- +-- ur_landusediversion +-- -------------------------------------------------------------------- +ALTER TABLE ur_landusediversion ADD CONSTRAINT ur_landusediversion_fk FOREIGN KEY (id) REFERENCES ur_statisticalgrid (id); -- -------------------------------------------------------------------- -- ur_numberofannualdiversio -- -------------------------------------------------------------------- -ALTER TABLE ur_numberofannualdiversio ADD CONSTRAINT ur_number_statis_number_fk FOREIGN KEY (statisticalg_numberofannu_id) -REFERENCES ur_statisticalgrid (id); +ALTER TABLE ur_numberofannualdiversio ADD CONSTRAINT ur_number_landus_number_fk FOREIGN KEY (landusediver_numberofannu_id) +REFERENCES ur_landusediversion (id); -- -------------------------------------------------------------------- -- ur_numberofhouseholds @@ -574,12 +1191,38 @@ REFERENCES ur_censusblock (id); ALTER TABLE ur_numberofhouseholds_1 ADD CONSTRAINT ur_number_censu_numbe_fk_1 FOREIGN KEY (censusblock_numberofhou_id_1) REFERENCES ur_censusblock (id); +-- -------------------------------------------------------------------- +-- ur_office +-- -------------------------------------------------------------------- +ALTER TABLE ur_office ADD CONSTRAINT ur_office_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + -- -------------------------------------------------------------------- -- ur_officesandemployees -- -------------------------------------------------------------------- ALTER TABLE ur_officesandemployees ADD CONSTRAINT ur_officesandemployees_fk FOREIGN KEY (id) REFERENCES ur_statisticalgrid (id); +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +ALTER TABLE ur_pathway ADD CONSTRAINT ur_pathway_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_pathway ADD CONSTRAINT ur_pathway_from_fk FOREIGN KEY (from_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +ALTER TABLE ur_pathway ADD CONSTRAINT ur_pathway_to_fk FOREIGN KEY (to_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +ALTER TABLE ur_point ADD CONSTRAINT ur_point_publictr_point_fk FOREIGN KEY (publictransit_point_id) +REFERENCES ur_publictransit (id); + -- -------------------------------------------------------------------- -- ur_pollution -- -------------------------------------------------------------------- @@ -601,7 +1244,29 @@ REFERENCES ur_population (id); -- -------------------------------------------------------------------- -- ur_publictransit -- -------------------------------------------------------------------- +ALTER TABLE ur_publictransit ADD CONSTRAINT ur_publictran_objectcla_fk FOREIGN KEY (objectclass_id) +REFERENCES objectclass (id); + ALTER TABLE ur_publictransit ADD CONSTRAINT ur_publictransit_fk FOREIGN KEY (id) +REFERENCES cityobject (id); + +ALTER TABLE ur_publictransit ADD CONSTRAINT ur_publictransit_target_fk FOREIGN KEY (target_id) +REFERENCES cityobject (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +ALTER TABLE ur_publictransitdatatype ADD CONSTRAINT ur_publictra_objectcl_fk_1 FOREIGN KEY (objectclass_id) +REFERENCES objectclass (id); + +ALTER TABLE ur_publictransitdatatype ADD CONSTRAINT ur_public_cityob_dataty_fk FOREIGN KEY (cityobjectgroup_datatype_id) +REFERENCES ur_cityobjectgroup_3 (id); + +-- -------------------------------------------------------------------- +-- ur_publictransportationfa +-- -------------------------------------------------------------------- +ALTER TABLE ur_publictransportationfa ADD CONSTRAINT ur_publictransportation_fk FOREIGN KEY (id) REFERENCES ur_urbanfunction (id); -- -------------------------------------------------------------------- @@ -611,20 +1276,96 @@ ALTER TABLE ur_recreations ADD CONSTRAINT ur_recreations_fk FOREIGN KEY (id) REFERENCES ur_urbanfunction (id); -- -------------------------------------------------------------------- --- ur_statisticalgrid +-- ur_route -- -------------------------------------------------------------------- -ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisticalgrid_fk FOREIGN KEY (id) -REFERENCES cityobject (id); +ALTER TABLE ur_route ADD CONSTRAINT ur_route_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_route ADD CONSTRAINT ur_route_description_fk FOREIGN KEY (description_id) +REFERENCES ur_description (id) +ON DELETE SET NULL; + +ALTER TABLE ur_route ADD CONSTRAINT ur_route_parentroute_fk FOREIGN KEY (parentroute_id) +REFERENCES ur_route (id) +ON DELETE SET NULL; + +ALTER TABLE ur_route ADD CONSTRAINT ur_route_agency_fk FOREIGN KEY (agency_id) +REFERENCES ur_agency (id) +ON DELETE SET NULL; +-- -------------------------------------------------------------------- +-- ur_statisticalgrid +-- -------------------------------------------------------------------- ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statistica_objectcla_fk FOREIGN KEY (objectclass_id) REFERENCES objectclass (id); -ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisti_lod_1multis_fk FOREIGN KEY (lod_1multisurfacegeometry_id) +ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisticalgrid_fk FOREIGN KEY (id) +REFERENCES cityobject (id); + +ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisti_lod_1multis_fk FOREIGN KEY (lod_1multisurface_id) REFERENCES surface_geometry (id); -ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisti_lod_2multis_fk FOREIGN KEY (lod_2multisurfacegeometry_id) +ALTER TABLE ur_statisticalgrid ADD CONSTRAINT ur_statisti_lod_2multis_fk FOREIGN KEY (lod_2multisurface_id) REFERENCES surface_geometry (id); +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +ALTER TABLE ur_stop ADD CONSTRAINT ur_stop_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_stop ADD CONSTRAINT ur_stop_parentstation_fk FOREIGN KEY (parentstation_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +ALTER TABLE ur_stop ADD CONSTRAINT ur_stop_level_fk FOREIGN KEY (level_id) +REFERENCES ur_publictransit (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +ALTER TABLE ur_stoptime ADD CONSTRAINT ur_stoptime_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_stoptime ADD CONSTRAINT ur_stoptime_trip_fk FOREIGN KEY (trip_id) +REFERENCES ur_trip (id) +ON DELETE SET NULL; + +ALTER TABLE ur_stoptime ADD CONSTRAINT ur_stoptime_stop_fk FOREIGN KEY (stop_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +ALTER TABLE ur_transfer ADD CONSTRAINT ur_transfer_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_transfer ADD CONSTRAINT ur_transfer_from_fk FOREIGN KEY (from_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +ALTER TABLE ur_transfer ADD CONSTRAINT ur_transfer_to_fk FOREIGN KEY (to_id) +REFERENCES ur_stop (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +ALTER TABLE ur_translation ADD CONSTRAINT ur_translation_fk FOREIGN KEY (id) +REFERENCES ur_publictransitdatatype (id); + +ALTER TABLE ur_translation ADD CONSTRAINT ur_translation_recordid_fk FOREIGN KEY (recordid_id) +REFERENCES ur_publictransit (id) +ON DELETE SET NULL; + +-- -------------------------------------------------------------------- +-- ur_translationjp +-- -------------------------------------------------------------------- +ALTER TABLE ur_translationjp ADD CONSTRAINT ur_translationjp_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- @@ -635,6 +1376,32 @@ ALTER TABLE ur_transportation_complex ADD CONSTRAINT ur_transp_comple_traffi_fk REFERENCES ur_trafficvolume (id) ON DELETE SET NULL; +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_fk FOREIGN KEY (id) +REFERENCES ur_publictransit (id); + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_route_fk FOREIGN KEY (route_id) +REFERENCES ur_route (id) +ON DELETE SET NULL; + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_calendar_fk FOREIGN KEY (calendar_id) +REFERENCES ur_calendar (id) +ON DELETE SET NULL; + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_calendardate_fk FOREIGN KEY (calendardate_id) +REFERENCES ur_calendardate (id) +ON DELETE SET NULL; + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_office_fk FOREIGN KEY (office_id) +REFERENCES ur_office (id) +ON DELETE SET NULL; + +ALTER TABLE ur_trip ADD CONSTRAINT ur_trip_shape_fk FOREIGN KEY (shape_id) +REFERENCES ur_publictransit (id) +ON DELETE SET NULL; + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -659,7 +1426,13 @@ ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfunct_legalgrou_fk FOREIGN K REFERENCES ur_legalgrounds (id) ON DELETE SET NULL; -ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfunction_area_fk FOREIGN KEY (area_id) +ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfunct_lod0multi_fk FOREIGN KEY (lod0multisurface_id) +REFERENCES surface_geometry (id); + +ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfun_lod_1multis_fk FOREIGN KEY (lod_1multisurface_id) +REFERENCES surface_geometry (id); + +ALTER TABLE ur_urbanfunction ADD CONSTRAINT ur_urbanfun_lod_2multis_fk FOREIGN KEY (lod_2multisurface_id) REFERENCES surface_geometry (id); -- -------------------------------------------------------------------- @@ -680,6 +1453,36 @@ REFERENCES ur_urbanfunction (id); -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Create Indexes ************************************* -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +CREATE INDEX ur_areaof_landus_areao_fkx ON ur_areaofannualdiversions + USING btree + ( + landusediver_areaofannual_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +CREATE INDEX ur_attribution_agency_fkx ON ur_attribution + USING btree + ( + agency_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_attribution_route_fkx ON ur_attribution + USING btree + ( + route_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_attribution_trip_fkx ON ur_attribution + USING btree + ( + trip_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -695,22 +1498,82 @@ CREATE INDEX ur_building_largecusto_fkx ON ur_building largecustomerfacilities_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +CREATE INDEX ur_calendarda_calendar_fkx ON ur_calendardate + USING btree + ( + calendar_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +CREATE INDEX ur_fareattribut_agency_fkx ON ur_fareattribute + USING btree + ( + agency_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +CREATE INDEX ur_farerule_fare_fkx ON ur_farerule + USING btree + ( + fare_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_farerule_route_fkx ON ur_farerule + USING btree + ( + route_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +CREATE INDEX ur_frequency_trip_fkx ON ur_frequency + USING btree + ( + trip_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +CREATE INDEX ur_keyval_statis_gener_fkx ON ur_keyvaluepair + USING btree + ( + statisticalg_genericvalue_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +CREATE INDEX ur_keyval_buildi_exten_fkx ON ur_keyvaluepair_1 + USING btree + ( + building_extendedattribut_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + -- -------------------------------------------------------------------- -- ur_landpriceperlanduse -- -------------------------------------------------------------------- -CREATE INDEX ur_landpr_statis_landp_fkx ON ur_landpriceperlanduse +CREATE INDEX ur_landpr_landpr_landp_fkx ON ur_landpriceperlanduse USING btree ( - statisticalgrid_landprice_id ASC NULLS LAST + landprice_landprice_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); -- -------------------------------------------------------------------- -- ur_numberofannualdiversio -- -------------------------------------------------------------------- -CREATE INDEX ur_number_statis_numbe_fkx ON ur_numberofannualdiversio +CREATE INDEX ur_number_landus_numbe_fkx ON ur_numberofannualdiversio USING btree ( - statisticalg_numberofannu_id ASC NULLS LAST + landusediver_numberofannu_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); -- -------------------------------------------------------------------- @@ -743,6 +1606,36 @@ CREATE INDEX ur_number_census_numbe_fkx ON ur_numberofhouseholds_1 censusblock_numberofhouse_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +CREATE INDEX ur_pathway_from_fkx ON ur_pathway + USING btree + ( + from_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_pathway_to_fkx ON ur_pathway + USING btree + ( + to_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +CREATE INDEX ur_point_point_spx ON ur_point + USING gist + ( + point + ); + +CREATE INDEX ur_point_publict_point_fkx ON ur_point + USING btree + ( + publictransit_point_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + -- -------------------------------------------------------------------- -- ur_populationbyageandsex -- -------------------------------------------------------------------- @@ -752,19 +1645,76 @@ CREATE INDEX ur_popula_popula_popul_fkx ON ur_populationbyageandsex population_populationbyag_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); +-- -------------------------------------------------------------------- +-- ur_publictransit +-- -------------------------------------------------------------------- +CREATE INDEX ur_publictra_objectcla_fkx ON ur_publictransit + USING btree + ( + objectclass_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_publictransi_target_fkx ON ur_publictransit + USING btree + ( + target_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +CREATE INDEX ur_public_cityob_datat_fkx ON ur_publictransitdatatype + USING btree + ( + cityobjectgroup_datatype_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_publictr_objectcl_fkx_1 ON ur_publictransitdatatype + USING btree + ( + objectclass_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_route +-- -------------------------------------------------------------------- +CREATE INDEX ur_route_agency_fkx ON ur_route + USING btree + ( + agency_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_route_description_fkx ON ur_route + USING btree + ( + description_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_route_lod0multicurv_spx ON ur_route + USING gist + ( + lod0multicurve + ); + +CREATE INDEX ur_route_parentroute_fkx ON ur_route + USING btree + ( + parentroute_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + -- -------------------------------------------------------------------- -- ur_statisticalgrid -- -------------------------------------------------------------------- CREATE INDEX ur_statist_lod_1multis_fkx ON ur_statisticalgrid USING btree ( - lod_1multisurfacegeometry_id ASC NULLS LAST + lod_1multisurface_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); CREATE INDEX ur_statist_lod_2multis_fkx ON ur_statisticalgrid USING btree ( - lod_2multisurfacegeometry_id ASC NULLS LAST + lod_2multisurface_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); CREATE INDEX ur_statistic_objectcla_fkx ON ur_statisticalgrid @@ -773,6 +1723,66 @@ CREATE INDEX ur_statistic_objectcla_fkx ON ur_statisticalgrid objectclass_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +CREATE INDEX ur_stop_level_fkx ON ur_stop + USING btree + ( + level_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_stop_parentstation_fkx ON ur_stop + USING btree + ( + parentstation_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_stop_point_spx ON ur_stop + USING gist + ( + point + ); + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +CREATE INDEX ur_stoptime_stop_fkx ON ur_stoptime + USING btree + ( + stop_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_stoptime_trip_fkx ON ur_stoptime + USING btree + ( + trip_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +CREATE INDEX ur_transfer_from_fkx ON ur_transfer + USING btree + ( + from_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_transfer_to_fkx ON ur_transfer + USING btree + ( + to_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +CREATE INDEX ur_translatio_recordid_fkx ON ur_translation + USING btree + ( + recordid_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- @@ -782,6 +1792,45 @@ CREATE INDEX ur_transp_comple_traff_fkx ON ur_transportation_complex trafficvolume_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +CREATE INDEX ur_trip_calendar_fkx ON ur_trip + USING btree + ( + calendar_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_trip_calendardate_fkx ON ur_trip + USING btree + ( + calendardate_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_trip_lod0multicurve_spx ON ur_trip + USING gist + ( + lod0multicurve + ); + +CREATE INDEX ur_trip_office_fkx ON ur_trip + USING btree + ( + office_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_trip_route_fkx ON ur_trip + USING btree + ( + route_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_trip_shape_fkx ON ur_trip + USING btree + ( + shape_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -800,30 +1849,66 @@ CREATE INDEX ur_urbanfu_to_cityobj_fk1x ON ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- -- ur_urbanfunction -- -------------------------------------------------------------------- -CREATE INDEX ur_urbanfunction_area_fkx ON ur_urbanfunction +CREATE INDEX ur_urbanfunc_legalgrou_fkx ON ur_urbanfunction USING btree ( - area_id ASC NULLS LAST + legalgrounds_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); -CREATE INDEX ur_urbanfunct_boundary_spx ON ur_urbanfunction +CREATE INDEX ur_urbanfunc_lod0multi_spx ON ur_urbanfunction USING gist ( - boundary + lod0multicurve ); -CREATE INDEX ur_urbanfunc_legalgrou_fkx ON ur_urbanfunction +CREATE INDEX ur_urbanfun_lod0mult_spx_1 ON ur_urbanfunction + USING gist + ( + lod0multipoint + ); + +CREATE INDEX ur_urbanfunc_lod0multi_fkx ON ur_urbanfunction USING btree ( - legalgrounds_id ASC NULLS LAST + lod0multisurface_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + +CREATE INDEX ur_urbanfu_lod_1multic_spx ON ur_urbanfunction + USING gist + ( + lod_1multicurve + ); + +CREATE INDEX ur_urbanfu_lod_1multip_spx ON ur_urbanfunction + USING gist + ( + lod_1multipoint + ); + +CREATE INDEX ur_urbanfu_lod_1multis_fkx ON ur_urbanfunction + USING btree + ( + lod_1multisurface_id ASC NULLS LAST ) WITH (FILLFACTOR = 90); -CREATE INDEX ur_urbanfunct_location_spx ON ur_urbanfunction +CREATE INDEX ur_urbanfu_lod_2multic_spx ON ur_urbanfunction USING gist ( - location + lod_2multicurve ); +CREATE INDEX ur_urbanfu_lod_2multip_spx ON ur_urbanfunction + USING gist + ( + lod_2multipoint + ); + +CREATE INDEX ur_urbanfu_lod_2multis_fkx ON ur_urbanfunction + USING btree + ( + lod_2multisurface_id ASC NULLS LAST + ) WITH (FILLFACTOR = 90); + CREATE INDEX ur_urbanfunc_objectcla_fkx ON ur_urbanfunction USING btree ( @@ -873,6 +1958,16 @@ NO CYCLE OWNED BY NONE; +CREATE SEQUENCE ur_areaofannualdivers_seq +INCREMENT BY 1 +MINVALUE 0 +MAXVALUE 2147483647 +START WITH 1 +CACHE 1 +NO CYCLE +OWNED BY NONE; + + CREATE SEQUENCE ur_numberofhouseholds_seq INCREMENT BY 1 MINVALUE 0 @@ -883,6 +1978,16 @@ NO CYCLE OWNED BY NONE; +CREATE SEQUENCE ur_keyvaluepair_seq +INCREMENT BY 1 +MINVALUE 0 +MAXVALUE 2147483647 +START WITH 1 +CACHE 1 +NO CYCLE +OWNED BY NONE; + + CREATE SEQUENCE ur_buildingdetails_seq INCREMENT BY 1 MINVALUE 0 @@ -903,6 +2008,16 @@ NO CYCLE OWNED BY NONE; +CREATE SEQUENCE ur_keyvaluepair_seq_1 +INCREMENT BY 1 +MINVALUE 0 +MAXVALUE 2147483647 +START WITH 1 +CACHE 1 +NO CYCLE +OWNED BY NONE; + + CREATE SEQUENCE ur_trafficvolume_seq INCREMENT BY 1 MINVALUE 0 @@ -933,3 +2048,33 @@ NO CYCLE OWNED BY NONE; +CREATE SEQUENCE ur_description_seq +INCREMENT BY 1 +MINVALUE 0 +MAXVALUE 2147483647 +START WITH 1 +CACHE 1 +NO CYCLE +OWNED BY NONE; + + +CREATE SEQUENCE ur_point_seq +INCREMENT BY 1 +MINVALUE 0 +MAXVALUE 2147483647 +START WITH 1 +CACHE 1 +NO CYCLE +OWNED BY NONE; + + +CREATE SEQUENCE ur_publictransitdatat_seq +INCREMENT BY 1 +MINVALUE 0 +MAXVALUE 2147483647 +START WITH 1 +CACHE 1 +NO CYCLE +OWNED BY NONE; + + diff --git a/resources/database/3dcitydb/postgreSQL/DROP_ADE_DB.sql b/resources/database/3dcitydb/postgreSQL/DROP_ADE_DB.sql index bfca91e..4707c82 100644 --- a/resources/database/3dcitydb/postgreSQL/DROP_ADE_DB.sql +++ b/resources/database/3dcitydb/postgreSQL/DROP_ADE_DB.sql @@ -1,7 +1,34 @@ --- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-03-20 09:53:29 +-- This document was automatically created by the ADE-Manager tool of 3DCityDB (https://www.3dcitydb.org) on 2020-08-25 11:09:20 -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Drop foreign keys ********************************** -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +-- -------------------------------------------------------------------- +-- ur_agency +-- -------------------------------------------------------------------- +ALTER TABLE ur_agency + DROP CONSTRAINT ur_agency_fk; + +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +ALTER TABLE ur_areaofannualdiversions + DROP CONSTRAINT ur_areaof_landus_areaof_fk; + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +ALTER TABLE ur_attribution + DROP CONSTRAINT ur_attribution_fk; + +ALTER TABLE ur_attribution + DROP CONSTRAINT ur_attribution_agency_fk; + +ALTER TABLE ur_attribution + DROP CONSTRAINT ur_attribution_route_fk; + +ALTER TABLE ur_attribution + DROP CONSTRAINT ur_attribution_trip_fk; + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -14,6 +41,21 @@ ALTER TABLE ur_building ALTER TABLE ur_building DROP CONSTRAINT ur_building_largecustom_fk; +-- -------------------------------------------------------------------- +-- ur_calendar +-- -------------------------------------------------------------------- +ALTER TABLE ur_calendar + DROP CONSTRAINT ur_calendar_fk; + +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +ALTER TABLE ur_calendardate + DROP CONSTRAINT ur_calendardate_fk; + +ALTER TABLE ur_calendardate + DROP CONSTRAINT ur_calendardat_calendar_fk; + -- -------------------------------------------------------------------- -- ur_censusblock -- -------------------------------------------------------------------- @@ -26,6 +68,24 @@ ALTER TABLE ur_censusblock ALTER TABLE ur_cityobjectgroup DROP CONSTRAINT ur_cityobjectgroup_fk; +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_1 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_1 + DROP CONSTRAINT ur_cityobjectgroup_fk_1; + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_2 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_2 + DROP CONSTRAINT ur_cityobjectgroup_fk_2; + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_3 +-- -------------------------------------------------------------------- +ALTER TABLE ur_cityobjectgroup_3 + DROP CONSTRAINT ur_cityobjectgroup_fk_3; + -- -------------------------------------------------------------------- -- ur_developmentproject -- -------------------------------------------------------------------- @@ -38,29 +98,89 @@ ALTER TABLE ur_developmentproject ALTER TABLE ur_disasterdamage DROP CONSTRAINT ur_disasterdamage_fk; +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +ALTER TABLE ur_fareattribute + DROP CONSTRAINT ur_fareattribute_fk; + +ALTER TABLE ur_fareattribute + DROP CONSTRAINT ur_fareattribute_agency_fk; + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +ALTER TABLE ur_farerule + DROP CONSTRAINT ur_farerule_fk; + +ALTER TABLE ur_farerule + DROP CONSTRAINT ur_farerule_fare_fk; + +ALTER TABLE ur_farerule + DROP CONSTRAINT ur_farerule_route_fk; + +-- -------------------------------------------------------------------- +-- ur_feedinfo +-- -------------------------------------------------------------------- +ALTER TABLE ur_feedinfo + DROP CONSTRAINT ur_feedinfo_fk; + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +ALTER TABLE ur_frequency + DROP CONSTRAINT ur_frequency_fk; + +ALTER TABLE ur_frequency + DROP CONSTRAINT ur_frequency_trip_fk; + -- -------------------------------------------------------------------- -- ur_households -- -------------------------------------------------------------------- ALTER TABLE ur_households DROP CONSTRAINT ur_households_fk; +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +ALTER TABLE ur_keyvaluepair + DROP CONSTRAINT ur_keyval_statis_generi_fk; + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +ALTER TABLE ur_keyvaluepair_1 + DROP CONSTRAINT ur_keyval_buildi_extend_fk; + -- -------------------------------------------------------------------- -- ur_land_use -- -------------------------------------------------------------------- ALTER TABLE ur_land_use DROP CONSTRAINT ur_land_use_fk; +-- -------------------------------------------------------------------- +-- ur_landprice +-- -------------------------------------------------------------------- +ALTER TABLE ur_landprice + DROP CONSTRAINT ur_landprice_fk; + -- -------------------------------------------------------------------- -- ur_landpriceperlanduse -- -------------------------------------------------------------------- ALTER TABLE ur_landpriceperlanduse - DROP CONSTRAINT ur_landpr_statis_landpr_fk; + DROP CONSTRAINT ur_landpr_landpr_landpr_fk; + +-- -------------------------------------------------------------------- +-- ur_landusediversion +-- -------------------------------------------------------------------- +ALTER TABLE ur_landusediversion + DROP CONSTRAINT ur_landusediversion_fk; -- -------------------------------------------------------------------- -- ur_numberofannualdiversio -- -------------------------------------------------------------------- ALTER TABLE ur_numberofannualdiversio - DROP CONSTRAINT ur_number_statis_number_fk; + DROP CONSTRAINT ur_number_landus_number_fk; -- -------------------------------------------------------------------- -- ur_numberofhouseholds @@ -80,12 +200,36 @@ ALTER TABLE ur_numberofhouseholds_1 ALTER TABLE ur_numberofhouseholds_1 DROP CONSTRAINT ur_number_censu_numbe_fk_1; +-- -------------------------------------------------------------------- +-- ur_office +-- -------------------------------------------------------------------- +ALTER TABLE ur_office + DROP CONSTRAINT ur_office_fk; + -- -------------------------------------------------------------------- -- ur_officesandemployees -- -------------------------------------------------------------------- ALTER TABLE ur_officesandemployees DROP CONSTRAINT ur_officesandemployees_fk; +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +ALTER TABLE ur_pathway + DROP CONSTRAINT ur_pathway_fk; + +ALTER TABLE ur_pathway + DROP CONSTRAINT ur_pathway_from_fk; + +ALTER TABLE ur_pathway + DROP CONSTRAINT ur_pathway_to_fk; + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +ALTER TABLE ur_point + DROP CONSTRAINT ur_point_publictr_point_fk; + -- -------------------------------------------------------------------- -- ur_pollution -- -------------------------------------------------------------------- @@ -107,23 +251,59 @@ ALTER TABLE ur_populationbyageandsex -- -------------------------------------------------------------------- -- ur_publictransit -- -------------------------------------------------------------------- +ALTER TABLE ur_publictransit + DROP CONSTRAINT ur_publictran_objectcla_fk; + ALTER TABLE ur_publictransit DROP CONSTRAINT ur_publictransit_fk; +ALTER TABLE ur_publictransit + DROP CONSTRAINT ur_publictransit_target_fk; + +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +ALTER TABLE ur_publictransitdatatype + DROP CONSTRAINT ur_publictra_objectcl_fk_1; + +ALTER TABLE ur_publictransitdatatype + DROP CONSTRAINT ur_public_cityob_dataty_fk; + +-- -------------------------------------------------------------------- +-- ur_publictransportationfa +-- -------------------------------------------------------------------- +ALTER TABLE ur_publictransportationfa + DROP CONSTRAINT ur_publictransportation_fk; + -- -------------------------------------------------------------------- -- ur_recreations -- -------------------------------------------------------------------- ALTER TABLE ur_recreations DROP CONSTRAINT ur_recreations_fk; +-- -------------------------------------------------------------------- +-- ur_route +-- -------------------------------------------------------------------- +ALTER TABLE ur_route + DROP CONSTRAINT ur_route_fk; + +ALTER TABLE ur_route + DROP CONSTRAINT ur_route_description_fk; + +ALTER TABLE ur_route + DROP CONSTRAINT ur_route_parentroute_fk; + +ALTER TABLE ur_route + DROP CONSTRAINT ur_route_agency_fk; + -- -------------------------------------------------------------------- -- ur_statisticalgrid -- -------------------------------------------------------------------- ALTER TABLE ur_statisticalgrid - DROP CONSTRAINT ur_statisticalgrid_fk; + DROP CONSTRAINT ur_statistica_objectcla_fk; ALTER TABLE ur_statisticalgrid - DROP CONSTRAINT ur_statistica_objectcla_fk; + DROP CONSTRAINT ur_statisticalgrid_fk; ALTER TABLE ur_statisticalgrid DROP CONSTRAINT ur_statisti_lod_1multis_fk; @@ -131,6 +311,57 @@ ALTER TABLE ur_statisticalgrid ALTER TABLE ur_statisticalgrid DROP CONSTRAINT ur_statisti_lod_2multis_fk; +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +ALTER TABLE ur_stop + DROP CONSTRAINT ur_stop_fk; + +ALTER TABLE ur_stop + DROP CONSTRAINT ur_stop_parentstation_fk; + +ALTER TABLE ur_stop + DROP CONSTRAINT ur_stop_level_fk; + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +ALTER TABLE ur_stoptime + DROP CONSTRAINT ur_stoptime_fk; + +ALTER TABLE ur_stoptime + DROP CONSTRAINT ur_stoptime_trip_fk; + +ALTER TABLE ur_stoptime + DROP CONSTRAINT ur_stoptime_stop_fk; + +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +ALTER TABLE ur_transfer + DROP CONSTRAINT ur_transfer_fk; + +ALTER TABLE ur_transfer + DROP CONSTRAINT ur_transfer_from_fk; + +ALTER TABLE ur_transfer + DROP CONSTRAINT ur_transfer_to_fk; + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +ALTER TABLE ur_translation + DROP CONSTRAINT ur_translation_fk; + +ALTER TABLE ur_translation + DROP CONSTRAINT ur_translation_recordid_fk; + +-- -------------------------------------------------------------------- +-- ur_translationjp +-- -------------------------------------------------------------------- +ALTER TABLE ur_translationjp + DROP CONSTRAINT ur_translationjp_fk; + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- @@ -140,6 +371,27 @@ ALTER TABLE ur_transportation_complex ALTER TABLE ur_transportation_complex DROP CONSTRAINT ur_transp_comple_traffi_fk; +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_route_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_calendar_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_calendardate_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_office_fk; + +ALTER TABLE ur_trip + DROP CONSTRAINT ur_trip_shape_fk; + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -162,7 +414,13 @@ ALTER TABLE ur_urbanfunction DROP CONSTRAINT ur_urbanfunct_legalgrou_fk; ALTER TABLE ur_urbanfunction - DROP CONSTRAINT ur_urbanfunction_area_fk; + DROP CONSTRAINT ur_urbanfunct_lod0multi_fk; + +ALTER TABLE ur_urbanfunction + DROP CONSTRAINT ur_urbanfun_lod_1multis_fk; + +ALTER TABLE ur_urbanfunction + DROP CONSTRAINT ur_urbanfun_lod_2multis_fk; -- -------------------------------------------------------------------- -- ur_urbanization @@ -182,6 +440,21 @@ ALTER TABLE ur_zone -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- *********************************** Drop tables *************************************** -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +-- -------------------------------------------------------------------- +-- ur_agency +-- -------------------------------------------------------------------- +DROP TABLE ur_agency; + +-- -------------------------------------------------------------------- +-- ur_areaofannualdiversions +-- -------------------------------------------------------------------- +DROP TABLE ur_areaofannualdiversions; + +-- -------------------------------------------------------------------- +-- ur_attribution +-- -------------------------------------------------------------------- +DROP TABLE ur_attribution; + -- -------------------------------------------------------------------- -- ur_building -- -------------------------------------------------------------------- @@ -192,6 +465,16 @@ DROP TABLE ur_building; -- -------------------------------------------------------------------- DROP TABLE ur_buildingdetails; +-- -------------------------------------------------------------------- +-- ur_calendar +-- -------------------------------------------------------------------- +DROP TABLE ur_calendar; + +-- -------------------------------------------------------------------- +-- ur_calendardate +-- -------------------------------------------------------------------- +DROP TABLE ur_calendardate; + -- -------------------------------------------------------------------- -- ur_censusblock -- -------------------------------------------------------------------- @@ -202,6 +485,26 @@ DROP TABLE ur_censusblock; -- -------------------------------------------------------------------- DROP TABLE ur_cityobjectgroup; +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_1 +-- -------------------------------------------------------------------- +DROP TABLE ur_cityobjectgroup_1; + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_2 +-- -------------------------------------------------------------------- +DROP TABLE ur_cityobjectgroup_2; + +-- -------------------------------------------------------------------- +-- ur_cityobjectgroup_3 +-- -------------------------------------------------------------------- +DROP TABLE ur_cityobjectgroup_3; + +-- -------------------------------------------------------------------- +-- ur_description +-- -------------------------------------------------------------------- +DROP TABLE ur_description; + -- -------------------------------------------------------------------- -- ur_developmentproject -- -------------------------------------------------------------------- @@ -212,21 +515,61 @@ DROP TABLE ur_developmentproject; -- -------------------------------------------------------------------- DROP TABLE ur_disasterdamage; +-- -------------------------------------------------------------------- +-- ur_fareattribute +-- -------------------------------------------------------------------- +DROP TABLE ur_fareattribute; + +-- -------------------------------------------------------------------- +-- ur_farerule +-- -------------------------------------------------------------------- +DROP TABLE ur_farerule; + +-- -------------------------------------------------------------------- +-- ur_feedinfo +-- -------------------------------------------------------------------- +DROP TABLE ur_feedinfo; + +-- -------------------------------------------------------------------- +-- ur_frequency +-- -------------------------------------------------------------------- +DROP TABLE ur_frequency; + -- -------------------------------------------------------------------- -- ur_households -- -------------------------------------------------------------------- DROP TABLE ur_households; +-- -------------------------------------------------------------------- +-- ur_keyvaluepair +-- -------------------------------------------------------------------- +DROP TABLE ur_keyvaluepair; + +-- -------------------------------------------------------------------- +-- ur_keyvaluepair_1 +-- -------------------------------------------------------------------- +DROP TABLE ur_keyvaluepair_1; + -- -------------------------------------------------------------------- -- ur_land_use -- -------------------------------------------------------------------- DROP TABLE ur_land_use; +-- -------------------------------------------------------------------- +-- ur_landprice +-- -------------------------------------------------------------------- +DROP TABLE ur_landprice; + -- -------------------------------------------------------------------- -- ur_landpriceperlanduse -- -------------------------------------------------------------------- DROP TABLE ur_landpriceperlanduse; +-- -------------------------------------------------------------------- +-- ur_landusediversion +-- -------------------------------------------------------------------- +DROP TABLE ur_landusediversion; + -- -------------------------------------------------------------------- -- ur_largecustomerfacilitie -- -------------------------------------------------------------------- @@ -252,11 +595,26 @@ DROP TABLE ur_numberofhouseholds; -- -------------------------------------------------------------------- DROP TABLE ur_numberofhouseholds_1; +-- -------------------------------------------------------------------- +-- ur_office +-- -------------------------------------------------------------------- +DROP TABLE ur_office; + -- -------------------------------------------------------------------- -- ur_officesandemployees -- -------------------------------------------------------------------- DROP TABLE ur_officesandemployees; +-- -------------------------------------------------------------------- +-- ur_pathway +-- -------------------------------------------------------------------- +DROP TABLE ur_pathway; + +-- -------------------------------------------------------------------- +-- ur_point +-- -------------------------------------------------------------------- +DROP TABLE ur_point; + -- -------------------------------------------------------------------- -- ur_pollution -- -------------------------------------------------------------------- @@ -277,26 +635,71 @@ DROP TABLE ur_populationbyageandsex; -- -------------------------------------------------------------------- DROP TABLE ur_publictransit; +-- -------------------------------------------------------------------- +-- ur_publictransitdatatype +-- -------------------------------------------------------------------- +DROP TABLE ur_publictransitdatatype; + +-- -------------------------------------------------------------------- +-- ur_publictransportationfa +-- -------------------------------------------------------------------- +DROP TABLE ur_publictransportationfa; + -- -------------------------------------------------------------------- -- ur_recreations -- -------------------------------------------------------------------- DROP TABLE ur_recreations; +-- -------------------------------------------------------------------- +-- ur_route +-- -------------------------------------------------------------------- +DROP TABLE ur_route; + -- -------------------------------------------------------------------- -- ur_statisticalgrid -- -------------------------------------------------------------------- DROP TABLE ur_statisticalgrid; +-- -------------------------------------------------------------------- +-- ur_stop +-- -------------------------------------------------------------------- +DROP TABLE ur_stop; + +-- -------------------------------------------------------------------- +-- ur_stoptime +-- -------------------------------------------------------------------- +DROP TABLE ur_stoptime; + -- -------------------------------------------------------------------- -- ur_trafficvolume -- -------------------------------------------------------------------- DROP TABLE ur_trafficvolume; +-- -------------------------------------------------------------------- +-- ur_transfer +-- -------------------------------------------------------------------- +DROP TABLE ur_transfer; + +-- -------------------------------------------------------------------- +-- ur_translation +-- -------------------------------------------------------------------- +DROP TABLE ur_translation; + +-- -------------------------------------------------------------------- +-- ur_translationjp +-- -------------------------------------------------------------------- +DROP TABLE ur_translationjp; + -- -------------------------------------------------------------------- -- ur_transportation_complex -- -------------------------------------------------------------------- DROP TABLE ur_transportation_complex; +-- -------------------------------------------------------------------- +-- ur_trip +-- -------------------------------------------------------------------- +DROP TABLE ur_trip; + -- -------------------------------------------------------------------- -- ur_urbanfunc_to_cityobjec -- -------------------------------------------------------------------- @@ -327,14 +730,26 @@ DROP SEQUENCE ur_landpriceperlandus_seq; DROP SEQUENCE ur_numberofannualdive_seq; +DROP SEQUENCE ur_areaofannualdivers_seq; + DROP SEQUENCE ur_numberofhouseholds_seq; +DROP SEQUENCE ur_keyvaluepair_seq; + DROP SEQUENCE ur_buildingdetails_seq; DROP SEQUENCE ur_largecustomerfacil_seq; +DROP SEQUENCE ur_keyvaluepair_seq_1; + DROP SEQUENCE ur_trafficvolume_seq; DROP SEQUENCE ur_legalgrounds_seq; DROP SEQUENCE ur_numberofhousehol_seq_1; + +DROP SEQUENCE ur_description_seq; + +DROP SEQUENCE ur_point_seq; + +DROP SEQUENCE ur_publictransitdatat_seq; diff --git a/resources/database/schema-mapping/schema-mapping.xml b/resources/database/schema-mapping/schema-mapping.xml index d620a3d..43dd910 100644 --- a/resources/database/schema-mapping/schema-mapping.xml +++ b/resources/database/schema-mapping/schema-mapping.xml @@ -2,60 +2,77 @@ i-UR ADE - 1.3 + 1.4 i-UR ADE ur - http://www.kantei.go.jp/jp/singi/tiiki/toshisaisei/itoshisaisei/iur/urg/1.3 + http://www.kantei.go.jp/jp/singi/tiiki/toshisaisei/itoshisaisei/iur/urg/1.4 - http://www.kantei.go.jp/jp/singi/tiiki/toshisaisei/itoshisaisei/iur/uro/1.3 + http://www.kantei.go.jp/jp/singi/tiiki/toshisaisei/itoshisaisei/iur/uro/1.4 - http://www.kantei.go.jp/jp/singi/tiiki/toshisaisei/itoshisaisei/iur/urf/1.3 + http://www.kantei.go.jp/jp/singi/tiiki/toshisaisei/itoshisaisei/iur/urf/1.4 + + + http://www.kantei.go.jp/jp/singi/tiiki/toshisaisei/itoshisaisei/iur/urt/1.4 - - - - - - - + + + - + - - - - - + + + + - + - + + + + + + + + + + + + + + + + + + + + @@ -114,7 +131,7 @@ - + @@ -161,7 +178,26 @@ - + + + + + + + + + + + + + + + + + + + + @@ -188,7 +224,7 @@ - + @@ -199,13 +235,159 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -234,8 +416,8 @@ - - + + @@ -257,23 +439,34 @@ - + - - + + + + - + + + + + - - + + + + - + + + + - + @@ -286,14 +479,20 @@ - + - + + + + + + + @@ -338,9 +537,15 @@ - - - + + + + + + + + + @@ -352,35 +557,35 @@ - + - + - + - + - + - + - + - + - + @@ -413,7 +618,7 @@ - + @@ -428,7 +633,7 @@ - + @@ -442,7 +647,7 @@ - + @@ -452,31 +657,31 @@ - + - + - + - + - + - + @@ -486,8 +691,292 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -496,6 +985,9 @@ + + + @@ -558,13 +1050,29 @@ - - + + + + + + + + + + + + + + + + + + diff --git a/resources/templates/balloons/buildings.html b/resources/templates/balloons/buildings.html index a85b575..fad669c 100644 --- a/resources/templates/balloons/buildings.html +++ b/resources/templates/balloons/buildings.html @@ -13,6 +13,35 @@ font-family: Tahoma,Arial; } + <3DCityDB>CITYOBJECT/GMLID</3DCityDB> @@ -23,29 +52,48 @@
- - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
class: <3DCityDB>BUILDING/CLASS,
function: <3DCityDB>BUILDING/FUNCTION.
usage: <3DCityDB>BUILDING/USAGE
yearOfConstruction: <3DCityDB>BUILDING/YEAR_OF_CONSTRUCTION
storeysAboveGround: <3DCityDB>BUILDING/STOREYS_ABOVE_GROUND.
storeysBelowGround: <3DCityDB>BUILDING/STOREYS_BELOW_GROUND.
serialNumberOfBuildingCertification: <3DCityDB>UR_BUILDINGDETAILS/SERIALNUMBEROFBUILDINGCERTIF.
siteArea: <3DCityDB>UR_BUILDINGDETAILS/SITEAREA.
buildingFootprintArea: <3DCityDB>UR_BUILDINGDETAILS/BUILDINGFOOTPRINTAREA.
buildingRoofEdgeArea: <3DCityDB>UR_BUILDINGDETAILS/BUILDINGROOFEDGEAREA.
developmentArea: <3DCityDB>UR_BUILDINGDETAILS/DEVELOPMENTAREA.
buildingStructureType: <3DCityDB>UR_BUILDINGDETAILS/BUILDINGSTRUCTURETYPE.
fireproofStructureType: <3DCityDB>UR_BUILDINGDETAILS/FIREPROOFSTRUCTURETYPE.
implementingBody: <3DCityDB>UR_BUILDINGDETAILS/IMPLEMENTINGBODY.
urbanPlanType: <3DCityDB>UR_BUILDINGDETAILS/URBANPLANTYPE.
districtsAndZonesType: <3DCityDB>UR_BUILDINGDETAILS/DISTRICTSANDZONESTYPE.
landUsePlanType: <3DCityDB>UR_BUILDINGDETAILS/LANDUSEPLANTYPE.
areaClassificationType: <3DCityDB>UR_BUILDINGDETAILS/AREACLASSIFICATIONTYPE.
prefecture: <3DCityDB>UR_BUILDINGDETAILS/PREFECTURE.
city: <3DCityDB>UR_BUILDINGDETAILS/CITY.
reference: <3DCityDB>UR_BUILDINGDETAILS/REFERENCE.
note: <3DCityDB>UR_BUILDINGDETAILS/NOTE.
surveyYear: <3DCityDB>UR_BUILDINGDETAILS/SURVEYYEAR.
class: <3DCityDB>BUILDING/CLASS,
function: <3DCityDB>BUILDING/FUNCTION.
usage: <3DCityDB>BUILDING/USAGE
yearOfConstruction: <3DCityDB>BUILDING/YEAR_OF_CONSTRUCTION
storeysAboveGround: <3DCityDB>BUILDING/STOREYS_ABOVE_GROUND.
storeysBelowGround: <3DCityDB>BUILDING/STOREYS_BELOW_GROUND.
serialNumberOfBuildingCertification: <3DCityDB>UR_BUILDINGDETAILS/SERIALNUMBEROFBUILDINGCERTIF.
siteArea: <3DCityDB>UR_BUILDINGDETAILS/SITEAREA.
siteArea_uom: <3DCityDB>UR_BUILDINGDETAILS/SITEAREA_UOM.
buildingFootprintArea: <3DCityDB>UR_BUILDINGDETAILS/BUILDINGFOOTPRINTAREA.
buildingFootprintArea_uom: <3DCityDB>UR_BUILDINGDETAILS/BUILDINGFOOTPRINTAREA_UOM.
buildingRoofEdgeArea: <3DCityDB>UR_BUILDINGDETAILS/BUILDINGROOFEDGEAREA.
buildingRoofEdgeArea_uom: <3DCityDB>UR_BUILDINGDETAILS/BUILDINGROOFEDGEAREA_UOM.
developmentArea: <3DCityDB>UR_BUILDINGDETAILS/DEVELOPMENTAREA.
developmentArea_uom: <3DCityDB>UR_BUILDINGDETAILS/DEVELOPMENTAREA_UOM.
buildingStructureType: <3DCityDB>UR_BUILDINGDETAILS/BUILDINGSTRUCTURETYPE.
buildingStructureType_codeSpace: <3DCityDB>UR_BUILDINGDETAILS/BUILDINGSTRUCTURET_CODESPACE.
fireproofStructureType: <3DCityDB>UR_BUILDINGDETAILS/FIREPROOFSTRUCTURETYPE.
fireproofStructureType_codeSpace: <3DCityDB>UR_BUILDINGDETAILS/FIREPROOFSTRUCTURE_CODESPACE.
implementingBody: <3DCityDB>UR_BUILDINGDETAILS/IMPLEMENTINGBODY.
urbanPlanType: <3DCityDB>UR_BUILDINGDETAILS/URBANPLANTYPE.
urbanPlanType_codeSpace: <3DCityDB>UR_BUILDINGDETAILS/URBANPLANTYPE_CODESPACE.
districtsAndZonesType: <3DCityDB>UR_BUILDINGDETAILS/DISTRICTSANDZONESTYPE.
districtsAndZonesType_codeSpace: <3DCityDB>UR_BUILDINGDETAILS/DISTRICTSANDZONEST_CODESPACE.
landUsePlanType: <3DCityDB>UR_BUILDINGDETAILS/LANDUSEPLANTYPE.
landUsePlanType_codeSpace: <3DCityDB>UR_BUILDINGDETAILS/LANDUSEPLANTYPE_CODESPACE.
areaClassificationType: <3DCityDB>UR_BUILDINGDETAILS/AREACLASSIFICATIONTYPE.
areaClassificationType_codeSpace: <3DCityDB>UR_BUILDINGDETAILS/AREACLASSIFICATION_CODESPACE.
prefecture: <3DCityDB>UR_BUILDINGDETAILS/PREFECTURE.
prefecture_codeSpace: <3DCityDB>UR_BUILDINGDETAILS/PREFECTURE_CODESPACE.
city: <3DCityDB>UR_BUILDINGDETAILS/CITY.
city_codeSpace: <3DCityDB>UR_BUILDINGDETAILS/CITY_CODESPACE.
reference: <3DCityDB>UR_BUILDINGDETAILS/REFERENCE.
note: <3DCityDB>UR_BUILDINGDETAILS/NOTE.
keyValuePairs (mouseOver for values): + + +
diff --git a/resources/templates/balloons/genericGrid.html b/resources/templates/balloons/genericGrid.html new file mode 100644 index 0000000..98f0e88 --- /dev/null +++ b/resources/templates/balloons/genericGrid.html @@ -0,0 +1,67 @@ + + + + + + + <3DCityDB>CITYOBJECT/GMLID</3DCityDB> + + + + + + +
GenericGridCell Attributes
+
+ + + + +
name: <3DCityDB>CITYOBJECT/NAME,
description: <3DCityDB>CITYOBJECT/DESCRIPTION,
keyValuePairs (mouseOver for values): + + +
+ + diff --git a/resources/templates/balloons/population.html b/resources/templates/balloons/population.html index c303840..0af0866 100644 --- a/resources/templates/balloons/population.html +++ b/resources/templates/balloons/population.html @@ -23,23 +23,24 @@
- - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
description: <3DCityDB>CITYOBJECT/DESCRIPTION,
name: <3DCityDB>CITYOBJECT/NAME.
areaClassificationType: <3DCityDB>UR_STATISTICALGRID/AREACLASSIFICATIONTYPE
prefecture: <3DCityDB>UR_STATISTICALGRID/PREFECTURE
city: <3DCityDB>UR_STATISTICALGRID/CITY.
surveyYear: <3DCityDB>UR_STATISTICALGRID/SURVEYYEAR.
total: <3DCityDB>UR_POPULATION/TOTAL.
daytimePopulation: <3DCityDB>UR_POPULATION/DAYTIMEPOPULATION.
naturalIncrease: <3DCityDB>UR_POPULATION/NATURALINCREASE.
births: <3DCityDB>UR_POPULATION/BIRTHS.
deaths: <3DCityDB>UR_POPULATION/DEATHS.
socialIncrease: <3DCityDB>UR_POPULATION/SOCIALINCREASE.
moveFrom: <3DCityDB>UR_POPULATION/MOVEFROM.
moveTo: <3DCityDB>UR_POPULATION/MOVETO.
increasement: <3DCityDB>UR_POPULATION/INCREASEMENT.
malePopulation: <3DCityDB>UR_POPULATION/MALEPOPULATION.
femalePopulation: <3DCityDB>UR_POPULATION/FEMALEPOPULATION.
description: <3DCityDB>CITYOBJECT/DESCRIPTION,
name: <3DCityDB>CITYOBJECT/NAME.
urbanPlanType: <3DCityDB>UR_STATISTICALGRID/urbanplantype.
areaClassificationType: <3DCityDB>UR_STATISTICALGRID/AREACLASSIFICATIONTYPE
prefecture: <3DCityDB>UR_STATISTICALGRID/PREFECTURE
city: <3DCityDB>UR_STATISTICALGRID/CITY.
surveyYear: <3DCityDB>UR_STATISTICALGRID/SURVEYYEAR.
total: <3DCityDB>UR_POPULATION/TOTAL.
daytimePopulation: <3DCityDB>UR_POPULATION/DAYTIMEPOPULATION.
naturalIncrease: <3DCityDB>UR_POPULATION/NATURALINCREASE.
births: <3DCityDB>UR_POPULATION/BIRTHS.
deaths: <3DCityDB>UR_POPULATION/DEATHS.
socialIncrease: <3DCityDB>UR_POPULATION/SOCIALINCREASE.
moveFrom: <3DCityDB>UR_POPULATION/MOVEFROM.
moveTo: <3DCityDB>UR_POPULATION/MOVETO.
increasement: <3DCityDB>UR_POPULATION/INCREASEMENT.
malePopulation: <3DCityDB>UR_POPULATION/MALEPOPULATION.
femalePopulation: <3DCityDB>UR_POPULATION/FEMALEPOPULATION.
diff --git a/resources/templates/balloons/areaClassification.html b/resources/templates/balloons/shape.html similarity index 59% rename from resources/templates/balloons/areaClassification.html rename to resources/templates/balloons/shape.html index 1cb3635..50c8c8c 100644 --- a/resources/templates/balloons/areaClassification.html +++ b/resources/templates/balloons/shape.html @@ -17,17 +17,16 @@ - +
AreaClassification Attributes
PublicTransit Attributes

- - - - - + + + +
class: <3DCityDB>UR_URBANFUNCTION/CLASS,
enactmentDate: <3DCityDB>UR_URBANFUNCTION/ENACTMENTDATE,
prefecture: <3DCityDB>UR_URBANFUNCTION/PREFECTURE,
city: <3DCityDB>UR_URBANFUNCTION/CITY.
note: <3DCityDB>UR_URBANFUNCTION/NOTE
orgId: <3DCityDB>UR_PUBLICTRANSIT/ORGID.
latitude: <3DCityDB>UR_POINT/LATITUDE
longitude: <3DCityDB>UR_POINT/LONGITUDE
pointSequence: <3DCityDB>UR_POINT/POINTSEQUENCE
diff --git a/resources/templates/balloons/stop.html b/resources/templates/balloons/stop.html new file mode 100644 index 0000000..40097fa --- /dev/null +++ b/resources/templates/balloons/stop.html @@ -0,0 +1,34 @@ + + + + + + <3DCityDB>CITYOBJECT/GMLID</3DCityDB> + + + + + + +
PublicTransit Attributes
+
+ + + + + + + +
name: <3DCityDB>CITYOBJECT/NAME,
orgId: <3DCityDB>UR_PUBLICTRANSIT/ORGID.
latitude: <3DCityDB>UR_STOP/LATITUDE
longitude: <3DCityDB>UR_STOP/LONGITUDE
zoneId: <3DCityDB>UR_STOP/ZONEID
locationType: <3DCityDB>UR_STOP/LOCATIONTYPE
+ + diff --git a/resources/templates/balloons/trip.html b/resources/templates/balloons/trip.html new file mode 100644 index 0000000..91cfb55 --- /dev/null +++ b/resources/templates/balloons/trip.html @@ -0,0 +1,33 @@ + + + + + + <3DCityDB>CITYOBJECT/GMLID</3DCityDB> + + + + + + +
PublicTransit Attributes
+
+ + + + + + +
orgId: <3DCityDB>UR_PUBLICTRANSIT/ORGID.
headsign: <3DCityDB>UR_TRIP/HEADSIGN
routeId: <3DCityDB>UR_TRIP/ROUTE_ID
calendarId: <3DCityDB>UR_TRIP/CALENDAR_ID
shapeId: <3DCityDB>UR_TRIP/SHAPE_ID
+ + diff --git a/resources/templates/spreadsheets/areaClassification.txt b/resources/templates/spreadsheets/areaClassification.txt deleted file mode 100644 index 84ede88..0000000 --- a/resources/templates/spreadsheets/areaClassification.txt +++ /dev/null @@ -1,5 +0,0 @@ -class:UR_URBANFUNCTION/CLASS -enactmentDate:UR_URBANFUNCTION/ENACTMENTDATE -prefecture:UR_URBANFUNCTION/PREFECTURE -city:UR_URBANFUNCTION/CITY -note:UR_URBANFUNCTION/NOTE \ No newline at end of file diff --git a/resources/templates/spreadsheets/buildings.txt b/resources/templates/spreadsheets/buildings.txt index 2c58c6a..4590cf7 100644 --- a/resources/templates/spreadsheets/buildings.txt +++ b/resources/templates/spreadsheets/buildings.txt @@ -1,23 +1,34 @@ -class:BUILDING/CLASS -function:BUILDING/FUNCTION -usage:BUILDING/USAGE -yearOfConstruction:BUILDING/YEAR_OF_CONSTRUCTION -storeysAboveGround:BUILDING/STOREYS_ABOVE_GROUND -storeysBelowGround:BUILDING/STOREYS_BELOW_GROUND -serialNumberOfBuildingCertification:UR_BUILDINGDETAILS/SERIALNUMBEROFBUILDINGCERTIF -siteArea:UR_BUILDINGDETAILS/SITEAREA -buildingFootprintArea:UR_BUILDINGDETAILS/BUILDINGFOOTPRINTAREA -buildingRoofEdgeArea:UR_BUILDINGDETAILS/BUILDINGROOFEDGEAREA -developmentArea:UR_BUILDINGDETAILS/DEVELOPMENTAREA -buildingStructureType:UR_BUILDINGDETAILS/BUILDINGSTRUCTURETYPE -fireproofStructureType:UR_BUILDINGDETAILS/FIREPROOFSTRUCTURETYPE -implementingBody:UR_BUILDINGDETAILS/IMPLEMENTINGBODY -urbanPlanType:UR_BUILDINGDETAILS/URBANPLANTYPE -districtsAndZonesType:UR_BUILDINGDETAILS/DISTRICTSANDZONESTYPE -landUsePlanType:UR_BUILDINGDETAILS/LANDUSEPLANTYPE -areaClassificationType:UR_BUILDINGDETAILS/AREACLASSIFICATIONTYPE -prefecture:UR_BUILDINGDETAILS/PREFECTURE -city:UR_BUILDINGDETAILS/CITY -reference:UR_BUILDINGDETAILS/REFERENCE -note:UR_BUILDINGDETAILS/NOTE -surveyYear:UR_BUILDINGDETAILS/SURVEYYEAR \ No newline at end of file +class: BUILDING/CLASS +function: BUILDING/FUNCTION +usage: BUILDING/USAGE +yearOfConstruction: BUILDING/YEAR_OF_CONSTRUCTION +storeysAboveGround: BUILDING/STOREYS_ABOVE_GROUND +storeysBelowGround: BUILDING/STOREYS_BELOW_GROUND +serialNumberOfBuildingCertification: UR_BUILDINGDETAILS/SERIALNUMBEROFBUILDINGCERTIF +siteArea: UR_BUILDINGDETAILS/SITEAREA +siteArea_uom: UR_BUILDINGDETAILS/SITEAREA_UOM +buildingFootprintArea: UR_BUILDINGDETAILS/BUILDINGFOOTPRINTAREA +buildingFootprintArea_uom: UR_BUILDINGDETAILS/BUILDINGFOOTPRINTAREA_UOM +buildingRoofEdgeArea: UR_BUILDINGDETAILS/BUILDINGROOFEDGEAREA +buildingRoofEdgeArea_uom: UR_BUILDINGDETAILS/BUILDINGROOFEDGEAREA_UOM +developmentArea: UR_BUILDINGDETAILS/DEVELOPMENTAREA +developmentArea_uom: UR_BUILDINGDETAILS/DEVELOPMENTAREA_UOM +buildingStructureType: UR_BUILDINGDETAILS/BUILDINGSTRUCTURETYPE +buildingStructureType_codeSpace: UR_BUILDINGDETAILS/BUILDINGSTRUCTURET_CODESPACE +fireproofStructureType: UR_BUILDINGDETAILS/FIREPROOFSTRUCTURETYPE +fireproofStructureType_codeSpace: UR_BUILDINGDETAILS/FIREPROOFSTRUCTURE_CODESPACE +implementingBody: UR_BUILDINGDETAILS/IMPLEMENTINGBODY +urbanPlanType: UR_BUILDINGDETAILS/URBANPLANTYPE +urbanPlanType_codeSpace: UR_BUILDINGDETAILS/URBANPLANTYPE_CODESPACE +districtsAndZonesType: UR_BUILDINGDETAILS/DISTRICTSANDZONESTYPE +districtsAndZonesType_codeSpace: UR_BUILDINGDETAILS/DISTRICTSANDZONEST_CODESPACE +landUsePlanType: UR_BUILDINGDETAILS/LANDUSEPLANTYPE +landUsePlanType_codeSpace: UR_BUILDINGDETAILS/LANDUSEPLANTYPE_CODESPACE +areaClassificationType: UR_BUILDINGDETAILS/AREACLASSIFICATIONTYPE +areaClassificationType_codeSpace: UR_BUILDINGDETAILS/AREACLASSIFICATION_CODESPACE +prefecture: UR_BUILDINGDETAILS/PREFECTURE +prefecture_codeSpace: UR_BUILDINGDETAILS/PREFECTURE_CODESPACE +city: UR_BUILDINGDETAILS/CITY +city_codeSpace: UR_BUILDINGDETAILS/CITY_CODESPACE +reference: UR_BUILDINGDETAILS/REFERENCE +note: UR_BUILDINGDETAILS/NOTE \ No newline at end of file diff --git a/resources/templates/spreadsheets/genericGrid.txt b/resources/templates/spreadsheets/genericGrid.txt new file mode 100644 index 0000000..8dd2f03 --- /dev/null +++ b/resources/templates/spreadsheets/genericGrid.txt @@ -0,0 +1,2 @@ +name: CITYOBJECT/NAME +description: CITYOBJECT/DESCRIPTION \ No newline at end of file diff --git a/resources/templates/spreadsheets/population.txt b/resources/templates/spreadsheets/population.txt index a8da666..0433249 100644 --- a/resources/templates/spreadsheets/population.txt +++ b/resources/templates/spreadsheets/population.txt @@ -1,17 +1,18 @@ -description:CITYOBJECT/DESCRIPTION -name:CITYOBJECT/NAME -areaClassificationType:UR_STATISTICALGRID/AREACLASSIFICATIONTYPE -prefecture:UR_STATISTICALGRID/PREFECTURE -city:UR_STATISTICALGRID/CITY -surveyYear:UR_STATISTICALGRID/SURVEYYEAR -total:UR_POPULATION/TOTAL -daytimePopulation:UR_POPULATION/DAYTIMEPOPULATION -naturalIncrease:UR_POPULATION/NATURALINCREASE -births:UR_POPULATION/BIRTHS -deaths:UR_POPULATION/DEATHS -socialIncrease:UR_POPULATION/SOCIALINCREASE -moveFrom:UR_POPULATION/MOVEFROM -moveTo:UR_POPULATION/MOVETO -increasement:UR_POPULATION/INCREASEMENT -malePopulation:UR_POPULATION/MALEPOPULATION -femalePopulation:UR_POPULATION/FEMALEPOPULATION \ No newline at end of file +description: CITYOBJECT/DESCRIPTION +name: CITYOBJECT/NAME +urbanPlanType: UR_STATISTICALGRID/urbanplantype +areaClassificationType: UR_STATISTICALGRID/AREACLASSIFICATIONTYPE +prefecture: UR_STATISTICALGRID/PREFECTURE +city: UR_STATISTICALGRID/CITY +surveyYear: UR_STATISTICALGRID/SURVEYYEAR +total: UR_POPULATION/TOTAL +daytimePopulation: UR_POPULATION/DAYTIMEPOPULATION +naturalIncrease: UR_POPULATION/NATURALINCREASE +births: UR_POPULATION/BIRTHS +deaths: UR_POPULATION/DEATHS +socialIncrease: UR_POPULATION/SOCIALINCREASE +moveFrom: UR_POPULATION/MOVEFROM +moveTo: UR_POPULATION/MOVETO +increasement: UR_POPULATION/INCREASEMENT +malePopulation: UR_POPULATION/MALEPOPULATION +femalePopulation: UR_POPULATION/FEMALEPOPULATION \ No newline at end of file diff --git a/resources/templates/spreadsheets/shape.txt b/resources/templates/spreadsheets/shape.txt new file mode 100644 index 0000000..fd5d984 --- /dev/null +++ b/resources/templates/spreadsheets/shape.txt @@ -0,0 +1,4 @@ +orgId: UR_PUBLICTRANSIT/ORGID +latitude: UR_POINT/LATITUDE +longitude: UR_POINT/LONGITUDE +pointSequence: UR_POINT/POINTSEQUENCE \ No newline at end of file diff --git a/resources/templates/spreadsheets/stop.txt b/resources/templates/spreadsheets/stop.txt new file mode 100644 index 0000000..2a7c67a --- /dev/null +++ b/resources/templates/spreadsheets/stop.txt @@ -0,0 +1,6 @@ +name: CITYOBJECT/NAME +orgId: UR_PUBLICTRANSIT/ORGID +latitude: UR_STOP/LATITUDE +longitude: UR_STOP/LONGITUDE +zoneId: UR_STOP/ZONEID +locationType: UR_STOP/LOCATIONTYPE \ No newline at end of file diff --git a/resources/templates/spreadsheets/trip.txt b/resources/templates/spreadsheets/trip.txt new file mode 100644 index 0000000..ebf19d6 --- /dev/null +++ b/resources/templates/spreadsheets/trip.txt @@ -0,0 +1,5 @@ +orgId: UR_PUBLICTRANSIT/ORGID +headsign: UR_TRIP/HEADSIGN +routeId: UR_TRIP/ROUTE_ID +calendarId: UR_TRIP/CALENDAR_ID +shapeId: UR_TRIP/SHAPE_ID \ No newline at end of file diff --git a/src/main/java/org/citydb/ade/iur/UrbanRevitalizationADE.java b/src/main/java/org/citydb/ade/iur/UrbanRevitalizationADE.java index cb896db..d00b7f1 100644 --- a/src/main/java/org/citydb/ade/iur/UrbanRevitalizationADE.java +++ b/src/main/java/org/citydb/ade/iur/UrbanRevitalizationADE.java @@ -22,25 +22,25 @@ package org.citydb.ade.iur; -import org.citydb.ImpExp; +import org.citydb.ImpExpLauncher; import org.citydb.ade.ADEExtension; import org.citydb.ade.ADEExtensionException; import org.citydb.ade.ADEObjectMapper; import org.citydb.ade.exporter.ADEExportManager; import org.citydb.ade.importer.ADEImportManager; -import org.citydb.ade.iur.kmlExporter.KMLExportManager; -import org.citydb.database.schema.mapping.SchemaMapping; -import org.citydb.modules.kml.ade.ADEBalloonManager; -import org.citydb.modules.kml.ade.ADEKmlExportExtension; -import org.citydb.modules.kml.ade.ADEKmlExportManager; -import org.citygml4j.model.citygml.ade.binding.ADEContext; import org.citydb.ade.iur.balloon.BalloonManager; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.kmlExporter.KMLExportManager; import org.citydb.ade.iur.schema.ADETableMapper; import org.citydb.ade.iur.schema.ObjectMapper; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.ade.kmlExporter.ADEBalloonManager; +import org.citydb.ade.kmlExporter.ADEKmlExportExtension; +import org.citydb.ade.kmlExporter.ADEKmlExportManager; +import org.citydb.database.schema.mapping.SchemaMapping; import org.citygml4j.ade.iur.UrbanRevitalizationADEContext; +import org.citygml4j.model.citygml.ade.binding.ADEContext; import java.nio.file.Paths; import java.util.Collections; @@ -55,7 +55,10 @@ public class UrbanRevitalizationADE extends ADEExtension implements ADEKmlExport public static void main(String[] args) { UrbanRevitalizationADE adeExtension = new UrbanRevitalizationADE(); adeExtension.setBasePath(Paths.get("resources", "database").toAbsolutePath()); - new ImpExp().doMain(args, adeExtension); + new ImpExpLauncher() + .withArgs(args) + .withADEExtension(adeExtension) + .start(); } @Override @@ -77,7 +80,7 @@ public ADEObjectMapper getADEObjectMapper() { @Override public ADEImportManager createADEImportManager() { - return new ImportManager(this, schemaMapper); + return new ImportManager(this, objectMapper, schemaMapper); } @Override diff --git a/src/main/java/org/citydb/ade/iur/balloon/BalloonManager.java b/src/main/java/org/citydb/ade/iur/balloon/BalloonManager.java index e1b5d7a..eb87114 100644 --- a/src/main/java/org/citydb/ade/iur/balloon/BalloonManager.java +++ b/src/main/java/org/citydb/ade/iur/balloon/BalloonManager.java @@ -24,18 +24,20 @@ import org.citydb.ade.iur.schema.ADETableMapper; import org.citydb.ade.iur.schema.SchemaMapper; -import org.citydb.modules.kml.ade.ADEBalloonException; -import org.citydb.modules.kml.ade.ADEBalloonHandler; -import org.citydb.modules.kml.ade.ADEBalloonManager; + +import org.citydb.ade.kmlExporter.ADEBalloonException; +import org.citydb.ade.kmlExporter.ADEBalloonHandler; +import org.citydb.ade.kmlExporter.ADEBalloonManager; import org.citydb.util.Util; +import org.citygml4j.ade.iur.model.urf.UrbanFunction; +import org.citygml4j.ade.iur.model.urg.StatisticalGrid; +import org.citygml4j.ade.iur.model.urt.PublicTransit; import org.citygml4j.model.citygml.building.AbstractBuilding; import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; import org.citygml4j.model.citygml.landuse.LandUse; import org.citygml4j.model.citygml.transportation.TransportationComplex; import org.citygml4j.model.gml.base.AbstractGML; import org.citygml4j.model.module.citygml.CityGMLVersion; -import org.citygml4j.ade.iur.model.urf.UrbanFunction; -import org.citygml4j.ade.iur.model.urg.StatisticalGrid; import java.util.HashMap; import java.util.Map; @@ -69,6 +71,8 @@ public ADEBalloonHandler getBalloonHandler(int objectClassId) throws ADEBalloonE balloonHandler = getBalloonHandler(UrbanFunctionBalloonHandler.class); } else if (modelObject instanceof StatisticalGrid) { balloonHandler = getBalloonHandler(StatisticalGridBalloonHandler.class); + } else if (modelObject instanceof PublicTransit) { + balloonHandler = getBalloonHandler(PublicTransitBalloonHandler.class); } return balloonHandler; @@ -94,6 +98,8 @@ private T getBalloonHandler(Class type) throws balloonHandler = new UrbanFunctionBalloonHandler(this); } else if (type == StatisticalGridBalloonHandler.class) { balloonHandler = new StatisticalGridBalloonHandler(this); + } else if (type == PublicTransitBalloonHandler.class) { + balloonHandler = new PublicTransitBalloonHandler(this); } if (balloonHandler == null) diff --git a/src/main/java/org/citydb/ade/iur/balloon/BuildingBalloonHandler.java b/src/main/java/org/citydb/ade/iur/balloon/BuildingBalloonHandler.java index 4437ac8..0c04256 100644 --- a/src/main/java/org/citydb/ade/iur/balloon/BuildingBalloonHandler.java +++ b/src/main/java/org/citydb/ade/iur/balloon/BuildingBalloonHandler.java @@ -24,7 +24,7 @@ import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; -import org.citydb.modules.kml.ade.ADEBalloonHandler; +import org.citydb.ade.kmlExporter.ADEBalloonHandler; public class BuildingBalloonHandler implements ADEBalloonHandler { private final SchemaMapper schemaMapper; @@ -54,7 +54,12 @@ public String getSqlStatement(String table, } else if (schemaMapper.getTableName(ADETable.LARGECUSTOMERFACILITIE).equalsIgnoreCase(table)) { sqlStatement = "SELECT " + aggregateColumnsClause + " FROM " + schemaName + "." + table + " " + tableShortId + ", " + schemaName + "." + schemaMapper.getTableName(ADETable.BUILDING) + " ub" + - " WHERE " + tableShortId + ".id = ub.largecustomerfacilitiespr_id" + + " WHERE " + tableShortId + ".id = ub.largecustomerfacilities_id" + + " AND ub.id = ?"; + } else if (schemaMapper.getTableName(ADETable.KEYVALUEPAIR_1).equalsIgnoreCase(table)) { + sqlStatement = "SELECT " + aggregateColumnsClause + + " FROM " + schemaName + "." + table + " " + tableShortId + ", " + schemaName + "." + schemaMapper.getTableName(ADETable.BUILDING) + " ub" + + " WHERE " + tableShortId + ".building_extendedattribut_id = ub.id" + " AND ub.id = ?"; } diff --git a/src/main/java/org/citydb/ade/iur/balloon/CityObjectGroupBalloonHandler.java b/src/main/java/org/citydb/ade/iur/balloon/CityObjectGroupBalloonHandler.java index 8b889f0..729cdaf 100644 --- a/src/main/java/org/citydb/ade/iur/balloon/CityObjectGroupBalloonHandler.java +++ b/src/main/java/org/citydb/ade/iur/balloon/CityObjectGroupBalloonHandler.java @@ -24,7 +24,7 @@ import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; -import org.citydb.modules.kml.ade.ADEBalloonHandler; +import org.citydb.ade.kmlExporter.ADEBalloonHandler; public class CityObjectGroupBalloonHandler implements ADEBalloonHandler { private final SchemaMapper schemaMapper; @@ -42,10 +42,28 @@ public String getSqlStatement(String table, String sqlStatement = null; - if (schemaMapper.getTableName(ADETable.CITYOBJECTGROUP).equalsIgnoreCase(table)) { + if (schemaMapper.getTableName(ADETable.CITYOBJECTGROUP).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_1).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_2).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_3).equalsIgnoreCase(table)) { sqlStatement = "SELECT " + aggregateColumnsClause + " FROM " + schemaName + "." + table + " " + tableShortId + " WHERE " + tableShortId + ".id = ?"; + } else if (schemaMapper.getTableName(ADETable.PUBLICTRANSITDATATYPE).equalsIgnoreCase(table)) { + sqlStatement = "SELECT " + aggregateColumnsClause + + " FROM " + schemaName + "." + table + " " + tableShortId + ", " + schemaName + "." + schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_3) + " ucog" + + " WHERE " + tableShortId + ".cityobjectgroup_datatype_id = ?"; + } else if (schemaMapper.getTableName(ADETable.FARERULE).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.FEEDINFO).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.FREQUENCY).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.STOPTIME).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.TRANSFER).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.TRANSLATION).equalsIgnoreCase(table)) { + sqlStatement = "SELECT " + aggregateColumnsClause + + " FROM " + schemaName + "." + table + " " + tableShortId + ", " + schemaName + "." + schemaMapper.getTableName(ADETable.PUBLICTRANSITDATATYPE) + " ptd, " + schemaName + + "." + schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_3) + " ucog" + + " WHERE " + tableShortId + ".id = ptd.id" + + " AND ptd.cityobjectgroup_datatype_id = ?"; } return sqlStatement; diff --git a/src/main/java/org/citydb/ade/iur/balloon/LandUseBalloonHandler.java b/src/main/java/org/citydb/ade/iur/balloon/LandUseBalloonHandler.java index b383d23..8a225bd 100644 --- a/src/main/java/org/citydb/ade/iur/balloon/LandUseBalloonHandler.java +++ b/src/main/java/org/citydb/ade/iur/balloon/LandUseBalloonHandler.java @@ -24,7 +24,7 @@ import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; -import org.citydb.modules.kml.ade.ADEBalloonHandler; +import org.citydb.ade.kmlExporter.ADEBalloonHandler; public class LandUseBalloonHandler implements ADEBalloonHandler { private final SchemaMapper schemaMapper; diff --git a/src/main/java/org/citydb/ade/iur/balloon/PublicTransitBalloonHandler.java b/src/main/java/org/citydb/ade/iur/balloon/PublicTransitBalloonHandler.java new file mode 100644 index 0000000..d9bdd4e --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/balloon/PublicTransitBalloonHandler.java @@ -0,0 +1,74 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.balloon; + +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.ade.kmlExporter.ADEBalloonHandler; + +public class PublicTransitBalloonHandler implements ADEBalloonHandler { + private final SchemaMapper schemaMapper; + + public PublicTransitBalloonHandler(BalloonManager manager) { + this.schemaMapper = manager.getSchemaMapper(); + } + + @Override + public String getSqlStatement(String table, + String tableShortId, + String aggregateColumnsClause, + int lod, + String schemaName) { + + String sqlStatement = null; + + if (schemaMapper.getTableName(ADETable.PUBLICTRANSIT).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.AGENCY).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.ATTRIBUTION).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.CALENDAR).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.CALENDARDATE).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.FAREATTRIBUTE).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.OFFICE).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.PATHWAY).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.ROUTE).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.STOP).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.TRANSLATIONJP).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.TRIP).equalsIgnoreCase(table)) { + sqlStatement = "SELECT " + aggregateColumnsClause + + " FROM " + schemaName + "." + table + " " + tableShortId + + " WHERE " + tableShortId + ".id = ?"; + } else if (schemaMapper.getTableName(ADETable.DESCRIPTION).equalsIgnoreCase(table)) { + sqlStatement = "SELECT " + aggregateColumnsClause + + " FROM " + schemaName + "." + table + " " + tableShortId + ", " + schemaName + "." + schemaMapper.getTableName(ADETable.ROUTE) + " r" + + " WHERE " + tableShortId + ".id = r.description_id" + + " AND r.id = ?"; + } else if (schemaMapper.getTableName(ADETable.POINT).equalsIgnoreCase(table)) { + sqlStatement = "SELECT " + aggregateColumnsClause + + " FROM " + schemaName + "." + table + " " + tableShortId + + " WHERE " + tableShortId + ".publictransit_point_id = ?"; + } + + return sqlStatement; + } + +} diff --git a/src/main/java/org/citydb/ade/iur/balloon/StatisticalGridBalloonHandler.java b/src/main/java/org/citydb/ade/iur/balloon/StatisticalGridBalloonHandler.java index d57b550..44e95c1 100644 --- a/src/main/java/org/citydb/ade/iur/balloon/StatisticalGridBalloonHandler.java +++ b/src/main/java/org/citydb/ade/iur/balloon/StatisticalGridBalloonHandler.java @@ -24,7 +24,7 @@ import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; -import org.citydb.modules.kml.ade.ADEBalloonHandler; +import org.citydb.ade.kmlExporter.ADEBalloonHandler; public class StatisticalGridBalloonHandler implements ADEBalloonHandler { private final SchemaMapper schemaMapper; @@ -45,7 +45,8 @@ public String getSqlStatement(String table, if (schemaMapper.getTableName(ADETable.STATISTICALGRID).equalsIgnoreCase(table) || schemaMapper.getTableName(ADETable.POPULATION).equalsIgnoreCase(table) || schemaMapper.getTableName(ADETable.HOUSEHOLDS).equalsIgnoreCase(table) - || schemaMapper.getTableName(ADETable.OFFICESANDEMPLOYEES).equalsIgnoreCase(table)) { + || schemaMapper.getTableName(ADETable.OFFICESANDEMPLOYEES).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.LANDPRICE).equalsIgnoreCase(table)) { sqlStatement = "SELECT " + aggregateColumnsClause + " FROM " + schemaName + "." + table + " " + tableShortId + " WHERE " + tableShortId + ".id = ?"; @@ -65,6 +66,14 @@ public String getSqlStatement(String table, sqlStatement = "SELECT " + aggregateColumnsClause + " FROM " + schemaName + "." + table + " " + tableShortId + " WHERE " + tableShortId + ".statisticalg_numberofannu_id = ?"; + } else if (schemaMapper.getTableName(ADETable.AREAOFANNUALDIVERSIONS).equalsIgnoreCase(table)) { + sqlStatement = "SELECT " + aggregateColumnsClause + + " FROM " + schemaName + "." + table + " " + tableShortId + + " WHERE " + tableShortId + ".landusediver_areaofannual_id = ?"; + } else if (schemaMapper.getTableName(ADETable.KEYVALUEPAIR).equalsIgnoreCase(table)) { + sqlStatement = "SELECT " + aggregateColumnsClause + + " FROM " + schemaName + "." + table + " " + tableShortId + + " WHERE " + tableShortId + ".statisticalg_genericvalue_id = ?"; } return sqlStatement; diff --git a/src/main/java/org/citydb/ade/iur/balloon/TransportationBalloonHandler.java b/src/main/java/org/citydb/ade/iur/balloon/TransportationBalloonHandler.java index cf52765..f260989 100644 --- a/src/main/java/org/citydb/ade/iur/balloon/TransportationBalloonHandler.java +++ b/src/main/java/org/citydb/ade/iur/balloon/TransportationBalloonHandler.java @@ -24,7 +24,7 @@ import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; -import org.citydb.modules.kml.ade.ADEBalloonHandler; +import org.citydb.ade.kmlExporter.ADEBalloonHandler; public class TransportationBalloonHandler implements ADEBalloonHandler { private final SchemaMapper schemaMapper; diff --git a/src/main/java/org/citydb/ade/iur/balloon/UrbanFunctionBalloonHandler.java b/src/main/java/org/citydb/ade/iur/balloon/UrbanFunctionBalloonHandler.java index 5a002ee..60a87ec 100644 --- a/src/main/java/org/citydb/ade/iur/balloon/UrbanFunctionBalloonHandler.java +++ b/src/main/java/org/citydb/ade/iur/balloon/UrbanFunctionBalloonHandler.java @@ -24,7 +24,7 @@ import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; -import org.citydb.modules.kml.ade.ADEBalloonHandler; +import org.citydb.ade.kmlExporter.ADEBalloonHandler; public class UrbanFunctionBalloonHandler implements ADEBalloonHandler { private final SchemaMapper schemaMapper; @@ -46,7 +46,7 @@ public String getSqlStatement(String table, || schemaMapper.getTableName(ADETable.ZONE).equalsIgnoreCase(table) || schemaMapper.getTableName(ADETable.DEVELOPMENTPROJECT).equalsIgnoreCase(table) || schemaMapper.getTableName(ADETable.POLLUTION).equalsIgnoreCase(table) - || schemaMapper.getTableName(ADETable.PUBLICTRANSIT).equalsIgnoreCase(table) + || schemaMapper.getTableName(ADETable.PUBLICTRANSPORTATIONFA).equalsIgnoreCase(table) || schemaMapper.getTableName(ADETable.RECREATIONS).equalsIgnoreCase(table) || schemaMapper.getTableName(ADETable.CENSUSBLOCK).equalsIgnoreCase(table) || schemaMapper.getTableName(ADETable.URBANIZATION).equalsIgnoreCase(table) diff --git a/src/main/java/org/citydb/ade/iur/exporter/ExportManager.java b/src/main/java/org/citydb/ade/iur/exporter/ExportManager.java index 9cdcc72..8817f95 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/ExportManager.java +++ b/src/main/java/org/citydb/ade/iur/exporter/ExportManager.java @@ -25,54 +25,100 @@ import org.citydb.ade.exporter.ADEExportManager; import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; -import org.citydb.ade.iur.schema.ADETable; -import org.citydb.ade.iur.schema.ObjectMapper; -import org.citydb.ade.iur.schema.SchemaMapper; -import org.citydb.citygml.exporter.CityGMLExportException; -import org.citydb.database.schema.mapping.AbstractObjectType; -import org.citydb.database.schema.mapping.FeatureType; -import org.citydb.query.filter.projection.ProjectionFilter; -import org.citygml4j.model.citygml.ade.binding.ADEModelObject; -import org.citygml4j.model.citygml.building.AbstractBuilding; -import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; -import org.citygml4j.model.citygml.landuse.LandUse; -import org.citygml4j.model.citygml.transportation.TransportationComplex; -import org.citygml4j.model.gml.feature.AbstractFeature; -import org.w3c.dom.Element; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; import org.citydb.ade.iur.exporter.urf.CensusBlockExporter; import org.citydb.ade.iur.exporter.urf.DevelopmentProjectExporter; import org.citydb.ade.iur.exporter.urf.DisasterDamageExporter; +import org.citydb.ade.iur.exporter.urf.DisasterPreventionBaseExporter; import org.citydb.ade.iur.exporter.urf.PollutionExporter; -import org.citydb.ade.iur.exporter.urf.PublicTransitExporter; +import org.citydb.ade.iur.exporter.urf.PublicTransportationFacilityExporter; import org.citydb.ade.iur.exporter.urf.RecreationsExporter; import org.citydb.ade.iur.exporter.urf.UrbanFunctionExporter; +import org.citydb.ade.iur.exporter.urf.UrbanFunctionModuleExporter; import org.citydb.ade.iur.exporter.urf.UrbanizationExporter; +import org.citydb.ade.iur.exporter.urf.ZoneExporter; +import org.citydb.ade.iur.exporter.urg.GenericGridCellExporter; import org.citydb.ade.iur.exporter.urg.HouseholdsExporter; import org.citydb.ade.iur.exporter.urg.LandPriceExporter; import org.citydb.ade.iur.exporter.urg.LandUseDiversionExporter; import org.citydb.ade.iur.exporter.urg.OfficesAndEmployeesExporter; import org.citydb.ade.iur.exporter.urg.PopulationExporter; +import org.citydb.ade.iur.exporter.urg.PublicTransitAccessibilityExporter; import org.citydb.ade.iur.exporter.urg.StatisticalGridExporter; +import org.citydb.ade.iur.exporter.urg.StatisticalGridModuleExporter; import org.citydb.ade.iur.exporter.uro.BuildingPropertiesExporter; -import org.citydb.ade.iur.exporter.uro.CityObjectGroupPropertiesExporter; import org.citydb.ade.iur.exporter.uro.LandUsePropertiesExporter; import org.citydb.ade.iur.exporter.uro.TransportationComplexPropertiesExporter; +import org.citydb.ade.iur.exporter.uro.UrbanObjectModuleExporter; +import org.citydb.ade.iur.exporter.urt.AgencyExporter; +import org.citydb.ade.iur.exporter.urt.AttributionExporter; +import org.citydb.ade.iur.exporter.urt.CalendarDateExporter; +import org.citydb.ade.iur.exporter.urt.CalendarExporter; +import org.citydb.ade.iur.exporter.urt.FareAttributeExporter; +import org.citydb.ade.iur.exporter.urt.FareRuleExporter; +import org.citydb.ade.iur.exporter.urt.FeedInfoExporter; +import org.citydb.ade.iur.exporter.urt.FrequencyExporter; +import org.citydb.ade.iur.exporter.urt.LevelExporter; +import org.citydb.ade.iur.exporter.urt.OfficeExporter; +import org.citydb.ade.iur.exporter.urt.PathwayExporter; +import org.citydb.ade.iur.exporter.urt.PublicTransitExporter; +import org.citydb.ade.iur.exporter.urt.PublicTransitModuleExporter; +import org.citydb.ade.iur.exporter.urt.RouteExporter; +import org.citydb.ade.iur.exporter.urt.ShapeExporter; +import org.citydb.ade.iur.exporter.urt.StopExporter; +import org.citydb.ade.iur.exporter.urt.StopTimeExporter; +import org.citydb.ade.iur.exporter.urt.TransferExporter; +import org.citydb.ade.iur.exporter.urt.TranslationExporter; +import org.citydb.ade.iur.exporter.urt.TranslationJPExporter; +import org.citydb.ade.iur.exporter.urt.TripExporter; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.ObjectMapper; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citydb.database.schema.mapping.FeatureType; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citygml4j.ade.iur.model.module.PublicTransitModule; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; import org.citygml4j.ade.iur.model.urf.CensusBlock; import org.citygml4j.ade.iur.model.urf.DevelopmentProject; import org.citygml4j.ade.iur.model.urf.DisasterDamage; +import org.citygml4j.ade.iur.model.urf.DisasterPreventionBase; import org.citygml4j.ade.iur.model.urf.Pollution; -import org.citygml4j.ade.iur.model.urf.PublicTransit; +import org.citygml4j.ade.iur.model.urf.PublicTransportationFacility; import org.citygml4j.ade.iur.model.urf.Recreations; import org.citygml4j.ade.iur.model.urf.UrbanFunction; import org.citygml4j.ade.iur.model.urf.Urbanization; +import org.citygml4j.ade.iur.model.urf.Zone; +import org.citygml4j.ade.iur.model.urg.GenericGridCell; import org.citygml4j.ade.iur.model.urg.Households; import org.citygml4j.ade.iur.model.urg.LandPrice; import org.citygml4j.ade.iur.model.urg.LandUseDiversion; import org.citygml4j.ade.iur.model.urg.OfficesAndEmployees; import org.citygml4j.ade.iur.model.urg.Population; -import org.citygml4j.ade.iur.model.urg.StatisticalGrid; +import org.citygml4j.ade.iur.model.urg.PublicTransitAccessibility; +import org.citygml4j.ade.iur.model.urt.Agency; +import org.citygml4j.ade.iur.model.urt.Attribution; +import org.citygml4j.ade.iur.model.urt.Calendar; +import org.citygml4j.ade.iur.model.urt.CalendarDate; +import org.citygml4j.ade.iur.model.urt.FareAttribute; +import org.citygml4j.ade.iur.model.urt.Level; +import org.citygml4j.ade.iur.model.urt.Office; +import org.citygml4j.ade.iur.model.urt.Pathway; +import org.citygml4j.ade.iur.model.urt.Route; +import org.citygml4j.ade.iur.model.urt.Shape; +import org.citygml4j.ade.iur.model.urt.Stop; +import org.citygml4j.ade.iur.model.urt.TranslationJP; +import org.citygml4j.ade.iur.model.urt.Trip; +import org.citygml4j.model.citygml.ade.binding.ADEModelObject; +import org.citygml4j.model.citygml.building.AbstractBuilding; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; +import org.citygml4j.model.citygml.landuse.LandUse; +import org.citygml4j.model.citygml.transportation.TransportationComplex; +import org.citygml4j.model.gml.feature.AbstractFeature; +import org.w3c.dom.Element; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -107,34 +153,70 @@ public void init(Connection connection, CityGMLExportHelper helper) throws CityG @Override public void exportObject(ADEModelObject object, long objectId, AbstractObjectType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { - if (object instanceof CensusBlock) - getExporter(CensusBlockExporter.class).doExport((CensusBlock) object, objectId, objectType, projectionFilter); - else if (object instanceof DisasterDamage) - getExporter(DisasterDamageExporter.class).doExport((DisasterDamage) object, objectId, objectType, projectionFilter); - else if (object instanceof Pollution) - getExporter(PollutionExporter.class).doExport((Pollution) object, objectId, objectType, projectionFilter); - else if (object instanceof PublicTransit) - getExporter(PublicTransitExporter.class).doExport((PublicTransit) object, objectId, objectType, projectionFilter); - else if (object instanceof Recreations) - getExporter(RecreationsExporter.class).doExport((Recreations) object, objectId, objectType, projectionFilter); - else if (object instanceof Urbanization) - getExporter(UrbanizationExporter.class).doExport((Urbanization) object, objectId, objectType, projectionFilter); - else if (object instanceof DevelopmentProject) - getExporter(DevelopmentProjectExporter.class).doExport((DevelopmentProject) object, objectId, objectType, projectionFilter); - else if (object instanceof UrbanFunction) - getExporter(UrbanFunctionExporter.class).doExport((UrbanFunction) object, objectId, objectType, projectionFilter); - else if (object instanceof Households) - getExporter(HouseholdsExporter.class).doExport((Households) object, objectId, objectType, projectionFilter); - else if (object instanceof LandPrice) - getExporter(LandPriceExporter.class).doExport((LandPrice) object, objectId, objectType, projectionFilter); - else if (object instanceof LandUseDiversion) - getExporter(LandUseDiversionExporter.class).doExport((LandUseDiversion) object, objectId, objectType, projectionFilter); - else if (object instanceof OfficesAndEmployees) - getExporter(OfficesAndEmployeesExporter.class).doExport((OfficesAndEmployees) object, objectId, objectType, projectionFilter); - else if (object instanceof Population) - getExporter(PopulationExporter.class).doExport((Population) object, objectId, objectType, projectionFilter); - else if (object instanceof StatisticalGrid) - getExporter(StatisticalGridExporter.class).doExport((StatisticalGrid) object, objectId, objectType, projectionFilter); + if (UrbanFunctionModule.v1_4.getModelPackageName().equals(object.getClass().getPackage().getName())) { + if (object instanceof CensusBlock) + getExporter(CensusBlockExporter.class).doExport((CensusBlock) object, objectId, objectType, projectionFilter); + else if (object instanceof DisasterDamage) + getExporter(DisasterDamageExporter.class).doExport((DisasterDamage) object, objectId, objectType, projectionFilter); + else if (object instanceof DisasterPreventionBase) + getExporter(DisasterPreventionBaseExporter.class).doExport((DisasterPreventionBase) object, objectId, objectType, projectionFilter); + else if (object instanceof Pollution) + getExporter(PollutionExporter.class).doExport((Pollution) object, objectId, objectType, projectionFilter); + else if (object instanceof PublicTransportationFacility) + getExporter(PublicTransportationFacilityExporter.class).doExport((PublicTransportationFacility) object, objectId, objectType, projectionFilter); + else if (object instanceof Recreations) + getExporter(RecreationsExporter.class).doExport((Recreations) object, objectId, objectType, projectionFilter); + else if (object instanceof Urbanization) + getExporter(UrbanizationExporter.class).doExport((Urbanization) object, objectId, objectType, projectionFilter); + else if (object instanceof DevelopmentProject) + getExporter(DevelopmentProjectExporter.class).doExport((DevelopmentProject) object, objectId, objectType, projectionFilter); + else if (object instanceof Zone) + getExporter(ZoneExporter.class).doExport((Zone) object, objectId, objectType, projectionFilter); + else if (object instanceof UrbanFunction) + getExporter(UrbanFunctionExporter.class).doExport((UrbanFunction) object, objectId, objectType, projectionFilter); + } else if (StatisticalGridModule.v1_4.getModelPackageName().equals(object.getClass().getPackage().getName())) { + if (object instanceof GenericGridCell) + getExporter(GenericGridCellExporter.class).doExport((GenericGridCell) object, objectId, objectType, projectionFilter); + else if (object instanceof Households) + getExporter(HouseholdsExporter.class).doExport((Households) object, objectId, objectType, projectionFilter); + else if (object instanceof LandPrice) + getExporter(LandPriceExporter.class).doExport((LandPrice) object, objectId, objectType, projectionFilter); + else if (object instanceof LandUseDiversion) + getExporter(LandUseDiversionExporter.class).doExport((LandUseDiversion) object, objectId, objectType, projectionFilter); + else if (object instanceof OfficesAndEmployees) + getExporter(OfficesAndEmployeesExporter.class).doExport((OfficesAndEmployees) object, objectId, objectType, projectionFilter); + else if (object instanceof Population) + getExporter(PopulationExporter.class).doExport((Population) object, objectId, objectType, projectionFilter); + else if (object instanceof PublicTransitAccessibility) + getExporter(PublicTransitAccessibilityExporter.class).doExport((PublicTransitAccessibility) object, objectId, objectType, projectionFilter); + } else if (PublicTransitModule.v1_4.getModelPackageName().equals(object.getClass().getPackage().getName())) { + if (object instanceof Agency) + getExporter(AgencyExporter.class).doExport((Agency) object, objectId, objectType, projectionFilter); + else if (object instanceof Attribution) + getExporter(AttributionExporter.class).doExport((Attribution) object, objectId, objectType, projectionFilter); + else if (object instanceof Calendar) + getExporter(CalendarExporter.class).doExport((Calendar) object, objectId, objectType, projectionFilter); + else if (object instanceof CalendarDate) + getExporter(CalendarDateExporter.class).doExport((CalendarDate) object, objectId, objectType, projectionFilter); + else if (object instanceof FareAttribute) + getExporter(FareAttributeExporter.class).doExport((FareAttribute) object, objectId, objectType, projectionFilter); + else if (object instanceof Level) + getExporter(LevelExporter.class).doExport((Level) object, objectId, objectType, projectionFilter); + else if (object instanceof Office) + getExporter(OfficeExporter.class).doExport((Office) object, objectId, objectType, projectionFilter); + else if (object instanceof Pathway) + getExporter(PathwayExporter.class).doExport((Pathway) object, objectId, objectType, projectionFilter); + else if (object instanceof Route) + getExporter(RouteExporter.class).doExport((Route) object, objectId, objectType, projectionFilter); + else if (object instanceof Shape) + getExporter(ShapeExporter.class).doExport((Shape) object, objectId, objectType, projectionFilter); + else if (object instanceof Stop) + getExporter(StopExporter.class).doExport((Stop) object, objectId, objectType, projectionFilter); + else if (object instanceof TranslationJP) + getExporter(TranslationJPExporter.class).doExport((TranslationJP) object, objectId, objectType, projectionFilter); + else if (object instanceof Trip) + getExporter(TripExporter.class).doExport((Trip) object, objectId, objectType, projectionFilter); + } } @Override @@ -145,8 +227,16 @@ else if (adeHookTable.equals(schemaMapper.getTableName(ADETable.LAND_USE)) && pa getExporter(LandUsePropertiesExporter.class).doExport((LandUse) parent, parentId, parentType, projectionFilter); else if (adeHookTable.equals(schemaMapper.getTableName(ADETable.TRANSPORTATION_COMPLEX)) && parent instanceof TransportationComplex) getExporter(TransportationComplexPropertiesExporter.class).doExport((TransportationComplex) parent, parentId, parentType, projectionFilter); - else if (adeHookTable.equals(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP)) && parent instanceof CityObjectGroup) - getExporter(CityObjectGroupPropertiesExporter.class).doExport((CityObjectGroup) parent, parentId, parentType, projectionFilter); + else if (parent instanceof CityObjectGroup) { + if (adeHookTable.equals(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP))) + getExporter(org.citydb.ade.iur.exporter.urg.CityObjectGroupPropertiesExporter.class).doExport((CityObjectGroup) parent, parentId, parentType, projectionFilter); + else if (adeHookTable.equals(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_1))) + getExporter(org.citydb.ade.iur.exporter.uro.CityObjectGroupPropertiesExporter.class).doExport((CityObjectGroup) parent, parentId, parentType, projectionFilter); + else if (adeHookTable.equals(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_2))) + getExporter(org.citydb.ade.iur.exporter.urf.CityObjectGroupPropertiesExporter.class).doExport((CityObjectGroup) parent, parentId, parentType, projectionFilter); + else if (adeHookTable.equals(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_3))) + getExporter(org.citydb.ade.iur.exporter.urt.CityObjectGroupPropertiesExporter.class).doExport((CityObjectGroup) parent, parentId, parentType, projectionFilter); + } } @Override @@ -180,47 +270,105 @@ public T getExporter(Class type) throws CityGMLExport ADEExporter exporter = exporters.get(type); if (exporter == null) { - // urban function module - if (type == UrbanFunctionExporter.class) - exporter = new UrbanFunctionExporter(connection, helper, this); - else if (type == CensusBlockExporter.class) - exporter = new CensusBlockExporter(connection, helper, this); - else if (type == DisasterDamageExporter.class) - exporter = new DisasterDamageExporter(connection, helper, this); - else if (type == PollutionExporter.class) - exporter = new PollutionExporter(connection, helper, this); - else if (type == PublicTransitExporter.class) - exporter = new PublicTransitExporter(connection, helper, this); - else if (type == RecreationsExporter.class) - exporter = new RecreationsExporter(connection, helper, this); - else if (type == UrbanizationExporter.class) - exporter = new UrbanizationExporter(connection, helper, this); - else if (type == DevelopmentProjectExporter.class) - exporter = new DevelopmentProjectExporter(connection, helper, this); - - // statistical grid module - else if (type == StatisticalGridExporter.class) - exporter = new StatisticalGridExporter(connection, helper, this); - else if (type == HouseholdsExporter.class) - exporter = new HouseholdsExporter(connection, helper, this); - else if (type == LandPriceExporter.class) - exporter = new LandPriceExporter(connection, helper, this); - else if (type == LandUseDiversionExporter.class) - exporter = new LandUseDiversionExporter(connection, helper, this); - else if (type == OfficesAndEmployeesExporter.class) - exporter = new OfficesAndEmployeesExporter(connection, helper, this); - else if (type == PopulationExporter.class) - exporter = new PopulationExporter(connection, helper, this); - - // urban object module - else if (type == BuildingPropertiesExporter.class) - exporter = new BuildingPropertiesExporter(connection, helper, this); - else if (type == LandUsePropertiesExporter.class) - exporter = new LandUsePropertiesExporter(connection, helper, this); - else if (type == TransportationComplexPropertiesExporter.class) - exporter = new TransportationComplexPropertiesExporter(connection, helper, this); - else if (type == CityObjectGroupPropertiesExporter.class) - exporter = new CityObjectGroupPropertiesExporter(connection, helper, this); + if (UrbanFunctionModuleExporter.class.isAssignableFrom(type)) { + // urban function module + if (type == UrbanFunctionExporter.class) + exporter = new UrbanFunctionExporter(connection, helper, this); + else if (type == DevelopmentProjectExporter.class) + exporter = new DevelopmentProjectExporter(connection, helper, this); + else if (type == CensusBlockExporter.class) + exporter = new CensusBlockExporter(connection, helper, this); + else if (type == DisasterDamageExporter.class) + exporter = new DisasterDamageExporter(connection, helper, this); + else if (type == DisasterPreventionBaseExporter.class) + exporter = new DisasterPreventionBaseExporter(connection, helper, this); + else if (type == PollutionExporter.class) + exporter = new PollutionExporter(connection, helper, this); + else if (type == PublicTransportationFacilityExporter.class) + exporter = new PublicTransportationFacilityExporter(connection, helper, this); + else if (type == RecreationsExporter.class) + exporter = new RecreationsExporter(connection, helper, this); + else if (type == UrbanizationExporter.class) + exporter = new UrbanizationExporter(connection, helper, this); + else if (type == ZoneExporter.class) + exporter = new ZoneExporter(connection, helper, this); + else if (type == org.citydb.ade.iur.exporter.urf.CityObjectGroupPropertiesExporter.class) + exporter = new org.citydb.ade.iur.exporter.urf.CityObjectGroupPropertiesExporter(connection, helper, this); + } else if (StatisticalGridModuleExporter.class.isAssignableFrom(type)) { + // statistical grid module + if (type == StatisticalGridExporter.class) + exporter = new StatisticalGridExporter(connection, helper, this); + else if (type == GenericGridCellExporter.class) + exporter = new GenericGridCellExporter(connection, helper, this); + else if (type == HouseholdsExporter.class) + exporter = new HouseholdsExporter(connection, helper, this); + else if (type == LandPriceExporter.class) + exporter = new LandPriceExporter(connection, helper, this); + else if (type == LandUseDiversionExporter.class) + exporter = new LandUseDiversionExporter(connection, helper, this); + else if (type == OfficesAndEmployeesExporter.class) + exporter = new OfficesAndEmployeesExporter(connection, helper, this); + else if (type == PopulationExporter.class) + exporter = new PopulationExporter(connection, helper, this); + else if (type == PublicTransitAccessibilityExporter.class) + exporter = new PublicTransitAccessibilityExporter(connection, helper, this); + else if (type == org.citydb.ade.iur.exporter.urg.CityObjectGroupPropertiesExporter.class) + exporter = new org.citydb.ade.iur.exporter.urg.CityObjectGroupPropertiesExporter(connection, helper, this); + } else if (UrbanObjectModuleExporter.class.isAssignableFrom(type)) { + // urban object module + if (type == BuildingPropertiesExporter.class) + exporter = new BuildingPropertiesExporter(connection, helper, this); + else if (type == LandUsePropertiesExporter.class) + exporter = new LandUsePropertiesExporter(connection, helper, this); + else if (type == TransportationComplexPropertiesExporter.class) + exporter = new TransportationComplexPropertiesExporter(connection, helper, this); + else if (type == org.citydb.ade.iur.exporter.uro.CityObjectGroupPropertiesExporter.class) + exporter = new org.citydb.ade.iur.exporter.uro.CityObjectGroupPropertiesExporter(connection, helper, this); + } else if (PublicTransitModuleExporter.class.isAssignableFrom(type)) { + // public transit module + if (type == AgencyExporter.class) + exporter = new AgencyExporter(connection, helper, this); + else if (type == AttributionExporter.class) + exporter = new AttributionExporter(connection, helper, this); + else if (type == CalendarExporter.class) + exporter = new CalendarExporter(connection, helper, this); + else if (type == CalendarDateExporter.class) + exporter = new CalendarDateExporter(connection, helper, this); + else if (type == org.citydb.ade.iur.exporter.urt.CityObjectGroupPropertiesExporter.class) + exporter = new org.citydb.ade.iur.exporter.urt.CityObjectGroupPropertiesExporter(connection, helper, this); + else if (type == FareAttributeExporter.class) + exporter = new FareAttributeExporter(connection, helper, this); + else if (type == FareRuleExporter.class) + exporter = new FareRuleExporter(connection, helper, this); + else if (type == FeedInfoExporter.class) + exporter = new FeedInfoExporter(connection, helper, this); + else if (type == FrequencyExporter.class) + exporter = new FrequencyExporter(connection, helper, this); + else if (type == LevelExporter.class) + exporter = new LevelExporter(connection, helper, this); + else if (type == OfficeExporter.class) + exporter = new OfficeExporter(connection, helper, this); + else if (type == PathwayExporter.class) + exporter = new PathwayExporter(connection, helper, this); + else if (type == PublicTransitExporter.class) + exporter = new PublicTransitExporter(connection, helper, this); + else if (type == RouteExporter.class) + exporter = new RouteExporter(connection, helper, this); + else if (type == ShapeExporter.class) + exporter = new ShapeExporter(connection, helper, this); + else if (type == StopExporter.class) + exporter = new StopExporter(connection, helper, this); + else if (type == StopTimeExporter.class) + exporter = new StopTimeExporter(connection, helper, this); + else if (type == TransferExporter.class) + exporter = new TransferExporter(connection, helper, this); + else if (type == TranslationExporter.class) + exporter = new TranslationExporter(connection, helper, this); + else if (type == TranslationJPExporter.class) + exporter = new TranslationJPExporter(connection, helper, this); + else if (type == TripExporter.class) + exporter = new TripExporter(connection, helper, this); + } if (exporter == null) throw new SQLException("Failed to build ADE exporter of type " + type.getName() + "."); diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/CensusBlockExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/CensusBlockExporter.java index 6e0c120..741fb3b 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urf/CensusBlockExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/CensusBlockExporter.java @@ -22,12 +22,12 @@ package org.citydb.ade.iur.exporter.urf; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; @@ -38,18 +38,21 @@ import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citydb.sqlbuilder.select.operator.logical.LogicalOperationName; -import org.citygml4j.model.gml.basicTypes.Code; import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; import org.citygml4j.ade.iur.model.urf.CensusBlock; import org.citygml4j.ade.iur.model.urf.NumberOfHouseholds; import org.citygml4j.ade.iur.model.urf.NumberOfHouseholdsProperty; +import org.citygml4j.ade.iur.model.urf.TargetProperty; +import org.citygml4j.model.gml.basicTypes.Code; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.HashSet; +import java.util.Set; -public class CensusBlockExporter implements ADEExporter { +public class CensusBlockExporter implements UrbanFunctionModuleExporter { private final PreparedStatement ps; private final String module; private final UrbanFunctionExporter urbanFunctionExporter; @@ -57,26 +60,43 @@ public class CensusBlockExporter implements ADEExporter { public CensusBlockExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.CENSUSBLOCK); CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); - module = UrbanFunctionModule.v1_3.getNamespaceURI(); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); - Table table = new Table(helper.getTableNameWithSchema(tableName)); - Table households = new Table(manager.getSchemaMapper().getTableName(ADETable.NUMBEROFHOUSEHOLDS_1)); + urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); - Select select = new Select().addProjection(table.getColumns("daytimepopulation", "daytimepopulationdensity", - "numberofmainhouseholds", "numberofordinaryhouseholds")); + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table urbanFunction = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION))); + + Select select = new Select().addJoin(JoinFactory.inner(urbanFunction, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + urbanFunctionExporter.addProjection(select, urbanFunction, projectionFilter, "uf"); + if (projectionFilter.containsProperty("daytimePopulation", module)) + select.addProjection(table.getColumn("daytimepopulation")); + if (projectionFilter.containsProperty("daytimePopulationDensity", module)) + select.addProjection(table.getColumn("daytimepopulationdensity")); + if (projectionFilter.containsProperty("numberOfOrdinaryHouseholds", module)) + select.addProjection(table.getColumn("numberofordinaryhouseholds")); + if (projectionFilter.containsProperty("numberOfMainHouseholds", module)) + select.addProjection(table.getColumn("numberofmainhouseholds")); if (projectionFilter.containsProperty("numberOfHouseholdsByOwnership", module) || projectionFilter.containsProperty("numberOfHouseholdsByStructure", module)) { - select.addProjection(households.getColumns("censusblock_numberofhouse_id", "censusblock_numberofhou_id_1", + Table households = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.NUMBEROFHOUSEHOLDS_1))); + select.addProjection(households.getColumn("id", "hhid")) + .addProjection(households.getColumns("censusblock_numberofhouse_id", "censusblock_numberofhou_id_1", "class", "class_codespace", "number_")); Join join = JoinFactory.left(households, "censusblock_numberofhouse_id", ComparisonName.EQUAL_TO, table.getColumn("id")); join.addCondition(ComparisonFactory.equalTo(households.getColumn("censusblock_numberofhou_id_1"), table.getColumn("id"))); join.setConditionOperationName(LogicalOperationName.OR); select.addJoin(join); } - select.addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + if (projectionFilter.containsProperty("target", module)) { + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("id", "tid"), cityObject.getColumn("gmlid")) + .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); + } ps = connection.prepareStatement(select.toString()); - - urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); } public void doExport(CensusBlock censusBlock, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { @@ -84,10 +104,12 @@ public void doExport(CensusBlock censusBlock, long objectId, AbstractType obj try (ResultSet rs = ps.executeQuery()) { boolean isInitialized = false; + Set households = new HashSet<>(); + Set targets = new HashSet<>(); while (rs.next()) { if (!isInitialized) { - urbanFunctionExporter.doExport(censusBlock, objectId, objectType, projectionFilter); + urbanFunctionExporter.doExport(censusBlock, projectionFilter, "uf", rs); if (projectionFilter.containsProperty("daytimePopulation", module)) { int daytimePopulation = rs.getInt("daytimepopulation"); @@ -116,16 +138,28 @@ public void doExport(CensusBlock censusBlock, long objectId, AbstractType obj isInitialized = true; } - if (projectionFilter.containsProperty("numberOfHouseholdsByOwnership", module)) { - long numberId = rs.getLong("censusblock_numberofhouse_id"); - if (numberId != 0) - censusBlock.getNumberOfHouseholdsByOwnership().add(getNumberOfHouseholds(rs)); + long housholdId = rs.getLong("hhid"); + if (!rs.wasNull() && households.add(housholdId)) { + if (projectionFilter.containsProperty("numberOfHouseholdsByOwnership", module)) { + long numberId = rs.getLong("censusblock_numberofhouse_id"); + if (numberId != 0) + censusBlock.getNumberOfHouseholdsByOwnership().add(getNumberOfHouseholds(rs)); + } + + if (projectionFilter.containsProperty("numberOfHouseholdsByStruture", module)) { + long numberId = rs.getLong("censusblock_numberofhou_id_1"); + if (numberId != 0) + censusBlock.getNumberOfHouseholdsByStructure().add(getNumberOfHouseholds(rs)); + } } - if (projectionFilter.containsProperty("numberOfHouseholdsByStruture", module)) { - long numberId = rs.getLong("censusblock_numberofhou_id_1"); - if (numberId != 0) - censusBlock.getNumberOfHouseholdsByStructure().add(getNumberOfHouseholds(rs)); + if (projectionFilter.containsProperty("target", module)) { + long targetId = rs.getLong("tid"); + if (!rs.wasNull() && targets.add(targetId)) { + String gmlId = rs.getString("gmlid"); + if (gmlId != null) + censusBlock.getTargets().add(new TargetProperty("#" + gmlId)); + } } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/CityObjectGroupPropertiesExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/CityObjectGroupPropertiesExporter.java new file mode 100644 index 0000000..f3d860b --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/CityObjectGroupPropertiesExporter.java @@ -0,0 +1,92 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urf; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.FeatureType; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citygml4j.ade.iur.model.module.UrbanObjectModule; +import org.citygml4j.ade.iur.model.urf.FiscalYearOfPublicationProperty; +import org.citygml4j.ade.iur.model.urf.LanguageProperty; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.Year; + +public class CityObjectGroupPropertiesExporter implements UrbanFunctionModuleExporter { + private final PreparedStatement ps; + private final String module; + + public CityObjectGroupPropertiesExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.CITYOBJECTGROUP_2); + module = UrbanObjectModule.v1_4.getNamespaceURI(); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Select select = new Select().addProjection(table.getColumns("fiscalyearofpublication", "language", "language_codespace")) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(CityObjectGroup parent, long parentId, FeatureType parentType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, parentId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + if (projectionFilter.containsProperty("fiscalYearOfPublication", module)) { + Date fiscalYearOfPublication = rs.getDate("fiscalyearofpublication"); + if (!rs.wasNull()) { + FiscalYearOfPublicationProperty property = new FiscalYearOfPublicationProperty(Year.of(fiscalYearOfPublication.toLocalDate().getYear())); + parent.addGenericApplicationPropertyOfCityObjectGroup(property); + } + } + + if (projectionFilter.containsProperty("language", module)) { + String language = rs.getString("language"); + if (!rs.wasNull()) { + Code code = new Code(language); + code.setCodeSpace(rs.getString("language_codespace")); + LanguageProperty property = new LanguageProperty(code); + parent.addGenericApplicationPropertyOfCityObjectGroup(property); + } + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/DevelopmentProjectExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/DevelopmentProjectExporter.java index ac197cc..4f03645 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urf/DevelopmentProjectExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/DevelopmentProjectExporter.java @@ -22,21 +22,25 @@ package org.citydb.ade.iur.exporter.urf; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; -import org.citygml4j.model.gml.basicTypes.Code; -import org.citygml4j.model.gml.basicTypes.Measure; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; import org.citygml4j.ade.iur.model.urf.DevelopmentProject; +import org.citygml4j.ade.iur.model.urf.TargetProperty; +import org.citygml4j.model.gml.basicTypes.Code; +import org.citygml4j.model.gml.basicTypes.Measure; import java.sql.Connection; import java.sql.Date; @@ -44,106 +48,146 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class DevelopmentProjectExporter implements ADEExporter { +public class DevelopmentProjectExporter implements UrbanFunctionModuleExporter { private final PreparedStatement ps; private final String module; private final UrbanFunctionExporter urbanFunctionExporter; public DevelopmentProjectExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.DEVELOPMENTPROJECT); - module = UrbanFunctionModule.v1_3.getNamespaceURI(); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); + + urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("benefitarea", "benefitarea_uom", "benefitperiod", - "completedarea", "completedarea_uom", "cost", "dateofdecision", "dateofdesignationfortemporar", - "mainpurpose", "mainpurpose_codespace", "ongoingarea", "ongoingarea_uom", "plannedarea", "plannedarea_uom", - "status", "status_codespace")) + Table urbanFunction = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION))); + + Select select = new Select().addJoin(JoinFactory.inner(urbanFunction, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + urbanFunctionExporter.addProjection(select, urbanFunction, projectionFilter, "uf"); + if (projectionFilter.containsProperty("status", module)) + select.addProjection(table.getColumns("status", "status_codespace")); + if (projectionFilter.containsProperty("mainPurpose", module)) + select.addProjection(table.getColumns("mainpurpose", "mainpurpose_codespace")); + if (projectionFilter.containsProperty("benefitArea", module)) + select.addProjection(table.getColumns("benefitarea", "benefitarea_uom")); + if (projectionFilter.containsProperty("benefitPeriod", module)) + select.addProjection(table.getColumn("benefitperiod")); + if (projectionFilter.containsProperty("cost", module)) + select.addProjection(table.getColumn("cost")); + if (projectionFilter.containsProperty("plannedArea", module)) + select.addProjection(table.getColumns("plannedarea", "plannedarea_uom")); + if (projectionFilter.containsProperty("ongoingArea", module)) + select.addProjection(table.getColumns("ongoingarea", "ongoingarea_uom")); + if (projectionFilter.containsProperty("completedArea", module)) + select.addProjection(table.getColumns("completedarea", "completedarea_uom")); + if (projectionFilter.containsProperty("dateOfDecision", module)) + select.addProjection(table.getColumn("dateofdecision")); + if (projectionFilter.containsProperty("dateOfDesignationForTemporaryReplotting", module)) + select.addProjection(table.getColumn("dateofdesignationfortemporar")); + if (projectionFilter.containsProperty("target", module)) { + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid")) + .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); + } ps = connection.prepareStatement(select.toString()); - - urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); } public void doExport(DevelopmentProject developmentProject, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { ps.setLong(1, objectId); try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - urbanFunctionExporter.doExport(developmentProject, objectId, objectType, projectionFilter); - - if (projectionFilter.containsProperty("status", module)) { - String status = rs.getString("status"); - if (!rs.wasNull()) { - Code code = new Code(status); - code.setCodeSpace(rs.getString("status_codespace")); - developmentProject.setStatus(code); + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + urbanFunctionExporter.doExport(developmentProject, projectionFilter, "uf", rs); + + if (projectionFilter.containsProperty("status", module)) { + String status = rs.getString("status"); + if (!rs.wasNull()) { + Code code = new Code(status); + code.setCodeSpace(rs.getString("status_codespace")); + developmentProject.setStatus(code); + } } - } - if (projectionFilter.containsProperty("mainPurpose", module)) { - String status = rs.getString("mainpurpose"); - if (!rs.wasNull()) { - Code code = new Code(status); - code.setCodeSpace(rs.getString("mainpurpose_codespace")); - developmentProject.setStatus(code); + if (projectionFilter.containsProperty("mainPurpose", module)) { + String status = rs.getString("mainpurpose"); + if (!rs.wasNull()) { + Code code = new Code(status); + code.setCodeSpace(rs.getString("mainpurpose_codespace")); + developmentProject.setStatus(code); + } } - } - if (projectionFilter.containsProperty("benefitArea", module)) { - double benefitArea = rs.getDouble("benefitarea"); - if (!rs.wasNull()) { - Measure measure = new Measure(benefitArea); - measure.setUom(rs.getString("benefitarea_uom")); - developmentProject.setBenefitArea(measure); + if (projectionFilter.containsProperty("benefitArea", module)) { + double benefitArea = rs.getDouble("benefitarea"); + if (!rs.wasNull()) { + Measure measure = new Measure(benefitArea); + measure.setUom(rs.getString("benefitarea_uom")); + developmentProject.setBenefitArea(measure); + } } - } - if (projectionFilter.containsProperty("benefitPeriod", module)) - developmentProject.setBenefitPeriod(rs.getString("benefitperiod")); + if (projectionFilter.containsProperty("benefitPeriod", module)) + developmentProject.setBenefitPeriod(rs.getString("benefitperiod")); - if (projectionFilter.containsProperty("cost", module)) { - int cost = rs.getInt("cost"); - if (!rs.wasNull()) - developmentProject.setCost(cost); - } + if (projectionFilter.containsProperty("cost", module)) { + int cost = rs.getInt("cost"); + if (!rs.wasNull()) + developmentProject.setCost(cost); + } - if (projectionFilter.containsProperty("plannedArea", module)) { - double plannedArea = rs.getDouble("plannedarea"); - if (!rs.wasNull()) { - Measure measure = new Measure(plannedArea); - measure.setUom(rs.getString("plannedarea_uom")); - developmentProject.setPlannedArea(measure); + if (projectionFilter.containsProperty("plannedArea", module)) { + double plannedArea = rs.getDouble("plannedarea"); + if (!rs.wasNull()) { + Measure measure = new Measure(plannedArea); + measure.setUom(rs.getString("plannedarea_uom")); + developmentProject.setPlannedArea(measure); + } } - } - if (projectionFilter.containsProperty("ongoingArea", module)) { - double ongoingArea = rs.getDouble("ongoingarea"); - if (!rs.wasNull()) { - Measure measure = new Measure(ongoingArea); - measure.setUom(rs.getString("ongoingarea_uom")); - developmentProject.setOngoingArea(measure); + if (projectionFilter.containsProperty("ongoingArea", module)) { + double ongoingArea = rs.getDouble("ongoingarea"); + if (!rs.wasNull()) { + Measure measure = new Measure(ongoingArea); + measure.setUom(rs.getString("ongoingarea_uom")); + developmentProject.setOngoingArea(measure); + } } - } - if (projectionFilter.containsProperty("completedArea", module)) { - double completedArea = rs.getDouble("completedarea"); - if (!rs.wasNull()) { - Measure measure = new Measure(completedArea); - measure.setUom(rs.getString("completedarea_uom")); - developmentProject.setCompletedArea(measure); + if (projectionFilter.containsProperty("completedArea", module)) { + double completedArea = rs.getDouble("completedarea"); + if (!rs.wasNull()) { + Measure measure = new Measure(completedArea); + measure.setUom(rs.getString("completedarea_uom")); + developmentProject.setCompletedArea(measure); + } + } + + if (projectionFilter.containsProperty("dateOfDecision", module)) { + Date dateOfDecision = rs.getDate("dateofdecision"); + if (!rs.wasNull()) + developmentProject.setDateOfDecision(dateOfDecision.toLocalDate()); + } + + if (projectionFilter.containsProperty("dateOfDesignationForTemporaryReplotting", module)) { + Date dateOfDesignationForTemporaryReplotting = rs.getDate("dateofdesignationfortemporar"); + if (!rs.wasNull()) + developmentProject.setDateOfDesignationForTemporaryReplotting(dateOfDesignationForTemporaryReplotting.toLocalDate()); } - } - if (projectionFilter.containsProperty("dateOfDecision", module)) { - Date dateOfDecision = rs.getDate("dateofdecision"); - if (!rs.wasNull()) - developmentProject.setDateOfDecision(dateOfDecision.toLocalDate()); + isInitialized = true; } - if (projectionFilter.containsProperty("dateOfDesignationForTemporaryReplotting", module)) { - Date dateOfDesignationForTemporaryReplotting = rs.getDate("dateofdesignationfortemporar"); - if (!rs.wasNull()) - developmentProject.setDateOfDesignationForTemporaryReplotting(dateOfDesignationForTemporaryReplotting.toLocalDate()); + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString("gmlid"); + if (gmlId != null) + developmentProject.getTargets().add(new TargetProperty("#" + gmlId)); } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/DisasterDamageExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/DisasterDamageExporter.java index bd74413..490365a 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urf/DisasterDamageExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/DisasterDamageExporter.java @@ -22,88 +22,126 @@ package org.citydb.ade.iur.exporter.urf; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; -import org.citygml4j.model.gml.basicTypes.Measure; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; import org.citygml4j.ade.iur.model.urf.DisasterDamage; +import org.citygml4j.ade.iur.model.urf.TargetProperty; +import org.citygml4j.model.gml.basicTypes.Measure; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class DisasterDamageExporter implements ADEExporter { +public class DisasterDamageExporter implements UrbanFunctionModuleExporter { private final PreparedStatement ps; private final String module; private final UrbanFunctionExporter urbanFunctionExporter; public DisasterDamageExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.DISASTERDAMAGE); - module = UrbanFunctionModule.v1_3.getNamespaceURI(); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); + + urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("damagedarea", "damagedarea_uom", "maximumrainfallperhour", - "numberofdamagedhouses", "numberofhousesfloodedabovefl", "numberofhousesfloodedbelowfl", "totalrainfall")) + Table urbanFunction = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION))); + + Select select = new Select().addJoin(JoinFactory.inner(urbanFunction, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + urbanFunctionExporter.addProjection(select, urbanFunction, projectionFilter, "uf"); + if (projectionFilter.containsProperty("damagedArea", module)) + select.addProjection(table.getColumns("damagedarea", "damagedarea_uom")); + if (projectionFilter.containsProperty("numberOfDamagedHouses", module)) + select.addProjection(table.getColumn("numberofdamagedhouses")); + if (projectionFilter.containsProperty("numberOfHousesFloodedAboveFloorLevel", module)) + select.addProjection(table.getColumn("numberofhousesfloodedabovefl")); + if (projectionFilter.containsProperty("numberOfHousesFloodedBelowFloorLevel", module)) + select.addProjection(table.getColumn("numberofhousesfloodedbelowfl")); + if (projectionFilter.containsProperty("maximumRainfallPerHour", module)) + select.addProjection(table.getColumn("maximumrainfallperhour")); + if (projectionFilter.containsProperty("totalRainfall", module)) + select.addProjection(table.getColumn("totalrainfall")); + if (projectionFilter.containsProperty("target", module)) { + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid")) + .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); + } ps = connection.prepareStatement(select.toString()); - - urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); } public void doExport(DisasterDamage disasterDamage, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { ps.setLong(1, objectId); try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - urbanFunctionExporter.doExport(disasterDamage, objectId, objectType, projectionFilter); - - if (projectionFilter.containsProperty("damagedArea", module)) { - double damagedArea = rs.getDouble("damagedarea"); - if (!rs.wasNull()) { - Measure measure = new Measure(damagedArea); - measure.setUom(rs.getString("damagedarea_uom")); - disasterDamage.setDamagedArea(measure); + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + urbanFunctionExporter.doExport(disasterDamage, projectionFilter, "uf", rs); + + if (projectionFilter.containsProperty("damagedArea", module)) { + double damagedArea = rs.getDouble("damagedarea"); + if (!rs.wasNull()) { + Measure measure = new Measure(damagedArea); + measure.setUom(rs.getString("damagedarea_uom")); + disasterDamage.setDamagedArea(measure); + } } - } - if (projectionFilter.containsProperty("numberOfDamagedHouses", module)) { - int numberOfDamagedHouses = rs.getInt("numberofdamagedhouses"); - if (!rs.wasNull()) - disasterDamage.setNumberOfDamagedHouses(numberOfDamagedHouses); - } + if (projectionFilter.containsProperty("numberOfDamagedHouses", module)) { + int numberOfDamagedHouses = rs.getInt("numberofdamagedhouses"); + if (!rs.wasNull()) + disasterDamage.setNumberOfDamagedHouses(numberOfDamagedHouses); + } - if (projectionFilter.containsProperty("numberOfHousesFloodedAboveFloorLevel", module)) { - int numberOfHousesFloodedAboveFloorLevel = rs.getInt("numberofhousesfloodedabovefl"); - if (!rs.wasNull()) - disasterDamage.setNumberOfHousesFloodedAboveFloorLevel(numberOfHousesFloodedAboveFloorLevel); - } + if (projectionFilter.containsProperty("numberOfHousesFloodedAboveFloorLevel", module)) { + int numberOfHousesFloodedAboveFloorLevel = rs.getInt("numberofhousesfloodedabovefl"); + if (!rs.wasNull()) + disasterDamage.setNumberOfHousesFloodedAboveFloorLevel(numberOfHousesFloodedAboveFloorLevel); + } - if (projectionFilter.containsProperty("numberOfHousesFloodedBelowFloorLevel", module)) { - int numberOfHousesFloodedBelowFloorLevel = rs.getInt("numberofhousesfloodedbelowfl"); - if (!rs.wasNull()) - disasterDamage.setNumberOfHousesFloodedBelowFloorLevel(numberOfHousesFloodedBelowFloorLevel); - } + if (projectionFilter.containsProperty("numberOfHousesFloodedBelowFloorLevel", module)) { + int numberOfHousesFloodedBelowFloorLevel = rs.getInt("numberofhousesfloodedbelowfl"); + if (!rs.wasNull()) + disasterDamage.setNumberOfHousesFloodedBelowFloorLevel(numberOfHousesFloodedBelowFloorLevel); + } + + if (projectionFilter.containsProperty("maximumRainfallPerHour", module)) { + int maximumRainfallPerHour = rs.getInt("maximumrainfallperhour"); + if (!rs.wasNull()) + disasterDamage.setMaximumRainfallPerHour(maximumRainfallPerHour); + } + + if (projectionFilter.containsProperty("totalRainfall", module)) { + int totalRainfall = rs.getInt("totalrainfall"); + if (!rs.wasNull()) + disasterDamage.setTotalRainfall(totalRainfall); + } - if (projectionFilter.containsProperty("maximumRainfallPerHour", module)) { - int maximumRainfallPerHour = rs.getInt("maximumrainfallperhour"); - if (!rs.wasNull()) - disasterDamage.setMaximumRainfallPerHour(maximumRainfallPerHour); + isInitialized = true; } - if (projectionFilter.containsProperty("totalRainfall", module)) { - int totalRainfall = rs.getInt("totalrainfall"); - if (!rs.wasNull()) - disasterDamage.setTotalRainfall(totalRainfall); + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString("gmlid"); + if (gmlId != null) + disasterDamage.getTargets().add(new TargetProperty("#" + gmlId)); } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/DisasterPreventionBaseExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/DisasterPreventionBaseExporter.java new file mode 100644 index 0000000..3f6792b --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/DisasterPreventionBaseExporter.java @@ -0,0 +1,106 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urf; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; +import org.citygml4j.ade.iur.model.urf.DisasterPreventionBase; +import org.citygml4j.ade.iur.model.urf.TargetProperty; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class DisasterPreventionBaseExporter implements UrbanFunctionModuleExporter { + private final PreparedStatement ps; + private final String module; + private final UrbanFunctionExporter urbanFunctionExporter; + + public DisasterPreventionBaseExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); + + urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Select select = urbanFunctionExporter.addProjection(new Select(), table, projectionFilter, "uf") + .addProjection(table.getColumn("capacity")) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + if (projectionFilter.containsProperty("target", module)) { + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid")) + .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(DisasterPreventionBase disasterPreventionBase, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + urbanFunctionExporter.doExport(disasterPreventionBase, projectionFilter, "uf", rs); + + if (projectionFilter.containsProperty("capacity", module)) { + int capacity = rs.getInt("capacity"); + if (!rs.wasNull()) + disasterPreventionBase.setCapacity(capacity); + } + + isInitialized = true; + } + + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString("gmlid"); + if (gmlId != null) + disasterPreventionBase.getTargets().add(new TargetProperty("#" + gmlId)); + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/PollutionExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/PollutionExporter.java index cab73d4..d86bf70 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urf/PollutionExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/PollutionExporter.java @@ -22,60 +22,91 @@ package org.citydb.ade.iur.exporter.urf; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; -import org.citygml4j.model.gml.basicTypes.Measure; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; import org.citygml4j.ade.iur.model.urf.Pollution; +import org.citygml4j.ade.iur.model.urf.TargetProperty; +import org.citygml4j.model.gml.basicTypes.Measure; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class PollutionExporter implements ADEExporter { +public class PollutionExporter implements UrbanFunctionModuleExporter { private final PreparedStatement ps; private final String module; private final UrbanFunctionExporter urbanFunctionExporter; public PollutionExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.POLLUTION); - module = UrbanFunctionModule.v1_3.getNamespaceURI(); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); + + urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("cause", "damagedarea", "damagedarea_uom")) + Table urbanFunction = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION))); + + Select select = new Select().addJoin(JoinFactory.inner(urbanFunction, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + urbanFunctionExporter.addProjection(select, urbanFunction, projectionFilter, "uf"); + if (projectionFilter.containsProperty("cause", module)) + select.addProjection(table.getColumn("cause")); + if (projectionFilter.containsProperty("damagedArea", module)) + select.addProjection(table.getColumns("damagedarea", "damagedarea_uom")); + if (projectionFilter.containsProperty("target", module)) { + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid")) + .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); + } ps = connection.prepareStatement(select.toString()); - - urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); } public void doExport(Pollution pollution, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { ps.setLong(1, objectId); try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - urbanFunctionExporter.doExport(pollution, objectId, objectType, projectionFilter); - - if (projectionFilter.containsProperty("cause", module)) - pollution.setCause(rs.getString("cause")); - - if (projectionFilter.containsProperty("damagedArea", module)) { - double damagedArea = rs.getInt("damagedarea"); - if (!rs.wasNull()) { - Measure measure = new Measure(damagedArea); - measure.setUom(rs.getString("damagedarea_uom")); - pollution.setDamagedArea(measure); + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + urbanFunctionExporter.doExport(pollution, projectionFilter, "uf", rs); + + if (projectionFilter.containsProperty("cause", module)) + pollution.setCause(rs.getString("cause")); + + if (projectionFilter.containsProperty("damagedArea", module)) { + double damagedArea = rs.getInt("damagedarea"); + if (!rs.wasNull()) { + Measure measure = new Measure(damagedArea); + measure.setUom(rs.getString("damagedarea_uom")); + pollution.setDamagedArea(measure); + } } + + isInitialized = true; + } + + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString("gmlid"); + if (gmlId != null) + pollution.getTargets().add(new TargetProperty("#" + gmlId)); } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/PublicTransportationFacilityExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/PublicTransportationFacilityExporter.java new file mode 100644 index 0000000..a30f135 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/PublicTransportationFacilityExporter.java @@ -0,0 +1,133 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urf; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; +import org.citygml4j.ade.iur.model.urf.PublicTransportationFacility; +import org.citygml4j.ade.iur.model.urf.TargetProperty; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class PublicTransportationFacilityExporter implements UrbanFunctionModuleExporter { + private final PreparedStatement ps; + private final String module; + private final UrbanFunctionExporter urbanFunctionExporter; + + public PublicTransportationFacilityExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSPORTATIONFA); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); + + urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table urbanFunction = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION))); + + Select select = new Select().addJoin(JoinFactory.inner(urbanFunction, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + urbanFunctionExporter.addProjection(select, urbanFunction, projectionFilter, "uf"); + if (projectionFilter.containsProperty("routeName", module)) + select.addProjection(table.getColumn("routename")); + if (projectionFilter.containsProperty("sectionName", module)) + select.addProjection(table.getColumn("sectionname")); + if (projectionFilter.containsProperty("companyName", module)) + select.addProjection(table.getColumn("companyname")); + if (projectionFilter.containsProperty("frequencyOfService", module)) + select.addProjection(table.getColumn("frequencyofservice")); + if (projectionFilter.containsProperty("numberOfCustomers", module)) + select.addProjection(table.getColumn("numberofcustomers")); + if (projectionFilter.containsProperty("target", module)) { + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid")) + .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(PublicTransportationFacility publicTransit, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + urbanFunctionExporter.doExport(publicTransit, projectionFilter, "uf", rs); + + if (projectionFilter.containsProperty("routeName", module)) + publicTransit.setRouteName(rs.getString("routename")); + + if (projectionFilter.containsProperty("sectionName", module)) + publicTransit.setSectionName(rs.getString("sectionname")); + + if (projectionFilter.containsProperty("companyName", module)) + publicTransit.setCompanyName(rs.getString("companyname")); + + if (projectionFilter.containsProperty("frequencyOfService", module)) { + int frequencyOfService = rs.getInt("frequencyofservice"); + if (!rs.wasNull()) + publicTransit.setFrequencyOfService(frequencyOfService); + } + + if (projectionFilter.containsProperty("numberOfCustomers", module)) { + double numberOfCustomers = rs.getDouble("numberofcustomers"); + if (!rs.wasNull()) + publicTransit.setNumberOfCustomers(numberOfCustomers); + } + + isInitialized = true; + } + + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString("gmlid"); + if (gmlId != null) + publicTransit.getTargets().add(new TargetProperty("#" + gmlId)); + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/RecreationsExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/RecreationsExporter.java index ed5549a..f7a386c 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urf/RecreationsExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/RecreationsExporter.java @@ -22,59 +22,90 @@ package org.citydb.ade.iur.exporter.urf; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; import org.citygml4j.ade.iur.model.urf.Recreations; +import org.citygml4j.ade.iur.model.urf.TargetProperty; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class RecreationsExporter implements ADEExporter { +public class RecreationsExporter implements UrbanFunctionModuleExporter { private final PreparedStatement ps; private final String module; private final UrbanFunctionExporter urbanFunctionExporter; public RecreationsExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.RECREATIONS); - module = UrbanFunctionModule.v1_3.getNamespaceURI(); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); + + urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("capacity", "numberofusers")) + Table urbanFunction = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION))); + + Select select = new Select().addJoin(JoinFactory.inner(urbanFunction, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + urbanFunctionExporter.addProjection(select, urbanFunction, projectionFilter, "uf"); + if (projectionFilter.containsProperty("capacity", module)) + select.addProjection(table.getColumn("capacity")); + if (projectionFilter.containsProperty("numberOfUsers", module)) + select.addProjection(table.getColumn("numberofusers")); + if (projectionFilter.containsProperty("target", module)) { + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid")) + .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); + } ps = connection.prepareStatement(select.toString()); - - urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); } public void doExport(Recreations recreations, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { ps.setLong(1, objectId); try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - urbanFunctionExporter.doExport(recreations, objectId, objectType, projectionFilter); + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + urbanFunctionExporter.doExport(recreations, projectionFilter, "uf", rs); + + if (projectionFilter.containsProperty("capacity", module)) { + int capacity = rs.getInt("capacity"); + if (!rs.wasNull()) + recreations.setCapacity(capacity); + } + + if (projectionFilter.containsProperty("numberOfUsers", module)) { + int numberOfUsers = rs.getInt("numberofusers"); + if (!rs.wasNull()) + recreations.setNumberOfUsers(numberOfUsers); + } - if (projectionFilter.containsProperty("capacity", module)) { - int capacity = rs.getInt("capacity"); - if (!rs.wasNull()) - recreations.setCapacity(capacity); + isInitialized = true; } - if (projectionFilter.containsProperty("numberOfUsers", module)) { - int numberOfUsers = rs.getInt("numberofusers"); - if (!rs.wasNull()) - recreations.setNumberOfUsers(numberOfUsers); + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString("gmlid"); + if (gmlId != null) + recreations.getTargets().add(new TargetProperty("#" + gmlId)); } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanFunctionExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanFunctionExporter.java index 37d4ec5..fb5cef2 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanFunctionExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanFunctionExporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.exporter.urf; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.citygml.exporter.database.content.GMLConverter; -import org.citydb.citygml.exporter.database.content.SurfaceGeometry; +import org.citydb.citygml.exporter.database.content.SurfaceGeometryExporter; import org.citydb.citygml.exporter.util.AttributeValueSplitter; import org.citydb.config.geometry.GeometryObject; import org.citydb.database.schema.mapping.AbstractType; @@ -41,30 +40,23 @@ import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; -import org.citygml4j.model.gml.GMLClass; -import org.citygml4j.model.gml.basicTypes.Code; -import org.citygml4j.model.gml.basicTypes.Measure; -import org.citygml4j.model.gml.geometry.aggregates.MultiCurveProperty; -import org.citygml4j.model.gml.geometry.aggregates.MultiPointProperty; -import org.citygml4j.model.gml.geometry.aggregates.MultiSurface; -import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty; import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; -import org.citygml4j.ade.iur.model.urf.DisasterPreventionBase; import org.citygml4j.ade.iur.model.urf.LegalGrounds; import org.citygml4j.ade.iur.model.urf.LegalGroundsProperty; import org.citygml4j.ade.iur.model.urf.TargetProperty; import org.citygml4j.ade.iur.model.urf.UrbanFunction; -import org.citygml4j.ade.iur.model.urf.Zone; +import org.citygml4j.model.gml.basicTypes.Code; +import org.citygml4j.model.gml.basicTypes.Measure; +import org.citygml4j.model.gml.geometry.aggregates.MultiCurveProperty; +import org.citygml4j.model.gml.geometry.aggregates.MultiPointProperty; -import java.sql.Connection; -import java.sql.Date; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.time.Year; -public class UrbanFunctionExporter implements ADEExporter { +public class UrbanFunctionExporter implements UrbanFunctionModuleExporter { private final CityGMLExportHelper helper; + private final ExportManager manager; + private final SurfaceGeometryExporter surfaceGeometryExporter; private final PreparedStatement ps; private final String module; @@ -73,46 +65,99 @@ public class UrbanFunctionExporter implements ADEExporter { public UrbanFunctionExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { this.helper = helper; + this.manager = manager; String tableName = manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION); CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); - module = UrbanFunctionModule.v1_3.getNamespaceURI(); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Table zone = new Table(manager.getSchemaMapper().getTableName(ADETable.ZONE)); - Table legalGrounds = new Table(manager.getSchemaMapper().getTableName(ADETable.LEGALGROUNDS)); - Table targets = new Table(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC)); - Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); - - Select select = new Select().addProjection(table.getColumns("legalgrounds_id", "abstract", "area_id", - "areaclassificationtype", "areaclassification_codespace", "city", "city_codespace", "class", - "class_codespace", "custodian", "enactmentdate", "enactmentfiscalyear", "expirationdate", - "expirationfiscalyear", "function", "function_codespace", "nominalarea", "nominalarea_uom", "note", - "prefecture", "prefecture_codespace", "reference", "surveyyear", "urbanplantype", "urbanplantype_codespace", - "validity", "capacity")) - .addProjection(zone.getColumns("areaapplied", "finalpublicationdate")) - .addJoin(JoinFactory.left(zone, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))); - if (projectionFilter.containsProperty("boundary", module)) - select.addProjection(helper.getGeometryColumn(table.getColumn("boundary"))); - if (projectionFilter.containsProperty("location", module)) - select.addProjection(helper.getGeometryColumn(table.getColumn("location"))); - if (projectionFilter.containsProperty("legalGrounds", module)) { - select.addProjection(legalGrounds.getColumns("articlesofregulation", "articlesofregulati_codespace", "date_", - "nameofregulation", "nameofregulation_codespace")) - .addJoin(JoinFactory.left(legalGrounds, "id", ComparisonName.EQUAL_TO, table.getColumn("legalgrounds_id"))); - } + Select select = addProjection(new Select(), table, projectionFilter, "") + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); if (projectionFilter.containsProperty("target", module)) { - select.addProjection(cityObject.getColumn(MappingConstants.GMLID)) + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("id", "tid"), cityObject.getColumn("gmlid")) .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); } - select.addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); ps = connection.prepareStatement(select.toString()); + surfaceGeometryExporter = helper.getSurfaceGeometryExporter(); gmlConverter = helper.getGMLConverter(); valueSplitter = helper.getAttributeValueSplitter(); } + public Select addProjection(Select select, Table table, CombinedProjectionFilter projectionFilter, String prefix) { + select.addProjection(table.getColumn("id", prefix + "id")); + if (projectionFilter.containsProperty("class", module)) + select.addProjection(table.getColumn("class", prefix + "class"), table.getColumn("class_codespace", prefix + "class_codespace")); + if (projectionFilter.containsProperty("function", module)) + select.addProjection(table.getColumn("function", prefix + "function"), table.getColumn("function_codespace", prefix + "function_codespace")); + if (projectionFilter.containsProperty("enactmentDate", module)) + select.addProjection(table.getColumn("enactmentdate", prefix + "enactmentdate")); + if (projectionFilter.containsProperty("expirationFiscalYear", module)) + select.addProjection(table.getColumn("enactmentfiscalyear", prefix + "enactmentfiscalyear")); + if (projectionFilter.containsProperty("expirationDate", module)) + select.addProjection(table.getColumn("expirationdate", prefix + "expirationdate")); + if (projectionFilter.containsProperty("expirationFiscalYear", module)) + select.addProjection(table.getColumn("expirationfiscalyear", prefix + "expirationfiscalyear")); + if (projectionFilter.containsProperty("custodian", module)) + select.addProjection(table.getColumn("custodian", prefix + "custodian")); + if (projectionFilter.containsProperty("nominalArea", module)) + select.addProjection(table.getColumn("nominalarea", prefix + "nominalarea"), table.getColumn("nominalarea_uom", prefix + "nominalarea_uom")); + if (projectionFilter.containsProperty("abstract", module)) + select.addProjection(table.getColumn("abstract", prefix + "abstract")); + if (projectionFilter.containsProperty("validity", module)) + select.addProjection(table.getColumn("validity", prefix + "validity")); + if (projectionFilter.containsProperty("urbanPlanType", module)) + select.addProjection(table.getColumn("urbanplantype", prefix + "urbanplantype"), table.getColumn("urbanplantype_codespace", prefix + "urbanplantype_codespace")); + if (projectionFilter.containsProperty("areaClassificationType", module)) + select.addProjection(table.getColumn("areaclassificationtype", prefix + "areaclassificationtype"), table.getColumn("areaclassification_codespace", prefix + "areaclassification_codespace")); + if (projectionFilter.containsProperty("prefecture", module)) + select.addProjection(table.getColumn("prefecture", prefix + "prefecture"), table.getColumn("prefecture_codespace", prefix + "prefecture_codespace")); + if (projectionFilter.containsProperty("city", module)) + select.addProjection(table.getColumn("city", prefix + "city"), table.getColumn("city_codespace", prefix + "city_codespace")); + if (projectionFilter.containsProperty("reference", module)) + select.addProjection(table.getColumn("reference", prefix + "reference")); + if (projectionFilter.containsProperty("note", module)) + select.addProjection(table.getColumn("note", prefix + "note")); + if (projectionFilter.containsProperty("surveyYear", module)) + select.addProjection(table.getColumn("surveyyear", prefix + "surveyyear")); + if (helper.getLodFilter().isEnabled(0)) { + if (projectionFilter.containsProperty("lod0MultiPoint", module)) + select.addProjection(helper.getGeometryColumn(table.getColumn("lod0multipoint"), prefix + "lod0multipoint")); + if (projectionFilter.containsProperty("lod0MultiCurve", module)) + select.addProjection(helper.getGeometryColumn(table.getColumn("lod0multicurve"), prefix + "lod0multicurve")); + if (projectionFilter.containsProperty("lod0MultiSurface", module)) + select.addProjection(table.getColumn("lod0multisurface_id", prefix + "lod0multisurface_id")); + } + if (projectionFilter.containsProperty("lod-1MultiPoint", module)) + select.addProjection(helper.getGeometryColumn(table.getColumn("lod_1multipoint"), prefix + "lod_1multipoint")); + if (projectionFilter.containsProperty("lod-2MultiPoint", module)) + select.addProjection(helper.getGeometryColumn(table.getColumn("lod_2multipoint"), prefix + "lod_2multipoint")); + if (projectionFilter.containsProperty("lod-1MultiCurve", module)) + select.addProjection(helper.getGeometryColumn(table.getColumn("lod_1multicurve"), prefix + "lod_1multicurve")); + if (projectionFilter.containsProperty("lod-2MultiCurve", module)) + select.addProjection(helper.getGeometryColumn(table.getColumn("lod_2multicurve"), prefix + "lod_2multicurve")); + if (projectionFilter.containsProperty("lod-1MultiSurface", module)) + select.addProjection(table.getColumn("lod_1multisurface_id", prefix + "lod_1multisurface_id")); + if (projectionFilter.containsProperty("lod-2MultiSurface", module)) + select.addProjection(table.getColumn("lod_2multisurface_id", prefix + "lod_2multisurface_id")); + if (projectionFilter.containsProperty("legalGrounds", module)) { + Table legalGrounds = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.LEGALGROUNDS))); + select.addProjection(table.getColumn("legalgrounds_id", prefix + "legalgrounds_id"), + legalGrounds.getColumn("articlesofregulation", prefix + "articlesofregulation"), + legalGrounds.getColumn("articlesofregulati_codespace", prefix + "articlesofregulati_codespace"), + legalGrounds.getColumn("date_", prefix + "date_"), + legalGrounds.getColumn("nameofregulation", prefix + "nameofregulation"), + legalGrounds.getColumn("nameofregulation_codespace", prefix + "nameofregulation_codespace")) + .addJoin(JoinFactory.left(legalGrounds, "id", ComparisonName.EQUAL_TO, table.getColumn("legalgrounds_id"))); + } + + return select; + } + public void doExport(UrbanFunction urbanFunction, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { ps.setLong(1, objectId); @@ -121,211 +166,237 @@ public void doExport(UrbanFunction urbanFunction, long objectId, AbstractType while (rs.next()) { if (!isInitialized) { - if (projectionFilter.containsProperty("class", module)) { - String classifier = rs.getString("class"); - if (!rs.wasNull()) { - Code code = new Code(classifier); - code.setCodeSpace(rs.getString("class_codespace")); - urbanFunction.setClassifier(code); - } - } + doExport(urbanFunction, projectionFilter, "", rs); + isInitialized = true; + } - if (projectionFilter.containsProperty("function", module)) { - for (AttributeValueSplitter.SplitValue splitValue : valueSplitter.split(rs.getString("function"), rs.getString("function_codespace"))) { - Code function = new Code(splitValue.result(0)); - function.setCodeSpace(splitValue.result(1)); - urbanFunction.getFunctions().add(function); - } - } + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString(MappingConstants.GMLID); + if (gmlId != null) + urbanFunction.getTargets().add(new TargetProperty("#" + gmlId)); + } + } + } + } - if (projectionFilter.containsProperty("enactmentDate", module)) { - Date enactmentDate = rs.getDate("enactmentdate"); - if (!rs.wasNull()) - urbanFunction.setEnactmentDate(enactmentDate.toLocalDate()); - } + public void doExport(UrbanFunction urbanFunction, ProjectionFilter projectionFilter, String prefix, ResultSet rs) throws CityGMLExportException, SQLException { + if (projectionFilter.containsProperty("class", module)) { + String classifier = rs.getString(prefix + "class"); + if (!rs.wasNull()) { + Code code = new Code(classifier); + code.setCodeSpace(rs.getString(prefix + "class_codespace")); + urbanFunction.setClassifier(code); + } + } - if (projectionFilter.containsProperty("enactmentFiscalYear", module)) { - Date enactmentFiscalYear = rs.getDate("enactmentfiscalyear"); - if (!rs.wasNull()) - urbanFunction.setEnactmentFiscalYear(Year.of(enactmentFiscalYear.toLocalDate().getYear())); - } + if (projectionFilter.containsProperty("function", module)) { + for (AttributeValueSplitter.SplitValue splitValue : valueSplitter.split(rs.getString(prefix + "function"), rs.getString(prefix + "function_codespace"))) { + Code function = new Code(splitValue.result(0)); + function.setCodeSpace(splitValue.result(1)); + urbanFunction.getFunctions().add(function); + } + } - if (projectionFilter.containsProperty("expirationDate", module)) { - Date expirationDate = rs.getDate("expirationdate"); - if (!rs.wasNull()) - urbanFunction.setExpirationDate(expirationDate.toLocalDate()); - } + if (projectionFilter.containsProperty("enactmentDate", module)) { + Date enactmentDate = rs.getDate(prefix + "enactmentdate"); + if (!rs.wasNull()) + urbanFunction.setEnactmentDate(enactmentDate.toLocalDate()); + } - if (projectionFilter.containsProperty("expirationFiscalYear", module)) { - Date expirationFiscalYear = rs.getDate("expirationfiscalyear"); - if (!rs.wasNull()) - urbanFunction.setExpirationFiscalYear(Year.of(expirationFiscalYear.toLocalDate().getYear())); - } + if (projectionFilter.containsProperty("enactmentFiscalYear", module)) { + Date enactmentFiscalYear = rs.getDate(prefix + "enactmentfiscalyear"); + if (!rs.wasNull()) + urbanFunction.setEnactmentFiscalYear(Year.of(enactmentFiscalYear.toLocalDate().getYear())); + } - if (projectionFilter.containsProperty("custodian", module)) - urbanFunction.setCustodian(rs.getString("custodian")); + if (projectionFilter.containsProperty("expirationDate", module)) { + Date expirationDate = rs.getDate(prefix + "expirationdate"); + if (!rs.wasNull()) + urbanFunction.setExpirationDate(expirationDate.toLocalDate()); + } - if (projectionFilter.containsProperty("nominalArea", module)) { - double nominalArea = rs.getDouble("nominalarea"); - if (!rs.wasNull()) { - Measure measure = new Measure(nominalArea); - measure.setUom(rs.getString("nominalarea_uom")); - urbanFunction.setNominalArea(measure); - } - } + if (projectionFilter.containsProperty("expirationFiscalYear", module)) { + Date expirationFiscalYear = rs.getDate(prefix + "expirationfiscalyear"); + if (!rs.wasNull()) + urbanFunction.setExpirationFiscalYear(Year.of(expirationFiscalYear.toLocalDate().getYear())); + } - if (projectionFilter.containsProperty("abstract", module)) - urbanFunction.setAbstract(rs.getString("abstract")); + if (projectionFilter.containsProperty("custodian", module)) + urbanFunction.setCustodian(rs.getString(prefix + "custodian")); - if (projectionFilter.containsProperty("validity", module)) { - boolean validity = rs.getBoolean("validity"); - if (!rs.wasNull()) - urbanFunction.setValidity(validity); - } + if (projectionFilter.containsProperty("nominalArea", module)) { + double nominalArea = rs.getDouble(prefix + "nominalarea"); + if (!rs.wasNull()) { + Measure measure = new Measure(nominalArea); + measure.setUom(rs.getString(prefix + "nominalarea_uom")); + urbanFunction.setNominalArea(measure); + } + } - if (projectionFilter.containsProperty("urbanPlanType", module)) { - String urbanPlanType = rs.getString("urbanplantype"); - if (!rs.wasNull()) { - Code code = new Code(urbanPlanType); - code.setCodeSpace(rs.getString("urbanplantype_codespace")); - urbanFunction.setUrbanPlanType(code); - } - } + if (projectionFilter.containsProperty("abstract", module)) + urbanFunction.setAbstract(rs.getString(prefix + "abstract")); - if (projectionFilter.containsProperty("areaClassificationType", module)) { - String areaClassificationType = rs.getString("areaclassificationtype"); - if (!rs.wasNull()) { - Code code = new Code(areaClassificationType); - code.setCodeSpace(rs.getString("areaclassification_codespace")); - urbanFunction.setAreaClassificationType(code); - } - } + if (projectionFilter.containsProperty("validity", module)) { + boolean validity = rs.getBoolean(prefix + "validity"); + if (!rs.wasNull()) + urbanFunction.setValidity(validity); + } - if (projectionFilter.containsProperty("prefecture", module)) { - String prefecture = rs.getString("prefecture"); - if (!rs.wasNull()) { - Code code = new Code(prefecture); - code.setCodeSpace(rs.getString("prefecture_codespace")); - urbanFunction.setPrefecture(code); - } - } + if (projectionFilter.containsProperty("urbanPlanType", module)) { + String urbanPlanType = rs.getString(prefix + "urbanplantype"); + if (!rs.wasNull()) { + Code code = new Code(urbanPlanType); + code.setCodeSpace(rs.getString(prefix + "urbanplantype_codespace")); + urbanFunction.setUrbanPlanType(code); + } + } - if (projectionFilter.containsProperty("city", module)) { - String city = rs.getString("city"); - if (!rs.wasNull()) { - Code code = new Code(city); - code.setCodeSpace(rs.getString("city_codespace")); - urbanFunction.setCity(code); - } - } + if (projectionFilter.containsProperty("areaClassificationType", module)) { + String areaClassificationType = rs.getString(prefix + "areaclassificationtype"); + if (!rs.wasNull()) { + Code code = new Code(areaClassificationType); + code.setCodeSpace(rs.getString(prefix + "areaclassification_codespace")); + urbanFunction.setAreaClassificationType(code); + } + } - if (projectionFilter.containsProperty("reference", module)) - urbanFunction.setReference(rs.getString("reference")); + if (projectionFilter.containsProperty("prefecture", module)) { + String prefecture = rs.getString(prefix + "prefecture"); + if (!rs.wasNull()) { + Code code = new Code(prefecture); + code.setCodeSpace(rs.getString(prefix + "prefecture_codespace")); + urbanFunction.setPrefecture(code); + } + } - if (projectionFilter.containsProperty("note", module)) - urbanFunction.setNote(rs.getString("note")); + if (projectionFilter.containsProperty("city", module)) { + String city = rs.getString(prefix + "city"); + if (!rs.wasNull()) { + Code code = new Code(city); + code.setCodeSpace(rs.getString(prefix + "city_codespace")); + urbanFunction.setCity(code); + } + } - if (projectionFilter.containsProperty("surveyYear", module)) { - Date surveyYear = rs.getDate("surveyyear"); - if (!rs.wasNull()) - urbanFunction.setSurveyYear(Year.of(surveyYear.toLocalDate().getYear())); - } + if (projectionFilter.containsProperty("reference", module)) + urbanFunction.setReference(rs.getString(prefix + "reference")); - if (projectionFilter.containsProperty("area", module)) { - long areaId = rs.getLong("area_id"); - if (!rs.wasNull()) { - SurfaceGeometry geometry = helper.exportSurfaceGeometry(areaId); - if (geometry != null && geometry.getType() == GMLClass.MULTI_SURFACE) { - MultiSurfaceProperty multiSurfaceProperty = new MultiSurfaceProperty(); - if (geometry.isSetGeometry()) - multiSurfaceProperty.setMultiSurface((MultiSurface) geometry.getGeometry()); - else - multiSurfaceProperty.setHref(geometry.getReference()); - - urbanFunction.setArea(multiSurfaceProperty); - } - } - } + if (projectionFilter.containsProperty("note", module)) + urbanFunction.setNote(rs.getString(prefix + "note")); - if (projectionFilter.containsProperty("boundary", module)) { - Object object = rs.getObject("boundary"); - if (object != null) { - GeometryObject multiCurve = helper.getDatabaseAdapter().getGeometryConverter().getMultiCurve(object); - if (multiCurve != null) { - MultiCurveProperty property = gmlConverter.getMultiCurveProperty(multiCurve, false); - urbanFunction.setBoundary(property); - } - } - } + if (projectionFilter.containsProperty("surveyYear", module)) { + Date surveyYear = rs.getDate(prefix + "surveyyear"); + if (!rs.wasNull()) + urbanFunction.setSurveyYear(Year.of(surveyYear.toLocalDate().getYear())); + } - if (projectionFilter.containsProperty("location", module)) { - Object object = rs.getObject("location"); - if (object != null) { - GeometryObject multiPoint = helper.getDatabaseAdapter().getGeometryConverter().getMultiPoint(object); - if (multiPoint != null) { - MultiPointProperty property = gmlConverter.getMultiPointProperty(multiPoint, false); - urbanFunction.setPointLocation(property); - } - } + for (int i = 0; i < 3; i++) { + if (!projectionFilter.containsProperty("lod" + (i == 0 ? i : "-" + i) + "MultiPoint")) + continue; + + if (i == 0 && !helper.getLodFilter().isEnabled(0)) + continue; + + Object geometry = rs.getObject(prefix + "lod" + (i == 0 ? i : "_" + i) + "multipoint"); + if (rs.wasNull()) + continue; + + GeometryObject multiPoint = helper.getDatabaseAdapter().getGeometryConverter().getMultiPoint(geometry); + if (multiPoint != null) { + MultiPointProperty property = gmlConverter.getMultiPointProperty(multiPoint); + if (property != null) { + switch (i) { + case 0: + urbanFunction.setLod0MultiPoint(property); + break; + case 1: + urbanFunction.setLod1MultiPoint(property); + break; + case 2: + urbanFunction.setLod2MultiPoint(property); + break; } + } + } + } - long legalGroundsId = rs.getLong("legalgrounds_id"); - if (legalGroundsId != 0 && projectionFilter.containsProperty("legalGrounds", module)) { - LegalGrounds legalGrounds = new LegalGrounds(); - - String articlesOfRegulation = rs.getString("articlesofregulation"); - if (!rs.wasNull()) { - Code code = new Code(articlesOfRegulation); - code.setCodeSpace(rs.getString("articlesofregulati_codespace")); - legalGrounds.setArticlesOfRegulation(code); - } - - Date date = rs.getDate("date_"); - if (!rs.wasNull()) - legalGrounds.setDate(date.toLocalDate()); - - String nameOfRegulation = rs.getString("nameofregulation"); - if (!rs.wasNull()) { - Code code = new Code(nameOfRegulation); - code.setCodeSpace(rs.getString("nameofregulation_codespace")); - legalGrounds.setNameOfRegulation(code); - } - - urbanFunction.setLegalGrounds(new LegalGroundsProperty(legalGrounds)); + for (int i = 0; i < 3; i++) { + if (!projectionFilter.containsProperty("lod" + (i == 0 ? i : "-" + i) + "MultiCurve")) + continue; + + if (i == 0 && !helper.getLodFilter().isEnabled(0)) + continue; + + Object geometry = rs.getObject(prefix + "lod" + (i == 0 ? i : "_" + i) + "multicurve"); + if (rs.wasNull()) + continue; + + GeometryObject multiCurve = helper.getDatabaseAdapter().getGeometryConverter().getMultiCurve(geometry); + if (multiCurve != null) { + MultiCurveProperty property = gmlConverter.getMultiCurveProperty(multiCurve); + if (property != null) { + switch (i) { + case 0: + urbanFunction.setLod0MultiCurve(property); + break; + case 1: + urbanFunction.setLod1MultiCurve(property); + break; + case 2: + urbanFunction.setLod2MultiCurve(property); + break; } + } + } + } - if (urbanFunction instanceof Zone) { - Zone zone = (Zone) urbanFunction; - - if (projectionFilter.containsProperty("finalPublicationDate", module)) { - Date finalPublicationDate = rs.getDate("finalpublicationdate"); - if (!rs.wasNull()) - zone.setFinalPublicationDate(finalPublicationDate.toLocalDate()); - } - - if (projectionFilter.containsProperty("areaApplied", module)) - zone.setAreaApplied(rs.getString("areaapplied")); - } + for (int i = 0; i < 3; i++) { + if (!projectionFilter.containsProperty("lod" + (i == 0 ? i : "-" + i) + "MultiSurface")) + continue; + + if (i == 0 && !helper.getLodFilter().isEnabled(0)) + continue; + + long surfaceGeometryId = rs.getLong(prefix + "lod" + (i == 0 ? i : "_" + i) + "multisurface_id"); + if (rs.wasNull()) + continue; + + switch (i) { + case 0: + surfaceGeometryExporter.addBatch(surfaceGeometryId, urbanFunction::setLod0MultiSurface); + break; + case 1: + surfaceGeometryExporter.addBatch(surfaceGeometryId, urbanFunction::setLod1MultiSurface); + break; + case 2: + surfaceGeometryExporter.addBatch(surfaceGeometryId, urbanFunction::setLod2MultiSurface); + break; + } + } - if (urbanFunction instanceof DisasterPreventionBase) { - DisasterPreventionBase disasterPreventionBase = (DisasterPreventionBase) urbanFunction; + long legalGroundsId = rs.getLong(prefix + "legalgrounds_id"); + if (legalGroundsId != 0 && projectionFilter.containsProperty("legalGrounds", module)) { + LegalGrounds legalGrounds = new LegalGrounds(); - if (projectionFilter.containsProperty("capacity", module)) { - int capacity = rs.getInt("capacity"); - if (!rs.wasNull()) - disasterPreventionBase.setCapacity(capacity); - } - } + String articlesOfRegulation = rs.getString(prefix + "articlesofregulation"); + if (!rs.wasNull()) { + Code code = new Code(articlesOfRegulation); + code.setCodeSpace(rs.getString(prefix + "articlesofregulati_codespace")); + legalGrounds.setArticlesOfRegulation(code); + } - isInitialized = true; - } + Date date = rs.getDate(prefix + "date_"); + if (!rs.wasNull()) + legalGrounds.setDate(date.toLocalDate()); - if (projectionFilter.containsProperty("target", module)) { - String gmlId = rs.getString(MappingConstants.GMLID); - if (gmlId != null) - urbanFunction.getTargets().add(new TargetProperty("#" + gmlId)); - } + String nameOfRegulation = rs.getString(prefix + "nameofregulation"); + if (!rs.wasNull()) { + Code code = new Code(nameOfRegulation); + code.setCodeSpace(rs.getString(prefix + "nameofregulation_codespace")); + legalGrounds.setNameOfRegulation(code); } + + urbanFunction.setLegalGrounds(new LegalGroundsProperty(legalGrounds)); } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanFunctionModuleExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanFunctionModuleExporter.java new file mode 100644 index 0000000..94864d3 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanFunctionModuleExporter.java @@ -0,0 +1,6 @@ +package org.citydb.ade.iur.exporter.urf; + +import org.citydb.ade.exporter.ADEExporter; + +public interface UrbanFunctionModuleExporter extends ADEExporter { +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanizationExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanizationExporter.java index 1ccd975..0df56b5 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanizationExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/UrbanizationExporter.java @@ -22,18 +22,22 @@ package org.citydb.ade.iur.exporter.urf; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; +import org.citygml4j.ade.iur.model.urf.TargetProperty; import org.citygml4j.ade.iur.model.urf.Urbanization; import java.sql.Connection; @@ -41,35 +45,62 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class UrbanizationExporter implements ADEExporter { +public class UrbanizationExporter implements UrbanFunctionModuleExporter { private final PreparedStatement ps; private final String module; private final UrbanFunctionExporter urbanFunctionExporter; public UrbanizationExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.URBANIZATION); - module = UrbanFunctionModule.v1_3.getNamespaceURI(); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); + + urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("period", "resources")) + Table urbanFunction = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION))); + + Select select = new Select().addJoin(JoinFactory.inner(urbanFunction, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + urbanFunctionExporter.addProjection(select, urbanFunction, projectionFilter, "uf"); + if (projectionFilter.containsProperty("period", module)) + select.addProjection(table.getColumn("period")); + if (projectionFilter.containsProperty("resources", module)) + select.addProjection(table.getColumn("resources")); + if (projectionFilter.containsProperty("target", module)) { + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid")) + .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); + } ps = connection.prepareStatement(select.toString()); - - urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); } public void doExport(Urbanization urbanization, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { ps.setLong(1, objectId); try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - urbanFunctionExporter.doExport(urbanization, objectId, objectType, projectionFilter); + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + urbanFunctionExporter.doExport(urbanization, projectionFilter, "uf", rs); + + if (projectionFilter.containsProperty("period", module)) + urbanization.setPeriod(rs.getString("period")); + + if (projectionFilter.containsProperty("resources", module)) + urbanization.setResources(rs.getString("resources")); - if (projectionFilter.containsProperty("period", module)) - urbanization.setPeriod(rs.getString("period")); + isInitialized = true; + } - if (projectionFilter.containsProperty("resources", module)) - urbanization.setResources(rs.getString("resources")); + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString("gmlid"); + if (gmlId != null) + urbanization.getTargets().add(new TargetProperty("#" + gmlId)); + } } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/ZoneExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urf/ZoneExporter.java new file mode 100644 index 0000000..42fdac9 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urf/ZoneExporter.java @@ -0,0 +1,116 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urf; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; +import org.citygml4j.ade.iur.model.urf.TargetProperty; +import org.citygml4j.ade.iur.model.urf.Zone; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ZoneExporter implements UrbanFunctionModuleExporter { + private final PreparedStatement ps; + private final String module; + private final UrbanFunctionExporter urbanFunctionExporter; + + public ZoneExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.ZONE); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); + + urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table urbanFunction = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNCTION))); + + Select select = new Select().addJoin(JoinFactory.inner(urbanFunction, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + urbanFunctionExporter.addProjection(select, urbanFunction, projectionFilter, "uf"); + if (projectionFilter.containsProperty("finalPublicationDate", module)) + select.addProjection(table.getColumn("finalpublicationdate")); + if (projectionFilter.containsProperty("areaApplied", module)) + select.addProjection(table.getColumn("areaapplied")); + if (projectionFilter.containsProperty("target", module)) { + Table targets = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.URBANFUNC_TO_CITYOBJEC))); + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid")) + .addJoin(JoinFactory.left(targets, "urbanfunction_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, targets.getColumn("cityobject_id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Zone zone, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + urbanFunctionExporter.doExport(zone, projectionFilter, "uf", rs); + + if (projectionFilter.containsProperty("finalPublicationDate", module)) { + Date finalPublicationDate = rs.getDate("finalpublicationdate"); + if (!rs.wasNull()) + zone.setFinalPublicationDate(finalPublicationDate.toLocalDate()); + } + + if (projectionFilter.containsProperty("areaApplied", module)) + zone.setAreaApplied(rs.getString("areaapplied")); + + isInitialized = true; + } + + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString("gmlid"); + if (gmlId != null) + zone.getTargets().add(new TargetProperty("#" + gmlId)); + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urg/CityObjectGroupPropertiesExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/CityObjectGroupPropertiesExporter.java new file mode 100644 index 0000000..c3edc10 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/CityObjectGroupPropertiesExporter.java @@ -0,0 +1,92 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urg; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.FeatureType; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citygml4j.ade.iur.model.module.UrbanObjectModule; +import org.citygml4j.ade.iur.model.urg.FiscalYearOfPublicationProperty; +import org.citygml4j.ade.iur.model.urg.LanguageProperty; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.Year; + +public class CityObjectGroupPropertiesExporter implements StatisticalGridModuleExporter { + private final PreparedStatement ps; + private final String module; + + public CityObjectGroupPropertiesExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.CITYOBJECTGROUP); + module = UrbanObjectModule.v1_4.getNamespaceURI(); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Select select = new Select().addProjection(table.getColumns("fiscalyearofpublication", "language", "language_codespace")) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(CityObjectGroup parent, long parentId, FeatureType parentType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, parentId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + if (projectionFilter.containsProperty("fiscalYearOfPublication", module)) { + Date fiscalYearOfPublication = rs.getDate("fiscalyearofpublication"); + if (!rs.wasNull()) { + FiscalYearOfPublicationProperty property = new FiscalYearOfPublicationProperty(Year.of(fiscalYearOfPublication.toLocalDate().getYear())); + parent.addGenericApplicationPropertyOfCityObjectGroup(property); + } + } + + if (projectionFilter.containsProperty("language", module)) { + String language = rs.getString("language"); + if (!rs.wasNull()) { + Code code = new Code(language); + code.setCodeSpace(rs.getString("language_codespace")); + LanguageProperty property = new LanguageProperty(code); + parent.addGenericApplicationPropertyOfCityObjectGroup(property); + } + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urg/GenericGridCellExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/GenericGridCellExporter.java new file mode 100644 index 0000000..1dd8e22 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/GenericGridCellExporter.java @@ -0,0 +1,137 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urg; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.urg.GenericGridCell; +import org.citygml4j.ade.iur.model.urg.KeyValuePair; +import org.citygml4j.ade.iur.model.urg.KeyValuePairProperty; +import org.citygml4j.model.gml.basicTypes.Code; +import org.citygml4j.model.gml.basicTypes.Measure; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class GenericGridCellExporter implements StatisticalGridModuleExporter { + private final PreparedStatement ps; + private final StatisticalGridExporter statisticalGridExporter; + + public GenericGridCellExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + + statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table keyValuePair = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.KEYVALUEPAIR))); + + Select select = statisticalGridExporter.addProjection(new Select(), table, projectionFilter, "sg") + .addProjection(keyValuePair.getColumns("key", "key_codespace", "codevalue", "codevalue_codespace", + "datevalue", "doublevalue", "intvalue", "measuredvalue", "measuredvalue_uom", "stringvalue", "urivalue")) + .addJoin(JoinFactory.left(keyValuePair, "statisticalg_genericvalue_id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(GenericGridCell genericGridCell, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + statisticalGridExporter.doExport(genericGridCell, projectionFilter, "sg", rs); + isInitialized = true; + } + + KeyValuePair keyValuePair = new KeyValuePair(); + + String key = rs.getString("key"); + if (!rs.wasNull()) { + Code code = new Code(key); + code.setCodeSpace(rs.getString("key_codespace")); + keyValuePair.setKey(code); + } else + continue; + + String codeValue = rs.getString("codevalue"); + if (!rs.wasNull()) { + Code code = new Code(codeValue); + code.setCodeSpace(rs.getString("codevalue_codespace")); + keyValuePair.setCodeValue(code); + } + + Date dateValue = rs.getDate("datevalue"); + if (!rs.wasNull()) + keyValuePair.setDateValue(dateValue.toLocalDate()); + + double doubleValue = rs.getDouble("doublevalue"); + if (!rs.wasNull()) + keyValuePair.setDoubleValue(doubleValue); + + int intValue = rs.getInt("intvalue"); + if (!rs.wasNull()) + keyValuePair.setIntValue(intValue); + + double measuredValue = rs.getDouble("measuredvalue"); + if (!rs.wasNull()) { + Measure measure = new Measure(measuredValue); + measure.setUom(rs.getString("measuredvalue_uom")); + keyValuePair.setMeasuredValue(measure); + } + + String stringValue = rs.getString("stringvalue"); + if (!rs.wasNull()) + keyValuePair.setStringValue(stringValue); + + String uriValue = rs.getString("urivalue"); + if (!rs.wasNull()) + keyValuePair.setUriValue(uriValue); + + if (keyValuePair.isSetValue()) + genericGridCell.getGenericValues().add(new KeyValuePairProperty(keyValuePair)); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urg/HouseholdsExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/HouseholdsExporter.java index 75931d0..b7aec40 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urg/HouseholdsExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/HouseholdsExporter.java @@ -22,7 +22,6 @@ package org.citydb.ade.iur.exporter.urg; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; @@ -38,18 +37,18 @@ import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citydb.sqlbuilder.select.operator.logical.LogicalOperationName; -import org.citygml4j.model.gml.basicTypes.Code; import org.citygml4j.ade.iur.model.module.StatisticalGridModule; import org.citygml4j.ade.iur.model.urg.Households; import org.citygml4j.ade.iur.model.urg.NumberOfHouseholds; import org.citygml4j.ade.iur.model.urg.NumberOfHouseholdsProperty; +import org.citygml4j.model.gml.basicTypes.Code; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class HouseholdsExporter implements ADEExporter { +public class HouseholdsExporter implements StatisticalGridModuleExporter { private final PreparedStatement ps; private final String module; private final StatisticalGridExporter statisticalGridExporter; @@ -57,14 +56,23 @@ public class HouseholdsExporter implements ADEExporter { public HouseholdsExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.HOUSEHOLDS); CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); - module = StatisticalGridModule.v1_3.getNamespaceURI(); + module = StatisticalGridModule.v1_4.getNamespaceURI(); - Table table = new Table(helper.getTableNameWithSchema(tableName)); - Table households = new Table(manager.getSchemaMapper().getTableName(ADETable.NUMBEROFHOUSEHOLDS)); + statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); - Select select = new Select().addProjection(table.getColumns("numberofmainhousehold", "numberofordinaryhousehold")); + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table statisticalGrid = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID))); + + Select select = statisticalGridExporter.addProjection(new Select(), statisticalGrid, projectionFilter, "sg") + .addJoin(JoinFactory.inner(statisticalGrid, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + if (projectionFilter.containsProperty("numberOfOrdinaryHousehold", module)) + select.addProjection(table.getColumn("numberofordinaryhousehold")); + if (projectionFilter.containsProperty("numberOfMainHousehold", module)) + select.addProjection(table.getColumn("numberofmainhousehold")); if (projectionFilter.containsProperty("numberOfHouseholdsByOwnership", module) || projectionFilter.containsProperty("numberOfHouseholdsByStructure", module)) { + Table households = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.NUMBEROFHOUSEHOLDS))); select.addProjection(households.getColumns("households_numberofhouseh_id", "households_numberofhous_id_1", "class", "class_codespace", "number_")); Join join = JoinFactory.left(households, "households_numberofhouseh_id", ComparisonName.EQUAL_TO, table.getColumn("id")); @@ -72,10 +80,7 @@ public HouseholdsExporter(Connection connection, CityGMLExportHelper helper, Exp join.setConditionOperationName(LogicalOperationName.OR); select.addJoin(join); } - select.addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); ps = connection.prepareStatement(select.toString()); - - statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); } public void doExport(Households households, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { @@ -86,7 +91,7 @@ public void doExport(Households households, long objectId, AbstractType objec while (rs.next()) { if (!isInitialized) { - statisticalGridExporter.doExport(households, objectId, objectType, projectionFilter); + statisticalGridExporter.doExport(households, projectionFilter, "sg", rs); if (projectionFilter.containsProperty("numberOfOrdinaryHousehold", module)) { int numberOfOrdinaryHousehold = rs.getInt("numberofordinaryhousehold"); diff --git a/src/main/java/org/citydb/ade/iur/exporter/urg/LandPriceExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/LandPriceExporter.java index 3b78779..9e7618a 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urg/LandPriceExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/LandPriceExporter.java @@ -22,67 +22,92 @@ package org.citydb.ade.iur.exporter.urg; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; -import org.citygml4j.model.gml.basicTypes.Code; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citygml4j.ade.iur.model.module.StatisticalGridModule; import org.citygml4j.ade.iur.model.urg.LandPrice; import org.citygml4j.ade.iur.model.urg.LandPricePerLandUse; import org.citygml4j.ade.iur.model.urg.LandPricePerLandUseProperty; +import org.citygml4j.model.gml.basicTypes.Code; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class LandPriceExporter implements ADEExporter { +public class LandPriceExporter implements StatisticalGridModuleExporter { private final PreparedStatement ps; private final String module; private final StatisticalGridExporter statisticalGridExporter; public LandPriceExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { - String tableName = manager.getSchemaMapper().getTableName(ADETable.LANDPRICEPERLANDUSE); - module = StatisticalGridModule.v1_3.getNamespaceURI(); + String tableName = manager.getSchemaMapper().getTableName(ADETable.LANDPRICE); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("currencyunit", "currencyunit_codespace", "landprice", - "landuse", "landuse_codespace")) - .addSelection(ComparisonFactory.equalTo(table.getColumn("statisticalgrid_landprice_id"), new PlaceHolder<>())); - ps = connection.prepareStatement(select.toString()); + Table statisticalGrid = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID))); - statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); + Select select = statisticalGridExporter.addProjection(new Select(), statisticalGrid, projectionFilter, "sg") + .addJoin(JoinFactory.inner(statisticalGrid, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + if (projectionFilter.containsProperty("currencyUnit", module)) + select.addProjection(table.getColumns("currencyunit", "currencyunit_codespace")); + if (projectionFilter.containsProperty("landPrice", module)) { + Table landPricePerLandUse = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.LANDPRICEPERLANDUSE))); + select.addProjection(landPricePerLandUse.getColumn("id", "lpid")) + .addProjection(landPricePerLandUse.getColumns("landprice", "landuse", "landuse_codespace")) + .addJoin(JoinFactory.left(landPricePerLandUse, "landprice_landprice_id", ComparisonName.EQUAL_TO, table.getColumn("id"))); + } + ps = connection.prepareStatement(select.toString()); } public void doExport(LandPrice landPrice, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { - statisticalGridExporter.doExport(landPrice, objectId, objectType, projectionFilter); + ps.setLong(1, objectId); - if (projectionFilter.containsProperty("landPrice", module)) { - ps.setLong(1, objectId); + try (ResultSet rs = ps.executeQuery()) { + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + statisticalGridExporter.doExport(landPrice, projectionFilter, "sg", rs); + + if (projectionFilter.containsProperty("currencyUnit", module)) { + String currencyUnit = rs.getString("currencyunit"); + if (!rs.wasNull()) { + Code code = new Code(currencyUnit); + code.setCodeSpace(rs.getString("currencyunit_codespace")); + landPrice.setCurrencyUnit(code); + } + } + + isInitialized = true; + } + + if (projectionFilter.containsProperty("landPrice", module)) { + rs.getLong("lpid"); + if (rs.wasNull()) + continue; - try (ResultSet rs = ps.executeQuery()) { - while (rs.next()) { LandPricePerLandUse landPricePerLandUse = new LandPricePerLandUse(); int price = rs.getInt("landprice"); if (!rs.wasNull()) landPricePerLandUse.setLandPrice(price); - String currencyUnit = rs.getString("currencyunit"); - if (!rs.wasNull()) { - Code code = new Code(currencyUnit); - code.setCodeSpace(rs.getString("currencyunit_codespace")); - landPricePerLandUse.setCurrencyUnit(code); - } - String landUse = rs.getString("landuse"); if (!rs.wasNull()) { Code code = new Code(landUse); diff --git a/src/main/java/org/citydb/ade/iur/exporter/urg/LandUseDiversionExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/LandUseDiversionExporter.java index f6e3d1d..c3d41cd 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urg/LandUseDiversionExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/LandUseDiversionExporter.java @@ -22,22 +22,26 @@ package org.citydb.ade.iur.exporter.urg; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; -import org.citygml4j.model.gml.basicTypes.Measure; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urg.AreaOfAnnualDiversions; +import org.citygml4j.ade.iur.model.urg.AreaOfAnnualDiversionsProperty; import org.citygml4j.ade.iur.model.urg.LandUseDiversion; import org.citygml4j.ade.iur.model.urg.NumberOfAnnualDiversions; import org.citygml4j.ade.iur.model.urg.NumberOfAnnualDiversionsProperty; +import org.citygml4j.model.gml.basicTypes.Measure; import java.sql.Connection; import java.sql.Date; @@ -45,50 +49,90 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.time.Year; +import java.util.HashSet; +import java.util.Set; -public class LandUseDiversionExporter implements ADEExporter { +public class LandUseDiversionExporter implements StatisticalGridModuleExporter { private final PreparedStatement ps; private final String module; private final StatisticalGridExporter statisticalGridExporter; public LandUseDiversionExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { - String tableName = manager.getSchemaMapper().getTableName(ADETable.NUMBEROFANNUALDIVERSIO); - module = StatisticalGridModule.v1_3.getNamespaceURI(); + String tableName = manager.getSchemaMapper().getTableName(ADETable.LANDUSEDIVERSION); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("area", "area_uom", "count", "year")) - .addSelection(ComparisonFactory.equalTo(table.getColumn("statisticalg_numberofannu_id"), new PlaceHolder<>())); - ps = connection.prepareStatement(select.toString()); + Table statisticalGrid = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID))); - statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); + Select select = statisticalGridExporter.addProjection(new Select(), statisticalGrid, projectionFilter, "sg") + .addJoin(JoinFactory.inner(statisticalGrid, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + if (projectionFilter.containsProperty("numberOfAnnualDiversion", module)) { + Table number = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.NUMBEROFANNUALDIVERSIO))); + select.addProjection(number.getColumn("id", "nid"), number.getColumn("count"), number.getColumn("year", "nyear")) + .addJoin(JoinFactory.left(number, "landusediver_numberofannu_id", ComparisonName.EQUAL_TO, table.getColumn("id"))); + } + if (projectionFilter.containsProperty("areaOfAnnualDiversion", module)) { + Table area = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.AREAOFANNUALDIVERSIONS))); + select.addProjection(area.getColumn("id", "aid"), area.getColumn("year", "ayear")) + .addProjection(area.getColumns("area", "area_uom")) + .addJoin(JoinFactory.left(area, "landusediver_areaofannual_id", ComparisonName.EQUAL_TO, table.getColumn("id"))); + } + ps = connection.prepareStatement(select.toString()); } public void doExport(LandUseDiversion landUseDiversion, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { - statisticalGridExporter.doExport(landUseDiversion, objectId, objectType, projectionFilter); + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + boolean isInitialized = false; + Set numberOfAnnualDiversions = new HashSet<>(); + Set areaOfAnnualDiversions = new HashSet<>(); + + while (rs.next()) { + if (!isInitialized) { + statisticalGridExporter.doExport(landUseDiversion, projectionFilter, "sg", rs); + isInitialized = true; + } - if (projectionFilter.containsProperty("numberOfAnnuallDiversion", module)) { - ps.setLong(1, objectId); + if (projectionFilter.containsProperty("numberOfAnnuallDiversion", module)) { + long numberId = rs.getLong("nid"); + if (!rs.wasNull() && numberOfAnnualDiversions.add(numberId)) { + NumberOfAnnualDiversions number = new NumberOfAnnualDiversions(); - try (ResultSet rs = ps.executeQuery()) { - while (rs.next()) { - NumberOfAnnualDiversions number = new NumberOfAnnualDiversions(); + int count = rs.getInt("count"); + if (!rs.wasNull()) + number.setCount(count); - double area = rs.getDouble("area"); - if (!rs.wasNull()) { - Measure measure = new Measure(area); - measure.setUom(rs.getString("area_uom")); - number.setArea(measure); + Date year = rs.getDate("nyear"); + if (!rs.wasNull()) + number.setYear(Year.of(year.toLocalDate().getYear())); + + landUseDiversion.getNumberOfAnnualDiversions().add(new NumberOfAnnualDiversionsProperty(number)); } + } - int count = rs.getInt("count"); - if (!rs.wasNull()) - number.setCount(count); + if (projectionFilter.containsProperty("areaOfAnnualDiversion", module)) { + long areaId = rs.getLong("aid"); + if (!rs.wasNull() && areaOfAnnualDiversions.add(areaId)) { + AreaOfAnnualDiversions area = new AreaOfAnnualDiversions(); - Date year = rs.getDate("year"); - if (!rs.wasNull()) - number.setYear(Year.of(year.toLocalDate().getYear())); + double areaValue = rs.getDouble("area"); + if (!rs.wasNull()) { + Measure measure = new Measure(areaValue); + measure.setUom(rs.getString("area_uom")); + area.setArea(measure); + } - landUseDiversion.getNumberOfAnnualDiversions().add(new NumberOfAnnualDiversionsProperty(number)); + Date year = rs.getDate("ayear"); + if (!rs.wasNull()) + area.setYear(Year.of(year.toLocalDate().getYear())); + + landUseDiversion.getAreaOfAnnualDiversions().add(new AreaOfAnnualDiversionsProperty(area)); + } } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urg/OfficesAndEmployeesExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/OfficesAndEmployeesExporter.java index 1b7ed36..f0774b5 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urg/OfficesAndEmployeesExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/OfficesAndEmployeesExporter.java @@ -22,17 +22,19 @@ package org.citydb.ade.iur.exporter.urg; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; import org.citygml4j.ade.iur.model.module.StatisticalGridModule; import org.citygml4j.ade.iur.model.urg.OfficesAndEmployees; @@ -41,21 +43,29 @@ import java.sql.ResultSet; import java.sql.SQLException; -public class OfficesAndEmployeesExporter implements ADEExporter { +public class OfficesAndEmployeesExporter implements StatisticalGridModuleExporter { private final PreparedStatement ps; private final String module; private final StatisticalGridExporter statisticalGridExporter; public OfficesAndEmployeesExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.OFFICESANDEMPLOYEES); - module = StatisticalGridModule.v1_3.getNamespaceURI(); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("numberofemployees", "numberofoffices")) + Table statisticalGrid = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID))); + + Select select = statisticalGridExporter.addProjection(new Select(), statisticalGrid, projectionFilter, "sg") + .addJoin(JoinFactory.inner(statisticalGrid, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + if (projectionFilter.containsProperty("numberOfOffices", module)) + select.addProjection(table.getColumn("numberofoffices")); + if (projectionFilter.containsProperty("numberOfEmployees", module)) + select.addProjection(table.getColumn("numberofemployees")); ps = connection.prepareStatement(select.toString()); - - statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); } public void doExport(OfficesAndEmployees officesAndEmployees, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { @@ -63,7 +73,7 @@ public void doExport(OfficesAndEmployees officesAndEmployees, long objectId, Abs try (ResultSet rs = ps.executeQuery()) { if (rs.next()) { - statisticalGridExporter.doExport(officesAndEmployees, objectId, objectType, projectionFilter); + statisticalGridExporter.doExport(officesAndEmployees, projectionFilter, "sg", rs); if (projectionFilter.containsProperty("numberOfOffices", module)) { int numberOfOffices = rs.getInt("numberofoffices"); diff --git a/src/main/java/org/citydb/ade/iur/exporter/urg/PopulationExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/PopulationExporter.java index 063071e..74ff71c 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urg/PopulationExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/PopulationExporter.java @@ -22,7 +22,6 @@ package org.citydb.ade.iur.exporter.urg; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; @@ -36,18 +35,18 @@ import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; -import org.citygml4j.model.gml.basicTypes.Code; import org.citygml4j.ade.iur.model.module.StatisticalGridModule; import org.citygml4j.ade.iur.model.urg.Population; import org.citygml4j.ade.iur.model.urg.PopulationByAgeAndSex; import org.citygml4j.ade.iur.model.urg.PopulationByAgeAndSexProperty; +import org.citygml4j.model.gml.basicTypes.Code; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class PopulationExporter implements ADEExporter { +public class PopulationExporter implements StatisticalGridModuleExporter { private final PreparedStatement ps; private final String module; private final StatisticalGridExporter statisticalGridExporter; @@ -55,22 +54,46 @@ public class PopulationExporter implements ADEExporter { public PopulationExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.POPULATION); CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); - module = StatisticalGridModule.v1_3.getNamespaceURI(); + module = StatisticalGridModule.v1_4.getNamespaceURI(); - Table table = new Table(helper.getTableNameWithSchema(tableName)); - Table population = new Table(manager.getSchemaMapper().getTableName(ADETable.POPULATIONBYAGEANDSEX)); + statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); - Select select = new Select().addProjection(table.getColumns("births", "daytimepopulation", - "daytimepopulationdensity", "deaths", "femalepopulation", "increasement", - "malepopulation", "movefrom", "moveto", "naturalincrease", "socialincrease", "total")); + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table statisticalGrid = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID))); + + Select select = statisticalGridExporter.addProjection(new Select(), statisticalGrid, projectionFilter, "sg") + .addJoin(JoinFactory.inner(statisticalGrid, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + if (projectionFilter.containsProperty("total", module)) + select.addProjection(table.getColumn("total")); + if (projectionFilter.containsProperty("daytimePopulation", module)) + select.addProjection(table.getColumn("daytimepopulation")); + if (projectionFilter.containsProperty("daytimePopulationDensity", module)) + select.addProjection(table.getColumn("daytimepopulationdensity")); + if (projectionFilter.containsProperty("naturalIncrease", module)) + select.addProjection(table.getColumn("naturalincrease")); + if (projectionFilter.containsProperty("births", module)) + select.addProjection(table.getColumn("births")); + if (projectionFilter.containsProperty("deaths", module)) + select.addProjection(table.getColumn("deaths")); + if (projectionFilter.containsProperty("socialIncrease", module)) + select.addProjection(table.getColumn("socialincrease")); + if (projectionFilter.containsProperty("moveFrom", module)) + select.addProjection(table.getColumn("movefrom")); + if (projectionFilter.containsProperty("moveTo", module)) + select.addProjection(table.getColumn("moveto")); + if (projectionFilter.containsProperty("increasement", module)) + select.addProjection(table.getColumn("increasement")); + if (projectionFilter.containsProperty("malePopulation", module)) + select.addProjection(table.getColumn("malepopulation")); + if (projectionFilter.containsProperty("femalePopulation", module)) + select.addProjection(table.getColumn("femalepopulation")); if (projectionFilter.containsProperty("populationByAgeAndSex", module)) { - select.addProjection(population.getColumns("age", "age_codespace", "number_", "sex", "sex_codespace")) + Table population = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.POPULATIONBYAGEANDSEX))); + select.addProjection(population.getColumns("ageandsex", "ageandsex_codespace", "number_")) .addJoin(JoinFactory.left(population, "population_populationbyag_id", ComparisonName.EQUAL_TO, table.getColumn("id"))); } - select.addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); ps = connection.prepareStatement(select.toString()); - - statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); } public void doExport(Population population, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { @@ -81,7 +104,7 @@ public void doExport(Population population, long objectId, AbstractType objec while (rs.next()) { if (!isInitialized) { - statisticalGridExporter.doExport(population, objectId, objectType, projectionFilter); + statisticalGridExporter.doExport(population, projectionFilter, "sg", rs); if (projectionFilter.containsProperty("total", module)) { int total = rs.getInt("total"); @@ -162,23 +185,16 @@ public void doExport(Population population, long objectId, AbstractType objec if (projectionFilter.containsProperty("populationByAgeAndSex", module)) { PopulationByAgeAndSex populationByAgeAndSex = new PopulationByAgeAndSex(); - int number = rs.getInt("number_"); - if (number != 0) - populationByAgeAndSex.setNumber(number); - - String age = rs.getString("age"); + String age = rs.getString("ageandsex"); if (!rs.wasNull()) { Code code = new Code(age); - code.setCodeSpace(rs.getString("age_codespace")); - populationByAgeAndSex.setAge(code); + code.setCodeSpace(rs.getString("ageandsex_codespace")); + populationByAgeAndSex.setAgeAndSex(code); } - String sex = rs.getString("sex"); - if (!rs.wasNull()) { - Code code = new Code(sex); - code.setCodeSpace(rs.getString("sex_codespace")); - populationByAgeAndSex.setSex(code); - } + int number = rs.getInt("number_"); + if (number != 0) + populationByAgeAndSex.setNumber(number); population.getPopulationByAgeAndSex().add(new PopulationByAgeAndSexProperty(populationByAgeAndSex)); } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urf/PublicTransitExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/PublicTransitAccessibilityExporter.java similarity index 54% rename from src/main/java/org/citydb/ade/iur/exporter/urf/PublicTransitExporter.java rename to src/main/java/org/citydb/ade/iur/exporter/urg/PublicTransitAccessibilityExporter.java index 16dcf77..4a32594 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urf/PublicTransitExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/PublicTransitAccessibilityExporter.java @@ -20,60 +20,59 @@ * limitations under the License. */ -package org.citydb.ade.iur.exporter.urf; +package org.citydb.ade.iur.exporter.urg; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; -import org.citygml4j.ade.iur.model.urf.PublicTransit; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urg.PublicTransitAccessibility; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -public class PublicTransitExporter implements ADEExporter { +public class PublicTransitAccessibilityExporter implements StatisticalGridModuleExporter { private final PreparedStatement ps; - private final UrbanFunctionExporter urbanFunctionExporter; + private final String module; + private final StatisticalGridExporter statisticalGridExporter; - public PublicTransitExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { - String tableName = manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT); + public PublicTransitAccessibilityExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + statisticalGridExporter = manager.getExporter(StatisticalGridExporter.class); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("companyname", "frequencyofservice", - "numberofcustomers", "routename", "sectionname")) + Select select = statisticalGridExporter.addProjection(new Select(), table, projectionFilter, "sg") .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + if (projectionFilter.containsProperty("availability", module)) + select.addProjection(table.getColumn("availability")); ps = connection.prepareStatement(select.toString()); - - urbanFunctionExporter = manager.getExporter(UrbanFunctionExporter.class); } - public void doExport(PublicTransit publicTransit, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + public void doExport(PublicTransitAccessibility publicTransitAccessibility, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { ps.setLong(1, objectId); try (ResultSet rs = ps.executeQuery()) { if (rs.next()) { - urbanFunctionExporter.doExport(publicTransit, objectId, objectType, projectionFilter); - - publicTransit.setCompanyName(rs.getString("companyname")); - publicTransit.setRouteName(rs.getString("routename")); - publicTransit.setSectionName(rs.getString("sectionname")); - - int frequencyOfService = rs.getInt("frequencyofservice"); - if (!rs.wasNull()) - publicTransit.setFrequencyOfService(frequencyOfService); + statisticalGridExporter.doExport(publicTransitAccessibility, projectionFilter, "sg", rs); - double numberOfCustomers = rs.getDouble("numberofcustomers"); - if (!rs.wasNull()) - publicTransit.setNumberOfCustomers(numberOfCustomers); + if (projectionFilter.containsProperty("availability", module)) { + boolean availability = rs.getBoolean("availability"); + if (!rs.wasNull()) + publicTransitAccessibility.setAvailability(availability); + } } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urg/StatisticalGridExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/StatisticalGridExporter.java index 0aca0b6..92068b7 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/urg/StatisticalGridExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/StatisticalGridExporter.java @@ -22,40 +22,31 @@ package org.citydb.ade.iur.exporter.urg; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.exporter.CityGMLExportException; -import org.citydb.citygml.exporter.database.content.SurfaceGeometry; +import org.citydb.citygml.exporter.database.content.SurfaceGeometryExporter; import org.citydb.citygml.exporter.util.AttributeValueSplitter; -import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; import org.citydb.query.filter.projection.ProjectionFilter; import org.citydb.sqlbuilder.expression.PlaceHolder; import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; -import org.citygml4j.model.gml.GMLClass; -import org.citygml4j.model.gml.basicTypes.Code; -import org.citygml4j.model.gml.geometry.aggregates.MultiSurface; -import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty; -import org.xml.sax.SAXException; import org.citygml4j.ade.iur.model.module.StatisticalGridModule; import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; -import org.citygml4j.ade.iur.model.urg.PublicTransportationAccessibility; import org.citygml4j.ade.iur.model.urg.StatisticalGrid; +import org.citygml4j.model.gml.basicTypes.Code; +import org.xml.sax.SAXException; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; -import java.sql.Connection; -import java.sql.Date; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.time.Year; -public class StatisticalGridExporter implements ADEExporter { - private final CityGMLExportHelper helper; +public class StatisticalGridExporter implements StatisticalGridModuleExporter { + private final SurfaceGeometryExporter surfaceGeometryExporter; private final ExportManager manager; private final PreparedStatement ps; private final String module; @@ -63,128 +54,126 @@ public class StatisticalGridExporter implements ADEExporter { private final AttributeValueSplitter valueSplitter; public StatisticalGridExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { - this.helper = helper; this.manager = manager; String tableName = manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID); - module = UrbanFunctionModule.v1_3.getNamespaceURI(); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Select select = new Select().addProjection(table.getColumns("areaclassificationtype", "areaclassification_codespace", - "city", "city_codespace", "class", "class_codespace", "lod_1multisurfacegeometry_id", - "lod_2multisurfacegeometry_id", "prefecture", "prefecture_codespace", "surveyyear", "urbanplantype", - "urbanplantype_codespace", "value", "availability")) + Select select = addProjection(new Select(), table, projectionFilter, "") .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); ps = connection.prepareStatement(select.toString()); + surfaceGeometryExporter = helper.getSurfaceGeometryExporter(); valueSplitter = helper.getAttributeValueSplitter(); } - public void doExport(StatisticalGrid statisticalGrid, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { - ps.setLong(1, objectId); - - try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - if (projectionFilter.containsProperty("class", module)) { - String classifier = rs.getString("class"); - if (!rs.wasNull()) { - Code code = new Code(classifier); - code.setCodeSpace(rs.getString("class_codespace")); - statisticalGrid.setClassifier(code); - } - } - - if (projectionFilter.containsProperty("urbanPlanType", module)) { - String urbanPlanType = rs.getString("urbanplantype"); - if (!rs.wasNull()) { - Code code = new Code(urbanPlanType); - code.setCodeSpace(rs.getString("urbanplantype_codespace")); - statisticalGrid.setUrbanPlanType(code); - } - } + public Select addProjection(Select select, Table table, CombinedProjectionFilter projectionFilter, String prefix) { + select.addProjection(table.getColumn("id", prefix + "id")); + if (projectionFilter.containsProperty("class", module)) + select.addProjection(table.getColumn("class", prefix + "class"), table.getColumn("class_codespace", prefix + "class_codespace")); + if (projectionFilter.containsProperty("urbanPlanType", module)) + select.addProjection(table.getColumn("urbanplantype", prefix + "urbanplantype"), table.getColumn("urbanplantype_codespace", prefix + "urbanplantype_codespace")); + if (projectionFilter.containsProperty("areaClassificationType", module)) + select.addProjection(table.getColumn("areaclassificationtype", prefix + "areaclassificationtype"), table.getColumn("areaclassification_codespace", prefix + "areaclassification_codespace")); + if (projectionFilter.containsProperty("prefecture", module)) + select.addProjection(table.getColumn("prefecture", prefix + "prefecture"), table.getColumn("prefecture_codespace", prefix + "prefecture_codespace")); + if (projectionFilter.containsProperty("city", module)) + select.addProjection(table.getColumn("city", prefix + "city"), table.getColumn("city_codespace", prefix + "city_codespace")); + if (projectionFilter.containsProperty("surveyYear", module)) + select.addProjection(table.getColumn("surveyyear", prefix + "surveyyear")); + if (projectionFilter.containsProperty("lod-1MultiSurface", module)) + select.addProjection(table.getColumn("lod_1multisurface_id", prefix + "lod_1multisurface_id")); + if (projectionFilter.containsProperty("lod-2MultiSurface", module)) + select.addProjection(table.getColumn("lod_2multisurface_id", prefix + "lod_2multisurface_id")); + if (projectionFilter.containsProperty("value", module)) + select.addProjection(table.getColumn("value", prefix + "value")); + if (projectionFilter.containsProperty("availability", module)) + select.addProjection(table.getColumn("availability", prefix + "availability")); + + return select; + } - if (projectionFilter.containsProperty("areaClassificationType", module)) { - String areaClassificationType = rs.getString("areaclassificationtype"); - if (!rs.wasNull()) { - Code code = new Code(areaClassificationType); - code.setCodeSpace(rs.getString("areaclassification_codespace")); - statisticalGrid.setAreaClassificationType(code); - } - } + public void doExport(StatisticalGrid statisticalGrid, ProjectionFilter projectionFilter, String prefix, ResultSet rs) throws CityGMLExportException, SQLException { + if (projectionFilter.containsProperty("class", module)) { + String classifier = rs.getString(prefix + "class"); + if (!rs.wasNull()) { + Code code = new Code(classifier); + code.setCodeSpace(rs.getString(prefix + "class_codespace")); + statisticalGrid.setClassifier(code); + } + } - if (projectionFilter.containsProperty("prefecture", module)) { - String prefecture = rs.getString("prefecture"); - if (!rs.wasNull()) { - Code code = new Code(prefecture); - code.setCodeSpace(rs.getString("prefecture_codespace")); - statisticalGrid.setPrefecture(code); - } - } + if (projectionFilter.containsProperty("urbanPlanType", module)) { + String urbanPlanType = rs.getString(prefix + "urbanplantype"); + if (!rs.wasNull()) { + Code code = new Code(urbanPlanType); + code.setCodeSpace(rs.getString(prefix + "urbanplantype_codespace")); + statisticalGrid.setUrbanPlanType(code); + } + } - if (projectionFilter.containsProperty("city", module)) { - String city = rs.getString("city"); - if (!rs.wasNull()) { - Code code = new Code(city); - code.setCodeSpace(rs.getString("city_codespace")); - statisticalGrid.setCity(code); - } - } + if (projectionFilter.containsProperty("areaClassificationType", module)) { + String areaClassificationType = rs.getString(prefix + "areaclassificationtype"); + if (!rs.wasNull()) { + Code code = new Code(areaClassificationType); + code.setCodeSpace(rs.getString(prefix + "areaclassification_codespace")); + statisticalGrid.setAreaClassificationType(code); + } + } - if (projectionFilter.containsProperty("surveyYear", module)) { - Date surveyYear = rs.getDate("surveyyear"); - if (!rs.wasNull()) - statisticalGrid.setSurveyYear(Year.of(surveyYear.toLocalDate().getYear())); - } + if (projectionFilter.containsProperty("prefecture", module)) { + String prefecture = rs.getString(prefix + "prefecture"); + if (!rs.wasNull()) { + Code code = new Code(prefecture); + code.setCodeSpace(rs.getString(prefix + "prefecture_codespace")); + statisticalGrid.setPrefecture(code); + } + } - if (projectionFilter.containsProperty("lod-1MultiSurfaceGeometry", module)) { - long lod1MultiSurfaceId = rs.getLong("lod_1multisurfacegeometry_id"); - if (!rs.wasNull()) { - SurfaceGeometry geometry = helper.exportSurfaceGeometry(lod1MultiSurfaceId); - if (geometry != null && geometry.getType() == GMLClass.MULTI_SURFACE) { - MultiSurfaceProperty multiSurfaceProperty = new MultiSurfaceProperty(); - if (geometry.isSetGeometry()) - multiSurfaceProperty.setMultiSurface((MultiSurface) geometry.getGeometry()); - else - multiSurfaceProperty.setHref(geometry.getReference()); - - statisticalGrid.setLod1MultiSurfaceGeometry(multiSurfaceProperty); - } - } - } + if (projectionFilter.containsProperty("city", module)) { + String city = rs.getString(prefix + "city"); + if (!rs.wasNull()) { + Code code = new Code(city); + code.setCodeSpace(rs.getString(prefix + "city_codespace")); + statisticalGrid.setCity(code); + } + } - if (projectionFilter.containsProperty("lod-2MultiSurfaceGeometry", module)) { - long lod2MultiSurfaceId = rs.getLong("lod_2multisurfacegeometry_id"); - if (!rs.wasNull()) { - SurfaceGeometry geometry = helper.exportSurfaceGeometry(lod2MultiSurfaceId); - if (geometry != null && geometry.getType() == GMLClass.MULTI_SURFACE) { - MultiSurfaceProperty multiSurfaceProperty = new MultiSurfaceProperty(); - if (geometry.isSetGeometry()) - multiSurfaceProperty.setMultiSurface((MultiSurface) geometry.getGeometry()); - else - multiSurfaceProperty.setHref(geometry.getReference()); - - statisticalGrid.setLod2MultiSurfaceGeometry(multiSurfaceProperty); - } - } - } + if (projectionFilter.containsProperty("surveyYear", module)) { + Date surveyYear = rs.getDate(prefix + "surveyyear"); + if (!rs.wasNull()) + statisticalGrid.setSurveyYear(Year.of(surveyYear.toLocalDate().getYear())); + } - if (projectionFilter.containsProperty("value", module)) { - try { - for (AttributeValueSplitter.SplitValue splitValue : valueSplitter.split(rs.getString("value"))) { - String value = "" + - splitValue.result(0) + ""; - statisticalGrid.getValues().add(manager.unmarshal(value)); - } - } catch (ParserConfigurationException | IOException | SAXException e) { - throw new CityGMLExportException("Failed to create element.", e); - } - } + for (int i = 0; i < 2; i++) { + if (!projectionFilter.containsProperty("lod-" + (i + 1) + "MultiSurface", module)) + continue; + + long surfaceGeometryId = rs.getLong(prefix + "lod_" + (i + 1) + "multisurface_id"); + if (rs.wasNull()) + continue; + + switch (i) { + case 0: + surfaceGeometryExporter.addBatch(surfaceGeometryId, statisticalGrid::setLod1MultiSurface); + break; + case 1: + surfaceGeometryExporter.addBatch(surfaceGeometryId, statisticalGrid::setLod2MultiSurface); + break; + } + } - if (statisticalGrid instanceof PublicTransportationAccessibility && projectionFilter.containsProperty("availability", module)) { - boolean availability = rs.getBoolean("availability"); - if (!rs.wasNull()) - ((PublicTransportationAccessibility) statisticalGrid).setAvailability(availability); + if (projectionFilter.containsProperty("value", module)) { + try { + for (AttributeValueSplitter.SplitValue splitValue : valueSplitter.split(rs.getString(prefix + "value"))) { + String value = "" + + splitValue.result(0) + ""; + statisticalGrid.getValues().add(manager.unmarshal(value)); } + } catch (ParserConfigurationException | IOException | SAXException e) { + throw new CityGMLExportException("Failed to create element.", e); } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/urg/StatisticalGridModuleExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urg/StatisticalGridModuleExporter.java new file mode 100644 index 0000000..1d2397c --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urg/StatisticalGridModuleExporter.java @@ -0,0 +1,6 @@ +package org.citydb.ade.iur.exporter.urg; + +import org.citydb.ade.exporter.ADEExporter; + +public interface StatisticalGridModuleExporter extends ADEExporter { +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/uro/BuildingPropertiesExporter.java b/src/main/java/org/citydb/ade/iur/exporter/uro/BuildingPropertiesExporter.java index ad6d184..6d0f052 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/uro/BuildingPropertiesExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/uro/BuildingPropertiesExporter.java @@ -22,7 +22,6 @@ package org.citydb.ade.iur.exporter.uro; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; @@ -36,16 +35,19 @@ import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; -import org.citygml4j.model.citygml.building.AbstractBuilding; -import org.citygml4j.model.gml.basicTypes.Code; -import org.citygml4j.model.gml.basicTypes.Measure; import org.citygml4j.ade.iur.model.module.UrbanObjectModule; import org.citygml4j.ade.iur.model.uro.BuildingDetails; import org.citygml4j.ade.iur.model.uro.BuildingDetailsProperty; import org.citygml4j.ade.iur.model.uro.BuildingDetailsPropertyElement; +import org.citygml4j.ade.iur.model.uro.ExtendedAttributeProperty; +import org.citygml4j.ade.iur.model.uro.KeyValuePair; +import org.citygml4j.ade.iur.model.uro.KeyValuePairProperty; import org.citygml4j.ade.iur.model.uro.LargeCustomerFacilities; import org.citygml4j.ade.iur.model.uro.LargeCustomerFacilitiesProperty; import org.citygml4j.ade.iur.model.uro.LargeCustomerFacilitiesPropertyElement; +import org.citygml4j.model.citygml.building.AbstractBuilding; +import org.citygml4j.model.gml.basicTypes.Code; +import org.citygml4j.model.gml.basicTypes.Measure; import java.sql.Connection; import java.sql.Date; @@ -54,21 +56,19 @@ import java.sql.SQLException; import java.time.Year; -public class BuildingPropertiesExporter implements ADEExporter { +public class BuildingPropertiesExporter implements UrbanObjectModuleExporter { private final PreparedStatement ps; private final String module; public BuildingPropertiesExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.BUILDING); CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); - module = UrbanObjectModule.v1_3.getNamespaceURI(); + module = UrbanObjectModule.v1_4.getNamespaceURI(); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Table details = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.BUILDINGDETAILS))); - Table facilities = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.LARGECUSTOMERFACILITIE))); - Select select = new Select().addProjection(table.getColumns("buildingdetails_id", "largecustomerfacilities_id")); if (projectionFilter.containsProperty("buildingDetailsProperty", module)) { + Table details = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.BUILDINGDETAILS))); select.addProjection(details.getColumns("areaclassificationtype", "areaclassification_codespace", "buildingfootprintarea", "buildingfootprintarea_uom", "buildingroofedgearea", "buildingroofedgearea_uom", "buildingstructuretype", "buildingstructuret_codespace", "city", "city_codespace", "developmentarea", "developmentarea_uom", @@ -79,6 +79,7 @@ public BuildingPropertiesExporter(Connection connection, CityGMLExportHelper hel .addJoin(JoinFactory.left(details, "id", ComparisonName.EQUAL_TO, table.getColumn("buildingdetails_id"))); } if (projectionFilter.containsProperty("largeCustomerFacilitiesProperty", module)) { + Table facilities = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.LARGECUSTOMERFACILITIE))); select.addProjection(facilities.getColumn("areaclassificationtype", "area_2"), facilities.getColumn("areaclassification_codespace", "area_codespace_2"), facilities.getColumn("city", "city_2"), facilities.getColumn("city_codespace", "city_codespace_2"), facilities.getColumn("districtsandzonestype", "districts_2"), facilities.getColumn("districtsandzonest_codespace", "districts_codespace_2"), @@ -92,6 +93,13 @@ public BuildingPropertiesExporter(Connection connection, CityGMLExportHelper hel "keytenants", "name", "owner", "totalstorefloorarea", "totalstorefloorarea_uom")) .addJoin(JoinFactory.left(facilities, "id", ComparisonName.EQUAL_TO, table.getColumn("largecustomerfacilities_id"))); } + if (projectionFilter.containsProperty("extendedAttribute", module)) { + Table keyValuePair = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.KEYVALUEPAIR_1))); + select.addProjection(keyValuePair.getColumn("id", "kvpid")) + .addProjection(keyValuePair.getColumns("key", "key_codespace", "codevalue", "codevalue_codespace", + "datevalue", "doublevalue", "intvalue", "measuredvalue", "measuredvalue_uom", "stringvalue", "urivalue")) + .addJoin(JoinFactory.left(keyValuePair, "building_extendedattribut_id", ComparisonName.EQUAL_TO, table.getColumn("id"))); + } select.addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); ps = connection.prepareStatement(select.toString()); } @@ -302,6 +310,61 @@ public void doExport(AbstractBuilding parent, long parentId, FeatureType parentT LargeCustomerFacilitiesPropertyElement property = new LargeCustomerFacilitiesPropertyElement(new LargeCustomerFacilitiesProperty(largeCustomerFacilities)); parent.addGenericApplicationPropertyOfAbstractBuilding(property); } + + do { + long keyValuePairId = rs.getLong("kvpid"); + if (rs.wasNull()) + continue; + + KeyValuePair keyValuePair = new KeyValuePair(); + + String key = rs.getString("key"); + if (!rs.wasNull()) { + Code code = new Code(key); + code.setCodeSpace(rs.getString("key_codespace")); + keyValuePair.setKey(code); + } else + continue; + + String codeValue = rs.getString("codevalue"); + if (!rs.wasNull()) { + Code code = new Code(codeValue); + code.setCodeSpace(rs.getString("codevalue_codespace")); + keyValuePair.setCodeValue(code); + } + + Date dateValue = rs.getDate("datevalue"); + if (!rs.wasNull()) + keyValuePair.setDateValue(dateValue.toLocalDate()); + + double doubleValue = rs.getDouble("doublevalue"); + if (!rs.wasNull()) + keyValuePair.setDoubleValue(doubleValue); + + int intValue = rs.getInt("intvalue"); + if (!rs.wasNull()) + keyValuePair.setIntValue(intValue); + + double measuredValue = rs.getDouble("measuredvalue"); + if (!rs.wasNull()) { + Measure measure = new Measure(measuredValue); + measure.setUom(rs.getString("measuredvalue_uom")); + keyValuePair.setMeasuredValue(measure); + } + + String stringValue = rs.getString("stringvalue"); + if (!rs.wasNull()) + keyValuePair.setStringValue(stringValue); + + String uriValue = rs.getString("urivalue"); + if (!rs.wasNull()) + keyValuePair.setUriValue(uriValue); + + if (keyValuePair.isSetValue()) { + ExtendedAttributeProperty property = new ExtendedAttributeProperty(new KeyValuePairProperty(keyValuePair)); + parent.addGenericApplicationPropertyOfAbstractBuilding(property); + } + } while (rs.next()); } } } diff --git a/src/main/java/org/citydb/ade/iur/exporter/uro/CityObjectGroupPropertiesExporter.java b/src/main/java/org/citydb/ade/iur/exporter/uro/CityObjectGroupPropertiesExporter.java index a45fa55..7e6184c 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/uro/CityObjectGroupPropertiesExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/uro/CityObjectGroupPropertiesExporter.java @@ -22,7 +22,6 @@ package org.citydb.ade.iur.exporter.uro; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; @@ -33,11 +32,11 @@ import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; -import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; -import org.citygml4j.model.gml.basicTypes.Code; import org.citygml4j.ade.iur.model.module.UrbanObjectModule; import org.citygml4j.ade.iur.model.uro.FiscalYearOfPublicationProperty; import org.citygml4j.ade.iur.model.uro.LanguageProperty; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; +import org.citygml4j.model.gml.basicTypes.Code; import java.sql.Connection; import java.sql.Date; @@ -46,13 +45,13 @@ import java.sql.SQLException; import java.time.Year; -public class CityObjectGroupPropertiesExporter implements ADEExporter { +public class CityObjectGroupPropertiesExporter implements UrbanObjectModuleExporter { private final PreparedStatement ps; private final String module; public CityObjectGroupPropertiesExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { - String tableName = manager.getSchemaMapper().getTableName(ADETable.CITYOBJECTGROUP); - module = UrbanObjectModule.v1_3.getNamespaceURI(); + String tableName = manager.getSchemaMapper().getTableName(ADETable.CITYOBJECTGROUP_1); + module = UrbanObjectModule.v1_4.getNamespaceURI(); Table table = new Table(helper.getTableNameWithSchema(tableName)); Select select = new Select().addProjection(table.getColumns("fiscalyearofpublication", "language", "language_codespace")) diff --git a/src/main/java/org/citydb/ade/iur/exporter/uro/LandUsePropertiesExporter.java b/src/main/java/org/citydb/ade/iur/exporter/uro/LandUsePropertiesExporter.java index fedfe74..595ba33 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/uro/LandUsePropertiesExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/uro/LandUsePropertiesExporter.java @@ -22,7 +22,6 @@ package org.citydb.ade.iur.exporter.uro; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; @@ -33,9 +32,6 @@ import org.citydb.sqlbuilder.schema.Table; import org.citydb.sqlbuilder.select.Select; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; -import org.citygml4j.model.citygml.landuse.LandUse; -import org.citygml4j.model.gml.basicTypes.Code; -import org.citygml4j.model.gml.basicTypes.Measure; import org.citygml4j.ade.iur.model.module.UrbanObjectModule; import org.citygml4j.ade.iur.model.uro.AreaClassificationTypeProperty; import org.citygml4j.ade.iur.model.uro.AreaInHaProperty; @@ -50,6 +46,9 @@ import org.citygml4j.ade.iur.model.uro.ReferenceProperty; import org.citygml4j.ade.iur.model.uro.SurveyYearProperty; import org.citygml4j.ade.iur.model.uro.UrbanPlanTypeProperty; +import org.citygml4j.model.citygml.landuse.LandUse; +import org.citygml4j.model.gml.basicTypes.Code; +import org.citygml4j.model.gml.basicTypes.Measure; import java.sql.Connection; import java.sql.Date; @@ -58,13 +57,13 @@ import java.sql.SQLException; import java.time.Year; -public class LandUsePropertiesExporter implements ADEExporter { +public class LandUsePropertiesExporter implements UrbanObjectModuleExporter { private final PreparedStatement ps; private final String module; public LandUsePropertiesExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.LAND_USE); - module = UrbanObjectModule.v1_3.getNamespaceURI(); + module = UrbanObjectModule.v1_4.getNamespaceURI(); Table table = new Table(helper.getTableNameWithSchema(tableName)); Select select = new Select().addProjection(table.getColumns("areaclassification_codespace", "areaclassificationtype", diff --git a/src/main/java/org/citydb/ade/iur/exporter/uro/TransportationComplexPropertiesExporter.java b/src/main/java/org/citydb/ade/iur/exporter/uro/TransportationComplexPropertiesExporter.java index a922c55..d16a314 100644 --- a/src/main/java/org/citydb/ade/iur/exporter/uro/TransportationComplexPropertiesExporter.java +++ b/src/main/java/org/citydb/ade/iur/exporter/uro/TransportationComplexPropertiesExporter.java @@ -22,7 +22,6 @@ package org.citydb.ade.iur.exporter.uro; -import org.citydb.ade.exporter.ADEExporter; import org.citydb.ade.exporter.CityGMLExportHelper; import org.citydb.ade.iur.exporter.ExportManager; import org.citydb.ade.iur.schema.ADETable; @@ -36,16 +35,16 @@ import org.citydb.sqlbuilder.select.join.JoinFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; -import org.citygml4j.model.citygml.transportation.Road; -import org.citygml4j.model.citygml.transportation.TransportationComplex; -import org.citygml4j.model.gml.basicTypes.Code; -import org.citygml4j.model.gml.measures.Length; import org.citygml4j.ade.iur.model.module.UrbanObjectModule; import org.citygml4j.ade.iur.model.uro.TrafficVolume; import org.citygml4j.ade.iur.model.uro.TrafficVolumeProperty; import org.citygml4j.ade.iur.model.uro.TrafficVolumePropertyElement; import org.citygml4j.ade.iur.model.uro.WidthProperty; import org.citygml4j.ade.iur.model.uro.WidthTypeProperty; +import org.citygml4j.model.citygml.transportation.Road; +import org.citygml4j.model.citygml.transportation.TransportationComplex; +import org.citygml4j.model.gml.basicTypes.Code; +import org.citygml4j.model.gml.measures.Length; import java.sql.Connection; import java.sql.Date; @@ -54,21 +53,20 @@ import java.sql.SQLException; import java.time.Year; -public class TransportationComplexPropertiesExporter implements ADEExporter { +public class TransportationComplexPropertiesExporter implements UrbanObjectModuleExporter { private final PreparedStatement ps; private final String module; public TransportationComplexPropertiesExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { String tableName = manager.getSchemaMapper().getTableName(ADETable.TRANSPORTATION_COMPLEX); CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); - module = UrbanObjectModule.v1_3.getNamespaceURI(); + module = UrbanObjectModule.v1_4.getNamespaceURI(); Table table = new Table(helper.getTableNameWithSchema(tableName)); - Table volume = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.TRAFFICVOLUME))); - Select select = new Select().addProjection(table.getColumns("trafficvolume_id", "width", "width_uom", "widthtype", "widthtype_codespace")); if (projectionFilter.containsProperty("trafficVolumeProperty", module)) { + Table volume = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.TRAFFICVOLUME))); select.addProjection(volume.getColumn("areaclassificationtype", "area_2"), volume.getColumn("areaclassification_codespace", "area_codespace_2"), volume.getColumn("city", "city_2"), volume.getColumn("city_codespace", "city_codespace_2"), volume.getColumn("note", "note_2"), volume.getColumn("prefecture", "prefecture_2"), diff --git a/src/main/java/org/citydb/ade/iur/exporter/uro/UrbanObjectModuleExporter.java b/src/main/java/org/citydb/ade/iur/exporter/uro/UrbanObjectModuleExporter.java new file mode 100644 index 0000000..69bb728 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/uro/UrbanObjectModuleExporter.java @@ -0,0 +1,6 @@ +package org.citydb.ade.iur.exporter.uro; + +import org.citydb.ade.exporter.ADEExporter; + +public interface UrbanObjectModuleExporter extends ADEExporter { +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/AgencyExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/AgencyExporter.java new file mode 100644 index 0000000..87249ee --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/AgencyExporter.java @@ -0,0 +1,122 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.Agency; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class AgencyExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + private final String module; + private final PublicTransitExporter publicTransitExporter; + + public AgencyExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.AGENCY); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + + Select select = new Select().addProjection(table.getColumns("name", "url", "timezone", "timezone_codespace")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + if (projectionFilter.containsProperty("language", module)) + select.addProjection(table.getColumns("language", "language_codespace")); + if (projectionFilter.containsProperty("phone", module)) + select.addProjection(table.getColumn("phone")); + if (projectionFilter.containsProperty("fareUrl", module)) + select.addProjection(table.getColumn("fareurl")); + if (projectionFilter.containsProperty("email", module)) + select.addProjection(table.getColumn("email")); + if (projectionFilter.containsProperty("officialName", module)) + select.addProjection(table.getColumn("officialname")); + if (projectionFilter.containsProperty("zipNumber", module)) + select.addProjection(table.getColumn("zipnumber")); + if (projectionFilter.containsProperty("address", module)) + select.addProjection(table.getColumn("address")); + if (projectionFilter.containsProperty("presidentPosition", module)) + select.addProjection(table.getColumn("presidentposition")); + if (projectionFilter.containsProperty("presidentName", module)) + select.addProjection(table.getColumn("presidentname")); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Agency agency, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(agency, projectionFilter, "pt", rs); + + agency.setAgencyName(rs.getString("name")); + agency.setUrl(rs.getString("url")); + + String timezone = rs.getString("timezone"); + if (!rs.wasNull()) { + Code code = new Code(timezone); + code.setCodeSpace(rs.getString("timezone_codespace")); + agency.setTimeZone(code); + } + + if (projectionFilter.containsProperty("language", module)) { + String language = rs.getString("language"); + if (!rs.wasNull()) { + Code code = new Code(language); + code.setCodeSpace(rs.getString("language_codespace")); + agency.setLanguage(code); + } + } + + if (projectionFilter.containsProperty("phone", module)) + agency.setPhone(rs.getString("phone")); + + if (projectionFilter.containsProperty("fareUrl", module)) + agency.setFareUrl(rs.getString("fareurl")); + + if (projectionFilter.containsProperty("email", module)) + agency.setEmail(rs.getString("email")); + + if (projectionFilter.containsProperty("officialName", module)) + agency.setOfficialName(rs.getString("officialname")); + + if (projectionFilter.containsProperty("zipNumber", module)) + agency.setZipNumber(rs.getString("zipnumber")); + + if (projectionFilter.containsProperty("address", module)) + agency.setAddress(rs.getString("address")); + + if (projectionFilter.containsProperty("presidentPosition", module)) + agency.setPresidentPosition(rs.getString("presidentposition")); + + if (projectionFilter.containsProperty("presidentName", module)) + agency.setPresidentName(rs.getString("presidentname")); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/AttributionExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/AttributionExporter.java new file mode 100644 index 0000000..08a8c0f --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/AttributionExporter.java @@ -0,0 +1,138 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.AgencyProperty; +import org.citygml4j.ade.iur.model.urt.Attribution; +import org.citygml4j.ade.iur.model.urt.RouteProperty; +import org.citygml4j.ade.iur.model.urt.TripProperty; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class AttributionExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + private final String module; + private final PublicTransitExporter publicTransitExporter; + + public AttributionExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.ATTRIBUTION); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + + Select select = new Select().addProjection(table.getColumn("organizationname")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + if (projectionFilter.containsProperty("isProducer", module)) + select.addProjection(table.getColumn("isproducer")); + if (projectionFilter.containsProperty("isOperator", module)) + select.addProjection(table.getColumn("isoperator")); + if (projectionFilter.containsProperty("isAuthority", module)) + select.addProjection(table.getColumn("isauthority")); + if (projectionFilter.containsProperty("url", module)) + select.addProjection(table.getColumn("url")); + if (projectionFilter.containsProperty("email", module)) + select.addProjection(table.getColumn("email")); + if (projectionFilter.containsProperty("phoneNumber", module)) + select.addProjection(table.getColumn("phonenumber")); + if (projectionFilter.containsProperty("agency", module)) { + Table parent = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(parent.getColumn("gmlid", "agmlid")) + .addJoin(JoinFactory.left(parent, "id", ComparisonName.EQUAL_TO, table.getColumn("agency_id"))); + } + if (projectionFilter.containsProperty("route", module)) { + Table parent = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(parent.getColumn("gmlid", "rgmlid")) + .addJoin(JoinFactory.left(parent, "id", ComparisonName.EQUAL_TO, table.getColumn("route_id"))); + } + if (projectionFilter.containsProperty("trip", module)) { + Table parent = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(parent.getColumn("gmlid", "tgmlid")) + .addJoin(JoinFactory.left(parent, "id", ComparisonName.EQUAL_TO, table.getColumn("trip_id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Attribution attribution, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(attribution, projectionFilter, "pt", rs); + + attribution.setOrganizationName(rs.getString("organizationname")); + + if (projectionFilter.containsProperty("isProducer", module)) { + boolean isProducer = rs.getBoolean("isproducer"); + if (!rs.wasNull()) + attribution.setIsProducer(isProducer); + } + + if (projectionFilter.containsProperty("isOperator", module)) { + boolean isOperator = rs.getBoolean("isoperator"); + if (!rs.wasNull()) + attribution.setIsOperator(isOperator); + } + + if (projectionFilter.containsProperty("isAuthority", module)) { + boolean isAuthority = rs.getBoolean("isauthority"); + if (!rs.wasNull()) + attribution.setIsAuthority(isAuthority); + } + + if (projectionFilter.containsProperty("url", module)) + attribution.setUrl(rs.getString("url")); + + if (projectionFilter.containsProperty("email", module)) + attribution.setEmail(rs.getString("email")); + + if (projectionFilter.containsProperty("phoneNumber", module)) + attribution.setPhoneNumber(rs.getString("phonenumber")); + + if (projectionFilter.containsProperty("agency", module)) { + String gmlId = rs.getString("agmlid"); + if (gmlId != null) + attribution.setAgency(new AgencyProperty("#" + gmlId)); + } + + if (projectionFilter.containsProperty("route", module)) { + String gmlId = rs.getString("rgmlid"); + if (gmlId != null) + attribution.setRoute(new RouteProperty("#" + gmlId)); + } + + if (projectionFilter.containsProperty("trip", module)) { + String gmlId = rs.getString("tgmlid"); + if (gmlId != null) + attribution.setTrip(new TripProperty("#" + gmlId)); + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/CalendarDateExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/CalendarDateExporter.java new file mode 100644 index 0000000..3f63973 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/CalendarDateExporter.java @@ -0,0 +1,86 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.CalendarDate; +import org.citygml4j.ade.iur.model.urt.CalendarProperty; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class CalendarDateExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + private final String module; + private final PublicTransitExporter publicTransitExporter; + + public CalendarDateExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.CALENDARDATE); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + + Select select = new Select().addProjection(table.getColumns("date_", "exceptiontype", "exceptiontype_codespace")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + if (projectionFilter.containsProperty("calendar", module)) { + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid", "cgmlid")) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, table.getColumn("calendar_id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(CalendarDate calendarDate, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(calendarDate, projectionFilter, "pt", rs); + + Date date = rs.getDate("date_"); + if (!rs.wasNull()) + calendarDate.setDate(date.toLocalDate()); + + String exceptionType = rs.getString("exceptiontype"); + if (!rs.wasNull()) { + Code code = new Code(exceptionType); + code.setCodeSpace(rs.getString("exceptiontype_codespace")); + calendarDate.setExceptionType(code); + } + + if (projectionFilter.containsProperty("calendar", module)) { + String gmlId = rs.getString("cgmlid"); + if (gmlId != null) + calendarDate.setCalendar(new CalendarProperty("#" + gmlId)); + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/CalendarExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/CalendarExporter.java new file mode 100644 index 0000000..7056fb8 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/CalendarExporter.java @@ -0,0 +1,75 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.urt.Calendar; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class CalendarExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + private final PublicTransitExporter publicTransitExporter; + + public CalendarExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.CALENDAR); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + + Select select = new Select().addProjection(table.getColumns("monday", "tuesday", "wednesday", "thursday", + "friday", "saturday", "sunday", "startdate", "enddate")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Calendar calendar, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(calendar, projectionFilter, "pt", rs); + + calendar.setMonday(rs.getBoolean("monday")); + calendar.setTuesday(rs.getBoolean("tuesday")); + calendar.setWednesday(rs.getBoolean("wednesday")); + calendar.setThursday(rs.getBoolean("thursday")); + calendar.setFriday(rs.getBoolean("friday")); + calendar.setSaturday(rs.getBoolean("saturday")); + calendar.setSunday(rs.getBoolean("sunday")); + + Date startDate = rs.getDate("startdate"); + if (!rs.wasNull()) + calendar.setStartDate(startDate.toLocalDate()); + + Date endDate = rs.getDate("enddate"); + if (!rs.wasNull()) + calendar.setEndDate(endDate.toLocalDate()); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/CityObjectGroupPropertiesExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/CityObjectGroupPropertiesExporter.java new file mode 100644 index 0000000..5120484 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/CityObjectGroupPropertiesExporter.java @@ -0,0 +1,127 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.ObjectMapper; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.FeatureType; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citygml4j.ade.iur.model.module.PublicTransitModule; +import org.citygml4j.ade.iur.model.urt.DataTypeProperty; +import org.citygml4j.ade.iur.model.urt.FareRule; +import org.citygml4j.ade.iur.model.urt.FeedInfo; +import org.citygml4j.ade.iur.model.urt.Frequency; +import org.citygml4j.ade.iur.model.urt.PublicTransitDataType; +import org.citygml4j.ade.iur.model.urt.PublicTransitDataTypeProperty; +import org.citygml4j.ade.iur.model.urt.StopTime; +import org.citygml4j.ade.iur.model.urt.Transfer; +import org.citygml4j.ade.iur.model.urt.Translation; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class CityObjectGroupPropertiesExporter implements PublicTransitModuleExporter { + private final CityGMLExportHelper helper; + private final ObjectMapper objectMapper; + private final PreparedStatement ps; + private final String module; + + private final FareRuleExporter fareRuleExporter; + private final FeedInfoExporter feedInfoExporter; + private final FrequencyExporter frequencyExporter; + private final StopTimeExporter stopTimeExporter; + private final TransferExporter transferExporter; + private final TranslationExporter translationExporter; + + public CityObjectGroupPropertiesExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + this.helper = helper; + this.objectMapper = manager.getObjectMapper(); + + String tableName = manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSITDATATYPE); + module = PublicTransitModule.v1_4.getNamespaceURI(); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Select select = new Select().addProjection(table.getColumns("id", "objectclass_id")) + .addSelection(ComparisonFactory.equalTo(table.getColumn("cityobjectgroup_datatype_id"), new PlaceHolder<>())); + + ps = connection.prepareStatement(select.toString()); + + fareRuleExporter = manager.getExporter(FareRuleExporter.class); + feedInfoExporter = manager.getExporter(FeedInfoExporter.class); + frequencyExporter = manager.getExporter(FrequencyExporter.class); + stopTimeExporter = manager.getExporter(StopTimeExporter.class); + transferExporter = manager.getExporter(TransferExporter.class); + translationExporter = manager.getExporter(TranslationExporter.class); + } + + public void doExport(CityObjectGroup parent, long parentId, FeatureType parentType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + if (projectionFilter.containsProperty("dataType", module)) { + ps.setLong(1, parentId); + + try (ResultSet rs = ps.executeQuery()) { + while (rs.next()) { + long objectId = rs.getLong(1); + int objectClassId = rs.getInt(2); + if (!rs.wasNull()) { + PublicTransitDataType dataType = objectMapper.createType(objectClassId, PublicTransitDataType.class); + if (dataType == null) { + helper.logOrThrowErrorMessage("Failed to instantiate public transit data type (id: " + objectId + ")."); + continue; + } + + if (dataType instanceof FareRule) + fareRuleExporter.doExport((FareRule) dataType, objectId); + else if (dataType instanceof FeedInfo) + feedInfoExporter.doExport((FeedInfo) dataType, objectId); + else if (dataType instanceof Frequency) + frequencyExporter.doExport((Frequency) dataType, objectId); + else if (dataType instanceof StopTime) + stopTimeExporter.doExport((StopTime) dataType, objectId); + else if (dataType instanceof Transfer) + transferExporter.doExport((Transfer) dataType, objectId); + else if (dataType instanceof Translation) + translationExporter.doExport((Translation) dataType, objectId); + + DataTypeProperty property = new DataTypeProperty(new PublicTransitDataTypeProperty(dataType)); + parent.addGenericApplicationPropertyOfCityObjectGroup(property); + } + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/FareAttributeExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/FareAttributeExporter.java new file mode 100644 index 0000000..663b984 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/FareAttributeExporter.java @@ -0,0 +1,108 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.AgencyProperty; +import org.citygml4j.ade.iur.model.urt.FareAttribute; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class FareAttributeExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + private final String module; + private final PublicTransitExporter publicTransitExporter; + + public FareAttributeExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.FAREATTRIBUTE); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + + Select select = new Select().addProjection(table.getColumns("price", "currencytype", "currencytype_codespace", + "paymentmethod", "paymentmethod_codespace", "transfers", "transfers_codespace")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + if (projectionFilter.containsProperty("transferDuration", module)) + select.addProjection(table.getColumn("transferduration")); + if (projectionFilter.containsProperty("agency", module)) { + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid", "agmlid")) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, table.getColumn("agency_id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(FareAttribute fareAttribute, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(fareAttribute, projectionFilter, "pt", rs); + + double price = rs.getDouble("price"); + if (!rs.wasNull()) + fareAttribute.setPrice(price); + + String currencyType = rs.getString("currencytype"); + if (!rs.wasNull()) { + Code code = new Code(currencyType); + code.setCodeSpace(rs.getString("currencytype_codespace")); + fareAttribute.setCurrencyType(code); + } + + String paymentMethod = rs.getString("paymentmethod"); + if (!rs.wasNull()) { + Code code = new Code(paymentMethod); + code.setCodeSpace(rs.getString("paymentmethod_codespace")); + fareAttribute.setPaymentMethod(code); + } + + String transfers = rs.getString("transfers"); + if (!rs.wasNull()) { + Code code = new Code(transfers); + code.setCodeSpace(rs.getString("transfers_codespace")); + fareAttribute.setTransfers(code); + } + + if (projectionFilter.containsProperty("transferDuration", module)) { + int transferDuration = rs.getInt("transferduration"); + if (!rs.wasNull()) + fareAttribute.setTransferDuration(transferDuration); + } + + if (projectionFilter.containsProperty("agency", module)) { + String gmlId = rs.getString("agmlid"); + if (gmlId != null) + fareAttribute.setAgency(new AgencyProperty("#" + gmlId)); + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/FareRuleExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/FareRuleExporter.java new file mode 100644 index 0000000..fa58238 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/FareRuleExporter.java @@ -0,0 +1,106 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.urt.FareAttributeProperty; +import org.citygml4j.ade.iur.model.urt.FareRule; +import org.citygml4j.ade.iur.model.urt.RouteProperty; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class FareRuleExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + + public FareRuleExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.FARERULE); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table fare = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + Table route = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + + Select select = new Select().addProjection(table.getColumns("containsid", "containsid_codespace", "destinationid", + "destinationid_codespace", "originid", "originid_codespace")) + .addProjection(fare.getColumn("gmlid", "fgmlid"), route.getColumn("gmlid", "rgmlid")) + .addJoin(JoinFactory.left(fare, "id", ComparisonName.EQUAL_TO, table.getColumn("fare_id"))) + .addJoin(JoinFactory.left(route, "id", ComparisonName.EQUAL_TO, table.getColumn("route_id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(FareRule fareRule, long objectId) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + String originId = rs.getString("originid"); + if (!rs.wasNull()) { + Code code = new Code(originId); + code.setCodeSpace(rs.getString("originid_codespace")); + fareRule.setOriginId(code); + } + + String destinationId = rs.getString("destinationid"); + if (!rs.wasNull()) { + Code code = new Code(destinationId); + code.setCodeSpace(rs.getString("destinationid_codespace")); + fareRule.setDestinationId(code); + } + + String containsId = rs.getString("containsid"); + if (!rs.wasNull()) { + Code code = new Code(containsId); + code.setCodeSpace(rs.getString("containsid_codespace")); + fareRule.setContainsId(code); + } + + String fareGmlId = rs.getString("fgmlid"); + if (fareGmlId != null) + fareRule.setFare(new FareAttributeProperty("#" + fareGmlId)); + + String routeGmlId = rs.getString("rgmlid"); + if (routeGmlId != null) + fareRule.setRoute(new RouteProperty("#" + routeGmlId)); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/FeedInfoExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/FeedInfoExporter.java new file mode 100644 index 0000000..474e73a --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/FeedInfoExporter.java @@ -0,0 +1,98 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citygml4j.ade.iur.model.urt.FeedInfo; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class FeedInfoExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + + public FeedInfoExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.FEEDINFO); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Select select = new Select().addProjection(table.getColumns("contactemail", "contacturl", "defaultlanguage", + "defaultlanguage_codespace", "detailedinfo", "enddate", "language", "language_codespace", + "publishername", "publisherurl", "startdate", "version")) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(FeedInfo feedInfo, long objectId) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + feedInfo.setPublisherName(rs.getString("publishername")); + feedInfo.setPublisherUrl(rs.getString("publisherurl")); + + String language = rs.getString("language"); + if (!rs.wasNull()) { + Code code = new Code(language); + code.setCodeSpace(rs.getString("language_codespace")); + feedInfo.setLanguage(code); + } + + String defaultLanguage = rs.getString("defaultlanguage"); + if (!rs.wasNull()) { + Code code = new Code(defaultLanguage); + code.setCodeSpace(rs.getString("defaultlanguage_codespace")); + feedInfo.setDefaultLanguage(code); + } + + Date startDate = rs.getDate("startdate"); + if (!rs.wasNull()) + feedInfo.setStartDate(startDate.toLocalDate()); + + Date endDate = rs.getDate("enddate"); + if (!rs.wasNull()) + feedInfo.setEndDate(endDate.toLocalDate()); + + feedInfo.setVersion(rs.getString("version")); + feedInfo.setContactEmail(rs.getString("contactemail")); + feedInfo.setContactURL(rs.getString("contacturl")); + feedInfo.setDetailedInfo(rs.getString("detailedinfo")); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/FrequencyExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/FrequencyExporter.java new file mode 100644 index 0000000..0498884 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/FrequencyExporter.java @@ -0,0 +1,98 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.urt.Frequency; +import org.citygml4j.ade.iur.model.urt.TripProperty; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Time; + +public class FrequencyExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + + public FrequencyExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.FREQUENCY); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table trip = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + + Select select = new Select().addProjection(table.getColumns("endtime", "exacttimes", "exacttimes_codespace", + "headwaysecs", "starttime")) + .addProjection(trip.getColumn("gmlid", "tgmlid")) + .addJoin(JoinFactory.left(trip, "id", ComparisonName.EQUAL_TO, table.getColumn("trip_id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Frequency frequency, long objectId) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + Time startTime = rs.getTime("starttime"); + if (!rs.wasNull()) + frequency.setStartTime(startTime.toLocalTime()); + + Time endTime = rs.getTime("endtime"); + if (!rs.wasNull()) + frequency.setEndTime(endTime.toLocalTime()); + + int headwaySecs = rs.getInt("headwaysecs"); + if (!rs.wasNull()) + frequency.setHeadwaySecs(headwaySecs); + + String exactTimes = rs.getString("exacttimes"); + if (!rs.wasNull()) { + Code code = new Code(exactTimes); + code.setCodeSpace(rs.getString("exacttimes_codespace")); + frequency.setExactTimes(code); + } + + String tripGmlId = rs.getString("tgmlid"); + if (tripGmlId != null) + frequency.setTrip(new TripProperty("#" + tripGmlId)); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/LevelExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/LevelExporter.java new file mode 100644 index 0000000..25b69d9 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/LevelExporter.java @@ -0,0 +1,53 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citygml4j.ade.iur.model.urt.Level; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class LevelExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + private final PublicTransitExporter publicTransitExporter; + + public LevelExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Select select = publicTransitExporter.addProjection(new Select(), table, projectionFilter, "pt") + .addProjection(table.getColumn("index_")) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Level level, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(level, projectionFilter, "pt", rs); + level.setIndex(rs.getDouble("index_")); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/OfficeExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/OfficeExporter.java new file mode 100644 index 0000000..653b236 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/OfficeExporter.java @@ -0,0 +1,72 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.Office; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class OfficeExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + private final String module; + private final PublicTransitExporter publicTransitExporter; + + public OfficeExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.OFFICE); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + + Select select = new Select().addProjection(table.getColumn("name")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + if (projectionFilter.containsProperty("url", module)) + select.addProjection(table.getColumn("url")); + if (projectionFilter.containsProperty("phone", module)) + select.addProjection(table.getColumn("phone")); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Office office, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(office, projectionFilter, "pt", rs); + + office.setOfficeName(rs.getString("name")); + + if (projectionFilter.containsProperty("url", module)) + office.setUrl(rs.getString("url")); + + if (projectionFilter.containsProperty("phone", module)) + office.setUrl(rs.getString("phone")); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/PathwayExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/PathwayExporter.java new file mode 100644 index 0000000..1be0a21 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/PathwayExporter.java @@ -0,0 +1,148 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.Pathway; +import org.citygml4j.ade.iur.model.urt.StopProperty; +import org.citygml4j.model.gml.basicTypes.Code; +import org.citygml4j.model.gml.measures.Length; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class PathwayExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + private final String module; + private final PublicTransitExporter publicTransitExporter; + + public PathwayExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.PATHWAY); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + Table from = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + Table to = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + + Select select = new Select().addProjection(table.getColumns("isbidirectional", "isbidirectional_codespace")) + .addProjection(from.getColumn("gmlid", "fgmlid"), to.getColumn("gmlid", "tgmlid")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(from, "id", ComparisonName.EQUAL_TO, table.getColumn("from_id"))) + .addJoin(JoinFactory.left(to, "id", ComparisonName.EQUAL_TO, table.getColumn("to_id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + if (projectionFilter.containsProperty("mode", module)) + select.addProjection(table.getColumns("mode_", "mode_codespace")); + if (projectionFilter.containsProperty("length", module)) + select.addProjection(table.getColumns("length", "length_uom")); + if (projectionFilter.containsProperty("traversalTime", module)) + select.addProjection(table.getColumn("traversaltime")); + if (projectionFilter.containsProperty("stairCount", module)) + select.addProjection(table.getColumn("staircount")); + if (projectionFilter.containsProperty("maxSlope", module)) + select.addProjection(table.getColumn("maxslope")); + if (projectionFilter.containsProperty("minWidth", module)) + select.addProjection(table.getColumn("minwidth")); + if (projectionFilter.containsProperty("signpostedAs", module)) + select.addProjection(table.getColumn("signpostedas")); + if (projectionFilter.containsProperty("reversedSignpostedAs", module)) + select.addProjection(table.getColumn("reversedsignpostedas")); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Pathway pathway, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(pathway, projectionFilter, "pt", rs); + + String isBidirectional = rs.getString("isbidirectional"); + if (!rs.wasNull()) { + Code code = new Code(isBidirectional); + code.setCodeSpace(rs.getString("isbidirectional_codespace")); + pathway.setIsBidirectional(code); + } + + String fromGmlId = rs.getString("fgmlid"); + if (fromGmlId != null) + pathway.setFrom(new StopProperty("#" + fromGmlId)); + + String toGmlId = rs.getString("tgmlid"); + if (toGmlId != null) + pathway.setTo(new StopProperty("#" + toGmlId)); + + if (projectionFilter.containsProperty("mode", module)) { + String mode = rs.getString("mode_"); + if (!rs.wasNull()) { + Code code = new Code(mode); + code.setCodeSpace(rs.getString("mode_codespace")); + pathway.setMode(code); + } + } + + if (projectionFilter.containsProperty("length", module)) { + double lengthValue = rs.getDouble("length"); + if (!rs.wasNull()) { + Length length = new Length(lengthValue); + length.setUom(rs.getString("length_uom")); + pathway.setLength(length); + } + } + + if (projectionFilter.containsProperty("traversalTime", module)) { + int traversalTime = rs.getInt("traversaltime"); + if (!rs.wasNull()) + pathway.setTraversalTime(traversalTime); + } + + if (projectionFilter.containsProperty("stairCount", module)) { + int stairCount = rs.getInt("staircount"); + if (!rs.wasNull()) + pathway.setStairCount(stairCount); + } + + if (projectionFilter.containsProperty("maxSlope", module)) { + double maxSlope = rs.getDouble("maxslope"); + if (!rs.wasNull()) + pathway.setMaxSlope(maxSlope); + } + + if (projectionFilter.containsProperty("minWidth", module)) { + double minWidth = rs.getDouble("minwidth"); + if (!rs.wasNull()) + pathway.setMinWidth(minWidth); + } + + if (projectionFilter.containsProperty("signpostedAs", module)) + pathway.setSignpostedAs(rs.getString("signpostedas")); + + if (projectionFilter.containsProperty("reversedSignpostedAs", module)) + pathway.setSignpostedAs(rs.getString("reversedsignpostedas")); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/PublicTransitExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/PublicTransitExporter.java new file mode 100644 index 0000000..9dc6a68 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/PublicTransitExporter.java @@ -0,0 +1,69 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; +import org.citygml4j.ade.iur.model.urt.PublicTransit; +import org.citygml4j.ade.iur.model.urt.TargetProperty; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class PublicTransitExporter implements PublicTransitModuleExporter { + private final CityGMLExportHelper helper; + private final PreparedStatement ps; + private final String module; + + public PublicTransitExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + this.helper = helper; + + String tableName = manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = UrbanFunctionModule.v1_4.getNamespaceURI(); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Select select = addProjection(new Select(), table, projectionFilter, "") + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public Select addProjection(Select select, Table table, CombinedProjectionFilter projectionFilter, String prefix) { + select.addProjection(table.getColumn("id", prefix + "id"), table.getColumn("orgid", prefix + "orgid")); + if (projectionFilter.containsProperty("target", module)) { + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(table.getColumn("target_id", prefix + "target_id"), + cityObject.getColumn("gmlid", prefix + "gmlid")) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, table.getColumn("target_id"))); + } + + return select; + } + + public void doExport(PublicTransit publicTransit, ProjectionFilter projectionFilter, String prefix, ResultSet rs) throws CityGMLExportException, SQLException { + publicTransit.setOrgId(rs.getString(prefix + "orgid")); + + if (projectionFilter.containsProperty("target", module)) { + String gmlId = rs.getString(prefix + "gmlid"); + if (gmlId != null) + publicTransit.setTarget(new TargetProperty("#" + gmlId)); + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/PublicTransitModuleExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/PublicTransitModuleExporter.java new file mode 100644 index 0000000..ae74827 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/PublicTransitModuleExporter.java @@ -0,0 +1,6 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.ADEExporter; + +public interface PublicTransitModuleExporter extends ADEExporter { +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/RouteExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/RouteExporter.java new file mode 100644 index 0000000..71b28ad --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/RouteExporter.java @@ -0,0 +1,209 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.citygml.exporter.database.content.GMLConverter; +import org.citydb.config.geometry.GeometryObject; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.AgencyProperty; +import org.citygml4j.ade.iur.model.urt.Description; +import org.citygml4j.ade.iur.model.urt.Route; +import org.citygml4j.ade.iur.model.urt.RouteProperty; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class RouteExporter implements PublicTransitModuleExporter { + private final CityGMLExportHelper helper; + private final PreparedStatement ps; + private final String module; + + private final PublicTransitExporter publicTransitExporter; + private final GMLConverter gmlConverter; + + public RouteExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + this.helper = helper; + + String tableName = manager.getSchemaMapper().getTableName(ADETable.ROUTE); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + gmlConverter = helper.getGMLConverter(); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + Table agency = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + + Select select = new Select().addProjection(table.getColumns("type", "type_codespace")) + .addProjection(agency.getColumn("gmlid", "agmlid")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(agency, "id", ComparisonName.EQUAL_TO, table.getColumn("agency_id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + if (projectionFilter.containsProperty("shortName", module)) + select.addProjection(table.getColumn("shortname")); + if (projectionFilter.containsProperty("longName", module)) + select.addProjection(table.getColumn("longname")); + if (projectionFilter.containsProperty("url", module)) + select.addProjection(table.getColumn("url")); + if (projectionFilter.containsProperty("color", module)) + select.addProjection(table.getColumn("color")); + if (projectionFilter.containsProperty("textColor", module)) + select.addProjection(table.getColumn("textcolor")); + if (projectionFilter.containsProperty("updateDate", module)) + select.addProjection(table.getColumn("updatedate")); + if (projectionFilter.containsProperty("originStop", module)) + select.addProjection(table.getColumn("originstop")); + if (projectionFilter.containsProperty("viaStop", module)) + select.addProjection(table.getColumn("viastop")); + if (projectionFilter.containsProperty("destinationStop", module)) + select.addProjection(table.getColumn("destinationstop")); + if (projectionFilter.containsProperty("routeSortOrder", module)) + select.addProjection(table.getColumn("routesortorder")); + if (projectionFilter.containsProperty("continuousPickup", module)) + select.addProjection(table.getColumns("continuouspickup", "continuouspickup_codespace")); + if (projectionFilter.containsProperty("continuousDropOff", module)) + select.addProjection(table.getColumns("continuousdropoff", "continuousdropoff_codespace")); + if (helper.getLodFilter().isEnabled(0) && projectionFilter.containsProperty("lod0MultiCurve", module)) + select.addProjection(table.getColumn("lod0multicurve")); + if (projectionFilter.containsProperty("parentRoute", module)) { + Table parent = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(parent.getColumn("gmlid", "pgmlid")) + .addJoin(JoinFactory.left(parent, "id", ComparisonName.EQUAL_TO, table.getColumn("parentroute_id"))); + } + if (projectionFilter.containsProperty("description", module)) { + Table description = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.DESCRIPTION))); + select.addProjection(table.getColumn("description_id")) + .addProjection(description.getColumns("description", "frequencyofservice", "numberofcustomers")) + .addJoin(JoinFactory.left(description, "id", ComparisonName.EQUAL_TO, table.getColumn("description_id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Route route, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(route, projectionFilter, "pt", rs); + + String type = rs.getString("type"); + if (!rs.wasNull()) { + Code code = new Code(type); + code.setCodeSpace(rs.getString("type_codespace")); + route.setType(code); + } + + String agencyGmlId = rs.getString("agmlid"); + if (agencyGmlId != null) + route.setAgency(new AgencyProperty("#" + agencyGmlId)); + + if (projectionFilter.containsProperty("shortName", module)) + route.setShortName(rs.getString("shortname")); + + if (projectionFilter.containsProperty("longName", module)) + route.setLongName(rs.getString("longname")); + + if (projectionFilter.containsProperty("url", module)) + route.setUrl(rs.getString("url")); + + if (projectionFilter.containsProperty("color", module)) + route.setColor(rs.getString("color")); + + if (projectionFilter.containsProperty("textColor", module)) + route.setTextColor(rs.getString("textcolor")); + + Date updateDate = rs.getDate("updatedate"); + if (!rs.wasNull()) + route.setUpdateDate(updateDate.toLocalDate()); + + if (projectionFilter.containsProperty("originStop", module)) + route.setOriginStop(rs.getString("originstop")); + + if (projectionFilter.containsProperty("viaStop", module)) + route.setViaStop(rs.getString("viastop")); + + if (projectionFilter.containsProperty("destinationStop", module)) + route.setDestinationStop(rs.getString("destinationstop")); + + if (projectionFilter.containsProperty("routeSortOrder", module)) { + int routeSortOrder = rs.getInt("routesortorder"); + if (!rs.wasNull()) + route.setRouteSortOrder(routeSortOrder); + } + + if (projectionFilter.containsProperty("continuousPickup", module)) { + String continuousPickup = rs.getString("continuouspickup"); + if (!rs.wasNull()) { + Code code = new Code(continuousPickup); + code.setCodeSpace(rs.getString("continuouspickup_codespace")); + route.setContinuousPickup(code); + } + } + + if (projectionFilter.containsProperty("continuousDropOff", module)) { + String continuousDropOff = rs.getString("continuousdropoff"); + if (!rs.wasNull()) { + Code code = new Code(continuousDropOff); + code.setCodeSpace(rs.getString("continuousdropoff_codespace")); + route.setContinuousDropOff(code); + } + } + + if (helper.getLodFilter().isEnabled(0) + && projectionFilter.containsProperty("lod0MultiCurve", module)) { + Object geometry = rs.getObject("lod0multicurve"); + if (!rs.wasNull()) { + GeometryObject multiCurve = helper.getDatabaseAdapter().getGeometryConverter().getMultiCurve(geometry); + route.setLod0MultiCurve(gmlConverter.getMultiCurveProperty(multiCurve)); + } + } + + if (projectionFilter.containsProperty("parentRoute", module)) { + String gmlId = rs.getString("pgmlid"); + if (gmlId != null) + route.setParentRoute(new RouteProperty("#" + gmlId)); + } + + if (projectionFilter.containsProperty("description", module)) { + rs.getLong("description_id"); + if (!rs.wasNull()) { + Description description = new Description(); + + description.setDescription(rs.getString("description")); + + int frequencyOfService = rs.getInt("frequencyofservice"); + if (!rs.wasNull()) + description.setFrequencyOfService(frequencyOfService); + + int numberOfCustomers = rs.getInt("numberofcustomers"); + if (!rs.wasNull()) + description.setNumberOfCustomers(numberOfCustomers); + } + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/ShapeExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/ShapeExporter.java new file mode 100644 index 0000000..434e12c --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/ShapeExporter.java @@ -0,0 +1,102 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.citygml.exporter.database.content.GMLConverter; +import org.citydb.config.geometry.GeometryObject; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.Point; +import org.citygml4j.ade.iur.model.urt.PointProperty; +import org.citygml4j.ade.iur.model.urt.Shape; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ShapeExporter implements PublicTransitModuleExporter { + private final CityGMLExportHelper helper; + private final PreparedStatement ps; + private final String module; + + private final PublicTransitExporter publicTransitExporter; + private final GMLConverter gmlConverter; + + public ShapeExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + this.helper = helper; + + String tableName = manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + gmlConverter = helper.getGMLConverter(); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Select select = publicTransitExporter.addProjection(new Select(), table, projectionFilter, "pt") + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + if (projectionFilter.containsProperty("point", module)) { + Table point = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.POINT))); + select.addProjection(point.getColumns("latitude", "longitude", "point", "pointdistancetraveled", "pointsequence")) + .addJoin(JoinFactory.left(point, "publictransit_point_id", ComparisonName.EQUAL_TO, table.getColumn("id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Shape shape, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + boolean isInitialized = false; + + while (rs.next()) { + if (!isInitialized) { + publicTransitExporter.doExport(shape, projectionFilter, "pt", rs); + isInitialized = true; + } + + Point point = new Point(); + + double latitude = rs.getDouble("latitude"); + if (!rs.wasNull()) + point.setLatitude(latitude); + + double longitude = rs.getDouble("longitude"); + if (!rs.wasNull()) + point.setLongitude(longitude); + + Object geometry = rs.getObject("point"); + if (!rs.wasNull()) { + GeometryObject pointGeometry = helper.getDatabaseAdapter().getGeometryConverter().getPoint(geometry); + point.setPoint(gmlConverter.getPointProperty(pointGeometry)); + } + + int pointSequence = rs.getInt("pointsequence"); + if (!rs.wasNull()) + point.setPointSequence(pointSequence); + + double pointDistanceTraveled = rs.getDouble("pointdistancetraveled"); + if (!rs.wasNull()) + point.setPointDistanceTraveled(pointDistanceTraveled); + + shape.getPoints().add(new PointProperty(point)); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/StopExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/StopExporter.java new file mode 100644 index 0000000..417646b --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/StopExporter.java @@ -0,0 +1,189 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.citygml.exporter.database.content.GMLConverter; +import org.citydb.config.geometry.GeometryObject; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.LevelProperty; +import org.citygml4j.ade.iur.model.urt.Stop; +import org.citygml4j.ade.iur.model.urt.StopProperty; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class StopExporter implements PublicTransitModuleExporter { + private final CityGMLExportHelper helper; + private final PreparedStatement ps; + private final String module; + + private final PublicTransitExporter publicTransitExporter; + private final GMLConverter gmlConverter; + + public StopExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + this.helper = helper; + + String tableName = manager.getSchemaMapper().getTableName(ADETable.STOP); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + gmlConverter = helper.getGMLConverter(); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + + Select select = new Select().addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + if (projectionFilter.containsProperty("code", module)) + select.addProjection(table.getColumns("code", "code_codespace")); + if (projectionFilter.containsProperty("ttsName", module)) + select.addProjection(table.getColumn("ttsname")); + if (projectionFilter.containsProperty("latitude", module)) + select.addProjection(table.getColumn("latitude")); + if (projectionFilter.containsProperty("longitude", module)) + select.addProjection(table.getColumn("longitude")); + if (projectionFilter.containsProperty("zoneId", module)) + select.addProjection(table.getColumns("zoneid", "zoneid_codespace")); + if (projectionFilter.containsProperty("url", module)) + select.addProjection(table.getColumn("url")); + if (projectionFilter.containsProperty("locationType", module)) + select.addProjection(table.getColumns("locationtype", "locationtype_codespace")); + if (projectionFilter.containsProperty("timeZone", module)) + select.addProjection(table.getColumns("timezone", "timezone_codespace")); + if (projectionFilter.containsProperty("wheelchairBoarding", module)) + select.addProjection(table.getColumns("wheelchairboarding", "wheelchairboarding_codespace")); + if (projectionFilter.containsProperty("platformCode", module)) + select.addProjection(table.getColumn("platformcode")); + if (projectionFilter.containsProperty("point", module)) + select.addProjection(table.getColumn("point")); + if (projectionFilter.containsProperty("level", module)) { + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid", "lgmlid")) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, table.getColumn("level_id"))); + } + if (projectionFilter.containsProperty("parentStation", module)) { + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid", "pgmlid")) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, table.getColumn("parentstation_id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Stop stop, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(stop, projectionFilter, "pt", rs); + + if (projectionFilter.containsProperty("code", module)) { + String codeValue = rs.getString("code"); + if (!rs.wasNull()) { + Code code = new Code(codeValue); + code.setCodeSpace(rs.getString("code_codespace")); + stop.setCode(code); + } + } + + if (projectionFilter.containsProperty("ttsName", module)) + stop.setTtsName(rs.getString("ttsname")); + + if (projectionFilter.containsProperty("latitude", module)) { + double latitude = rs.getDouble("latitude"); + if (!rs.wasNull()) + stop.setLatitude(latitude); + } + + if (projectionFilter.containsProperty("longitude", module)) { + double longitude = rs.getDouble("longitude"); + if (!rs.wasNull()) + stop.setLongitude(longitude); + } + + if (projectionFilter.containsProperty("zoneId", module)) { + String zoneId = rs.getString("zoneid"); + if (!rs.wasNull()) { + Code code = new Code(zoneId); + code.setCodeSpace(rs.getString("zoneid_codespace")); + stop.setZoneId(code); + } + } + + if (projectionFilter.containsProperty("url", module)) + stop.setUrl(rs.getString("url")); + + if (projectionFilter.containsProperty("locationType", module)) { + String locationType = rs.getString("locationtype"); + if (!rs.wasNull()) { + Code code = new Code(locationType); + code.setCodeSpace(rs.getString("locationtype_codespace")); + stop.setLocationType(code); + } + } + + if (projectionFilter.containsProperty("timeZone", module)) { + String timeZone = rs.getString("timezone"); + if (!rs.wasNull()) { + Code code = new Code(timeZone); + code.setCodeSpace(rs.getString("timezone_codespace")); + stop.setTimeZone(code); + } + } + + if (projectionFilter.containsProperty("wheelchairBoarding", module)) { + String wheelchairBoarding = rs.getString("wheelchairboarding"); + if (!rs.wasNull()) { + Code code = new Code(wheelchairBoarding); + code.setCodeSpace(rs.getString("wheelchairboarding_codespace")); + stop.setWheelchairBoarding(code); + } + } + + if (projectionFilter.containsProperty("platformCode", module)) + stop.setPlatformCode(rs.getString("platformcode")); + + if (projectionFilter.containsProperty("point", module)) { + Object geometry = rs.getObject("point"); + if (!rs.wasNull()) { + GeometryObject point = helper.getDatabaseAdapter().getGeometryConverter().getPoint(geometry); + stop.setPoint(gmlConverter.getPointProperty(point)); + } + } + + if (projectionFilter.containsProperty("level", module)) { + String gmlId = rs.getString("lgmlid"); + if (gmlId != null) + stop.setLevel(new LevelProperty("#" + gmlId)); + } + + if (projectionFilter.containsProperty("parentStation", module)) { + String gmlId = rs.getString("pgmlid"); + if (gmlId != null) + stop.setParentStation(new StopProperty("#" + gmlId)); + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/StopTimeExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/StopTimeExporter.java new file mode 100644 index 0000000..1e29ca7 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/StopTimeExporter.java @@ -0,0 +1,141 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.urt.StopProperty; +import org.citygml4j.ade.iur.model.urt.StopTime; +import org.citygml4j.ade.iur.model.urt.TripProperty; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Time; + +public class StopTimeExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + + public StopTimeExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.STOPTIME); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table stop = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + Table trip = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + + Select select = new Select().addProjection(table.getColumns("arrivaltime", "continuousdropofftype", + "continuousdropofft_codespace", "continuouspickuptype", "continuouspickupty_codespace", "departuretime", + "dropofftype", "dropofftype_codespace", "headsign", "pickuptype", "pickuptype_codespace", + "shapedistancetraveled", "stopsequence", "timepoint", "timepoint_codespace")) + .addProjection(stop.getColumn("gmlid", "sgmlid"), trip.getColumn("gmlid", "tgmlid")) + .addJoin(JoinFactory.left(stop, "id", ComparisonName.EQUAL_TO, table.getColumn("stop_id"))) + .addJoin(JoinFactory.left(trip, "id", ComparisonName.EQUAL_TO, table.getColumn("trip_id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(StopTime stopTime, long objectId) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + Time arrivalTime = rs.getTime("arrivaltime"); + if (!rs.wasNull()) + stopTime.setArrivalTime(arrivalTime.toLocalTime()); + + Time departureTime = rs.getTime("departuretime"); + if (!rs.wasNull()) + stopTime.setDepartureTime(departureTime.toLocalTime()); + + int stopSequence = rs.getInt("stopsequence"); + if (!rs.wasNull()) + stopTime.setStopSequence(stopSequence); + + stopTime.setHeadsign(rs.getString("headsign")); + + String pickupType = rs.getString("pickuptype"); + if (!rs.wasNull()) { + Code code = new Code(pickupType); + code.setCodeSpace(rs.getString("pickuptype_codespace")); + stopTime.setPickupType(code); + } + + String dropoffType = rs.getString("dropofftype"); + if (!rs.wasNull()) { + Code code = new Code(dropoffType); + code.setCodeSpace(rs.getString("dropofftype_codespace")); + stopTime.setDropoffType(code); + } + + String continuousPickupType = rs.getString("continuouspickuptype"); + if (!rs.wasNull()) { + Code code = new Code(continuousPickupType); + code.setCodeSpace(rs.getString("continuouspickupty_codespace")); + stopTime.setContinuousPickupType(code); + } + + String continuousDropoffType = rs.getString("continuousdropofftype"); + if (!rs.wasNull()) { + Code code = new Code(continuousDropoffType); + code.setCodeSpace(rs.getString("continuousdropofft_codespace")); + stopTime.setContinuousDropoffType(code); + } + + double shapeDistanceTraveled = rs.getDouble("shapedistancetraveled"); + if (!rs.wasNull()) + stopTime.setShapeDistanceTraveled(shapeDistanceTraveled); + + String timePoint = rs.getString("timepoint"); + if (!rs.wasNull()) { + Code code = new Code(timePoint); + code.setCodeSpace(rs.getString("timepoint_codespace")); + stopTime.setTimePoint(code); + } + + String tripGmlId = rs.getString("tgmlid"); + if (tripGmlId != null) + stopTime.setTrip(new TripProperty("#" + tripGmlId)); + + String stopGmlId = rs.getString("sgmlid"); + if (stopGmlId != null) + stopTime.setStop(new StopProperty("#" + stopGmlId)); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/TransferExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/TransferExporter.java new file mode 100644 index 0000000..37e7942 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/TransferExporter.java @@ -0,0 +1,94 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.urt.StopProperty; +import org.citygml4j.ade.iur.model.urt.Transfer; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class TransferExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + + public TransferExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.TRANSFER); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table from = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + Table to = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + + Select select = new Select().addProjection(table.getColumns("mintransfertime", "transfertype", "transfertype_codespace")) + .addProjection(from.getColumn("gmlid", "fgmlid"), to.getColumn("gmlid", "tgmlid")) + .addJoin(JoinFactory.left(from, "id", ComparisonName.EQUAL_TO, table.getColumn("from_id"))) + .addJoin(JoinFactory.left(to, "id", ComparisonName.EQUAL_TO, table.getColumn("to_id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Transfer transfer, long objectId) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + String transferType = rs.getString("transfertype"); + if (!rs.wasNull()) { + Code code = new Code(transferType); + code.setCodeSpace(rs.getString("transfertype_codespace")); + transfer.setTransferType(code); + } + + int minTransferTime = rs.getInt("mintransfertime"); + if (!rs.wasNull()) + transfer.setMinTransferTime(minTransferTime); + + String fromGmlId = rs.getString("fgmlid"); + if (fromGmlId != null) + transfer.setFrom(new StopProperty("#" + fromGmlId)); + + String toGmlId = rs.getString("tgmlid"); + if (toGmlId != null) + transfer.setTo(new StopProperty("#" + toGmlId)); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/TranslationExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/TranslationExporter.java new file mode 100644 index 0000000..d384e04 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/TranslationExporter.java @@ -0,0 +1,99 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.urt.PublicTransitProperty; +import org.citygml4j.ade.iur.model.urt.Translation; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class TranslationExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + + public TranslationExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.TRANSLATION); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table trip = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + + Select select = new Select().addProjection(table.getColumns("fieldname", "fieldvalue", "language", + "language_codespace", "recordsubid", "tablename", "tablename_codespace", "translation")) + .addProjection(trip.getColumn("gmlid", "rgmlid")) + .addJoin(JoinFactory.left(trip, "id", ComparisonName.EQUAL_TO, table.getColumn("recordid_id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Translation translation, long objectId) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + String tableName = rs.getString("tablename"); + if (!rs.wasNull()) { + Code code = new Code(tableName); + code.setCodeSpace(rs.getString("tablename_codespace")); + translation.setTableName(code); + } + + translation.setFieldName(rs.getString("fieldname")); + + String language = rs.getString("language"); + if (!rs.wasNull()) { + Code code = new Code(language); + code.setCodeSpace(rs.getString("language_codespace")); + translation.setLanguage(code); + } + + translation.setTranslation(rs.getString("translation")); + translation.setFieldValue(rs.getString("fieldvalue")); + + String recordId = rs.getString("rgmlid"); + if (recordId != null) + translation.setRecordId(new PublicTransitProperty("#" + recordId)); + + translation.setRecordSubId(rs.getString("recordsubid")); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/TranslationJPExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/TranslationJPExporter.java new file mode 100644 index 0000000..54187d8 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/TranslationJPExporter.java @@ -0,0 +1,67 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.urt.TranslationJP; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class TranslationJPExporter implements PublicTransitModuleExporter { + private final PreparedStatement ps; + private final PublicTransitExporter publicTransitExporter; + + public TranslationJPExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + String tableName = manager.getSchemaMapper().getTableName(ADETable.TRANSLATIONJP); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + + Select select = new Select().addProjection(table.getColumns("language", "language_codespace", "translation")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(TranslationJP translationJP, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(translationJP, projectionFilter, "pt", rs); + + String language = rs.getString("language"); + if (!rs.wasNull()) { + Code code = new Code(language); + code.setCodeSpace(rs.getString("language_codespace")); + translationJP.setLanguage(code); + } + + translationJP.setTranslation(rs.getString("translation")); + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/exporter/urt/TripExporter.java b/src/main/java/org/citydb/ade/iur/exporter/urt/TripExporter.java new file mode 100644 index 0000000..76f78b5 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/exporter/urt/TripExporter.java @@ -0,0 +1,189 @@ +package org.citydb.ade.iur.exporter.urt; + +import org.citydb.ade.exporter.CityGMLExportHelper; +import org.citydb.ade.iur.exporter.ExportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.exporter.CityGMLExportException; +import org.citydb.citygml.exporter.database.content.GMLConverter; +import org.citydb.config.geometry.GeometryObject; +import org.citydb.database.schema.mapping.AbstractType; +import org.citydb.database.schema.mapping.MappingConstants; +import org.citydb.query.filter.projection.CombinedProjectionFilter; +import org.citydb.query.filter.projection.ProjectionFilter; +import org.citydb.sqlbuilder.expression.PlaceHolder; +import org.citydb.sqlbuilder.schema.Table; +import org.citydb.sqlbuilder.select.Select; +import org.citydb.sqlbuilder.select.join.JoinFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonFactory; +import org.citydb.sqlbuilder.select.operator.comparison.ComparisonName; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.urt.CalendarDateProperty; +import org.citygml4j.ade.iur.model.urt.CalendarProperty; +import org.citygml4j.ade.iur.model.urt.OfficeProperty; +import org.citygml4j.ade.iur.model.urt.RouteProperty; +import org.citygml4j.ade.iur.model.urt.ShapeProperty; +import org.citygml4j.ade.iur.model.urt.Trip; +import org.citygml4j.model.gml.basicTypes.Code; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class TripExporter implements PublicTransitModuleExporter { + private final CityGMLExportHelper helper; + private final PreparedStatement ps; + private final String module; + + private final PublicTransitExporter publicTransitExporter; + private final GMLConverter gmlConverter; + + public TripExporter(Connection connection, CityGMLExportHelper helper, ExportManager manager) throws CityGMLExportException, SQLException { + this.helper = helper; + + String tableName = manager.getSchemaMapper().getTableName(ADETable.TRIP); + CombinedProjectionFilter projectionFilter = helper.getCombinedProjectionFilter(tableName); + module = StatisticalGridModule.v1_4.getNamespaceURI(); + + publicTransitExporter = manager.getExporter(PublicTransitExporter.class); + gmlConverter = helper.getGMLConverter(); + + Table table = new Table(helper.getTableNameWithSchema(tableName)); + Table publicTransit = new Table(helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT))); + Table route = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + + Select select = new Select().addProjection(route.getColumn("gmlid", "rgmlid")) + .addJoin(JoinFactory.inner(publicTransit, "id", ComparisonName.EQUAL_TO, table.getColumn("id"))) + .addJoin(JoinFactory.left(route, "id", ComparisonName.EQUAL_TO, table.getColumn("route_id"))) + .addSelection(ComparisonFactory.equalTo(table.getColumn("id"), new PlaceHolder<>())); + publicTransitExporter.addProjection(select, publicTransit, projectionFilter, "pt"); + if (projectionFilter.containsProperty("headsign", module)) + select.addProjection(table.getColumn("headsign")); + if (projectionFilter.containsProperty("shortName", module)) + select.addProjection(table.getColumn("shortname")); + if (projectionFilter.containsProperty("directionId", module)) + select.addProjection(table.getColumns("directionid", "directionid_codespace")); + if (projectionFilter.containsProperty("blockId", module)) + select.addProjection(table.getColumn("blockid")); + if (projectionFilter.containsProperty("wheelchairAccessible", module)) + select.addProjection(table.getColumns("wheelchairaccessible", "wheelchairaccessib_codespace")); + if (projectionFilter.containsProperty("bikeAllowed", module)) + select.addProjection(table.getColumns("bikeallowed", "bikeallowed_codespace")); + if (projectionFilter.containsProperty("symbol", module)) + select.addProjection(table.getColumn("symbol")); + if (helper.getLodFilter().isEnabled(0) && projectionFilter.containsProperty("lod0MultiCurve", module)) + select.addProjection(table.getColumn("lod0multicurve")); + if (projectionFilter.containsProperty("calendar", module)) { + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid", "cgmlid")) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, table.getColumn("calendar_id"))); + } + if (projectionFilter.containsProperty("calendarDate", module)) { + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid", "cdgmlid")) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, table.getColumn("calendardate_id"))); + } + if (projectionFilter.containsProperty("office", module)) { + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid", "ogmlid")) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, table.getColumn("office_id"))); + } + if (projectionFilter.containsProperty("shape", module)) { + Table cityObject = new Table(helper.getTableNameWithSchema(MappingConstants.CITYOBJECT)); + select.addProjection(cityObject.getColumn("gmlid", "sgmlid")) + .addJoin(JoinFactory.left(cityObject, "id", ComparisonName.EQUAL_TO, table.getColumn("shape_id"))); + } + ps = connection.prepareStatement(select.toString()); + } + + public void doExport(Trip trip, long objectId, AbstractType objectType, ProjectionFilter projectionFilter) throws CityGMLExportException, SQLException { + ps.setLong(1, objectId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + publicTransitExporter.doExport(trip, projectionFilter, "pt", rs); + + String routeGmlId = rs.getString("rgmlid"); + if (routeGmlId != null) + trip.setRoute(new RouteProperty("#" + routeGmlId)); + + if (projectionFilter.containsProperty("headsign", module)) + trip.setHeadsign(rs.getString("headsign")); + + if (projectionFilter.containsProperty("shortName", module)) + trip.setShortName(rs.getString("shortname")); + + if (projectionFilter.containsProperty("directionId", module)) { + String directionId = rs.getString("directionid"); + if (!rs.wasNull()) { + Code code = new Code(directionId); + code.setCodeSpace(rs.getString("directionid_codespace")); + trip.setDirectionId(code); + } + } + + if (projectionFilter.containsProperty("blockId", module)) + trip.setBlockId(rs.getString("blockid")); + + if (projectionFilter.containsProperty("wheelchairAccessible", module)) { + String wheelchairAccessible = rs.getString("wheelchairaccessible"); + if (!rs.wasNull()) { + Code code = new Code(wheelchairAccessible); + code.setCodeSpace(rs.getString("wheelchairaccessib_codespace")); + trip.setWheelchairAccessible(code); + } + } + + if (projectionFilter.containsProperty("bikeAllowed", module)) { + String bikeAllowed = rs.getString("bikeallowed"); + if (!rs.wasNull()) { + Code code = new Code(bikeAllowed); + code.setCodeSpace(rs.getString("bikeallowed_codespace")); + trip.setBikeAllowed(code); + } + } + + if (projectionFilter.containsProperty("symbol", module)) + trip.setBlockId(rs.getString("symbol")); + + if (helper.getLodFilter().isEnabled(0) + && projectionFilter.containsProperty("lod0MultiCurve", module)) { + Object geometry = rs.getObject("lod0multicurve"); + if (!rs.wasNull()) { + GeometryObject multiCurve = helper.getDatabaseAdapter().getGeometryConverter().getMultiCurve(geometry); + trip.setLod0MultiCurve(gmlConverter.getMultiCurveProperty(multiCurve)); + } + } + + if (projectionFilter.containsProperty("calendar", module)) { + String gmlId = rs.getString("cgmlid"); + if (gmlId != null) + trip.setCalendar(new CalendarProperty("#" + gmlId)); + } + + if (projectionFilter.containsProperty("calendarDate", module)) { + String gmlId = rs.getString("cdgmlid"); + if (gmlId != null) + trip.setCalendarDate(new CalendarDateProperty("#" + gmlId)); + } + + if (projectionFilter.containsProperty("office", module)) { + String gmlId = rs.getString("ogmlid"); + if (gmlId != null) + trip.setOffice(new OfficeProperty("#" + gmlId)); + } + + if (projectionFilter.containsProperty("shape", module)) { + String gmlId = rs.getString("sgmlid"); + if (gmlId != null) + trip.setShape(new ShapeProperty("#" + gmlId)); + } + } + } + } + + @Override + public void close() throws CityGMLExportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/ImportManager.java b/src/main/java/org/citydb/ade/iur/importer/ImportManager.java index d47b6d8..44068d2 100644 --- a/src/main/java/org/citydb/ade/iur/importer/ImportManager.java +++ b/src/main/java/org/citydb/ade/iur/importer/ImportManager.java @@ -29,54 +29,101 @@ import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; import org.citydb.ade.iur.importer.urf.CensusBlockImporter; +import org.citydb.ade.iur.importer.urf.DevelopmentProjectImporter; import org.citydb.ade.iur.importer.urf.DisasterDamageImporter; import org.citydb.ade.iur.importer.urf.LegalGroundsImporter; import org.citydb.ade.iur.importer.urf.PollutionImporter; -import org.citydb.ade.iur.importer.urf.PublicTransitImporter; +import org.citydb.ade.iur.importer.urf.PublicTransportationFacilityImporter; import org.citydb.ade.iur.importer.urf.RecreationsImporter; import org.citydb.ade.iur.importer.urf.UrbanFunctionImporter; +import org.citydb.ade.iur.importer.urf.UrbanFunctionModuleImporter; import org.citydb.ade.iur.importer.urf.UrbanFunctionToCityObjectImporter; +import org.citydb.ade.iur.importer.urf.UrbanizationImporter; +import org.citydb.ade.iur.importer.urf.ZoneImporter; +import org.citydb.ade.iur.importer.urg.AreaOfAnnualDiversionsImporter; import org.citydb.ade.iur.importer.urg.HouseholdsImporter; +import org.citydb.ade.iur.importer.urg.LandPriceImporter; import org.citydb.ade.iur.importer.urg.LandPricePerLandUseImporter; +import org.citydb.ade.iur.importer.urg.LandUseDiversionImporter; import org.citydb.ade.iur.importer.urg.NumberOfAnnualDiversionsImporter; -import org.citydb.ade.iur.importer.urg.NumberOfHouseholdsImporter; import org.citydb.ade.iur.importer.urg.OfficesAndEmployeesImporter; import org.citydb.ade.iur.importer.urg.PopulationByAgeAndSexImporter; import org.citydb.ade.iur.importer.urg.PopulationImporter; import org.citydb.ade.iur.importer.urg.StatisticalGridImporter; +import org.citydb.ade.iur.importer.urg.StatisticalGridModuleImporter; import org.citydb.ade.iur.importer.uro.BuildingDetailsImporter; import org.citydb.ade.iur.importer.uro.BuildingPropertiesImporter; -import org.citydb.ade.iur.importer.uro.CityObjectGroupPropertiesImporter; import org.citydb.ade.iur.importer.uro.LandUsePropertiesImporter; import org.citydb.ade.iur.importer.uro.LargeCustomerFacilitiesImporter; import org.citydb.ade.iur.importer.uro.TrafficVolumeImporter; import org.citydb.ade.iur.importer.uro.TransportationComplexPropertiesImporter; +import org.citydb.ade.iur.importer.uro.UrbanObjectModuleImporter; +import org.citydb.ade.iur.importer.urt.AgencyImporter; +import org.citydb.ade.iur.importer.urt.AttributionImporter; +import org.citydb.ade.iur.importer.urt.CalendarDateImporter; +import org.citydb.ade.iur.importer.urt.CalendarImporter; +import org.citydb.ade.iur.importer.urt.DescriptionImporter; +import org.citydb.ade.iur.importer.urt.FareAttributeImporter; +import org.citydb.ade.iur.importer.urt.FareRuleImporter; +import org.citydb.ade.iur.importer.urt.FeedInfoImporter; +import org.citydb.ade.iur.importer.urt.FrequencyImporter; +import org.citydb.ade.iur.importer.urt.OfficeImporter; +import org.citydb.ade.iur.importer.urt.PathwayImporter; +import org.citydb.ade.iur.importer.urt.PointImporter; +import org.citydb.ade.iur.importer.urt.PublicTransitDataTypeImporter; +import org.citydb.ade.iur.importer.urt.PublicTransitImporter; +import org.citydb.ade.iur.importer.urt.PublicTransitModuleImporter; +import org.citydb.ade.iur.importer.urt.RouteImporter; +import org.citydb.ade.iur.importer.urt.StopImporter; +import org.citydb.ade.iur.importer.urt.StopTimeImporter; +import org.citydb.ade.iur.importer.urt.TransferImporter; +import org.citydb.ade.iur.importer.urt.TranslationImporter; +import org.citydb.ade.iur.importer.urt.TranslationJPImporter; +import org.citydb.ade.iur.importer.urt.TripImporter; import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.ObjectMapper; import org.citydb.ade.iur.schema.SchemaMapper; import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.database.schema.mapping.AbstractObjectType; import org.citydb.database.schema.mapping.FeatureType; -import org.citygml4j.model.citygml.ade.binding.ADEModelObject; -import org.citygml4j.model.citygml.building.AbstractBuilding; -import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; -import org.citygml4j.model.citygml.landuse.LandUse; -import org.citygml4j.model.citygml.transportation.TransportationComplex; -import org.citygml4j.model.gml.feature.AbstractFeature; -import org.w3c.dom.Node; -import org.citydb.ade.iur.importer.urf.DevelopmentProjectImporter; -import org.citydb.ade.iur.importer.urf.UrbanizationImporter; +import org.citygml4j.ade.iur.model.module.PublicTransitModule; +import org.citygml4j.ade.iur.model.module.StatisticalGridModule; +import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; import org.citygml4j.ade.iur.model.urf.CensusBlock; import org.citygml4j.ade.iur.model.urf.DevelopmentProject; import org.citygml4j.ade.iur.model.urf.DisasterDamage; import org.citygml4j.ade.iur.model.urf.Pollution; -import org.citygml4j.ade.iur.model.urf.PublicTransit; +import org.citygml4j.ade.iur.model.urf.PublicTransportationFacility; import org.citygml4j.ade.iur.model.urf.Recreations; import org.citygml4j.ade.iur.model.urf.UrbanFunction; import org.citygml4j.ade.iur.model.urf.Urbanization; +import org.citygml4j.ade.iur.model.urf.Zone; import org.citygml4j.ade.iur.model.urg.Households; +import org.citygml4j.ade.iur.model.urg.LandPrice; +import org.citygml4j.ade.iur.model.urg.LandUseDiversion; import org.citygml4j.ade.iur.model.urg.OfficesAndEmployees; import org.citygml4j.ade.iur.model.urg.Population; import org.citygml4j.ade.iur.model.urg.StatisticalGrid; +import org.citygml4j.ade.iur.model.urt.Agency; +import org.citygml4j.ade.iur.model.urt.Attribution; +import org.citygml4j.ade.iur.model.urt.Calendar; +import org.citygml4j.ade.iur.model.urt.CalendarDate; +import org.citygml4j.ade.iur.model.urt.DataTypeProperty; +import org.citygml4j.ade.iur.model.urt.FareAttribute; +import org.citygml4j.ade.iur.model.urt.Office; +import org.citygml4j.ade.iur.model.urt.Pathway; +import org.citygml4j.ade.iur.model.urt.PublicTransit; +import org.citygml4j.ade.iur.model.urt.Route; +import org.citygml4j.ade.iur.model.urt.Stop; +import org.citygml4j.ade.iur.model.urt.TranslationJP; +import org.citygml4j.ade.iur.model.urt.Trip; +import org.citygml4j.model.citygml.ade.binding.ADEModelObject; +import org.citygml4j.model.citygml.building.AbstractBuilding; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; +import org.citygml4j.model.citygml.landuse.LandUse; +import org.citygml4j.model.citygml.transportation.TransportationComplex; +import org.citygml4j.model.gml.feature.AbstractFeature; +import org.w3c.dom.Node; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; @@ -93,6 +140,7 @@ public class ImportManager implements ADEImportManager { private final ADEExtension adeExtension; + private final ObjectMapper objectMapper; private final SchemaMapper schemaMapper; private final Map, ADEImporter> importers; @@ -100,8 +148,9 @@ public class ImportManager implements ADEImportManager { private CityGMLImportHelper helper; private Transformer transformer; - public ImportManager(ADEExtension adeExtension, SchemaMapper schemaMapper) { + public ImportManager(ADEExtension adeExtension, ObjectMapper objectMapper, SchemaMapper schemaMapper) { this.adeExtension = adeExtension; + this.objectMapper = objectMapper; this.schemaMapper = schemaMapper; importers = new HashMap<>(); } @@ -114,30 +163,64 @@ public void init(Connection connection, CityGMLImportHelper helper) throws CityG @Override public void importObject(ADEModelObject object, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { - if (object instanceof CensusBlock) - getImporter(CensusBlockImporter.class).doImport((CensusBlock) object, objectId, objectType, foreignKeys); - else if (object instanceof DevelopmentProject) - getImporter(DevelopmentProjectImporter.class).doImport((DevelopmentProject) object, objectId, objectType, foreignKeys); - else if (object instanceof DisasterDamage) - getImporter(DisasterDamageImporter.class).doImport((DisasterDamage) object, objectId, objectType, foreignKeys); - else if (object instanceof Pollution) - getImporter(PollutionImporter.class).doImport((Pollution) object, objectId, objectType, foreignKeys); - else if (object instanceof PublicTransit) - getImporter(PublicTransitImporter.class).doImport((PublicTransit) object, objectId, objectType, foreignKeys); - else if (object instanceof Recreations) - getImporter(RecreationsImporter.class).doImport((Recreations) object, objectId, objectType, foreignKeys); - else if (object instanceof Urbanization) - getImporter(UrbanizationImporter.class).doImport((Urbanization) object, objectId, objectType, foreignKeys); - else if (object instanceof UrbanFunction) - getImporter(UrbanFunctionImporter.class).doImport((UrbanFunction) object, objectId, objectType, foreignKeys); - else if (object instanceof Households) - getImporter(HouseholdsImporter.class).doImport((Households) object, objectId, objectType, foreignKeys); - else if (object instanceof OfficesAndEmployees) - getImporter(OfficesAndEmployeesImporter.class).doImport((OfficesAndEmployees) object, objectId, objectType, foreignKeys); - else if (object instanceof Population) - getImporter(PopulationImporter.class).doImport((Population) object, objectId, objectType, foreignKeys); - else if (object instanceof StatisticalGrid) - getImporter(StatisticalGridImporter.class).doImport((StatisticalGrid) object, objectId, objectType, foreignKeys); + if (UrbanFunctionModule.v1_4.getModelPackageName().equals(object.getClass().getPackage().getName())) { + if (object instanceof CensusBlock) + getImporter(CensusBlockImporter.class).doImport((CensusBlock) object, objectId, objectType, foreignKeys); + else if (object instanceof DevelopmentProject) + getImporter(DevelopmentProjectImporter.class).doImport((DevelopmentProject) object, objectId, objectType, foreignKeys); + else if (object instanceof DisasterDamage) + getImporter(DisasterDamageImporter.class).doImport((DisasterDamage) object, objectId, objectType, foreignKeys); + else if (object instanceof Pollution) + getImporter(PollutionImporter.class).doImport((Pollution) object, objectId, objectType, foreignKeys); + else if (object instanceof PublicTransportationFacility) + getImporter(PublicTransportationFacilityImporter.class).doImport((PublicTransportationFacility) object, objectId, objectType, foreignKeys); + else if (object instanceof Recreations) + getImporter(RecreationsImporter.class).doImport((Recreations) object, objectId, objectType, foreignKeys); + else if (object instanceof Urbanization) + getImporter(UrbanizationImporter.class).doImport((Urbanization) object, objectId, objectType, foreignKeys); + else if (object instanceof Zone) + getImporter(ZoneImporter.class).doImport((Zone) object, objectId, objectType, foreignKeys); + else if (object instanceof UrbanFunction) + getImporter(UrbanFunctionImporter.class).doImport((UrbanFunction) object, objectId, objectType, foreignKeys); + } else if (StatisticalGridModule.v1_4.getModelPackageName().equals(object.getClass().getPackage().getName())) { + if (object instanceof Households) + getImporter(HouseholdsImporter.class).doImport((Households) object, objectId, objectType, foreignKeys); + else if (object instanceof LandPrice) + getImporter(LandPriceImporter.class).doImport((LandPrice) object, objectId, objectType, foreignKeys); + else if (object instanceof LandUseDiversion) + getImporter(LandUseDiversionImporter.class).doImport((LandUseDiversion) object, objectId, objectType, foreignKeys); + else if (object instanceof OfficesAndEmployees) + getImporter(OfficesAndEmployeesImporter.class).doImport((OfficesAndEmployees) object, objectId, objectType, foreignKeys); + else if (object instanceof Population) + getImporter(PopulationImporter.class).doImport((Population) object, objectId, objectType, foreignKeys); + else if (object instanceof StatisticalGrid) + getImporter(StatisticalGridImporter.class).doImport((StatisticalGrid) object, objectId, objectType, foreignKeys); + } else if (PublicTransitModule.v1_4.getModelPackageName().equals(object.getClass().getPackage().getName())) { + if (object instanceof Agency) + getImporter(AgencyImporter.class).doImport((Agency) object, objectId, objectType, foreignKeys); + else if (object instanceof Attribution) + getImporter(AttributionImporter.class).doImport((Attribution) object, objectId, objectType, foreignKeys); + else if (object instanceof Calendar) + getImporter(CalendarImporter.class).doImport((Calendar) object, objectId, objectType, foreignKeys); + else if (object instanceof CalendarDate) + getImporter(CalendarDateImporter.class).doImport((CalendarDate) object, objectId, objectType, foreignKeys); + else if (object instanceof FareAttribute) + getImporter(FareAttributeImporter.class).doImport((FareAttribute) object, objectId, objectType, foreignKeys); + else if (object instanceof Office) + getImporter(OfficeImporter.class).doImport((Office) object, objectId, objectType, foreignKeys); + else if (object instanceof Pathway) + getImporter(PathwayImporter.class).doImport((Pathway) object, objectId, objectType, foreignKeys); + else if (object instanceof Route) + getImporter(RouteImporter.class).doImport((Route) object, objectId, objectType, foreignKeys); + else if (object instanceof Stop) + getImporter(StopImporter.class).doImport((Stop) object, objectId, objectType, foreignKeys); + else if (object instanceof TranslationJP) + getImporter(TranslationJPImporter.class).doImport((TranslationJP) object, objectId, objectType, foreignKeys); + else if (object instanceof Trip) + getImporter(TripImporter.class).doImport((Trip) object, objectId, objectType, foreignKeys); + else if (object instanceof PublicTransit) + getImporter(PublicTransitImporter.class).doImport((PublicTransit) object, objectId, objectType, foreignKeys); + } } @Override @@ -148,8 +231,22 @@ else if (parent instanceof LandUse) getImporter(LandUsePropertiesImporter.class).doImport(properties, (LandUse) parent, parentId, parentType); else if (parent instanceof TransportationComplex) getImporter(TransportationComplexPropertiesImporter.class).doImport(properties, (TransportationComplex) parent, parentId, parentType); - else if (parent instanceof CityObjectGroup) - getImporter(CityObjectGroupPropertiesImporter.class).doImport(properties, (CityObjectGroup) parent, parentId, parentType); + else if (parent instanceof CityObjectGroup) { + if (properties.containsOneOf(org.citygml4j.ade.iur.model.urf.FiscalYearOfPublicationProperty.class, + org.citygml4j.ade.iur.model.urf.LanguageProperty.class)) { + getImporter(org.citydb.ade.iur.importer.urf.CityObjectGroupPropertiesImporter.class).doImport(properties, (CityObjectGroup) parent, parentId, parentType); + } + if (properties.containsOneOf(org.citygml4j.ade.iur.model.urg.FiscalYearOfPublicationProperty.class, + org.citygml4j.ade.iur.model.urg.LanguageProperty.class)) { + getImporter(org.citydb.ade.iur.importer.urg.CityObjectGroupPropertiesImporter.class).doImport(properties, (CityObjectGroup) parent, parentId, parentType); + } + if (properties.containsOneOf(org.citygml4j.ade.iur.model.uro.FiscalYearOfPublicationProperty.class, + org.citygml4j.ade.iur.model.uro.LanguageProperty.class)) { + getImporter(org.citydb.ade.iur.importer.uro.CityObjectGroupPropertiesImporter.class).doImport(properties, (CityObjectGroup) parent, parentId, parentType); + } + if (properties.contains(DataTypeProperty.class)) + getImporter(org.citydb.ade.iur.importer.urt.CityObjectGroupPropertiesImporter.class).doImport(properties, (CityObjectGroup) parent, parentId, parentType); + } } @Override @@ -161,7 +258,6 @@ public void executeBatch(String tableName) throws CityGMLImportException, SQLExc importer.executeBatch(); } else throw new CityGMLImportException("The table " + tableName + " is not managed by the ADE extension for '" + adeExtension.getMetadata().getIdentifier() + "'."); - } @Override @@ -170,6 +266,10 @@ public void close() throws CityGMLImportException, SQLException { importer.close(); } + public ObjectMapper getObjectMapper() { + return objectMapper; + } + public SchemaMapper getSchemaMapper() { return schemaMapper; } @@ -194,63 +294,127 @@ public T getImporter(Class type) throws CityGMLImport ADEImporter importer = importers.get(type); if (importer == null) { - // urban function module - if (type == UrbanFunctionImporter.class) - importer = new UrbanFunctionImporter(connection, helper, this); - else if (type == DevelopmentProjectImporter.class) - importer = new DevelopmentProjectImporter(connection, helper, this); - else if (type == CensusBlockImporter.class) - importer = new CensusBlockImporter(connection, helper, this); - else if (type == DisasterDamageImporter.class) - importer = new DisasterDamageImporter(connection, helper, this); - else if (type == PollutionImporter.class) - importer = new PollutionImporter(connection, helper, this); - else if (type == PublicTransitImporter.class) - importer = new PublicTransitImporter(connection, helper, this); - else if (type == RecreationsImporter.class) - importer = new RecreationsImporter(connection, helper, this); - else if (type == UrbanizationImporter.class) - importer = new UrbanizationImporter(connection, helper, this); - else if (type == LegalGroundsImporter.class) - importer = new LegalGroundsImporter(connection, helper, this); - else if (type == org.citydb.ade.iur.importer.urf.NumberOfHouseholdsImporter.class) - importer = new org.citydb.ade.iur.importer.urf.NumberOfHouseholdsImporter(connection, helper, this); - else if (type == UrbanFunctionToCityObjectImporter.class) - importer = new UrbanFunctionToCityObjectImporter(connection, helper, this); - - // statistical grid module - else if (type == StatisticalGridImporter.class) - importer = new StatisticalGridImporter(connection, helper, this); - else if (type == HouseholdsImporter.class) - importer = new HouseholdsImporter(connection, helper, this); - else if (type == OfficesAndEmployeesImporter.class) - importer = new OfficesAndEmployeesImporter(connection, helper, this); - else if (type == PopulationImporter.class) - importer = new PopulationImporter(connection, helper, this); - else if (type == NumberOfHouseholdsImporter.class) - importer = new NumberOfHouseholdsImporter(connection, helper, this); - else if (type == LandPricePerLandUseImporter.class) - importer = new LandPricePerLandUseImporter(connection, helper, this); - else if (type == NumberOfAnnualDiversionsImporter.class) - importer = new NumberOfAnnualDiversionsImporter(connection, helper, this); - else if (type == PopulationByAgeAndSexImporter.class) - importer = new PopulationByAgeAndSexImporter(connection, helper, this); - - // urban object module - else if (type == BuildingPropertiesImporter.class) - importer = new BuildingPropertiesImporter(connection, helper, this); - else if (type == LandUsePropertiesImporter.class) - importer = new LandUsePropertiesImporter(connection, helper, this); - else if (type == TransportationComplexPropertiesImporter.class) - importer = new TransportationComplexPropertiesImporter(connection, helper, this); - else if (type == CityObjectGroupPropertiesImporter.class) - importer = new CityObjectGroupPropertiesImporter(connection, helper, this); - else if (type == BuildingDetailsImporter.class) - importer = new BuildingDetailsImporter(connection, helper, this); - else if (type == LargeCustomerFacilitiesImporter.class) - importer = new LargeCustomerFacilitiesImporter(connection, helper, this); - else if (type == TrafficVolumeImporter.class) - importer = new TrafficVolumeImporter(connection, helper, this); + if (UrbanFunctionModuleImporter.class.isAssignableFrom(type)) { + // urban function module + if (type == UrbanFunctionImporter.class) + importer = new UrbanFunctionImporter(connection, helper, this); + else if (type == DevelopmentProjectImporter.class) + importer = new DevelopmentProjectImporter(connection, helper, this); + else if (type == CensusBlockImporter.class) + importer = new CensusBlockImporter(connection, helper, this); + else if (type == DisasterDamageImporter.class) + importer = new DisasterDamageImporter(connection, helper, this); + else if (type == PollutionImporter.class) + importer = new PollutionImporter(connection, helper, this); + else if (type == PublicTransportationFacilityImporter.class) + importer = new PublicTransportationFacilityImporter(connection, helper, this); + else if (type == RecreationsImporter.class) + importer = new RecreationsImporter(connection, helper, this); + else if (type == UrbanizationImporter.class) + importer = new UrbanizationImporter(connection, helper, this); + else if (type == ZoneImporter.class) + importer = new ZoneImporter(connection, helper, this); + else if (type == LegalGroundsImporter.class) + importer = new LegalGroundsImporter(connection, helper, this); + else if (type == org.citydb.ade.iur.importer.urf.NumberOfHouseholdsImporter.class) + importer = new org.citydb.ade.iur.importer.urf.NumberOfHouseholdsImporter(connection, helper, this); + else if (type == org.citydb.ade.iur.importer.urf.CityObjectGroupPropertiesImporter.class) + importer = new org.citydb.ade.iur.importer.urf.CityObjectGroupPropertiesImporter(connection, helper, this); + else if (type == UrbanFunctionToCityObjectImporter.class) + importer = new UrbanFunctionToCityObjectImporter(connection, helper, this); + } else if (StatisticalGridModuleImporter.class.isAssignableFrom(type)) { + // statistical grid module + if (type == StatisticalGridImporter.class) + importer = new StatisticalGridImporter(connection, helper, this); + else if (type == HouseholdsImporter.class) + importer = new HouseholdsImporter(connection, helper, this); + else if (type == LandPriceImporter.class) + importer = new LandPriceImporter(connection, helper, this); + else if (type == LandUseDiversionImporter.class) + importer = new LandUseDiversionImporter(connection, helper, this); + else if (type == OfficesAndEmployeesImporter.class) + importer = new OfficesAndEmployeesImporter(connection, helper, this); + else if (type == PopulationImporter.class) + importer = new PopulationImporter(connection, helper, this); + else if (type == org.citydb.ade.iur.importer.urg.NumberOfHouseholdsImporter.class) + importer = new org.citydb.ade.iur.importer.urg.NumberOfHouseholdsImporter(connection, helper, this); + else if (type == LandPricePerLandUseImporter.class) + importer = new LandPricePerLandUseImporter(connection, helper, this); + else if (type == AreaOfAnnualDiversionsImporter.class) + importer = new AreaOfAnnualDiversionsImporter(connection, helper, this); + else if (type == NumberOfAnnualDiversionsImporter.class) + importer = new NumberOfAnnualDiversionsImporter(connection, helper, this); + else if (type == PopulationByAgeAndSexImporter.class) + importer = new PopulationByAgeAndSexImporter(connection, helper, this); + else if (type == org.citydb.ade.iur.importer.urg.KeyValuePairImporter.class) + importer = new org.citydb.ade.iur.importer.urg.KeyValuePairImporter(connection, helper, this); + else if (type == org.citydb.ade.iur.importer.urg.CityObjectGroupPropertiesImporter.class) + importer = new org.citydb.ade.iur.importer.urg.CityObjectGroupPropertiesImporter(connection, helper, this); + } else if (UrbanObjectModuleImporter.class.isAssignableFrom(type)) { + // urban object module + if (type == BuildingPropertiesImporter.class) + importer = new BuildingPropertiesImporter(connection, helper, this); + else if (type == LandUsePropertiesImporter.class) + importer = new LandUsePropertiesImporter(connection, helper, this); + else if (type == TransportationComplexPropertiesImporter.class) + importer = new TransportationComplexPropertiesImporter(connection, helper, this); + else if (type == org.citydb.ade.iur.importer.uro.CityObjectGroupPropertiesImporter.class) + importer = new org.citydb.ade.iur.importer.uro.CityObjectGroupPropertiesImporter(connection, helper, this); + else if (type == org.citydb.ade.iur.importer.uro.KeyValuePairImporter.class) + importer = new org.citydb.ade.iur.importer.uro.KeyValuePairImporter(connection, helper, this); + else if (type == BuildingDetailsImporter.class) + importer = new BuildingDetailsImporter(connection, helper, this); + else if (type == LargeCustomerFacilitiesImporter.class) + importer = new LargeCustomerFacilitiesImporter(connection, helper, this); + else if (type == TrafficVolumeImporter.class) + importer = new TrafficVolumeImporter(connection, helper, this); + } else if (PublicTransitModuleImporter.class.isAssignableFrom(type)) { + // public transit module + if (type == AgencyImporter.class) + importer = new AgencyImporter(connection, helper, this); + else if (type == AttributionImporter.class) + importer = new AttributionImporter(connection, helper, this); + else if (type == CalendarImporter.class) + importer = new CalendarImporter(connection, helper, this); + else if (type == CalendarDateImporter.class) + importer = new CalendarDateImporter(connection, helper, this); + else if (type == org.citydb.ade.iur.importer.urt.CityObjectGroupPropertiesImporter.class) + importer = new org.citydb.ade.iur.importer.urt.CityObjectGroupPropertiesImporter(connection, helper, this); + else if (type == DescriptionImporter.class) + importer = new DescriptionImporter(connection, helper, this); + else if (type == FareAttributeImporter.class) + importer = new FareAttributeImporter(connection, helper, this); + else if (type == FareRuleImporter.class) + importer = new FareRuleImporter(connection, helper, this); + else if (type == FeedInfoImporter.class) + importer = new FeedInfoImporter(connection, helper, this); + else if (type == FrequencyImporter.class) + importer = new FrequencyImporter(connection, helper, this); + else if (type == OfficeImporter.class) + importer = new OfficeImporter(connection, helper, this); + else if (type == PathwayImporter.class) + importer = new PathwayImporter(connection, helper, this); + else if (type == PointImporter.class) + importer = new PointImporter(connection, helper, this); + else if (type == PublicTransitDataTypeImporter.class) + importer = new PublicTransitDataTypeImporter(connection, helper, this); + else if (type == RouteImporter.class) + importer = new RouteImporter(connection, helper, this); + else if (type == StopImporter.class) + importer = new StopImporter(connection, helper, this); + else if (type == StopTimeImporter.class) + importer = new StopTimeImporter(connection, helper, this); + else if (type == TransferImporter.class) + importer = new TransferImporter(connection, helper, this); + else if (type == TranslationImporter.class) + importer = new TranslationImporter(connection, helper, this); + else if (type == TranslationJPImporter.class) + importer = new TranslationJPImporter(connection, helper, this); + else if (type == TripImporter.class) + importer = new TripImporter(connection, helper, this); + else if (type == PublicTransitImporter.class) + importer = new PublicTransitImporter(connection, helper, this); + } if (importer == null) throw new SQLException("Failed to build ADE importer of type " + type.getName() + "."); diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/CensusBlockImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/CensusBlockImporter.java index 2514ec8..949777b 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/CensusBlockImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/CensusBlockImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.AbstractObjectType; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; import org.citygml4j.ade.iur.model.urf.CensusBlock; import org.citygml4j.ade.iur.model.urf.NumberOfHouseholdsProperty; @@ -37,7 +36,7 @@ import java.sql.SQLException; import java.sql.Types; -public class CensusBlockImporter implements ADEImporter { +public class CensusBlockImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/CityObjectGroupPropertiesImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/CityObjectGroupPropertiesImporter.java new file mode 100644 index 0000000..7ddd00a --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urf/CityObjectGroupPropertiesImporter.java @@ -0,0 +1,95 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.importer.urf; + +import org.citydb.ade.importer.ADEPropertyCollection; +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.FeatureType; +import org.citygml4j.ade.iur.model.urf.FiscalYearOfPublicationProperty; +import org.citygml4j.ade.iur.model.urf.LanguageProperty; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; +import java.time.LocalDate; + +public class CityObjectGroupPropertiesImporter implements UrbanFunctionModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private int batchCounter; + + public CityObjectGroupPropertiesImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_2)) + " " + + "(id, fiscalyearofpublication, language, language_codespace) " + + "values (?, ?, ?, ?)"); + } + + public void doImport(ADEPropertyCollection properties, CityObjectGroup parent, long parentId, FeatureType parentType) throws CityGMLImportException, SQLException { + ps.setLong(1, parentId); + + FiscalYearOfPublicationProperty fiscalYearOfPublication = properties.getFirst(FiscalYearOfPublicationProperty.class); + if (fiscalYearOfPublication != null && fiscalYearOfPublication.isSetValue()) + ps.setDate(2, Date.valueOf(LocalDate.of(fiscalYearOfPublication.getValue().getValue(), 1, 1))); + else + ps.setNull(2, Types.DATE); + + LanguageProperty language = properties.getFirst(LanguageProperty.class); + if (language != null && language.isSetValue()) { + ps.setString(3, language.getValue().getValue()); + ps.setString(4, language.getValue().getCodeSpace()); + } else { + ps.setNull(3, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + } + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_2)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/DevelopmentProjectImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/DevelopmentProjectImporter.java index 56543da..acf8f81 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/DevelopmentProjectImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/DevelopmentProjectImporter.java @@ -22,7 +22,6 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; import org.citydb.ade.iur.importer.ImportManager; @@ -37,10 +36,10 @@ import java.sql.SQLException; import java.sql.Types; -public class DevelopmentProjectImporter implements ADEImporter { +public class DevelopmentProjectImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; - private final UrbanFunctionImporter urbanFunctionImporter; + private final ZoneImporter zoneImporter; private int batchCounter; @@ -54,11 +53,11 @@ public DevelopmentProjectImporter(Connection connection, CityGMLImportHelper hel "plannedarea, plannedarea_uom, status, status_codespace) " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - urbanFunctionImporter = manager.getImporter(UrbanFunctionImporter.class); + zoneImporter = manager.getImporter(ZoneImporter.class); } public void doImport(DevelopmentProject developmentProject, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { - urbanFunctionImporter.doImport(developmentProject, objectId, objectType, foreignKeys); + zoneImporter.doImport(developmentProject, objectId, objectType, foreignKeys); ps.setLong(1, objectId); if (developmentProject.getBenefitArea() != null && developmentProject.getBenefitArea().isSetValue()) { diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/DisasterDamageImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/DisasterDamageImporter.java index 796a173..f7e47c0 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/DisasterDamageImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/DisasterDamageImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.AbstractObjectType; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; import org.citygml4j.ade.iur.model.urf.DisasterDamage; import java.sql.Connection; @@ -36,7 +35,7 @@ import java.sql.SQLException; import java.sql.Types; -public class DisasterDamageImporter implements ADEImporter { +public class DisasterDamageImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; private final UrbanFunctionImporter urbanFunctionImporter; diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/LegalGroundsImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/LegalGroundsImporter.java index 55da65d..5c8d55c 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/LegalGroundsImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/LegalGroundsImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADESequence; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; import org.citygml4j.ade.iur.model.urf.LegalGrounds; import java.sql.Connection; @@ -37,7 +36,7 @@ import java.sql.SQLException; import java.sql.Types; -public class LegalGroundsImporter implements ADEImporter { +public class LegalGroundsImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/NumberOfHouseholdsImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/NumberOfHouseholdsImporter.java index 67c3ad6..ff92dfe 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/NumberOfHouseholdsImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/NumberOfHouseholdsImporter.java @@ -22,7 +22,6 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADESequence; @@ -36,7 +35,7 @@ import java.sql.SQLException; import java.sql.Types; -public class NumberOfHouseholdsImporter implements ADEImporter { +public class NumberOfHouseholdsImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/PollutionImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/PollutionImporter.java index a5e1747..2c63dd4 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/PollutionImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/PollutionImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.AbstractObjectType; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; import org.citygml4j.ade.iur.model.urf.Pollution; import java.sql.Connection; @@ -36,7 +35,7 @@ import java.sql.SQLException; import java.sql.Types; -public class PollutionImporter implements ADEImporter { +public class PollutionImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; private final UrbanFunctionImporter urbanFunctionImporter; diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/PublicTransitImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/PublicTransportationFacilityImporter.java similarity index 83% rename from src/main/java/org/citydb/ade/iur/importer/urf/PublicTransitImporter.java rename to src/main/java/org/citydb/ade/iur/importer/urf/PublicTransportationFacilityImporter.java index 41f7f3d..22352c1 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/PublicTransitImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/PublicTransportationFacilityImporter.java @@ -22,39 +22,38 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.AbstractObjectType; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; -import org.citygml4j.ade.iur.model.urf.PublicTransit; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urf.PublicTransportationFacility; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Types; -public class PublicTransitImporter implements ADEImporter { +public class PublicTransportationFacilityImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; private final UrbanFunctionImporter urbanFunctionImporter; private int batchCounter; - public PublicTransitImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + public PublicTransportationFacilityImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { this.helper = helper; ps = connection.prepareStatement("insert into " + - helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT)) + " " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSPORTATIONFA)) + " " + "(id, companyname, frequencyofservice, numberofcustomers, routename, sectionname) " + "values (?, ?, ?)"); urbanFunctionImporter = manager.getImporter(UrbanFunctionImporter.class); } - public void doImport(PublicTransit publicTransit, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + public void doImport(PublicTransportationFacility publicTransit, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { urbanFunctionImporter.doImport(publicTransit, objectId, objectType, foreignKeys); ps.setLong(1, objectId); diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/RecreationsImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/RecreationsImporter.java index bc35299..8ae86eb 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/RecreationsImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/RecreationsImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.AbstractObjectType; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; import org.citygml4j.ade.iur.model.urf.Recreations; import java.sql.Connection; @@ -36,7 +35,7 @@ import java.sql.SQLException; import java.sql.Types; -public class RecreationsImporter implements ADEImporter { +public class RecreationsImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; private final UrbanFunctionImporter urbanFunctionImporter; diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionImporter.java index ebe196c..be85d01 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionImporter.java @@ -22,24 +22,24 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.citygml.importer.database.content.GeometryConverter; import org.citydb.citygml.importer.util.AttributeValueJoiner; import org.citydb.config.geometry.GeometryObject; import org.citydb.database.schema.mapping.AbstractObjectType; -import org.citygml4j.model.citygml.core.AbstractCityObject; -import org.citygml4j.model.gml.basicTypes.Code; -import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty; -import org.citydb.ade.iur.importer.ImportManager; -import org.citydb.ade.iur.schema.ADETable; -import org.citydb.ade.iur.schema.SchemaMapper; import org.citygml4j.ade.iur.model.urf.DisasterPreventionBase; import org.citygml4j.ade.iur.model.urf.TargetProperty; import org.citygml4j.ade.iur.model.urf.UrbanFunction; -import org.citygml4j.ade.iur.model.urf.Zone; +import org.citygml4j.model.citygml.core.AbstractCityObject; +import org.citygml4j.model.gml.basicTypes.Code; +import org.citygml4j.model.gml.geometry.aggregates.MultiCurveProperty; +import org.citygml4j.model.gml.geometry.aggregates.MultiPointProperty; +import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty; import java.sql.Connection; import java.sql.Date; @@ -48,12 +48,11 @@ import java.sql.Types; import java.time.LocalDate; -public class UrbanFunctionImporter implements ADEImporter { +public class UrbanFunctionImporter implements UrbanFunctionModuleImporter { private final Connection connection; private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; - private final PreparedStatement psUrbanFunction; - private final PreparedStatement psZone; + private final PreparedStatement ps; private final LegalGroundsImporter legalGroundsImporter; private final UrbanFunctionToCityObjectImporter urbanFunctionToCityObjectImporter; @@ -67,19 +66,17 @@ public UrbanFunctionImporter(Connection connection, CityGMLImportHelper helper, this.helper = helper; this.schemaMapper = manager.getSchemaMapper(); - psUrbanFunction = connection.prepareStatement("insert into " + + ps = connection.prepareStatement("insert into " + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.URBANFUNCTION)) + " " + - "(id, objectclass_id, abstract, area_id, areaclassificationtype, areaclassification_codespace, boundary, " + - "city, city_codespace, class, class_codespace, custodian, enactmentdate, enactmentfiscalyear, " + - "expirationdate, expirationfiscalyear, function, function_codespace, legalgrounds_id, location, " + + "(id, objectclass_id, abstract, areaclassificationtype, areaclassification_codespace, city, city_codespace, " + + "class, class_codespace, custodian, enactmentdate, enactmentfiscalyear, expirationdate, expirationfiscalyear, " + + "function, function_codespace, legalgrounds_id, " + + "lod0multipoint, lod_1multipoint, lod_2multipoint, " + + "lod0multicurve, lod_1multicurve, lod_2multicurve, " + + "lod0multisurface_id, lod_1multisurface_id, lod_2multisurface_id, " + "nominalarea, nominalarea_uom, note, prefecture, prefecture_codespace, reference, surveyyear, urbanplantype, " + "urbanplantype_codespace, validity, capacity) " + - "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - - psZone = connection.prepareStatement("insert into " + - helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.ZONE)) + " " + - "(id, objectclass_id, areaapplied, finalpublicationdate) " + - "values (?, ?, ?, ?)"); + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); legalGroundsImporter = manager.getImporter(LegalGroundsImporter.class); urbanFunctionToCityObjectImporter = manager.getImporter(UrbanFunctionToCityObjectImporter.class); @@ -88,94 +85,64 @@ public UrbanFunctionImporter(Connection connection, CityGMLImportHelper helper, } public void doImport(UrbanFunction urbanFunction, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { - psUrbanFunction.setLong(1, objectId); - psUrbanFunction.setInt(2, objectType.getObjectClassId()); - - psUrbanFunction.setString(3, urbanFunction.getAbstract()); + ps.setLong(1, objectId); + ps.setInt(2, objectType.getObjectClassId()); - long areaId = 0; - if (urbanFunction.getArea() != null) { - MultiSurfaceProperty property = urbanFunction.getArea(); - if (property.isSetMultiSurface()) { - areaId = helper.importSurfaceGeometry(property.getMultiSurface(), objectId); - property.unsetMultiSurface(); - } else { - String href = property.getHref(); - if (href != null && !href.isEmpty()) - helper.propagateSurfaceGeometryXlink(href, schemaMapper.getTableName(ADETable.URBANFUNCTION), objectId, "area_id"); - } - } - - if (areaId != 0) - psUrbanFunction.setLong(4, areaId); - else - psUrbanFunction.setNull(4, Types.NULL); + ps.setString(3, urbanFunction.getAbstract()); if (urbanFunction.getAreaClassificationType() != null && urbanFunction.getAreaClassificationType().isSetValue()) { - psUrbanFunction.setString(5, urbanFunction.getAreaClassificationType().getValue()); - psUrbanFunction.setString(6, urbanFunction.getAreaClassificationType().getCodeSpace()); + ps.setString(4, urbanFunction.getAreaClassificationType().getValue()); + ps.setString(5, urbanFunction.getAreaClassificationType().getCodeSpace()); } else { - psUrbanFunction.setNull(5, Types.VARCHAR); - psUrbanFunction.setNull(6, Types.VARCHAR); - } - - GeometryObject boundary = null; - if (urbanFunction.getBoundary() != null && urbanFunction.getBoundary().isSetMultiCurve()) { - boundary = geometryConverter.getMultiCurve(urbanFunction.getBoundary().getMultiCurve()); - urbanFunction.setBoundary(null); + ps.setNull(4, Types.VARCHAR); + ps.setNull(5, Types.VARCHAR); } - if (boundary != null) - psUrbanFunction.setObject(7, helper.getDatabaseAdapter().getGeometryConverter().getDatabaseObject(boundary, connection)); - else - psUrbanFunction.setNull(7, helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryType(), - helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryTypeName()); - if (urbanFunction.getCity() != null && urbanFunction.getCity().isSetValue()) { - psUrbanFunction.setString(8, urbanFunction.getCity().getValue()); - psUrbanFunction.setString(9, urbanFunction.getCity().getCodeSpace()); + ps.setString(6, urbanFunction.getCity().getValue()); + ps.setString(7, urbanFunction.getCity().getCodeSpace()); } else { - psUrbanFunction.setNull(8, Types.VARCHAR); - psUrbanFunction.setNull(9, Types.VARCHAR); + ps.setNull(6, Types.VARCHAR); + ps.setNull(7, Types.VARCHAR); } if (urbanFunction.getClassifier() != null && urbanFunction.getClassifier().isSetValue()) { - psUrbanFunction.setString(10, urbanFunction.getClassifier().getValue()); - psUrbanFunction.setString(11, urbanFunction.getClassifier().getCodeSpace()); + ps.setString(8, urbanFunction.getClassifier().getValue()); + ps.setString(9, urbanFunction.getClassifier().getCodeSpace()); } else { - psUrbanFunction.setNull(10, Types.VARCHAR); - psUrbanFunction.setNull(11, Types.VARCHAR); + ps.setNull(8, Types.VARCHAR); + ps.setNull(9, Types.VARCHAR); } - psUrbanFunction.setString(12, urbanFunction.getCustodian()); + ps.setString(10, urbanFunction.getCustodian()); if (urbanFunction.getEnactmentDate() != null) - psUrbanFunction.setDate(13, Date.valueOf(urbanFunction.getEnactmentDate())); + ps.setDate(11, Date.valueOf(urbanFunction.getEnactmentDate())); else - psUrbanFunction.setNull(13, Types.DATE); + ps.setNull(11, Types.DATE); if (urbanFunction.getEnactmentFiscalYear() != null) - psUrbanFunction.setDate(14, Date.valueOf(LocalDate.of(urbanFunction.getEnactmentFiscalYear().getValue(), 1, 1))); + ps.setDate(12, Date.valueOf(LocalDate.of(urbanFunction.getEnactmentFiscalYear().getValue(), 1, 1))); else - psUrbanFunction.setNull(14, Types.DATE); + ps.setNull(12, Types.DATE); if (urbanFunction.getExpirationDate() != null) - psUrbanFunction.setDate(15, Date.valueOf(urbanFunction.getExpirationDate())); + ps.setDate(13, Date.valueOf(urbanFunction.getExpirationDate())); else - psUrbanFunction.setNull(15, Types.DATE); + ps.setNull(13, Types.DATE); if (urbanFunction.getExpirationFiscalYear() != null) - psUrbanFunction.setDate(16, Date.valueOf(LocalDate.of(urbanFunction.getExpirationFiscalYear().getValue(), 1, 1))); + ps.setDate(14, Date.valueOf(LocalDate.of(urbanFunction.getExpirationFiscalYear().getValue(), 1, 1))); else - psUrbanFunction.setNull(16, Types.DATE); + ps.setNull(14, Types.DATE); if (!urbanFunction.getFunctions().isEmpty()) { valueJoiner.join(urbanFunction.getFunctions(), Code::getValue, Code::getCodeSpace); - psUrbanFunction.setString(17, valueJoiner.result(0)); - psUrbanFunction.setString(18, valueJoiner.result(1)); + ps.setString(15, valueJoiner.result(0)); + ps.setString(16, valueJoiner.result(1)); } else { - psUrbanFunction.setNull(17, Types.VARCHAR); - psUrbanFunction.setNull(18, Types.VARCHAR); + ps.setNull(15, Types.VARCHAR); + ps.setNull(16, Types.VARCHAR); } long legalGroundsId = 0; @@ -183,72 +150,155 @@ public void doImport(UrbanFunction urbanFunction, long objectId, AbstractObjectT legalGroundsId = legalGroundsImporter.doImport(urbanFunction.getLegalGrounds().getObject()); if (legalGroundsId != 0) - psUrbanFunction.setLong(19, legalGroundsId); + ps.setLong(17, legalGroundsId); else - psUrbanFunction.setNull(19, Types.NULL); + ps.setNull(17, Types.NULL); + + for (int i = 0; i < 3; i++) { + MultiPointProperty property = null; + GeometryObject multiPoint = null; + + switch (i) { + case 0: + property = urbanFunction.getLod0MultiPoint(); + break; + case 1: + property = urbanFunction.getLod1MultiPoint(); + break; + case 2: + property = urbanFunction.getLod2MultiPoint(); + break; + } - GeometryObject pointLocation = null; - if (urbanFunction.getPointLocation() != null && urbanFunction.getPointLocation().isSetMultiPoint()) { - pointLocation = geometryConverter.getMultiPoint(urbanFunction.getPointLocation().getMultiPoint()); - urbanFunction.setPointLocation(null); + if (property != null) { + multiPoint = geometryConverter.getMultiPoint(property); + property.unsetMultiPoint(); + } + + if (multiPoint != null) + ps.setObject(18 + i, helper.getDatabaseAdapter().getGeometryConverter().getDatabaseObject(multiPoint, connection)); + else + ps.setNull(18 + i, helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryType(), + helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryTypeName()); } - if (pointLocation != null) - psUrbanFunction.setObject(20, helper.getDatabaseAdapter().getGeometryConverter().getDatabaseObject(pointLocation, connection)); - else - psUrbanFunction.setNull(20, helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryType(), - helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryTypeName()); + for (int i = 0; i < 3; i++) { + MultiCurveProperty property = null; + GeometryObject multiCurve = null; + + switch (i) { + case 0: + property = urbanFunction.getLod0MultiCurve(); + break; + case 1: + property = urbanFunction.getLod1MultiCurve(); + break; + case 2: + property = urbanFunction.getLod2MultiCurve(); + break; + } + + if (property != null) { + multiCurve = geometryConverter.getMultiCurve(property); + property.unsetMultiCurve(); + } + + if (multiCurve != null) + ps.setObject(21 + i, helper.getDatabaseAdapter().getGeometryConverter().getDatabaseObject(multiCurve, connection)); + else + ps.setNull(21 + i, helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryType(), + helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryTypeName()); + } + + for (int i = 0; i < 3; i++) { + MultiSurfaceProperty property = null; + long surfaceGeometryId = 0; + + switch (i) { + case 0: + property = urbanFunction.getLod0MultiSurface(); + break; + case 1: + property = urbanFunction.getLod1MultiSurface(); + break; + case 2: + property = urbanFunction.getLod2MultiSurface(); + break; + } + + if (property != null) { + if (property.isSetMultiSurface()) { + surfaceGeometryId = helper.importSurfaceGeometry(property.getMultiSurface(), objectId); + property.unsetMultiSurface(); + } else { + String href = property.getHref(); + if (href != null && !href.isEmpty()) { + String propertyColumn = i == 0 ? + "lod0multisurface_id" : + "lod_" + i + "multisurface_id"; + helper.propagateSurfaceGeometryXlink(href, schemaMapper.getTableName(ADETable.URBANFUNCTION), objectId, propertyColumn); + } + } + } + + if (surfaceGeometryId != 0) + ps.setLong(24 + i, surfaceGeometryId); + else + ps.setNull(24 + i, Types.NULL); + } if (urbanFunction.getNominalArea() != null && urbanFunction.getNominalArea().isSetValue()) { - psUrbanFunction.setDouble(21, urbanFunction.getNominalArea().getValue()); - psUrbanFunction.setString(22, urbanFunction.getNominalArea().getUom()); + ps.setDouble(27, urbanFunction.getNominalArea().getValue()); + ps.setString(28, urbanFunction.getNominalArea().getUom()); } else { - psUrbanFunction.setNull(21, Types.DOUBLE); - psUrbanFunction.setNull(22, Types.VARCHAR); + ps.setNull(27, Types.DOUBLE); + ps.setNull(28, Types.VARCHAR); } - psUrbanFunction.setString(23, urbanFunction.getNote()); + ps.setString(29, urbanFunction.getNote()); if (urbanFunction.getPrefecture() != null && urbanFunction.getPrefecture().isSetValue()) { - psUrbanFunction.setString(24, urbanFunction.getPrefecture().getValue()); - psUrbanFunction.setString(25, urbanFunction.getPrefecture().getCodeSpace()); + ps.setString(30, urbanFunction.getPrefecture().getValue()); + ps.setString(31, urbanFunction.getPrefecture().getCodeSpace()); } else { - psUrbanFunction.setNull(24, Types.VARCHAR); - psUrbanFunction.setNull(25, Types.VARCHAR); + ps.setNull(30, Types.VARCHAR); + ps.setNull(31, Types.VARCHAR); } - psUrbanFunction.setString(26, urbanFunction.getReference()); + ps.setString(32, urbanFunction.getReference()); if (urbanFunction.getSurveyYear() != null) - psUrbanFunction.setDate(27, Date.valueOf(LocalDate.of(urbanFunction.getSurveyYear().getValue(), 1, 1))); + ps.setDate(33, Date.valueOf(LocalDate.of(urbanFunction.getSurveyYear().getValue(), 1, 1))); else - psUrbanFunction.setNull(27, Types.DATE); + ps.setNull(33, Types.DATE); if (urbanFunction.getUrbanPlanType() != null && urbanFunction.getUrbanPlanType().isSetValue()) { - psUrbanFunction.setString(28, urbanFunction.getUrbanPlanType().getValue()); - psUrbanFunction.setString(29, urbanFunction.getUrbanPlanType().getCodeSpace()); + ps.setString(34, urbanFunction.getUrbanPlanType().getValue()); + ps.setString(35, urbanFunction.getUrbanPlanType().getCodeSpace()); } else { - psUrbanFunction.setNull(28, Types.VARCHAR); - psUrbanFunction.setNull(29, Types.VARCHAR); + ps.setNull(34, Types.VARCHAR); + ps.setNull(35, Types.VARCHAR); } if (urbanFunction.getValidity() != null) - psUrbanFunction.setInt(30, urbanFunction.getValidity() ? 1 : 0); + ps.setInt(36, urbanFunction.getValidity() ? 1 : 0); else - psUrbanFunction.setNull(30, Types.INTEGER); + ps.setNull(36, Types.INTEGER); if (urbanFunction instanceof DisasterPreventionBase && ((DisasterPreventionBase) urbanFunction).getCapacity() != null) - psUrbanFunction.setInt(31, ((DisasterPreventionBase) urbanFunction).getCapacity()); + ps.setInt(37, ((DisasterPreventionBase) urbanFunction).getCapacity()); else - psUrbanFunction.setNull(31, Types.INTEGER); + ps.setNull(37, Types.INTEGER); - psUrbanFunction.addBatch(); + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); for (TargetProperty property : urbanFunction.getTargets()) { - AbstractCityObject cityObject = property.getCityObject(); + AbstractCityObject cityObject = property.getObject(); if (cityObject != null) { long cityObjectId = helper.importObject(cityObject); - property.unsetCityObject(); + property.unsetObject(); urbanFunctionToCityObjectImporter.doImport(cityObjectId, objectId); } else { String href = property.getHref(); @@ -260,39 +310,18 @@ public void doImport(UrbanFunction urbanFunction, long objectId, AbstractObjectT } } } - - if (urbanFunction instanceof Zone) { - Zone zone = (Zone) urbanFunction; - - psZone.setLong(1, objectId); - psZone.setInt(2, objectType.getObjectClassId()); - - psZone.setString(3, zone.getAreaApplied()); - - if (zone.getFinalPublicationDate() != null) - psZone.setDate(4, Date.valueOf(zone.getFinalPublicationDate())); - else - psZone.setNull(4, Types.DATE); - - psZone.addBatch(); - } - - if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) - helper.executeBatch(objectType); } @Override public void executeBatch() throws CityGMLImportException, SQLException { if (batchCounter > 0) { - psUrbanFunction.executeBatch(); - psZone.executeBatch(); + ps.executeBatch(); batchCounter = 0; } } @Override public void close() throws CityGMLImportException, SQLException { - psUrbanFunction.close(); - psZone.close(); + ps.close(); } } diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionModuleImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionModuleImporter.java new file mode 100644 index 0000000..7881a45 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionModuleImporter.java @@ -0,0 +1,6 @@ +package org.citydb.ade.iur.importer.urf; + +import org.citydb.ade.importer.ADEImporter; + +public interface UrbanFunctionModuleImporter extends ADEImporter { +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionToCityObjectImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionToCityObjectImporter.java index 4856440..e248cbb 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionToCityObjectImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/UrbanFunctionToCityObjectImporter.java @@ -22,18 +22,17 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -public class UrbanFunctionToCityObjectImporter implements ADEImporter { +public class UrbanFunctionToCityObjectImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/UrbanizationImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/UrbanizationImporter.java index 505b188..4c4b903 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urf/UrbanizationImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urf/UrbanizationImporter.java @@ -22,7 +22,6 @@ package org.citydb.ade.iur.importer.urf; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; import org.citydb.ade.iur.importer.ImportManager; @@ -35,7 +34,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; -public class UrbanizationImporter implements ADEImporter { +public class UrbanizationImporter implements UrbanFunctionModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; private final UrbanFunctionImporter urbanFunctionImporter; diff --git a/src/main/java/org/citydb/ade/iur/importer/urf/ZoneImporter.java b/src/main/java/org/citydb/ade/iur/importer/urf/ZoneImporter.java new file mode 100644 index 0000000..5317fe1 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urf/ZoneImporter.java @@ -0,0 +1,87 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.importer.urf; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urf.Zone; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class ZoneImporter implements UrbanFunctionModuleImporter { + private final CityGMLImportHelper helper; + private final PreparedStatement ps; + private final UrbanFunctionImporter urbanFunctionImporter; + + private int batchCounter; + + public ZoneImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.ZONE)) + " " + + "(id, objectclass_id, areaapplied, finalpublicationdate) " + + "values (?, ?, ?, ?)"); + + urbanFunctionImporter = manager.getImporter(UrbanFunctionImporter.class); + } + + public void doImport(Zone zone, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + urbanFunctionImporter.doImport(zone, objectId, objectType, foreignKeys); + + ps.setLong(1, objectId); + ps.setInt(2, objectType.getObjectClassId()); + + ps.setString(3, zone.getAreaApplied()); + + if (zone.getFinalPublicationDate() != null) + ps.setDate(4, Date.valueOf(zone.getFinalPublicationDate())); + else + ps.setNull(4, Types.DATE); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/AreaOfAnnualDiversionsImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/AreaOfAnnualDiversionsImporter.java new file mode 100644 index 0000000..fe1c836 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urg/AreaOfAnnualDiversionsImporter.java @@ -0,0 +1,92 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.importer.urg; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADESequence; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urg.AreaOfAnnualDiversions; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; +import java.time.LocalDate; + +public class AreaOfAnnualDiversionsImporter implements StatisticalGridModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private int batchCounter; + + public AreaOfAnnualDiversionsImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.AREAOFANNUALDIVERSIONS)) + " " + + "(id, landusediver_areaofannual_id, area, area_uom, year) " + + "values (?, ?, ?, ?, ?)"); + } + + public void doImport(AreaOfAnnualDiversions areaOfAnnualDiversions, long parentId) throws CityGMLImportException, SQLException { + long objectId = helper.getNextSequenceValue(schemaMapper.getSequenceName(ADESequence.AREAOFANNUALDIVERS_SEQ)); + ps.setLong(1, objectId); + ps.setLong(2, parentId); + + if (areaOfAnnualDiversions.getArea() != null && areaOfAnnualDiversions.getArea().isSetValue()) { + ps.setDouble(3, areaOfAnnualDiversions.getArea().getValue()); + ps.setString(4, areaOfAnnualDiversions.getArea().getUom()); + } else { + ps.setNull(3, Types.DOUBLE); + ps.setNull(4, Types.VARCHAR); + } + + if (areaOfAnnualDiversions.getYear() != null) + ps.setDate(5, Date.valueOf(LocalDate.of(areaOfAnnualDiversions.getYear().getValue(), 1, 1))); + else + ps.setNull(5, Types.DATE); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.AREAOFANNUALDIVERSIONS)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/CityObjectGroupPropertiesImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/CityObjectGroupPropertiesImporter.java new file mode 100644 index 0000000..8daa26a --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urg/CityObjectGroupPropertiesImporter.java @@ -0,0 +1,95 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.importer.urg; + +import org.citydb.ade.importer.ADEPropertyCollection; +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.FeatureType; +import org.citygml4j.ade.iur.model.urg.FiscalYearOfPublicationProperty; +import org.citygml4j.ade.iur.model.urg.LanguageProperty; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; +import java.time.LocalDate; + +public class CityObjectGroupPropertiesImporter implements StatisticalGridModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private int batchCounter; + + public CityObjectGroupPropertiesImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP)) + " " + + "(id, fiscalyearofpublication, language, language_codespace) " + + "values (?, ?, ?, ?)"); + } + + public void doImport(ADEPropertyCollection properties, CityObjectGroup parent, long parentId, FeatureType parentType) throws CityGMLImportException, SQLException { + ps.setLong(1, parentId); + + FiscalYearOfPublicationProperty fiscalYearOfPublication = properties.getFirst(FiscalYearOfPublicationProperty.class); + if (fiscalYearOfPublication != null && fiscalYearOfPublication.isSetValue()) + ps.setDate(2, Date.valueOf(LocalDate.of(fiscalYearOfPublication.getValue().getValue(), 1, 1))); + else + ps.setNull(2, Types.DATE); + + LanguageProperty language = properties.getFirst(LanguageProperty.class); + if (language != null && language.isSetValue()) { + ps.setString(3, language.getValue().getValue()); + ps.setString(4, language.getValue().getCodeSpace()); + } else { + ps.setNull(3, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + } + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/HouseholdsImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/HouseholdsImporter.java index 5193b78..cef3c87 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urg/HouseholdsImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urg/HouseholdsImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urg; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.AbstractObjectType; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; import org.citygml4j.ade.iur.model.urg.Households; import org.citygml4j.ade.iur.model.urg.NumberOfHouseholdsProperty; @@ -37,7 +36,7 @@ import java.sql.SQLException; import java.sql.Types; -public class HouseholdsImporter implements ADEImporter { +public class HouseholdsImporter implements StatisticalGridModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/KeyValuePairImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/KeyValuePairImporter.java new file mode 100644 index 0000000..8003086 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urg/KeyValuePairImporter.java @@ -0,0 +1,102 @@ +package org.citydb.ade.iur.importer.urg; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADESequence; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urg.KeyValuePair; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class KeyValuePairImporter implements StatisticalGridModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private int batchCounter; + + public KeyValuePairImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.KEYVALUEPAIR)) + " " + + "(id, statisticalg_genericvalue_id, key, key_codespace, codevalue, codevalue_codespace, datevalue, " + + "doublevalue, intvalue, measuredvalue, measuredvalue_uom, stringvalue, urivalue) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + } + + public long doImport(KeyValuePair keyValuePair, long parentId) throws CityGMLImportException, SQLException { + long objectId = helper.getNextSequenceValue(schemaMapper.getSequenceName(ADESequence.KEYVALUEPAIR_SEQ)); + ps.setLong(1, objectId); + + ps.setLong(2, parentId); + + if (keyValuePair.getKey() != null && keyValuePair.getKey().isSetValue()) { + ps.setString(3, keyValuePair.getKey().getValue()); + ps.setString(4, keyValuePair.getKey().getCodeSpace()); + } else { + ps.setNull(3, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + } + + if (keyValuePair.isSetCodeValue() && keyValuePair.getCodeValue().isSetValue()) { + ps.setString(5, keyValuePair.getCodeValue().getValue()); + ps.setString(6, keyValuePair.getCodeValue().getCodeSpace()); + } else { + ps.setNull(5, Types.VARCHAR); + ps.setNull(6, Types.VARCHAR); + } + + if (keyValuePair.isSetDateValue()) + ps.setDate(7, Date.valueOf(keyValuePair.getDateValue())); + else + ps.setNull(7, Types.DATE); + + if (keyValuePair.isSetDoubleValue()) + ps.setDouble(8, keyValuePair.getDoubleValue()); + else + ps.setNull(8, Types.DOUBLE); + + if (keyValuePair.isSetIntValue()) + ps.setInt(9, keyValuePair.getIntValue()); + else + ps.setNull(9, Types.INTEGER); + + if (keyValuePair.isSetMeasuredValue() && keyValuePair.getMeasuredValue().isSetValue()) { + ps.setDouble(10, keyValuePair.getMeasuredValue().getValue()); + ps.setString(11, keyValuePair.getMeasuredValue().getUom()); + } else { + ps.setNull(10, Types.DOUBLE); + ps.setNull(11, Types.VARCHAR); + } + + ps.setString(12, keyValuePair.getStringValue()); + ps.setString(13, keyValuePair.getUriValue()); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.KEYVALUEPAIR)); + + return objectId; + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/LandPriceImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/LandPriceImporter.java new file mode 100644 index 0000000..cf48e41 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urg/LandPriceImporter.java @@ -0,0 +1,94 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.importer.urg; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urg.LandPrice; +import org.citygml4j.ade.iur.model.urg.LandPricePerLandUseProperty; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class LandPriceImporter implements StatisticalGridModuleImporter { + private final CityGMLImportHelper helper; + private final PreparedStatement ps; + + private final LandPricePerLandUseImporter landPricePerLandUseImporter; + private final StatisticalGridImporter statisticalGridImporter; + + private int batchCounter; + + public LandPriceImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.LANDPRICE)) + " " + + "(id, currencyunit, currencyunit_codespace) " + + "values (?, ?, ?)"); + + landPricePerLandUseImporter = manager.getImporter(LandPricePerLandUseImporter.class); + statisticalGridImporter = manager.getImporter(StatisticalGridImporter.class); + } + + public void doImport(LandPrice landPrice, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + statisticalGridImporter.doImport(landPrice, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + if (landPrice.getCurrencyUnit() != null && landPrice.getCurrencyUnit().isSetValue()) { + ps.setString(2, landPrice.getCurrencyUnit().getValue()); + ps.setString(3, landPrice.getCurrencyUnit().getCodeSpace()); + } else { + ps.setNull(2, Types.VARCHAR); + ps.setNull(3, Types.VARCHAR); + } + + for (LandPricePerLandUseProperty property : landPrice.getLandPrices()) { + if (property.isSetObject()) + landPricePerLandUseImporter.doImport(property.getObject(), objectId); + } + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/LandPricePerLandUseImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/LandPricePerLandUseImporter.java index 92f706e..9657daf 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urg/LandPricePerLandUseImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urg/LandPricePerLandUseImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urg; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADESequence; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; import org.citygml4j.ade.iur.model.urg.LandPricePerLandUse; import java.sql.Connection; @@ -36,7 +35,7 @@ import java.sql.SQLException; import java.sql.Types; -public class LandPricePerLandUseImporter implements ADEImporter { +public class LandPricePerLandUseImporter implements StatisticalGridModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; @@ -49,8 +48,8 @@ public LandPricePerLandUseImporter(Connection connection, CityGMLImportHelper he ps = connection.prepareStatement("insert into " + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.LANDPRICEPERLANDUSE)) + " " + - "(id, statisticalgrid_landprice_id, currencyunit, currencyunit_codespace, landprice, landuse, landuse_codespace) " + - "values (?, ?, ?, ?, ?, ?, ?)"); + "(id, landprice_landprice_id, landprice, landuse, landuse_codespace) " + + "values (?, ?, ?, ?, ?)"); } public void doImport(LandPricePerLandUse landPricePerLandUse, long parentId) throws CityGMLImportException, SQLException { @@ -58,25 +57,17 @@ public void doImport(LandPricePerLandUse landPricePerLandUse, long parentId) thr ps.setLong(1, objectId); ps.setLong(2, parentId); - if (landPricePerLandUse.getCurrencyUnit() != null && landPricePerLandUse.getCurrencyUnit().isSetValue()) { - ps.setString(3, landPricePerLandUse.getCurrencyUnit().getValue()); - ps.setString(4, landPricePerLandUse.getCurrencyUnit().getCodeSpace()); - } else { - ps.setNull(3, Types.VARCHAR); - ps.setNull(4, Types.VARCHAR); - } - if (landPricePerLandUse.getLandPrice() != null) - ps.setInt(5, landPricePerLandUse.getLandPrice()); + ps.setInt(3, landPricePerLandUse.getLandPrice()); else - ps.setNull(5, Types.INTEGER); + ps.setNull(3, Types.INTEGER); if (landPricePerLandUse.getLandUse() != null && landPricePerLandUse.getLandUse().isSetValue()) { - ps.setString(6, landPricePerLandUse.getLandUse().getValue()); - ps.setString(7, landPricePerLandUse.getLandUse().getCodeSpace()); + ps.setString(4, landPricePerLandUse.getLandUse().getValue()); + ps.setString(5, landPricePerLandUse.getLandUse().getCodeSpace()); } else { - ps.setNull(6, Types.VARCHAR); - ps.setNull(7, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + ps.setNull(5, Types.VARCHAR); } ps.addBatch(); diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/LandUseDiversionImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/LandUseDiversionImporter.java new file mode 100644 index 0000000..466bcaf --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urg/LandUseDiversionImporter.java @@ -0,0 +1,92 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.importer.urg; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urg.AreaOfAnnualDiversionsProperty; +import org.citygml4j.ade.iur.model.urg.LandUseDiversion; +import org.citygml4j.ade.iur.model.urg.NumberOfAnnualDiversionsProperty; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class LandUseDiversionImporter implements StatisticalGridModuleImporter { + private final CityGMLImportHelper helper; + private final PreparedStatement ps; + + private final NumberOfAnnualDiversionsImporter numberOfAnnualDiversionsImporter; + private final AreaOfAnnualDiversionsImporter areaOfAnnualDiversionsImporter; + private final StatisticalGridImporter statisticalGridImporter; + + private int batchCounter; + + public LandUseDiversionImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.LANDUSEDIVERSION)) + " " + + "(id) values (?)"); + + numberOfAnnualDiversionsImporter = manager.getImporter(NumberOfAnnualDiversionsImporter.class); + areaOfAnnualDiversionsImporter = manager.getImporter(AreaOfAnnualDiversionsImporter.class); + statisticalGridImporter = manager.getImporter(StatisticalGridImporter.class); + } + + public void doImport(LandUseDiversion landUseDiversion, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + statisticalGridImporter.doImport(landUseDiversion, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + for (NumberOfAnnualDiversionsProperty property : landUseDiversion.getNumberOfAnnualDiversions()) { + if (property.isSetObject()) + numberOfAnnualDiversionsImporter.doImport(property.getObject(), objectId); + } + + for (AreaOfAnnualDiversionsProperty property : landUseDiversion.getAreaOfAnnualDiversions()) { + if (property.isSetObject()) + areaOfAnnualDiversionsImporter.doImport(property.getObject(), objectId); + } + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/NumberOfAnnualDiversionsImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/NumberOfAnnualDiversionsImporter.java index 3e26874..5bac4ae 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urg/NumberOfAnnualDiversionsImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urg/NumberOfAnnualDiversionsImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urg; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADESequence; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; import org.citygml4j.ade.iur.model.urg.NumberOfAnnualDiversions; import java.sql.Connection; @@ -38,7 +37,7 @@ import java.sql.Types; import java.time.LocalDate; -public class NumberOfAnnualDiversionsImporter implements ADEImporter { +public class NumberOfAnnualDiversionsImporter implements StatisticalGridModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; @@ -51,32 +50,24 @@ public NumberOfAnnualDiversionsImporter(Connection connection, CityGMLImportHelp ps = connection.prepareStatement("insert into " + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.NUMBEROFANNUALDIVERSIO)) + " " + - "(id, statisticalg_numberofannu_id, area, area_uom, count, year) " + - "values (?, ?, ?, ?, ?)"); + "(id, landusediver_numberofannu_id, count, year) " + + "values (?, ?, ?, ?)"); } public void doImport(NumberOfAnnualDiversions numberOfAnnualDiversions, long parentId) throws CityGMLImportException, SQLException { long objectId = helper.getNextSequenceValue(schemaMapper.getSequenceName(ADESequence.NUMBEROFANNUALDIVE_SEQ)); ps.setLong(1, objectId); ps.setLong(2, parentId); - - if (numberOfAnnualDiversions.getArea() != null && numberOfAnnualDiversions.getArea().isSetValue()) { - ps.setDouble(3, numberOfAnnualDiversions.getArea().getValue()); - ps.setString(4, numberOfAnnualDiversions.getArea().getUom()); - } else { - ps.setNull(3, Types.DOUBLE); - ps.setNull(4, Types.VARCHAR); - } if (numberOfAnnualDiversions.getCount() != null) - ps.setInt(5, numberOfAnnualDiversions.getCount()); + ps.setInt(3, numberOfAnnualDiversions.getCount()); else - ps.setNull(5, Types.INTEGER); + ps.setNull(3, Types.INTEGER); if (numberOfAnnualDiversions.getYear() != null) - ps.setDate(6, Date.valueOf(LocalDate.of(numberOfAnnualDiversions.getYear().getValue(), 1, 1))); + ps.setDate(4, Date.valueOf(LocalDate.of(numberOfAnnualDiversions.getYear().getValue(), 1, 1))); else - ps.setNull(6, Types.DATE); + ps.setNull(4, Types.DATE); ps.addBatch(); if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/NumberOfHouseholdsImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/NumberOfHouseholdsImporter.java index 633aec3..d5f1365 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urg/NumberOfHouseholdsImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urg/NumberOfHouseholdsImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urg; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADESequence; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; import org.citygml4j.ade.iur.model.urg.NumberOfHouseholds; import java.sql.Connection; @@ -36,7 +35,7 @@ import java.sql.SQLException; import java.sql.Types; -public class NumberOfHouseholdsImporter implements ADEImporter { +public class NumberOfHouseholdsImporter implements StatisticalGridModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/OfficesAndEmployeesImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/OfficesAndEmployeesImporter.java index b7d0326..2915927 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urg/OfficesAndEmployeesImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urg/OfficesAndEmployeesImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urg; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.AbstractObjectType; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; import org.citygml4j.ade.iur.model.urg.OfficesAndEmployees; import java.sql.Connection; @@ -36,7 +35,7 @@ import java.sql.SQLException; import java.sql.Types; -public class OfficesAndEmployeesImporter implements ADEImporter { +public class OfficesAndEmployeesImporter implements StatisticalGridModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; private final StatisticalGridImporter statisticalGridImporter; diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/PopulationByAgeAndSexImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/PopulationByAgeAndSexImporter.java index 0316ce9..7a9e39a 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urg/PopulationByAgeAndSexImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urg/PopulationByAgeAndSexImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urg; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADESequence; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; import org.citygml4j.ade.iur.model.urg.PopulationByAgeAndSex; import java.sql.Connection; @@ -36,7 +35,7 @@ import java.sql.SQLException; import java.sql.Types; -public class PopulationByAgeAndSexImporter implements ADEImporter { +public class PopulationByAgeAndSexImporter implements StatisticalGridModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; @@ -49,8 +48,8 @@ public PopulationByAgeAndSexImporter(Connection connection, CityGMLImportHelper ps = connection.prepareStatement("insert into " + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.POPULATIONBYAGEANDSEX)) + " " + - "(id, population_populationbyag_id, age, age_codespace, number_, sex, sex_codespace) " + - "values (?, ?, ?, ?, ?, ?, ?)"); + "(id, population_populationbyag_id, ageandsex, ageandsex_codespace, number_) " + + "values (?, ?, ?, ?, ?)"); } public void doImport(PopulationByAgeAndSex populationByAgeAndSex, long parentId) throws CityGMLImportException, SQLException { @@ -58,9 +57,9 @@ public void doImport(PopulationByAgeAndSex populationByAgeAndSex, long parentId) ps.setLong(1, objectId); ps.setLong(2, parentId); - if (populationByAgeAndSex.getAge() != null && populationByAgeAndSex.getAge().isSetValue()) { - ps.setString(3, populationByAgeAndSex.getAge().getValue()); - ps.setString(4, populationByAgeAndSex.getAge().getCodeSpace()); + if (populationByAgeAndSex.getAgeAndSex() != null && populationByAgeAndSex.getAgeAndSex().isSetValue()) { + ps.setString(3, populationByAgeAndSex.getAgeAndSex().getValue()); + ps.setString(4, populationByAgeAndSex.getAgeAndSex().getCodeSpace()); } else { ps.setNull(3, Types.VARCHAR); ps.setNull(4, Types.VARCHAR); @@ -71,14 +70,6 @@ public void doImport(PopulationByAgeAndSex populationByAgeAndSex, long parentId) else ps.setNull(5, Types.INTEGER); - if (populationByAgeAndSex.getSex() != null && populationByAgeAndSex.getSex().isSetValue()) { - ps.setString(6, populationByAgeAndSex.getSex().getValue()); - ps.setString(7, populationByAgeAndSex.getSex().getCodeSpace()); - } else { - ps.setNull(6, Types.VARCHAR); - ps.setNull(7, Types.VARCHAR); - } - ps.addBatch(); if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) helper.executeBatch(schemaMapper.getTableName(ADETable.POPULATIONBYAGEANDSEX)); diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/PopulationImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/PopulationImporter.java index 2f152f5..844e064 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urg/PopulationImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urg/PopulationImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.urg; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.AbstractObjectType; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; import org.citygml4j.ade.iur.model.urg.Population; import org.citygml4j.ade.iur.model.urg.PopulationByAgeAndSexProperty; @@ -37,7 +36,7 @@ import java.sql.SQLException; import java.sql.Types; -public class PopulationImporter implements ADEImporter { +public class PopulationImporter implements StatisticalGridModuleImporter { private final CityGMLImportHelper helper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/StatisticalGridImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/StatisticalGridImporter.java index 95acf7f..96d0fb6 100644 --- a/src/main/java/org/citydb/ade/iur/importer/urg/StatisticalGridImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/urg/StatisticalGridImporter.java @@ -22,22 +22,19 @@ package org.citydb.ade.iur.importer.urg; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.citygml.importer.util.AttributeValueJoiner; import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urg.GenericGridCell; +import org.citygml4j.ade.iur.model.urg.KeyValuePairProperty; +import org.citygml4j.ade.iur.model.urg.PublicTransitAccessibility; +import org.citygml4j.ade.iur.model.urg.StatisticalGrid; import org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty; import org.w3c.dom.Element; -import org.citydb.ade.iur.importer.ImportManager; -import org.citydb.ade.iur.schema.ADETable; -import org.citygml4j.ade.iur.model.urg.LandPrice; -import org.citygml4j.ade.iur.model.urg.LandPricePerLandUseProperty; -import org.citygml4j.ade.iur.model.urg.LandUseDiversion; -import org.citygml4j.ade.iur.model.urg.NumberOfAnnualDiversionsProperty; -import org.citygml4j.ade.iur.model.urg.PublicTransportationAccessibility; -import org.citygml4j.ade.iur.model.urg.StatisticalGrid; import javax.xml.transform.TransformerException; import java.sql.Connection; @@ -50,13 +47,12 @@ import java.util.Iterator; import java.util.List; -public class StatisticalGridImporter implements ADEImporter { +public class StatisticalGridImporter implements StatisticalGridModuleImporter { private final CityGMLImportHelper helper; private final ImportManager manager; private final PreparedStatement ps; - private final LandPricePerLandUseImporter landPricePerLandUseImporter; - private final NumberOfAnnualDiversionsImporter numberOfAnnualDiversionsImporter; + private final KeyValuePairImporter keyValuePairImporter; private final AttributeValueJoiner valueJoiner; private int batchCounter; @@ -68,12 +64,11 @@ public StatisticalGridImporter(Connection connection, CityGMLImportHelper helper ps = connection.prepareStatement("insert into " + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID)) + " " + "(id, objectclass_id, areaclassificationtype, areaclassification_codespace, city, city_codespace, " + - "class, class_codespace, lod_1multisurfacegeometry_id, lod_2multisurfacegeometry_id, " + - "prefecture, prefecture_codespace, surveyyear, urbanplantype, urbanplantype_codespace, value, availability) " + + "class, class_codespace, lod_1multisurface_id, lod_2multisurface_id, prefecture, prefecture_codespace, " + + "surveyyear, urbanplantype, urbanplantype_codespace, value, availability) " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - landPricePerLandUseImporter = manager.getImporter(LandPricePerLandUseImporter.class); - numberOfAnnualDiversionsImporter = manager.getImporter(NumberOfAnnualDiversionsImporter.class); + keyValuePairImporter = manager.getImporter(KeyValuePairImporter.class); valueJoiner = helper.getAttributeValueJoiner(); } @@ -105,41 +100,35 @@ public void doImport(StatisticalGrid statisticalGrid, long objectId, AbstractObj ps.setNull(8, Types.VARCHAR); } - long lod1MultiSurfaceId = 0; - if (statisticalGrid.getLod1MultiSurfaceGeometry() != null) { - MultiSurfaceProperty property = statisticalGrid.getLod1MultiSurfaceGeometry(); - if (property.isSetMultiSurface()) { - lod1MultiSurfaceId = helper.importSurfaceGeometry(property.getMultiSurface(), objectId); - property.unsetMultiSurface(); - } else { - String href = property.getHref(); - if (href != null && !href.isEmpty()) - helper.propagateSurfaceGeometryXlink(href, manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID), objectId, "lod_1multisurfacegeometry_id"); + for (int i = 0; i < 2; i++) { + MultiSurfaceProperty property = null; + long surfaceGeometryId = 0; + + switch (i) { + case 0: + property = statisticalGrid.getLod1MultiSurface(); + break; + case 1: + property = statisticalGrid.getLod2MultiSurface(); + break; } - } - if (lod1MultiSurfaceId != 0) - ps.setLong(9, lod1MultiSurfaceId); - else - ps.setNull(9, Types.NULL); - - long lod2MultiSurfaceId = 0; - if (statisticalGrid.getLod2MultiSurfaceGeometry() != null) { - MultiSurfaceProperty property = statisticalGrid.getLod2MultiSurfaceGeometry(); - if (property.isSetMultiSurface()) { - lod2MultiSurfaceId = helper.importSurfaceGeometry(property.getMultiSurface(), objectId); - property.unsetMultiSurface(); - } else { - String href = property.getHref(); - if (href != null && !href.isEmpty()) - helper.propagateSurfaceGeometryXlink(href, manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID), objectId, "lod_2multisurfacegeometry_id"); + if (property != null) { + if (property.isSetMultiSurface()) { + surfaceGeometryId = helper.importSurfaceGeometry(property.getMultiSurface(), objectId); + property.unsetMultiSurface(); + } else { + String href = property.getHref(); + if (href != null && !href.isEmpty()) + helper.propagateSurfaceGeometryXlink(href, manager.getSchemaMapper().getTableName(ADETable.STATISTICALGRID), objectId, "lod_" + (i + 1) + "multisurface_id"); + } } - } - if (lod2MultiSurfaceId != 0) - ps.setLong(10, lod2MultiSurfaceId); - else - ps.setNull(10, Types.NULL); + if (surfaceGeometryId != 0) + ps.setLong(9 + i, surfaceGeometryId); + else + ps.setNull(9 + i, Types.NULL); + } if (statisticalGrid.getPrefecture() != null && statisticalGrid.getPrefecture().isSetValue()) { ps.setString(11, statisticalGrid.getPrefecture().getValue()); @@ -180,8 +169,8 @@ public void doImport(StatisticalGrid statisticalGrid, long objectId, AbstractObj else ps.setNull(16, Types.VARCHAR); - if (statisticalGrid instanceof PublicTransportationAccessibility && ((PublicTransportationAccessibility) statisticalGrid).getAvailability() != null) - ps.setInt(17, ((PublicTransportationAccessibility) statisticalGrid).getAvailability() ? 1 : 0); + if (statisticalGrid instanceof PublicTransitAccessibility && ((PublicTransitAccessibility) statisticalGrid).getAvailability() != null) + ps.setInt(17, ((PublicTransitAccessibility) statisticalGrid).getAvailability() ? 1 : 0); else ps.setNull(17, Types.INTEGER); @@ -189,17 +178,11 @@ public void doImport(StatisticalGrid statisticalGrid, long objectId, AbstractObj if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) helper.executeBatch(objectType); - if (statisticalGrid instanceof LandPrice) { - LandPrice landPrice = (LandPrice) statisticalGrid; - for (LandPricePerLandUseProperty property : landPrice.getLandPrices()) { - if (property.isSetObject()) - landPricePerLandUseImporter.doImport(property.getObject(), objectId); - } - } else if (statisticalGrid instanceof LandUseDiversion) { - LandUseDiversion landUseDiversion = (LandUseDiversion) statisticalGrid; - for (NumberOfAnnualDiversionsProperty property : landUseDiversion.getNumberOfAnnualDiversions()) { + if (statisticalGrid instanceof GenericGridCell) { + GenericGridCell genericGridCell = (GenericGridCell) statisticalGrid; + for (KeyValuePairProperty property : genericGridCell.getGenericValues()) { if (property.isSetObject()) - numberOfAnnualDiversionsImporter.doImport(property.getObject(), objectId); + keyValuePairImporter.doImport(property.getObject(), objectId); } } } diff --git a/src/main/java/org/citydb/ade/iur/importer/urg/StatisticalGridModuleImporter.java b/src/main/java/org/citydb/ade/iur/importer/urg/StatisticalGridModuleImporter.java new file mode 100644 index 0000000..786f823 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urg/StatisticalGridModuleImporter.java @@ -0,0 +1,6 @@ +package org.citydb.ade.iur.importer.urg; + +import org.citydb.ade.importer.ADEImporter; + +public interface StatisticalGridModuleImporter extends ADEImporter { +} diff --git a/src/main/java/org/citydb/ade/iur/importer/uro/BuildingDetailsImporter.java b/src/main/java/org/citydb/ade/iur/importer/uro/BuildingDetailsImporter.java index 961dae7..41837d7 100644 --- a/src/main/java/org/citydb/ade/iur/importer/uro/BuildingDetailsImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/uro/BuildingDetailsImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.uro; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADESequence; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; import org.citygml4j.ade.iur.model.uro.BuildingDetails; import java.sql.Connection; @@ -38,7 +37,7 @@ import java.sql.Types; import java.time.LocalDate; -public class BuildingDetailsImporter implements ADEImporter { +public class BuildingDetailsImporter implements UrbanObjectModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/uro/BuildingPropertiesImporter.java b/src/main/java/org/citydb/ade/iur/importer/uro/BuildingPropertiesImporter.java index 212356b..d7e8ac0 100644 --- a/src/main/java/org/citydb/ade/iur/importer/uro/BuildingPropertiesImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/uro/BuildingPropertiesImporter.java @@ -22,30 +22,31 @@ package org.citydb.ade.iur.importer.uro; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.ADEPropertyCollection; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.FeatureType; -import org.citygml4j.model.citygml.building.AbstractBuilding; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.FeatureType; import org.citygml4j.ade.iur.model.uro.BuildingDetailsPropertyElement; +import org.citygml4j.ade.iur.model.uro.ExtendedAttributeProperty; import org.citygml4j.ade.iur.model.uro.LargeCustomerFacilitiesPropertyElement; +import org.citygml4j.model.citygml.building.AbstractBuilding; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Types; -public class BuildingPropertiesImporter implements ADEImporter { +public class BuildingPropertiesImporter implements UrbanObjectModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; private final BuildingDetailsImporter buildingDetailsImporter; private final LargeCustomerFacilitiesImporter largeCustomerFacilitiesImporter; + private final KeyValuePairImporter keyValuePairImporter; private int batchCounter; @@ -60,6 +61,7 @@ public BuildingPropertiesImporter(Connection connection, CityGMLImportHelper hel buildingDetailsImporter = manager.getImporter(BuildingDetailsImporter.class); largeCustomerFacilitiesImporter = manager.getImporter(LargeCustomerFacilitiesImporter.class); + keyValuePairImporter = manager.getImporter(KeyValuePairImporter.class); } public void doImport(ADEPropertyCollection properties, AbstractBuilding parent, long parentId, FeatureType parentType) throws CityGMLImportException, SQLException { @@ -96,6 +98,13 @@ public void doImport(ADEPropertyCollection properties, AbstractBuilding parent, ps.addBatch(); if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) helper.executeBatch(schemaMapper.getTableName(ADETable.BUILDING)); + + if (properties.contains(ExtendedAttributeProperty.class)) { + for (ExtendedAttributeProperty property : properties.getAll(ExtendedAttributeProperty.class)) { + if (property.isSetValue() && property.getValue().isSetObject()) + keyValuePairImporter.doImport(property.getValue().getObject(), parentId); + } + } } @Override diff --git a/src/main/java/org/citydb/ade/iur/importer/uro/CityObjectGroupPropertiesImporter.java b/src/main/java/org/citydb/ade/iur/importer/uro/CityObjectGroupPropertiesImporter.java index 053ff78..32379bf 100644 --- a/src/main/java/org/citydb/ade/iur/importer/uro/CityObjectGroupPropertiesImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/uro/CityObjectGroupPropertiesImporter.java @@ -22,17 +22,16 @@ package org.citydb.ade.iur.importer.uro; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.ADEPropertyCollection; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.FeatureType; -import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.FeatureType; import org.citygml4j.ade.iur.model.uro.FiscalYearOfPublicationProperty; import org.citygml4j.ade.iur.model.uro.LanguageProperty; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; import java.sql.Connection; import java.sql.Date; @@ -41,7 +40,7 @@ import java.sql.Types; import java.time.LocalDate; -public class CityObjectGroupPropertiesImporter implements ADEImporter { +public class CityObjectGroupPropertiesImporter implements UrbanObjectModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; @@ -53,7 +52,7 @@ public CityObjectGroupPropertiesImporter(Connection connection, CityGMLImportHel this.schemaMapper = manager.getSchemaMapper(); ps = connection.prepareStatement("insert into " + - helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP)) + " " + + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_1)) + " " + "(id, fiscalyearofpublication, language, language_codespace) " + "values (?, ?, ?, ?)"); } @@ -78,7 +77,7 @@ public void doImport(ADEPropertyCollection properties, CityObjectGroup parent, l ps.addBatch(); if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) - helper.executeBatch(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP)); + helper.executeBatch(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_1)); } @Override diff --git a/src/main/java/org/citydb/ade/iur/importer/uro/KeyValuePairImporter.java b/src/main/java/org/citydb/ade/iur/importer/uro/KeyValuePairImporter.java new file mode 100644 index 0000000..3106f49 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/uro/KeyValuePairImporter.java @@ -0,0 +1,102 @@ +package org.citydb.ade.iur.importer.uro; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADESequence; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.uro.KeyValuePair; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class KeyValuePairImporter implements UrbanObjectModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private int batchCounter; + + public KeyValuePairImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.KEYVALUEPAIR_1)) + " " + + "(id, building_extendedattribut_id, key, key_codespace, codevalue, codevalue_codespace, datevalue, " + + "doublevalue, intvalue, measuredvalue, measuredvalue_uom, stringvalue, urivalue) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + } + + public long doImport(KeyValuePair keyValuePair, long parentId) throws CityGMLImportException, SQLException { + long objectId = helper.getNextSequenceValue(schemaMapper.getSequenceName(ADESequence.KEYVALUEPAIR_SEQ_1)); + ps.setLong(1, objectId); + + ps.setLong(2, parentId); + + if (keyValuePair.getKey() != null && keyValuePair.getKey().isSetValue()) { + ps.setString(3, keyValuePair.getKey().getValue()); + ps.setString(4, keyValuePair.getKey().getCodeSpace()); + } else { + ps.setNull(3, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + } + + if (keyValuePair.isSetCodeValue() && keyValuePair.getCodeValue().isSetValue()) { + ps.setString(5, keyValuePair.getCodeValue().getValue()); + ps.setString(6, keyValuePair.getCodeValue().getCodeSpace()); + } else { + ps.setNull(5, Types.VARCHAR); + ps.setNull(6, Types.VARCHAR); + } + + if (keyValuePair.isSetDateValue()) + ps.setDate(7, Date.valueOf(keyValuePair.getDateValue())); + else + ps.setNull(7, Types.DATE); + + if (keyValuePair.isSetDoubleValue()) + ps.setDouble(8, keyValuePair.getDoubleValue()); + else + ps.setNull(8, Types.DOUBLE); + + if (keyValuePair.isSetIntValue()) + ps.setInt(9, keyValuePair.getIntValue()); + else + ps.setNull(9, Types.INTEGER); + + if (keyValuePair.isSetMeasuredValue() && keyValuePair.getMeasuredValue().isSetValue()) { + ps.setDouble(10, keyValuePair.getMeasuredValue().getValue()); + ps.setString(11, keyValuePair.getMeasuredValue().getUom()); + } else { + ps.setNull(10, Types.DOUBLE); + ps.setNull(11, Types.VARCHAR); + } + + ps.setString(12, keyValuePair.getStringValue()); + ps.setString(13, keyValuePair.getUriValue()); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.KEYVALUEPAIR_1)); + + return objectId; + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/uro/LandUsePropertiesImporter.java b/src/main/java/org/citydb/ade/iur/importer/uro/LandUsePropertiesImporter.java index 9a713bc..783675e 100644 --- a/src/main/java/org/citydb/ade/iur/importer/uro/LandUsePropertiesImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/uro/LandUsePropertiesImporter.java @@ -22,15 +22,13 @@ package org.citydb.ade.iur.importer.uro; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.ADEPropertyCollection; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.FeatureType; -import org.citygml4j.model.citygml.landuse.LandUse; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.FeatureType; import org.citygml4j.ade.iur.model.uro.AreaClassificationTypeProperty; import org.citygml4j.ade.iur.model.uro.AreaInHaProperty; import org.citygml4j.ade.iur.model.uro.AreaInSquareMeterProperty; @@ -45,6 +43,7 @@ import org.citygml4j.ade.iur.model.uro.ReferenceProperty; import org.citygml4j.ade.iur.model.uro.SurveyYearProperty; import org.citygml4j.ade.iur.model.uro.UrbanPlanTypeProperty; +import org.citygml4j.model.citygml.landuse.LandUse; import java.sql.Connection; import java.sql.Date; @@ -53,7 +52,7 @@ import java.sql.Types; import java.time.LocalDate; -public class LandUsePropertiesImporter implements ADEImporter { +public class LandUsePropertiesImporter implements UrbanObjectModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/uro/LargeCustomerFacilitiesImporter.java b/src/main/java/org/citydb/ade/iur/importer/uro/LargeCustomerFacilitiesImporter.java index 3b1b902..78ea846 100644 --- a/src/main/java/org/citydb/ade/iur/importer/uro/LargeCustomerFacilitiesImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/uro/LargeCustomerFacilitiesImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.uro; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADESequence; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; import org.citygml4j.ade.iur.model.uro.LargeCustomerFacilities; import java.sql.Connection; @@ -38,7 +37,7 @@ import java.sql.Types; import java.time.LocalDate; -public class LargeCustomerFacilitiesImporter implements ADEImporter { +public class LargeCustomerFacilitiesImporter implements UrbanObjectModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/uro/TrafficVolumeImporter.java b/src/main/java/org/citydb/ade/iur/importer/uro/TrafficVolumeImporter.java index 5d3d07b..cee8ed2 100644 --- a/src/main/java/org/citydb/ade/iur/importer/uro/TrafficVolumeImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/uro/TrafficVolumeImporter.java @@ -22,13 +22,12 @@ package org.citydb.ade.iur.importer.uro; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADESequence; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; import org.citygml4j.ade.iur.model.uro.TrafficVolume; import java.sql.Connection; @@ -38,7 +37,7 @@ import java.sql.Types; import java.time.LocalDate; -public class TrafficVolumeImporter implements ADEImporter { +public class TrafficVolumeImporter implements UrbanObjectModuleImporter { private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; private final PreparedStatement ps; diff --git a/src/main/java/org/citydb/ade/iur/importer/uro/TransportationComplexPropertiesImporter.java b/src/main/java/org/citydb/ade/iur/importer/uro/TransportationComplexPropertiesImporter.java index 86d8cb2..b0e3b26 100644 --- a/src/main/java/org/citydb/ade/iur/importer/uro/TransportationComplexPropertiesImporter.java +++ b/src/main/java/org/citydb/ade/iur/importer/uro/TransportationComplexPropertiesImporter.java @@ -22,26 +22,25 @@ package org.citydb.ade.iur.importer.uro; -import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.importer.ADEPropertyCollection; import org.citydb.ade.importer.CityGMLImportHelper; -import org.citydb.citygml.importer.CityGMLImportException; -import org.citydb.database.schema.mapping.FeatureType; -import org.citygml4j.model.citygml.transportation.Road; -import org.citygml4j.model.citygml.transportation.TransportationComplex; import org.citydb.ade.iur.importer.ImportManager; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.FeatureType; import org.citygml4j.ade.iur.model.uro.TrafficVolumePropertyElement; import org.citygml4j.ade.iur.model.uro.WidthProperty; import org.citygml4j.ade.iur.model.uro.WidthTypeProperty; +import org.citygml4j.model.citygml.transportation.Road; +import org.citygml4j.model.citygml.transportation.TransportationComplex; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Types; -public class TransportationComplexPropertiesImporter implements ADEImporter { +public class TransportationComplexPropertiesImporter implements UrbanObjectModuleImporter { private final Connection connection; private final CityGMLImportHelper helper; private final SchemaMapper schemaMapper; diff --git a/src/main/java/org/citydb/ade/iur/importer/uro/UrbanObjectModuleImporter.java b/src/main/java/org/citydb/ade/iur/importer/uro/UrbanObjectModuleImporter.java new file mode 100644 index 0000000..58bfdef --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/uro/UrbanObjectModuleImporter.java @@ -0,0 +1,6 @@ +package org.citydb.ade.iur.importer.uro; + +import org.citydb.ade.importer.ADEImporter; + +public interface UrbanObjectModuleImporter extends ADEImporter { +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/AgencyImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/AgencyImporter.java new file mode 100644 index 0000000..526a659 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/AgencyImporter.java @@ -0,0 +1,85 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Agency; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class AgencyImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final PreparedStatement ps; + private final PublicTransitImporter publicTransitImporter; + + private int batchCounter; + + public AgencyImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.AGENCY)) + " " + + "(id, address, email, fareurl, language, language_codespace, name, officialname, phone, " + + "presidentname, presidentposition, timezone, timezone_codespace, url, zipnumber) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + } + + public void doImport(Agency agency, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(agency, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + ps.setString(2, agency.getAddress()); + ps.setString(3, agency.getEmail()); + ps.setString(4, agency.getFareUrl()); + + if (agency.getLanguage() != null && agency.getLanguage().isSetValue()) { + ps.setString(5, agency.getLanguage().getValue()); + ps.setString(6, agency.getLanguage().getCodeSpace()); + } else { + ps.setNull(5, Types.VARCHAR); + ps.setNull(6, Types.VARCHAR); + } + + ps.setString(7, agency.getAgencyName()); + ps.setString(8, agency.getOfficialName()); + ps.setString(9, agency.getPhone()); + ps.setString(10, agency.getPresidentName()); + ps.setString(11, agency.getPresidentPosition()); + + if (agency.getTimeZone() != null && agency.getTimeZone().isSetValue()) { + ps.setString(12, agency.getTimeZone().getValue()); + ps.setString(13, agency.getTimeZone().getCodeSpace()); + } else { + ps.setNull(12, Types.VARCHAR); + ps.setNull(13, Types.VARCHAR); + } + + ps.setString(14, agency.getUrl()); + ps.setString(15, agency.getZipNumber()); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/AttributionImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/AttributionImporter.java new file mode 100644 index 0000000..fd2e92d --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/AttributionImporter.java @@ -0,0 +1,146 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Agency; +import org.citygml4j.ade.iur.model.urt.Attribution; +import org.citygml4j.ade.iur.model.urt.Route; +import org.citygml4j.ade.iur.model.urt.Trip; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class AttributionImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitImporter publicTransitImporter; + + private int batchCounter; + + public AttributionImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.ATTRIBUTION)) + " " + + "(id, email, isauthority, isoperator, isproducer, organizationname, phonenumber, url, " + + "agency_id, route_id, trip_id) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + } + + public void doImport(Attribution attribution, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(attribution, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + ps.setString(2, attribution.getEmail()); + + if (attribution.getIsAuthority() != null) + ps.setInt(3, attribution.getIsAuthority() ? 1 : 0); + else + ps.setNull(3, Types.INTEGER); + + if (attribution.getIsOperator() != null) + ps.setInt(4, attribution.getIsOperator() ? 1 : 0); + else + ps.setNull(4, Types.INTEGER); + + if (attribution.getIsProducer() != null) + ps.setInt(5, attribution.getIsProducer() ? 1 : 0); + else + ps.setNull(5, Types.INTEGER); + + ps.setString(6, attribution.getOrganizationName()); + ps.setString(7, attribution.getPhoneNumber()); + ps.setString(8, attribution.getUrl()); + + long agencyId = 0; + if (attribution.getAgency() != null) { + Agency agency = attribution.getAgency().getObject(); + if (agency != null) { + agencyId = helper.importObject(agency); + attribution.getAgency().unsetObject(); + } else { + String href = attribution.getAgency().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.ATTRIBUTION), + objectId, href, "agency_id"); + } + } + } + + if (agencyId != 0) + ps.setLong(9, agencyId); + else + ps.setNull(9, Types.NULL); + + long routeId = 0; + if (attribution.getRoute() != null) { + Route route = attribution.getRoute().getObject(); + if (route != null) { + routeId = helper.importObject(route); + attribution.getRoute().unsetObject(); + } else { + String href = attribution.getRoute().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.ATTRIBUTION), + objectId, href, "route_id"); + } + } + } + + if (routeId != 0) + ps.setLong(10, routeId); + else + ps.setNull(10, Types.NULL); + + long tripId = 0; + if (attribution.getTrip() != null) { + Trip trip = attribution.getTrip().getObject(); + if (trip != null) { + tripId = helper.importObject(trip); + attribution.getTrip().unsetObject(); + } else { + String href = attribution.getTrip().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.TRIP), + objectId, href, "trip_id"); + } + } + } + + if (tripId != 0) + ps.setLong(11, tripId); + else + ps.setNull(11, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/CalendarDateImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/CalendarDateImporter.java new file mode 100644 index 0000000..bdfdb83 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/CalendarDateImporter.java @@ -0,0 +1,94 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Calendar; +import org.citygml4j.ade.iur.model.urt.CalendarDate; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class CalendarDateImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitImporter publicTransitImporter; + + private int batchCounter; + + public CalendarDateImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.CALENDARDATE)) + " " + + "(id, date_, exceptiontype, exceptiontype_codespace, calendar_id) " + + "values (?, ?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + } + + public void doImport(CalendarDate calendarDate, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(calendarDate, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + if (calendarDate.getDate() != null) + ps.setDate(2, Date.valueOf(calendarDate.getDate())); + else + ps.setNull(2, Types.DATE); + + if (calendarDate.getExceptionType() != null && calendarDate.getExceptionType().isSetValue()) { + ps.setString(3, calendarDate.getExceptionType().getValue()); + ps.setString(4, calendarDate.getExceptionType().getCodeSpace()); + } else { + ps.setNull(3, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + } + + long calendarId = 0; + if (calendarDate.getCalendar() != null) { + Calendar calendar = calendarDate.getCalendar().getObject(); + if (calendar != null) { + calendarId = helper.importObject(calendar); + calendarDate.getCalendar().unsetObject(); + } else { + String href = calendarDate.getCalendar().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.CALENDARDATE), + objectId, href, "calendar_id"); + } + } + } + + if (calendarId != 0) + ps.setLong(5, calendarId); + else + ps.setNull(5, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/CalendarImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/CalendarImporter.java new file mode 100644 index 0000000..dc72953 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/CalendarImporter.java @@ -0,0 +1,74 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Calendar; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class CalendarImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final PreparedStatement ps; + private final PublicTransitImporter publicTransitImporter; + + private int batchCounter; + + public CalendarImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.CALENDAR)) + " " + + "(id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, startdate, enddate) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + } + + public void doImport(Calendar calendar, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(calendar, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + ps.setInt(2, calendar.isMonday() ? 1 : 0); + ps.setInt(3, calendar.isTuesday() ? 1 : 0); + ps.setInt(4, calendar.isWednesday() ? 1 : 0); + ps.setInt(5, calendar.isThursday() ? 1 : 0); + ps.setInt(6, calendar.isFriday() ? 1 : 0); + ps.setInt(7, calendar.isSaturday() ? 1 : 0); + ps.setInt(8, calendar.isSunday() ? 1 : 0); + + if (calendar.getStartDate() != null) + ps.setDate(9, Date.valueOf(calendar.getStartDate())); + else + ps.setNull(9, Types.DATE); + + if (calendar.getEndDate() != null) + ps.setDate(10, Date.valueOf(calendar.getEndDate())); + else + ps.setNull(10, Types.DATE); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/CityObjectGroupPropertiesImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/CityObjectGroupPropertiesImporter.java new file mode 100644 index 0000000..dced5df --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/CityObjectGroupPropertiesImporter.java @@ -0,0 +1,115 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.ADEPropertyCollection; +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.FeatureType; +import org.citygml4j.ade.iur.model.urt.DataTypeProperty; +import org.citygml4j.ade.iur.model.urt.FareRule; +import org.citygml4j.ade.iur.model.urt.FeedInfo; +import org.citygml4j.ade.iur.model.urt.Frequency; +import org.citygml4j.ade.iur.model.urt.PublicTransitDataType; +import org.citygml4j.ade.iur.model.urt.StopTime; +import org.citygml4j.ade.iur.model.urt.Transfer; +import org.citygml4j.ade.iur.model.urt.Translation; +import org.citygml4j.model.citygml.cityobjectgroup.CityObjectGroup; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class CityObjectGroupPropertiesImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private final FareRuleImporter fareRuleImporter; + private final FeedInfoImporter feedInfoImporter; + private final FrequencyImporter frequencyImporter; + private final StopTimeImporter stopTimeImporter; + private final TransferImporter transferImporter; + private final TranslationImporter translationImporter; + + private int batchCounter; + + public CityObjectGroupPropertiesImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_3)) + " " + + "(id) " + + "values (?)"); + + fareRuleImporter = manager.getImporter(FareRuleImporter.class); + feedInfoImporter = manager.getImporter(FeedInfoImporter.class); + frequencyImporter = manager.getImporter(FrequencyImporter.class); + stopTimeImporter = manager.getImporter(StopTimeImporter.class); + transferImporter = manager.getImporter(TransferImporter.class); + translationImporter = manager.getImporter(TranslationImporter.class); + } + + public void doImport(ADEPropertyCollection properties, CityObjectGroup parent, long parentId, FeatureType parentType) throws CityGMLImportException, SQLException { + ps.setLong(1, parentId); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_3)); + + for (DataTypeProperty property : properties.getAll(DataTypeProperty.class)) { + if (property.isSetValue() && property.getValue().isSetObject()) { + PublicTransitDataType dataType = property.getValue().getObject(); + if (dataType instanceof FareRule) + fareRuleImporter.doImport((FareRule) dataType, parentId); + else if (dataType instanceof FeedInfo) + feedInfoImporter.doImport((FeedInfo) dataType, parentId); + else if (dataType instanceof Frequency) + frequencyImporter.doImport((Frequency) dataType, parentId); + else if (dataType instanceof StopTime) + stopTimeImporter.doImport((StopTime) dataType, parentId); + else if (dataType instanceof Transfer) + transferImporter.doImport((Transfer) dataType, parentId); + else if (dataType instanceof Translation) + translationImporter.doImport((Translation) dataType, parentId); + } + } + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/DescriptionImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/DescriptionImporter.java new file mode 100644 index 0000000..9421c8f --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/DescriptionImporter.java @@ -0,0 +1,68 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADESequence; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urt.Description; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class DescriptionImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private int batchCounter; + + public DescriptionImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.DESCRIPTION)) + " " + + "(id, description, frequencyofservice, numberofcustomers) " + + "values (?, ?, ?, ?)"); + } + + public long doImport(Description description) throws CityGMLImportException, SQLException { + long objectId = helper.getNextSequenceValue(schemaMapper.getSequenceName(ADESequence.DESCRIPTION_SEQ)); + ps.setLong(1, objectId); + + ps.setString(2, description.getDescription()); + + if (description.getFrequencyOfService() != null) + ps.setInt(3, description.getFrequencyOfService()); + else + ps.setNull(3, Types.INTEGER); + + if (description.getNumberOfCustomers() != null) + ps.setInt(4, description.getNumberOfCustomers()); + else + ps.setNull(4, Types.INTEGER); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.DESCRIPTION)); + + return objectId; + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/FareAttributeImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/FareAttributeImporter.java new file mode 100644 index 0000000..bb9567c --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/FareAttributeImporter.java @@ -0,0 +1,112 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Agency; +import org.citygml4j.ade.iur.model.urt.FareAttribute; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class FareAttributeImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitImporter publicTransitImporter; + + private int batchCounter; + + public FareAttributeImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.FAREATTRIBUTE)) + " " + + "(id, currencytype, currencytype_codespace, paymentmethod, paymentmethod_codespace, price, " + + "transferduration, transfers, transfers_codespace, agency_id) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + } + + public void doImport(FareAttribute fareAttribute, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(fareAttribute, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + if (fareAttribute.getCurrencyType() != null && fareAttribute.getCurrencyType().isSetValue()) { + ps.setString(2, fareAttribute.getCurrencyType().getValue()); + ps.setString(3, fareAttribute.getCurrencyType().getCodeSpace()); + } else { + ps.setNull(2, Types.VARCHAR); + ps.setNull(3, Types.VARCHAR); + } + + if (fareAttribute.getPaymentMethod() != null && fareAttribute.getPaymentMethod().isSetValue()) { + ps.setString(4, fareAttribute.getPaymentMethod().getValue()); + ps.setString(5, fareAttribute.getPaymentMethod().getCodeSpace()); + } else { + ps.setNull(4, Types.VARCHAR); + ps.setNull(5, Types.VARCHAR); + } + + ps.setDouble(6, fareAttribute.getPrice()); + + if (fareAttribute.getTransferDuration() != null) + ps.setInt(7, fareAttribute.getTransferDuration()); + else + ps.setNull(7, Types.INTEGER); + + if (fareAttribute.getTransfers() != null && fareAttribute.getTransfers().isSetValue()) { + ps.setString(8, fareAttribute.getTransfers().getValue()); + ps.setString(9, fareAttribute.getTransfers().getCodeSpace()); + } else { + ps.setNull(8, Types.VARCHAR); + ps.setNull(9, Types.VARCHAR); + } + + long agencyId = 0; + if (fareAttribute.getAgency() != null) { + Agency agency = fareAttribute.getAgency().getObject(); + if (agency != null) { + agencyId = helper.importObject(agency); + fareAttribute.getAgency().unsetObject(); + } else { + String href = fareAttribute.getAgency().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.ROUTE), + objectId, href, "agency_id"); + } + } + } + + if (agencyId != 0) + ps.setLong(10, agencyId); + else + ps.setNull(10, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/FareRuleImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/FareRuleImporter.java new file mode 100644 index 0000000..81d662f --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/FareRuleImporter.java @@ -0,0 +1,125 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urt.FareAttribute; +import org.citygml4j.ade.iur.model.urt.FareRule; +import org.citygml4j.ade.iur.model.urt.Route; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class FareRuleImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitDataTypeImporter dataTypeImporter; + + private int batchCounter; + + public FareRuleImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.FARERULE)) + " " + + "(id, containsid, containsid_codespace, destinationid, destinationid_codespace, originid, " + + "originid_codespace, fare_id, route_id) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + dataTypeImporter = manager.getImporter(PublicTransitDataTypeImporter.class); + } + + public void doImport(FareRule fareRule, long cityObjectGroupId) throws CityGMLImportException, SQLException { + long objectId = dataTypeImporter.doImport(fareRule, cityObjectGroupId); + ps.setLong(1, objectId); + + if (fareRule.getContainsId() != null && fareRule.getContainsId().isSetValue()) { + ps.setString(2, fareRule.getContainsId().getValue()); + ps.setString(3, fareRule.getContainsId().getCodeSpace()); + } else { + ps.setNull(2, Types.VARCHAR); + ps.setNull(3, Types.VARCHAR); + } + + if (fareRule.getDestinationId() != null && fareRule.getDestinationId().isSetValue()) { + ps.setString(4, fareRule.getDestinationId().getValue()); + ps.setString(5, fareRule.getDestinationId().getCodeSpace()); + } else { + ps.setNull(4, Types.VARCHAR); + ps.setNull(5, Types.VARCHAR); + } + + if (fareRule.getOriginId() != null && fareRule.getOriginId().isSetValue()) { + ps.setString(6, fareRule.getOriginId().getValue()); + ps.setString(7, fareRule.getOriginId().getCodeSpace()); + } else { + ps.setNull(6, Types.VARCHAR); + ps.setNull(7, Types.VARCHAR); + } + + long fareId = 0; + if (fareRule.getFare() != null) { + FareAttribute fareAttribute = fareRule.getFare().getObject(); + if (fareAttribute != null) { + fareId = helper.importObject(fareAttribute); + fareRule.getFare().unsetObject(); + } else { + String href = fareRule.getFare().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.FARERULE), + objectId, href, "fare_id"); + } + } + } + + if (fareId != 0) + ps.setLong(8, fareId); + else + ps.setNull(8, Types.NULL); + + long routeId = 0; + if (fareRule.getRoute() != null) { + Route route = fareRule.getRoute().getObject(); + if (route != null) { + routeId = helper.importObject(route); + fareRule.getRoute().unsetObject(); + } else { + String href = fareRule.getRoute().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.FARERULE), + objectId, href, "route_id"); + } + } + } + + if (routeId != 0) + ps.setLong(9, routeId); + else + ps.setNull(9, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.FARERULE)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/FeedInfoImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/FeedInfoImporter.java new file mode 100644 index 0000000..0fcc2dc --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/FeedInfoImporter.java @@ -0,0 +1,94 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urt.FeedInfo; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class FeedInfoImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitDataTypeImporter dataTypeImporter; + + private int batchCounter; + + public FeedInfoImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.FEEDINFO)) + " " + + "(id, contactemail, contacturl, defaultlanguage, defaultlanguage_codespace, detailedinfo, " + + "enddate, language, language_codespace, publishername, publisherurl, startdate, version) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + dataTypeImporter = manager.getImporter(PublicTransitDataTypeImporter.class); + } + + public void doImport(FeedInfo feedInfo, long cityObjectGroupId) throws CityGMLImportException, SQLException { + long objectId = dataTypeImporter.doImport(feedInfo, cityObjectGroupId); + ps.setLong(1, objectId); + + ps.setString(2, feedInfo.getContactEmail()); + ps.setString(3, feedInfo.getContactURL()); + + if (feedInfo.getDefaultLanguage() != null && feedInfo.getDefaultLanguage().isSetValue()) { + ps.setString(4, feedInfo.getDefaultLanguage().getValue()); + ps.setString(5, feedInfo.getDefaultLanguage().getCodeSpace()); + } else { + ps.setNull(4, Types.VARCHAR); + ps.setNull(5, Types.VARCHAR); + } + + ps.setString(6, feedInfo.getDetailedInfo()); + + if (feedInfo.getEndDate() != null) + ps.setDate(7, Date.valueOf(feedInfo.getEndDate())); + else + ps.setNull(7, Types.DATE); + + if (feedInfo.getLanguage() != null && feedInfo.getLanguage().isSetValue()) { + ps.setString(8, feedInfo.getLanguage().getValue()); + ps.setString(9, feedInfo.getLanguage().getCodeSpace()); + } else { + ps.setNull(8, Types.VARCHAR); + ps.setNull(9, Types.VARCHAR); + } + + ps.setString(10, feedInfo.getPublisherName()); + ps.setString(11, feedInfo.getPublisherUrl()); + + if (feedInfo.getStartDate() != null) + ps.setDate(12, Date.valueOf(feedInfo.getStartDate())); + else + ps.setNull(12, Types.DATE); + + ps.setString(13, feedInfo.getVersion()); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.FEEDINFO)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/FrequencyImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/FrequencyImporter.java new file mode 100644 index 0000000..d4c0ae7 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/FrequencyImporter.java @@ -0,0 +1,104 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urt.Frequency; +import org.citygml4j.ade.iur.model.urt.Trip; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.sql.Types; +import java.time.LocalDate; +import java.time.LocalDateTime; + +public class FrequencyImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitDataTypeImporter dataTypeImporter; + + private int batchCounter; + + public FrequencyImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.FREQUENCY)) + " " + + "(id, endtime, exacttimes, exacttimes_codespace, headwaysecs, starttime, trip_id) " + + "values (?, ?, ?, ?, ?, ?, ?)"); + + dataTypeImporter = manager.getImporter(PublicTransitDataTypeImporter.class); + } + + public void doImport(Frequency frequency, long cityObjectGroupId) throws CityGMLImportException, SQLException { + long objectId = dataTypeImporter.doImport(frequency, cityObjectGroupId); + ps.setLong(1, objectId); + + if (frequency.getEndTime() != null) + ps.setTimestamp(2, Timestamp.valueOf(LocalDateTime.of(LocalDate.ofEpochDay(0), frequency.getEndTime()))); + else + ps.setNull(2, Types.TIMESTAMP_WITH_TIMEZONE); + + if (frequency.getExactTimes() != null && frequency.getExactTimes().isSetValue()) { + ps.setString(3, frequency.getExactTimes().getValue()); + ps.setString(4, frequency.getExactTimes().getCodeSpace()); + } else { + ps.setNull(3, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + } + + if (frequency.getHeadwaySecs() != null) + ps.setInt(5, frequency.getHeadwaySecs()); + else + ps.setNull(5, Types.INTEGER); + + if (frequency.getStartTime() != null) + ps.setTimestamp(6, Timestamp.valueOf(LocalDateTime.of(LocalDate.ofEpochDay(0), frequency.getStartTime()))); + else + ps.setNull(6, Types.TIMESTAMP_WITH_TIMEZONE); + + long tripId = 0; + if (frequency.getTrip() != null) { + Trip trip = frequency.getTrip().getObject(); + if (trip != null) { + tripId = helper.importObject(trip); + frequency.getTrip().unsetObject(); + } else { + String href = frequency.getTrip().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.FREQUENCY), + objectId, href, "trip_id"); + } + } + } + + if (tripId != 0) + ps.setLong(7, tripId); + else + ps.setNull(7, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.FREQUENCY)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/OfficeImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/OfficeImporter.java new file mode 100644 index 0000000..477a5d5 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/OfficeImporter.java @@ -0,0 +1,58 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Office; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class OfficeImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final PreparedStatement ps; + private final PublicTransitImporter publicTransitImporter; + + private int batchCounter; + + public OfficeImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.OFFICE)) + " " + + "(id, name, phone, url) " + + "values (?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + } + + public void doImport(Office office, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(office, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + ps.setString(2, office.getOfficeName()); + ps.setString(3, office.getPhone()); + ps.setString(4, office.getUrl()); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/PathwayImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/PathwayImporter.java new file mode 100644 index 0000000..1a0cf2d --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/PathwayImporter.java @@ -0,0 +1,150 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Pathway; +import org.citygml4j.ade.iur.model.urt.Stop; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class PathwayImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitImporter publicTransitImporter; + + private int batchCounter; + + public PathwayImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PATHWAY)) + " " + + "(id, isbidirectional, isbidirectional_codespace, length, length_uom, maxslope, minwidth, " + + "mode_, mode_codespace, reversedsignpostedas, signpostedas, staircount, traversaltime, " + + "from_id, to_id) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + } + + public void doImport(Pathway pathway, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(pathway, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + if (pathway.getIsBidirectional() != null && pathway.getIsBidirectional().isSetValue()) { + ps.setString(2, pathway.getIsBidirectional().getValue()); + ps.setString(3, pathway.getIsBidirectional().getCodeSpace()); + } else { + ps.setNull(2, Types.VARCHAR); + ps.setNull(3, Types.VARCHAR); + } + + if (pathway.getLength() != null && pathway.getLength().isSetValue()) { + ps.setDouble(4, pathway.getLength().getValue()); + ps.setString(5, pathway.getLength().getUom()); + } else { + ps.setNull(4, Types.DOUBLE); + ps.setNull(5, Types.VARCHAR); + } + + if (pathway.getMaxSlope() != null) + ps.setDouble(6, pathway.getMaxSlope()); + else + ps.setNull(6, Types.DOUBLE); + + if (pathway.getMinWidth() != null) + ps.setDouble(7, pathway.getMinWidth()); + else + ps.setNull(7, Types.DOUBLE); + + if (pathway.getMode() != null && pathway.getMode().isSetValue()) { + ps.setString(8, pathway.getMode().getValue()); + ps.setString(9, pathway.getMode().getCodeSpace()); + } else { + ps.setNull(8, Types.VARCHAR); + ps.setNull(9, Types.VARCHAR); + } + + ps.setString(10, pathway.getReversedSignpostedAs()); + ps.setString(11, pathway.getSignpostedAs()); + + if (pathway.getStairCount() != null) + ps.setInt(12, pathway.getStairCount()); + else + ps.setNull(12, Types.INTEGER); + + if (pathway.getTraversalTime() != null) + ps.setInt(13, pathway.getTraversalTime()); + else + ps.setNull(13, Types.INTEGER); + + long fromId = 0; + if (pathway.getFrom() != null) { + Stop object = pathway.getFrom().getObject(); + if (object != null) { + fromId = helper.importObject(object); + pathway.getFrom().unsetObject(); + } else { + String href = pathway.getFrom().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.PATHWAY), + objectId, href, "from_id"); + } + } + } + + if (fromId != 0) + ps.setLong(14, fromId); + else + ps.setNull(14, Types.NULL); + + long toId = 0; + if (pathway.getTo() != null) { + Stop object = pathway.getTo().getObject(); + if (object != null) { + toId = helper.importObject(object); + pathway.getTo().unsetObject(); + } else { + String href = pathway.getTo().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.PATHWAY), + objectId, href, "to_id"); + } + } + } + + if (toId != 0) + ps.setLong(15, toId); + else + ps.setNull(15, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/PointImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/PointImporter.java new file mode 100644 index 0000000..ea23177 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/PointImporter.java @@ -0,0 +1,90 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADESequence; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.citygml.importer.database.content.GeometryConverter; +import org.citydb.config.geometry.GeometryObject; +import org.citygml4j.ade.iur.model.urt.Point; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class PointImporter implements PublicTransitModuleImporter { + private final Connection connection; + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final GeometryConverter geometryConverter; + + private int batchCounter; + + public PointImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.connection = connection; + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.POINT)) + " " + + "(id, publictransit_point_id, latitude, longitude, point, pointdistancetraveled, pointsequence) " + + "values (?, ?, ?, ?, ?, ?, ?)"); + + geometryConverter = helper.getGeometryConverter(); + } + + public void doImport(Point point, long parentId) throws CityGMLImportException, SQLException { + long objectId = helper.getNextSequenceValue(schemaMapper.getSequenceName(ADESequence.POINT_SEQ)); + ps.setLong(1, objectId); + ps.setLong(2, parentId); + + if (point.getLatitude() != null) + ps.setDouble(3, point.getLatitude()); + else + ps.setNull(3, Types.DOUBLE); + + if (point.getLongitude() != null) + ps.setDouble(4, point.getLongitude()); + else + ps.setNull(4, Types.DOUBLE); + + GeometryObject geometry = geometryConverter.getPoint(point.getPoint()); + if (geometry != null) { + ps.setObject(5, helper.getDatabaseAdapter().getGeometryConverter().getDatabaseObject(geometry, connection)); + point.setPoint(null); + } else + ps.setNull(5, helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryType(), + helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryTypeName()); + + if (point.getPointDistanceTraveled() != null) + ps.setDouble(6, point.getPointDistanceTraveled()); + else + ps.setNull(6, Types.DOUBLE); + + if (point.getPointSequence() != null) + ps.setInt(7, point.getPointSequence()); + else + ps.setNull(7, Types.INTEGER); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.POINT)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitDataTypeImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitDataTypeImporter.java new file mode 100644 index 0000000..f0a10bd --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitDataTypeImporter.java @@ -0,0 +1,60 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADESequence; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.ObjectMapper; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urt.PublicTransitDataType; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class PublicTransitDataTypeImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final ObjectMapper objectMapper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private int batchCounter; + + public PublicTransitDataTypeImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + this.objectMapper = manager.getObjectMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSITDATATYPE)) + " " + + "(id, objectclass_id, cityobjectgroup_datatype_id) " + + "values (?, ?, ?)"); + } + + public long doImport(PublicTransitDataType dataType, long cityObjectGroupId) throws CityGMLImportException, SQLException { + long objectId = helper.getNextSequenceValue(schemaMapper.getSequenceName(ADESequence.PUBLICTRANSITDATAT_SEQ)); + ps.setLong(1, objectId); + ps.setLong(2, objectMapper.getTypeClassId(dataType.getClass())); + ps.setLong(3, cityObjectGroupId); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.PUBLICTRANSITDATATYPE)); + + return objectId; + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitImporter.java new file mode 100644 index 0000000..52ad859 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitImporter.java @@ -0,0 +1,100 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Level; +import org.citygml4j.ade.iur.model.urt.PointProperty; +import org.citygml4j.ade.iur.model.urt.PublicTransit; +import org.citygml4j.ade.iur.model.urt.Shape; +import org.citygml4j.model.citygml.core.AbstractCityObject; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class PublicTransitImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PointImporter pointImporter; + + private int batchCounter; + + public PublicTransitImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.PUBLICTRANSIT)) + " " + + "(id, objectclass_id, orgid, target_id, index_) " + + "values (?, ?, ?, ?, ?)"); + + pointImporter = manager.getImporter(PointImporter.class); + } + + public void doImport(PublicTransit publicTransit, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + ps.setLong(1, objectId); + ps.setInt(2, objectType.getObjectClassId()); + + ps.setString(3,publicTransit.getOrgId()); + + long cityObjectId = 0; + if (publicTransit.getTarget() != null) { + AbstractCityObject cityObject = publicTransit.getTarget().getObject(); + if (cityObject != null) { + cityObjectId = helper.importObject(cityObject); + publicTransit.getTarget().unsetObject(); + } else { + String href = publicTransit.getTarget().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.PUBLICTRANSIT), + objectId, href, "target_id"); + } + } + } + + if (cityObjectId != 0) + ps.setLong(4, cityObjectId); + else + ps.setNull(4, Types.NULL); + + if (publicTransit instanceof Level) + ps.setDouble(5, ((Level) publicTransit).getIndex()); + else + ps.setNull(5, Types.DOUBLE); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + + if (publicTransit instanceof Shape) { + Shape shape = (Shape) publicTransit; + for (PointProperty property : shape.getPoints()) { + if (property.getObject() != null) { + pointImporter.doImport(property.getObject(), objectId); + property.unsetObject(); + } + } + } + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitModuleImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitModuleImporter.java new file mode 100644 index 0000000..cb0dbc9 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/PublicTransitModuleImporter.java @@ -0,0 +1,6 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.ADEImporter; + +public interface PublicTransitModuleImporter extends ADEImporter { +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/RouteImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/RouteImporter.java new file mode 100644 index 0000000..4c4aeb8 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/RouteImporter.java @@ -0,0 +1,179 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.citygml.importer.database.content.GeometryConverter; +import org.citydb.config.geometry.GeometryObject; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Agency; +import org.citygml4j.ade.iur.model.urt.Route; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class RouteImporter implements PublicTransitModuleImporter { + private final Connection connection; + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private final PublicTransitImporter publicTransitImporter; + private final DescriptionImporter descriptionImporter; + private final GeometryConverter geometryConverter; + + private int batchCounter; + + public RouteImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.connection = connection; + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.ROUTE)) + " " + + "(id, color, continuousdropoff, continuousdropoff_codespace, continuouspickup, continuouspickup_codespace, " + + "destinationstop, lod0multicurve, longname, originstop, routesortorder, shortname, textcolor, " + + "type, type_codespace, updatedate, url, viastop, description_id, agency_id, parentroute_id) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + descriptionImporter = manager.getImporter(DescriptionImporter.class); + geometryConverter = helper.getGeometryConverter(); + } + + public void doImport(Route route, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(route, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + ps.setString(2, route.getColor()); + + if (route.getContinuousDropOff() != null && route.getContinuousDropOff().isSetValue()) { + ps.setString(3, route.getContinuousDropOff().getValue()); + ps.setString(4, route.getContinuousDropOff().getCodeSpace()); + } else { + ps.setNull(3, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + } + + if (route.getContinuousPickup() != null && route.getContinuousPickup().isSetValue()) { + ps.setString(5, route.getContinuousPickup().getValue()); + ps.setString(6, route.getContinuousPickup().getCodeSpace()); + } else { + ps.setNull(5, Types.VARCHAR); + ps.setNull(6, Types.VARCHAR); + } + + ps.setString(7, route.getDestinationStop()); + + GeometryObject multiCurve = geometryConverter.getMultiCurve(route.getLod0MultiCurve()); + if (multiCurve != null) { + ps.setObject(8, helper.getDatabaseAdapter().getGeometryConverter().getDatabaseObject(multiCurve, connection)); + route.setLod0MultiCurve(null); + } else + ps.setNull(8, helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryType(), + helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryTypeName()); + + ps.setString(9, route.getLongName()); + ps.setString(10, route.getOriginStop()); + + if (route.getRouteSortOrder() != null) + ps.setInt(11, route.getRouteSortOrder()); + else + ps.setNull(11, Types.INTEGER); + + ps.setString(12, route.getShortName()); + ps.setString(13, route.getTextColor()); + + if (route.getType() != null && route.getType().isSetValue()) { + ps.setString(14, route.getType().getValue()); + ps.setString(15, route.getType().getCodeSpace()); + } else { + ps.setNull(14, Types.VARCHAR); + ps.setNull(15, Types.VARCHAR); + } + + if (route.getUpdateDate() != null) + ps.setDate(16, Date.valueOf(route.getUpdateDate())); + else + ps.setNull(16, Types.DATE); + + ps.setString(17, route.getUrl()); + ps.setString(18, route.getViaStop()); + + long descriptionId = 0; + if (route.getRouteDescription() != null && route.getRouteDescription().getObject() != null) { + descriptionId = descriptionImporter.doImport(route.getRouteDescription().getObject()); + route.getRouteDescription().setObject(null); + } + + if (descriptionId != 0) + ps.setLong(19, descriptionId); + else + ps.setNull(19, Types.NULL); + + long agencyId = 0; + if (route.getAgency() != null) { + Agency agency = route.getAgency().getObject(); + if (agency != null) { + agencyId = helper.importObject(agency); + route.getAgency().unsetObject(); + } else { + String href = route.getAgency().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.ROUTE), + objectId, href, "agency_id"); + } + } + } + + if (agencyId != 0) + ps.setLong(20, agencyId); + else + ps.setNull(20, Types.NULL); + + long parentRouteId = 0; + if (route.getParentRoute() != null) { + Route parent = route.getParentRoute().getObject(); + if (parent != null) { + parentRouteId = helper.importObject(parent); + route.getParentRoute().unsetObject(); + } else { + String href = route.getParentRoute().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.ROUTE), + objectId, href, "parentroute_id"); + } + } + } + + if (parentRouteId != 0) + ps.setLong(21, parentRouteId); + else + ps.setNull(21, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/StopImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/StopImporter.java new file mode 100644 index 0000000..7320fda --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/StopImporter.java @@ -0,0 +1,173 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.citygml.importer.database.content.GeometryConverter; +import org.citydb.config.geometry.GeometryObject; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Level; +import org.citygml4j.ade.iur.model.urt.Stop; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class StopImporter implements PublicTransitModuleImporter { + private final Connection connection; + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private final PublicTransitImporter publicTransitImporter; + private final GeometryConverter geometryConverter; + + private int batchCounter; + + public StopImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.connection = connection; + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.STOP)) + " " + + "(id, code, code_codespace, latitude, longitude, locationtype, locationtype_codespace, platformcode, " + + "point, timezone, timezone_codespace, ttsname, url, wheelchairboarding, wheelchairboarding_codespace, " + + "zoneid, zoneid_codespace, level_id, parentstation_id) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + geometryConverter = helper.getGeometryConverter(); + } + + public void doImport(Stop stop, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(stop, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + if (stop.getCode() != null && stop.getCode().isSetValue()) { + ps.setString(2, stop.getCode().getValue()); + ps.setString(3, stop.getCode().getCodeSpace()); + } else { + ps.setNull(2, Types.VARCHAR); + ps.setNull(3, Types.VARCHAR); + } + + if (stop.getLatitude() != null) + ps.setDouble(4, stop.getLatitude()); + else + ps.setNull(4, Types.DOUBLE); + + if (stop.getLongitude() != null) + ps.setDouble(5, stop.getLongitude()); + else + ps.setNull(5, Types.DOUBLE); + + if (stop.getLocationType() != null && stop.getLocationType().isSetValue()) { + ps.setString(6, stop.getLocationType().getValue()); + ps.setString(7, stop.getLocationType().getCodeSpace()); + } else { + ps.setNull(6, Types.VARCHAR); + ps.setNull(7, Types.VARCHAR); + } + + ps.setString(8, stop.getPlatformCode()); + + GeometryObject point = geometryConverter.getPoint(stop.getPoint()); + if (point != null) { + ps.setObject(9, helper.getDatabaseAdapter().getGeometryConverter().getDatabaseObject(point, connection)); + stop.setPoint(null); + } else + ps.setNull(9, helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryType(), + helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryTypeName()); + + if (stop.getTimeZone() != null && stop.getTimeZone().isSetValue()) { + ps.setString(10, stop.getTimeZone().getValue()); + ps.setString(11, stop.getTimeZone().getCodeSpace()); + } else { + ps.setNull(10, Types.VARCHAR); + ps.setNull(11, Types.VARCHAR); + } + + ps.setString(12, stop.getTtsName()); + ps.setString(13, stop.getUrl()); + + if (stop.getWheelchairBoarding() != null && stop.getWheelchairBoarding().isSetValue()) { + ps.setString(14, stop.getWheelchairBoarding().getValue()); + ps.setString(15, stop.getWheelchairBoarding().getCodeSpace()); + } else { + ps.setNull(14, Types.VARCHAR); + ps.setNull(15, Types.VARCHAR); + } + + if (stop.getZoneId() != null && stop.getZoneId().isSetValue()) { + ps.setString(16, stop.getZoneId().getValue()); + ps.setString(17, stop.getZoneId().getCodeSpace()); + } else { + ps.setNull(16, Types.VARCHAR); + ps.setNull(17, Types.VARCHAR); + } + + long levelId = 0; + if (stop.getLevel() != null) { + Level level = stop.getLevel().getObject(); + if (level != null) { + levelId = helper.importObject(level); + stop.getLevel().unsetObject(); + } else { + String href = stop.getLevel().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.STOP), + objectId, href, "level_id"); + } + } + } + + if (levelId != 0) + ps.setLong(18, levelId); + else + ps.setNull(18, Types.NULL); + + long parentStationId = 0; + if (stop.getParentStation() != null) { + Stop parent = stop.getParentStation().getObject(); + if (parent != null) { + parentStationId = helper.importObject(parent); + stop.getParentStation().unsetObject(); + } else { + String href = stop.getParentStation().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.STOP), + objectId, href, "parentstation_id"); + } + } + } + + if (parentStationId != 0) + ps.setLong(19, parentStationId); + else + ps.setNull(19, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/StopTimeImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/StopTimeImporter.java new file mode 100644 index 0000000..871bb9b --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/StopTimeImporter.java @@ -0,0 +1,168 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urt.Stop; +import org.citygml4j.ade.iur.model.urt.StopTime; +import org.citygml4j.ade.iur.model.urt.Trip; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.sql.Types; +import java.time.LocalDate; +import java.time.LocalDateTime; + +public class StopTimeImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitDataTypeImporter dataTypeImporter; + + private int batchCounter; + + public StopTimeImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.STOPTIME)) + " " + + "(id, arrivaltime, continuousdropofftype, continuousdropofft_codespace, continuouspickuptype, " + + "continuouspickupty_codespace, departuretime, dropofftype, dropofftype_codespace, headsign, " + + "pickuptype, pickuptype_codespace, shapedistancetraveled, stopsequence, timepoint, timepoint_codespace, " + + "stop_id, trip_id) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + dataTypeImporter = manager.getImporter(PublicTransitDataTypeImporter.class); + } + + public void doImport(StopTime stopTime, long cityObjectGroupId) throws CityGMLImportException, SQLException { + long objectId = dataTypeImporter.doImport(stopTime, cityObjectGroupId); + ps.setLong(1, objectId); + + if (stopTime.getArrivalTime() != null) + ps.setTimestamp(2, Timestamp.valueOf(LocalDateTime.of(LocalDate.ofEpochDay(0), stopTime.getArrivalTime()))); + else + ps.setNull(2, Types.TIMESTAMP_WITH_TIMEZONE); + + if (stopTime.getContinuousDropoffType() != null && stopTime.getContinuousDropoffType().isSetValue()) { + ps.setString(3, stopTime.getContinuousDropoffType().getValue()); + ps.setString(4, stopTime.getContinuousDropoffType().getCodeSpace()); + } else { + ps.setNull(3, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + } + + if (stopTime.getContinuousPickupType() != null && stopTime.getContinuousPickupType().isSetValue()) { + ps.setString(5, stopTime.getContinuousPickupType().getValue()); + ps.setString(6, stopTime.getContinuousPickupType().getCodeSpace()); + } else { + ps.setNull(5, Types.VARCHAR); + ps.setNull(6, Types.VARCHAR); + } + + if (stopTime.getDepartureTime() != null) + ps.setTimestamp(7, Timestamp.valueOf(LocalDateTime.of(LocalDate.ofEpochDay(0), stopTime.getDepartureTime()))); + else + ps.setNull(7, Types.TIMESTAMP_WITH_TIMEZONE); + + if (stopTime.getDropoffType() != null && stopTime.getDropoffType().isSetValue()) { + ps.setString(8, stopTime.getDropoffType().getValue()); + ps.setString(9, stopTime.getDropoffType().getCodeSpace()); + } else { + ps.setNull(8, Types.VARCHAR); + ps.setNull(9, Types.VARCHAR); + } + + ps.setString(10, stopTime.getHeadsign()); + + if (stopTime.getPickupType() != null && stopTime.getPickupType().isSetValue()) { + ps.setString(11, stopTime.getPickupType().getValue()); + ps.setString(12, stopTime.getPickupType().getCodeSpace()); + } else { + ps.setNull(11, Types.VARCHAR); + ps.setNull(12, Types.VARCHAR); + } + + if (stopTime.getShapeDistanceTraveled() != null) + ps.setDouble(13, stopTime.getShapeDistanceTraveled()); + else + ps.setNull(13, Types.DOUBLE); + + if (stopTime.getStopSequence() != null) + ps.setInt(14, stopTime.getStopSequence()); + else + ps.setNull(14, Types.INTEGER); + + if (stopTime.getTimePoint() != null && stopTime.getTimePoint().isSetValue()) { + ps.setString(15, stopTime.getTimePoint().getValue()); + ps.setString(16, stopTime.getTimePoint().getCodeSpace()); + } else { + ps.setNull(15, Types.VARCHAR); + ps.setNull(16, Types.VARCHAR); + } + + long stopId = 0; + if (stopTime.getStop() != null) { + Stop stop = stopTime.getStop().getObject(); + if (stop != null) { + stopId = helper.importObject(stop); + stopTime.getStop().unsetObject(); + } else { + String href = stopTime.getStop().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.STOPTIME), + objectId, href, "stop_id"); + } + } + } + + if (stopId != 0) + ps.setLong(17, stopId); + else + ps.setNull(17, Types.NULL); + + long tripId = 0; + if (stopTime.getTrip() != null) { + Trip trip = stopTime.getTrip().getObject(); + if (trip != null) { + tripId = helper.importObject(trip); + stopTime.getTrip().unsetObject(); + } else { + String href = stopTime.getTrip().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.STOPTIME), + objectId, href, "trip_id"); + } + } + } + + if (tripId != 0) + ps.setLong(18, tripId); + else + ps.setNull(18, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.STOPTIME)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/TransferImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/TransferImporter.java new file mode 100644 index 0000000..21f1556 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/TransferImporter.java @@ -0,0 +1,112 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urt.Stop; +import org.citygml4j.ade.iur.model.urt.Transfer; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class TransferImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitDataTypeImporter dataTypeImporter; + + private int batchCounter; + + public TransferImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.TRANSFER)) + " " + + "(id, mintransfertime, transfertype, transfertype_codespace, from_id, to_id) " + + "values (?, ?, ?, ?, ?, ?)"); + + dataTypeImporter = manager.getImporter(PublicTransitDataTypeImporter.class); + } + + public void doImport(Transfer transfer, long cityObjectGroupId) throws CityGMLImportException, SQLException { + long objectId = dataTypeImporter.doImport(transfer, cityObjectGroupId); + ps.setLong(1, objectId); + + if (transfer.getMinTransferTime() != null) + ps.setInt(2, transfer.getMinTransferTime()); + else + ps.setNull(2, Types.INTEGER); + + if (transfer.getTransferType() != null && transfer.getTransferType().isSetValue()) { + ps.setString(3, transfer.getTransferType().getValue()); + ps.setString(4, transfer.getTransferType().getCodeSpace()); + } else { + ps.setNull(3, Types.VARCHAR); + ps.setNull(4, Types.VARCHAR); + } + + long fromId = 0; + if (transfer.getFrom() != null) { + Stop stop = transfer.getFrom().getObject(); + if (stop != null) { + fromId = helper.importObject(stop); + transfer.getFrom().unsetObject(); + } else { + String href = transfer.getFrom().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.TRANSFER), + objectId, href, "from_id"); + } + } + } + + if (fromId != 0) + ps.setLong(5, fromId); + else + ps.setNull(5, Types.NULL); + + long toId = 0; + if (transfer.getTo() != null) { + Stop stop = transfer.getTo().getObject(); + if (stop != null) { + toId = helper.importObject(stop); + transfer.getTo().unsetObject(); + } else { + String href = transfer.getTo().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.TRANSFER), + objectId, href, "to_id"); + } + } + } + + if (toId != 0) + ps.setLong(6, toId); + else + ps.setNull(6, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.TRANSFER)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/TranslationImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/TranslationImporter.java new file mode 100644 index 0000000..3cb3eac --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/TranslationImporter.java @@ -0,0 +1,102 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citygml4j.ade.iur.model.urt.PublicTransit; +import org.citygml4j.ade.iur.model.urt.Translation; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class TranslationImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + private final PublicTransitDataTypeImporter dataTypeImporter; + + private int batchCounter; + + public TranslationImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.TRANSLATION)) + " " + + "(id, fieldname, fieldvalue, language, language_codespace, recordsubid, tablename, tablename_codespace " + + "translation, recordid_id) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + dataTypeImporter = manager.getImporter(PublicTransitDataTypeImporter.class); + } + + public void doImport(Translation translation, long cityObjectGroupId) throws CityGMLImportException, SQLException { + long objectId = dataTypeImporter.doImport(translation, cityObjectGroupId); + ps.setLong(1, objectId); + + ps.setString(2, translation.getFieldName()); + ps.setString(3, translation.getFieldValue()); + + if (translation.getLanguage() != null && translation.getLanguage().isSetValue()) { + ps.setString(4, translation.getLanguage().getValue()); + ps.setString(5, translation.getLanguage().getCodeSpace()); + } else { + ps.setNull(4, Types.VARCHAR); + ps.setNull(5, Types.VARCHAR); + } + + ps.setString(6, translation.getRecordSubId()); + + if (translation.getTableName() != null && translation.getTableName().isSetValue()) { + ps.setString(7, translation.getTableName().getValue()); + ps.setString(8, translation.getTableName().getCodeSpace()); + } else { + ps.setNull(7, Types.VARCHAR); + ps.setNull(8, Types.VARCHAR); + } + + ps.setString(9, translation.getTranslation()); + + long recordId = 0; + if (translation.getRecordId() != null) { + PublicTransit publicTransit = translation.getRecordId().getObject(); + if (publicTransit != null) { + recordId = helper.importObject(publicTransit); + translation.getRecordId().unsetObject(); + } else { + String href = translation.getRecordId().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.TRANSLATION), + objectId, href, "recordid_id"); + } + } + } + + if (recordId != 0) + ps.setLong(10, recordId); + else + ps.setNull(10, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(schemaMapper.getTableName(ADETable.TRANSLATION)); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/TranslationJPImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/TranslationJPImporter.java new file mode 100644 index 0000000..b2dd7ea --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/TranslationJPImporter.java @@ -0,0 +1,65 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.TranslationJP; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class TranslationJPImporter implements PublicTransitModuleImporter { + private final CityGMLImportHelper helper; + private final PreparedStatement ps; + private final PublicTransitImporter publicTransitImporter; + + private int batchCounter; + + public TranslationJPImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.helper = helper; + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.TRANSLATIONJP)) + " " + + "(id, language, language_codespace, translation) " + + "values (?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + } + + public void doImport(TranslationJP translationJP, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(translationJP, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + if (translationJP.getLanguage() != null && translationJP.getLanguage().isSetValue()) { + ps.setString(2, translationJP.getLanguage().getValue()); + ps.setString(3, translationJP.getLanguage().getCodeSpace()); + } else { + ps.setNull(2, Types.VARCHAR); + ps.setNull(3, Types.VARCHAR); + } + + ps.setString(4, translationJP.getTranslation()); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/importer/urt/TripImporter.java b/src/main/java/org/citydb/ade/iur/importer/urt/TripImporter.java new file mode 100644 index 0000000..cfbfd8a --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/importer/urt/TripImporter.java @@ -0,0 +1,216 @@ +package org.citydb.ade.iur.importer.urt; + +import org.citydb.ade.importer.CityGMLImportHelper; +import org.citydb.ade.importer.ForeignKeys; +import org.citydb.ade.iur.importer.ImportManager; +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.citygml.importer.CityGMLImportException; +import org.citydb.citygml.importer.database.content.GeometryConverter; +import org.citydb.config.geometry.GeometryObject; +import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citygml4j.ade.iur.model.urt.Calendar; +import org.citygml4j.ade.iur.model.urt.CalendarDate; +import org.citygml4j.ade.iur.model.urt.Office; +import org.citygml4j.ade.iur.model.urt.Route; +import org.citygml4j.ade.iur.model.urt.Shape; +import org.citygml4j.ade.iur.model.urt.Trip; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Types; + +public class TripImporter implements PublicTransitModuleImporter { + private final Connection connection; + private final CityGMLImportHelper helper; + private final SchemaMapper schemaMapper; + private final PreparedStatement ps; + + private final PublicTransitImporter publicTransitImporter; + private final GeometryConverter geometryConverter; + + private int batchCounter; + + public TripImporter(Connection connection, CityGMLImportHelper helper, ImportManager manager) throws CityGMLImportException, SQLException { + this.connection = connection; + this.helper = helper; + this.schemaMapper = manager.getSchemaMapper(); + + ps = connection.prepareStatement("insert into " + + helper.getTableNameWithSchema(manager.getSchemaMapper().getTableName(ADETable.TRIP)) + " " + + "(id, bikeallowed, bikeallowed_codespace, blockid, directionid, directionid_codespace, headsign, " + + "lod0multicurve, shortname, symbol, wheelchairaccessible, wheelchairaccessib_codespace, " + + "calendar_id, calendardate_id, office_id, route_id, shape_id) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + publicTransitImporter = manager.getImporter(PublicTransitImporter.class); + geometryConverter = helper.getGeometryConverter(); + } + + public void doImport(Trip trip, long objectId, AbstractObjectType objectType, ForeignKeys foreignKeys) throws CityGMLImportException, SQLException { + publicTransitImporter.doImport(trip, objectId, objectType, foreignKeys); + ps.setLong(1, objectId); + + if (trip.getBikeAllowed() != null && trip.getBikeAllowed().isSetValue()) { + ps.setString(2, trip.getBikeAllowed().getValue()); + ps.setString(3, trip.getBikeAllowed().getCodeSpace()); + } else { + ps.setNull(2, Types.VARCHAR); + ps.setNull(3, Types.VARCHAR); + } + + ps.setString(4, trip.getBlockId()); + + if (trip.getDirectionId() != null && trip.getDirectionId().isSetValue()) { + ps.setString(5, trip.getDirectionId().getValue()); + ps.setString(6, trip.getDirectionId().getCodeSpace()); + } else { + ps.setNull(5, Types.VARCHAR); + ps.setNull(6, Types.VARCHAR); + } + + ps.setString(7, trip.getHeadsign()); + + GeometryObject multiCurve = geometryConverter.getMultiCurve(trip.getLod0MultiCurve()); + if (multiCurve != null) { + ps.setObject(8, helper.getDatabaseAdapter().getGeometryConverter().getDatabaseObject(multiCurve, connection)); + trip.setLod0MultiCurve(null); + } else + ps.setNull(8, helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryType(), + helper.getDatabaseAdapter().getGeometryConverter().getNullGeometryTypeName()); + + ps.setString(9, trip.getShortName()); + ps.setString(10, trip.getSymbol()); + + if (trip.getWheelchairAccessible() != null && trip.getWheelchairAccessible().isSetValue()) { + ps.setString(11, trip.getWheelchairAccessible().getValue()); + ps.setString(12, trip.getWheelchairAccessible().getCodeSpace()); + } else { + ps.setNull(11, Types.VARCHAR); + ps.setNull(12, Types.VARCHAR); + } + + long calendarId = 0; + if (trip.getCalendar() != null) { + Calendar calendar = trip.getCalendar().getObject(); + if (calendar != null) { + calendarId = helper.importObject(calendar); + trip.getCalendar().unsetObject(); + } else { + String href = trip.getCalendar().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.TRIP), + objectId, href, "calendar_id"); + } + } + } + + if (calendarId != 0) + ps.setLong(13, calendarId); + else + ps.setNull(13, Types.NULL); + + long calendarDateId = 0; + if (trip.getCalendarDate() != null) { + CalendarDate calendarDate = trip.getCalendarDate().getObject(); + if (calendarDate != null) { + calendarDateId = helper.importObject(calendarDate); + trip.getCalendarDate().unsetObject(); + } else { + String href = trip.getCalendarDate().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.TRIP), + objectId, href, "calendardate_id"); + } + } + } + + if (calendarDateId != 0) + ps.setLong(14, calendarDateId); + else + ps.setNull(14, Types.NULL); + + long officeId = 0; + if (trip.getOffice() != null) { + Office office = trip.getOffice().getObject(); + if (office != null) { + officeId = helper.importObject(office); + trip.getOffice().unsetObject(); + } else { + String href = trip.getOffice().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.TRIP), + objectId, href, "office_id"); + } + } + } + + if (officeId != 0) + ps.setLong(15, officeId); + else + ps.setNull(15, Types.NULL); + + long routeId = 0; + if (trip.getRoute() != null) { + Route route = trip.getRoute().getObject(); + if (route != null) { + routeId = helper.importObject(route); + trip.getRoute().unsetObject(); + } else { + String href = trip.getRoute().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.TRIP), + objectId, href, "route_id"); + } + } + } + + if (routeId != 0) + ps.setLong(16, routeId); + else + ps.setNull(16, Types.NULL); + + long shapeId = 0; + if (trip.getShape() != null) { + Shape shape = trip.getShape().getObject(); + if (shape != null) { + shapeId = helper.importObject(shape); + trip.getShape().unsetObject(); + } else { + String href = trip.getShape().getHref(); + if (href != null && !href.isEmpty()) { + helper.propagateObjectXlink( + schemaMapper.getTableName(ADETable.TRIP), + objectId, href, "shape_id"); + } + } + } + + if (shapeId != 0) + ps.setLong(17, shapeId); + else + ps.setNull(17, Types.NULL); + + ps.addBatch(); + if (++batchCounter == helper.getDatabaseAdapter().getMaxBatchSize()) + helper.executeBatch(objectType); + } + + @Override + public void executeBatch() throws CityGMLImportException, SQLException { + if (batchCounter > 0) { + ps.executeBatch(); + batchCounter = 0; + } + } + + @Override + public void close() throws CityGMLImportException, SQLException { + ps.close(); + } +} diff --git a/src/main/java/org/citydb/ade/iur/kmlExporter/KMLExportManager.java b/src/main/java/org/citydb/ade/iur/kmlExporter/KMLExportManager.java index 99b78a8..1c0d8b1 100644 --- a/src/main/java/org/citydb/ade/iur/kmlExporter/KMLExportManager.java +++ b/src/main/java/org/citydb/ade/iur/kmlExporter/KMLExportManager.java @@ -22,16 +22,20 @@ package org.citydb.ade.iur.kmlExporter; -import org.citydb.modules.kml.ade.ADEKmlExportException; -import org.citydb.modules.kml.ade.ADEKmlExportHelper; -import org.citydb.modules.kml.ade.ADEKmlExportManager; -import org.citydb.modules.kml.ade.ADEKmlExporter; -import org.citydb.util.Util; -import org.citygml4j.model.gml.base.AbstractGML; -import org.citygml4j.model.module.citygml.CityGMLVersion; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.ade.kmlExporter.ADEKmlExportException; +import org.citydb.ade.kmlExporter.ADEKmlExportHelper; +import org.citydb.ade.kmlExporter.ADEKmlExportManager; +import org.citydb.ade.kmlExporter.ADEKmlExporter; +import org.citydb.util.Util; import org.citygml4j.ade.iur.model.urf.UrbanFunction; import org.citygml4j.ade.iur.model.urg.StatisticalGrid; +import org.citygml4j.ade.iur.model.urt.Route; +import org.citygml4j.ade.iur.model.urt.Shape; +import org.citygml4j.ade.iur.model.urt.Stop; +import org.citygml4j.ade.iur.model.urt.Trip; +import org.citygml4j.model.gml.base.AbstractGML; +import org.citygml4j.model.module.citygml.CityGMLVersion; import java.util.HashMap; import java.util.Map; @@ -60,6 +64,14 @@ public ADEKmlExporter getKmlExporter(int objectClassId) throws ADEKmlExportExcep exporter = getKmlExporter(UrbanFunctionKmlExporter.class); } else if (modelObject instanceof StatisticalGrid) { exporter = getKmlExporter(StatisticalGridKmlExporter.class); + } else if (modelObject instanceof Route) { + exporter = getKmlExporter(RouteKmlExporter.class); + } else if (modelObject instanceof Shape) { + exporter = getKmlExporter(ShapeKmlExporter.class); + } else if (modelObject instanceof Stop) { + exporter = getKmlExporter(StopKmlExporter.class); + } else if (modelObject instanceof Trip) { + exporter = getKmlExporter(TripKmlExporter.class); } return exporter; @@ -77,6 +89,14 @@ private T getKmlExporter(Class type) throws ADEKml exporter = new StatisticalGridKmlExporter(helper, this); } else if (type == UrbanFunctionKmlExporter.class) { exporter = new UrbanFunctionKmlExporter(helper, this); + } else if (type == RouteKmlExporter.class) { + exporter = new RouteKmlExporter(helper, this); + } else if (type == ShapeKmlExporter.class) { + exporter = new ShapeKmlExporter(helper, this); + } else if (type == StopKmlExporter.class) { + exporter = new StopKmlExporter(helper, this); + } else if (type == TripKmlExporter.class) { + exporter = new TripKmlExporter(helper, this); } if (exporter == null) diff --git a/src/main/java/org/citydb/ade/iur/kmlExporter/RouteKmlExporter.java b/src/main/java/org/citydb/ade/iur/kmlExporter/RouteKmlExporter.java new file mode 100644 index 0000000..01b1b92 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/kmlExporter/RouteKmlExporter.java @@ -0,0 +1,62 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.kmlExporter; + +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.ade.kmlExporter.ADEKmlExportHelper; +import org.citydb.ade.kmlExporter.ADEKmlExporter; + +public class RouteKmlExporter implements ADEKmlExporter { + private final ADEKmlExportHelper helper; + private final String schema; + private final SchemaMapper schemaMapper; + + public RouteKmlExporter(ADEKmlExportHelper helper, KMLExportManager manager) { + this.helper = helper; + this.schema = helper.getDatabaseAdapter().getConnectionDetails().getSchema(); + this.schemaMapper = manager.getSchemaMapper(); + } + + @Override + public String getPointAndCurveQuery(int lod) { + if (lod == 0) { + return "select r.lod0multicurve, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.ROUTE) + " r " + + "WHERE r.id=? and r.lod0multicurve is not null"; + } + return null; + } + + @Override + public String getSurfaceGeometryQuery(int lod) { + return null; + } + + @Override + public String getSurfaceGeometryRefIdsQuery(int lod) { + return null; + } + +} diff --git a/src/main/java/org/citydb/ade/iur/kmlExporter/ShapeKmlExporter.java b/src/main/java/org/citydb/ade/iur/kmlExporter/ShapeKmlExporter.java new file mode 100644 index 0000000..037b150 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/kmlExporter/ShapeKmlExporter.java @@ -0,0 +1,62 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.kmlExporter; + +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.ade.kmlExporter.ADEKmlExportHelper; +import org.citydb.ade.kmlExporter.ADEKmlExporter; + +public class ShapeKmlExporter implements ADEKmlExporter { + private final ADEKmlExportHelper helper; + private final String schema; + private final SchemaMapper schemaMapper; + + public ShapeKmlExporter(ADEKmlExportHelper helper, KMLExportManager manager) { + this.helper = helper; + this.schema = helper.getDatabaseAdapter().getConnectionDetails().getSchema(); + this.schemaMapper = manager.getSchemaMapper(); + } + + @Override + public String getPointAndCurveQuery(int lod) { + if (lod == 0) { + return "select p.point, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.POINT) + " p " + + "WHERE p.publictransit_point_id=? and p.point is not null"; + } + return null; + } + + @Override + public String getSurfaceGeometryQuery(int lod) { + return null; + } + + @Override + public String getSurfaceGeometryRefIdsQuery(int lod) { + return null; + } + +} diff --git a/src/main/java/org/citydb/ade/iur/kmlExporter/StatisticalGridKmlExporter.java b/src/main/java/org/citydb/ade/iur/kmlExporter/StatisticalGridKmlExporter.java index 5e61ac3..f9b4c5f 100644 --- a/src/main/java/org/citydb/ade/iur/kmlExporter/StatisticalGridKmlExporter.java +++ b/src/main/java/org/citydb/ade/iur/kmlExporter/StatisticalGridKmlExporter.java @@ -22,10 +22,10 @@ package org.citydb.ade.iur.kmlExporter; -import org.citydb.modules.kml.ade.ADEKmlExportHelper; -import org.citydb.modules.kml.ade.ADEKmlExporter; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.ade.kmlExporter.ADEKmlExportHelper; +import org.citydb.ade.kmlExporter.ADEKmlExporter; public class StatisticalGridKmlExporter implements ADEKmlExporter { private final ADEKmlExportHelper helper; @@ -45,30 +45,34 @@ public String getPointAndCurveQuery(int lod) { @Override public String getSurfaceGeometryQuery(int lod) { - if (lod == 1 || lod == 2) { - return new StringBuilder("select sg.geometry, ") - .append(helper.getSQLQueries().getImplicitGeometryNullColumns()) - .append("from ") - .append(schema).append(".surface_geometry sg ") - .append("where sg.root_id in (") - .append("select usg.lod_").append(lod).append("multisurfacegeometry_id from ") - .append(schema).append(".").append(schemaMapper.getTableName(ADETable.STATISTICALGRID)).append(" usg ") - .append("WHERE usg.id=? and sg.geometry is not null)").toString(); - } else { - return null; - } + // always export lod -1 and -2 + return "select sg.geometry, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + ".surface_geometry sg " + + "where sg.root_id in (" + + "select usg.lod_1multisurface_id from " + schema + "." + schemaMapper.getTableName(ADETable.STATISTICALGRID) + " usg " + + "WHERE usg.id=? and sg.geometry is not null) " + + "UNION ALL " + + "select sg.geometry, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + ".surface_geometry sg " + + "where sg.root_id in (" + + "select usg.lod_2multisurface_id from " + schema + "." + schemaMapper.getTableName(ADETable.STATISTICALGRID) + " usg " + + "WHERE usg.id=? and sg.geometry is not null)"; } @Override public String getSurfaceGeometryRefIdsQuery(int lod) { - if (lod == 1 || lod == 2) { - return new StringBuilder("select usg.lod_").append(lod).append("multisurfacegeometry_id, usg.objectclass_id, ") - .append(helper.getSQLQueries().getImplicitGeometryNullColumns()) - .append("from ").append(schema).append(".").append(schemaMapper.getTableName(ADETable.STATISTICALGRID)).append(" usg ") - .append("WHERE usg.id=? and usg.lod_").append(lod).append("multisurfacegeometry_id is not null").toString(); - } else { - return null; - } + // always export lod -1 and -2 + return "select usg.lod_1multisurface_id, usg.objectclass_id, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.STATISTICALGRID) + " usg " + + "WHERE usg.id=? and usg.lod_1multisurface_id is not null " + + "UNION ALL " + + "select usg.lod_2multisurface_id, usg.objectclass_id, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.STATISTICALGRID) + " usg " + + "WHERE usg.id=? and usg.lod_2multisurface_id is not null"; } } diff --git a/src/main/java/org/citydb/ade/iur/kmlExporter/StopKmlExporter.java b/src/main/java/org/citydb/ade/iur/kmlExporter/StopKmlExporter.java new file mode 100644 index 0000000..fc7dc23 --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/kmlExporter/StopKmlExporter.java @@ -0,0 +1,59 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.kmlExporter; + +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.ade.kmlExporter.ADEKmlExportHelper; +import org.citydb.ade.kmlExporter.ADEKmlExporter; + +public class StopKmlExporter implements ADEKmlExporter { + private final ADEKmlExportHelper helper; + private final String schema; + private final SchemaMapper schemaMapper; + + public StopKmlExporter(ADEKmlExportHelper helper, KMLExportManager manager) { + this.helper = helper; + this.schema = helper.getDatabaseAdapter().getConnectionDetails().getSchema(); + this.schemaMapper = manager.getSchemaMapper(); + } + + @Override + public String getPointAndCurveQuery(int lod) { + return "select s.point, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.STOP) + " s " + + "WHERE s.id=? and s.point is not null"; + } + + @Override + public String getSurfaceGeometryQuery(int lod) { + return null; + } + + @Override + public String getSurfaceGeometryRefIdsQuery(int lod) { + return null; + } + +} diff --git a/src/main/java/org/citydb/ade/iur/kmlExporter/TripKmlExporter.java b/src/main/java/org/citydb/ade/iur/kmlExporter/TripKmlExporter.java new file mode 100644 index 0000000..f16c98b --- /dev/null +++ b/src/main/java/org/citydb/ade/iur/kmlExporter/TripKmlExporter.java @@ -0,0 +1,62 @@ +/* + * iur-ade-citydb - i-Urban Revitalization ADE extension for the 3DCityDB + * https://github.com/3dcitydb/iur-ade-citydb + * + * iur-ade-citydb is part of the 3D City Database project + * + * Copyright 2019-2020 virtualcitySYSTEMS GmbH + * https://www.virtualcitysystems.de/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.citydb.ade.iur.kmlExporter; + +import org.citydb.ade.iur.schema.ADETable; +import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.ade.kmlExporter.ADEKmlExportHelper; +import org.citydb.ade.kmlExporter.ADEKmlExporter; + +public class TripKmlExporter implements ADEKmlExporter { + private final ADEKmlExportHelper helper; + private final String schema; + private final SchemaMapper schemaMapper; + + public TripKmlExporter(ADEKmlExportHelper helper, KMLExportManager manager) { + this.helper = helper; + this.schema = helper.getDatabaseAdapter().getConnectionDetails().getSchema(); + this.schemaMapper = manager.getSchemaMapper(); + } + + @Override + public String getPointAndCurveQuery(int lod) { + if (lod == 0) { + return "select t.lod0multicurve, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.TRIP) + " t " + + "WHERE t.id=? and t.lod0multicurve is not null"; + } + return null; + } + + @Override + public String getSurfaceGeometryQuery(int lod) { + return null; + } + + @Override + public String getSurfaceGeometryRefIdsQuery(int lod) { + return null; + } + +} diff --git a/src/main/java/org/citydb/ade/iur/kmlExporter/UrbanFunctionKmlExporter.java b/src/main/java/org/citydb/ade/iur/kmlExporter/UrbanFunctionKmlExporter.java index 3e8ee2e..16051dc 100644 --- a/src/main/java/org/citydb/ade/iur/kmlExporter/UrbanFunctionKmlExporter.java +++ b/src/main/java/org/citydb/ade/iur/kmlExporter/UrbanFunctionKmlExporter.java @@ -22,10 +22,10 @@ package org.citydb.ade.iur.kmlExporter; -import org.citydb.modules.kml.ade.ADEKmlExportHelper; -import org.citydb.modules.kml.ade.ADEKmlExporter; import org.citydb.ade.iur.schema.ADETable; import org.citydb.ade.iur.schema.SchemaMapper; +import org.citydb.ade.kmlExporter.ADEKmlExportHelper; +import org.citydb.ade.kmlExporter.ADEKmlExporter; public class UrbanFunctionKmlExporter implements ADEKmlExporter { private final ADEKmlExportHelper helper; @@ -40,33 +40,86 @@ public UrbanFunctionKmlExporter(ADEKmlExportHelper helper, KMLExportManager mana @Override public String getPointAndCurveQuery(int lod) { - return "select uf.location, " + - helper.getSQLQueries().getImplicitGeometryNullColumns() + - "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + - "WHERE uf.id=? and uf.location is not null " + - "UNION ALL " + - "select uf.boundary, " + - helper.getSQLQueries().getImplicitGeometryNullColumns() + - "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + - "WHERE uf.id=? and uf.boundary is not null"; + if (lod == 0) { + return "select uf.lod0multicurve, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and uf.lod0multicurve is not null " + + "UNION ALL " + + "select uf.lod0multipoint, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and uf.lod0multipoint is not null"; + } else { + // always export lod -1 and -2 + return "select uf.lod_1multicurve, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and uf.lod_1multicurve is not null " + + "UNION ALL " + + "select uf.lod_1multipoint, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and uf.lod_1multipoint is not null " + + "UNION ALL " + + "select uf.lod_2multicurve, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and uf.lod_2multicurve is not null " + + "UNION ALL " + + "select uf.lod_2multipoint, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and uf.lod_2multipoint is not null"; + } } @Override public String getSurfaceGeometryQuery(int lod) { - return "select sg.geometry, " + - helper.getSQLQueries().getImplicitGeometryNullColumns() + - "from " + schema + ".surface_geometry sg " + - "where sg.root_id in (" + - "select uf.area_id from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + - "WHERE uf.id=? and sg.geometry is not null)"; + if (lod == 0) { + return "select sg.geometry, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + ".surface_geometry sg " + + "where sg.root_id in (" + + "select uf.lod0multisurface_id from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and sg.geometry is not null)"; + } else { + // always export lod -1 and -2 + return "select sg.geometry, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + ".surface_geometry sg " + + "where sg.root_id in (" + + "select uf.lod_1multisurface_id from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and sg.geometry is not null) " + + "UNION ALL " + + "select sg.geometry, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + ".surface_geometry sg " + + "where sg.root_id in (" + + "select uf.lod_2multisurface_id from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and sg.geometry is not null)"; + } } @Override public String getSurfaceGeometryRefIdsQuery(int lod) { - return "select uf.area_id, uf.objectclass_id, " + - helper.getSQLQueries().getImplicitGeometryNullColumns() + - "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + - "WHERE uf.id=? and uf.area_id is not null"; + if (lod == 0) { + return "select uf.lod0multisurface_id, uf.objectclass_id, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and uf.lod0multisurface_id is not null"; + } else { + // always export lod -1 and -2 + return "select uf.lod_1multisurface_id, uf.objectclass_id, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and uf.lod_1multisurface_id is not null " + + "UNION ALL " + + "select uf.lod_2multisurface_id, uf.objectclass_id, " + + helper.getSQLQueryHelper().getImplicitGeometryNullColumns() + + "from " + schema + "." + schemaMapper.getTableName(ADETable.URBANFUNCTION) + " uf " + + "WHERE uf.id=? and uf.lod_2multisurface_id is not null"; + } } } diff --git a/src/main/java/org/citydb/ade/iur/schema/ADESequence.java b/src/main/java/org/citydb/ade/iur/schema/ADESequence.java index de2ae41..52491c5 100644 --- a/src/main/java/org/citydb/ade/iur/schema/ADESequence.java +++ b/src/main/java/org/citydb/ade/iur/schema/ADESequence.java @@ -26,10 +26,16 @@ public enum ADESequence { POPULATIONBYAGEAND_SEQ, LANDPRICEPERLANDUS_SEQ, NUMBEROFANNUALDIVE_SEQ, + AREAOFANNUALDIVERS_SEQ, NUMBEROFHOUSEHOLDS_SEQ, + KEYVALUEPAIR_SEQ, BUILDINGDETAILS_SEQ, LARGECUSTOMERFACIL_SEQ, + KEYVALUEPAIR_SEQ_1, TRAFFICVOLUME_SEQ, LEGALGROUNDS_SEQ, - NUMBEROFHOUSEHOL_SEQ_1 + NUMBEROFHOUSEHOL_SEQ_1, + DESCRIPTION_SEQ, + POINT_SEQ, + PUBLICTRANSITDATAT_SEQ } diff --git a/src/main/java/org/citydb/ade/iur/schema/ADETable.java b/src/main/java/org/citydb/ade/iur/schema/ADETable.java index 0e98ce3..37c7408 100644 --- a/src/main/java/org/citydb/ade/iur/schema/ADETable.java +++ b/src/main/java/org/citydb/ade/iur/schema/ADETable.java @@ -24,61 +24,113 @@ import org.citydb.ade.importer.ADEImporter; import org.citydb.ade.iur.importer.urf.CensusBlockImporter; +import org.citydb.ade.iur.importer.urf.DevelopmentProjectImporter; import org.citydb.ade.iur.importer.urf.DisasterDamageImporter; import org.citydb.ade.iur.importer.urf.LegalGroundsImporter; import org.citydb.ade.iur.importer.urf.PollutionImporter; -import org.citydb.ade.iur.importer.urf.PublicTransitImporter; +import org.citydb.ade.iur.importer.urf.PublicTransportationFacilityImporter; import org.citydb.ade.iur.importer.urf.RecreationsImporter; import org.citydb.ade.iur.importer.urf.UrbanFunctionImporter; import org.citydb.ade.iur.importer.urf.UrbanFunctionToCityObjectImporter; +import org.citydb.ade.iur.importer.urf.UrbanizationImporter; +import org.citydb.ade.iur.importer.urf.ZoneImporter; +import org.citydb.ade.iur.importer.urg.AreaOfAnnualDiversionsImporter; import org.citydb.ade.iur.importer.urg.HouseholdsImporter; +import org.citydb.ade.iur.importer.urg.LandPriceImporter; import org.citydb.ade.iur.importer.urg.LandPricePerLandUseImporter; +import org.citydb.ade.iur.importer.urg.LandUseDiversionImporter; import org.citydb.ade.iur.importer.urg.NumberOfAnnualDiversionsImporter; -import org.citydb.ade.iur.importer.urg.NumberOfHouseholdsImporter; import org.citydb.ade.iur.importer.urg.OfficesAndEmployeesImporter; import org.citydb.ade.iur.importer.urg.PopulationByAgeAndSexImporter; import org.citydb.ade.iur.importer.urg.PopulationImporter; import org.citydb.ade.iur.importer.urg.StatisticalGridImporter; import org.citydb.ade.iur.importer.uro.BuildingDetailsImporter; import org.citydb.ade.iur.importer.uro.BuildingPropertiesImporter; -import org.citydb.ade.iur.importer.uro.CityObjectGroupPropertiesImporter; import org.citydb.ade.iur.importer.uro.LandUsePropertiesImporter; import org.citydb.ade.iur.importer.uro.LargeCustomerFacilitiesImporter; import org.citydb.ade.iur.importer.uro.TrafficVolumeImporter; import org.citydb.ade.iur.importer.uro.TransportationComplexPropertiesImporter; -import org.citydb.ade.iur.importer.urf.DevelopmentProjectImporter; -import org.citydb.ade.iur.importer.urf.UrbanizationImporter; +import org.citydb.ade.iur.importer.urt.AgencyImporter; +import org.citydb.ade.iur.importer.urt.AttributionImporter; +import org.citydb.ade.iur.importer.urt.CalendarDateImporter; +import org.citydb.ade.iur.importer.urt.CalendarImporter; +import org.citydb.ade.iur.importer.urt.DescriptionImporter; +import org.citydb.ade.iur.importer.urt.FareAttributeImporter; +import org.citydb.ade.iur.importer.urt.FareRuleImporter; +import org.citydb.ade.iur.importer.urt.FeedInfoImporter; +import org.citydb.ade.iur.importer.urt.FrequencyImporter; +import org.citydb.ade.iur.importer.urt.OfficeImporter; +import org.citydb.ade.iur.importer.urt.PathwayImporter; +import org.citydb.ade.iur.importer.urt.PointImporter; +import org.citydb.ade.iur.importer.urt.PublicTransitDataTypeImporter; +import org.citydb.ade.iur.importer.urt.PublicTransitImporter; +import org.citydb.ade.iur.importer.urt.RouteImporter; +import org.citydb.ade.iur.importer.urt.StopImporter; +import org.citydb.ade.iur.importer.urt.StopTimeImporter; +import org.citydb.ade.iur.importer.urt.TransferImporter; +import org.citydb.ade.iur.importer.urt.TranslationImporter; +import org.citydb.ade.iur.importer.urt.TranslationJPImporter; +import org.citydb.ade.iur.importer.urt.TripImporter; public enum ADETable { + AGENCY(AgencyImporter.class), + AREAOFANNUALDIVERSIONS(AreaOfAnnualDiversionsImporter.class), + ATTRIBUTION(AttributionImporter.class), BUILDING(BuildingPropertiesImporter.class), BUILDINGDETAILS(BuildingDetailsImporter.class), + CALENDAR(CalendarImporter.class), + CALENDARDATE(CalendarDateImporter.class), CENSUSBLOCK(CensusBlockImporter.class), - CITYOBJECTGROUP(CityObjectGroupPropertiesImporter.class), + CITYOBJECTGROUP(org.citydb.ade.iur.importer.urg.CityObjectGroupPropertiesImporter.class), + CITYOBJECTGROUP_1(org.citydb.ade.iur.importer.uro.CityObjectGroupPropertiesImporter.class), + CITYOBJECTGROUP_2(org.citydb.ade.iur.importer.urf.CityObjectGroupPropertiesImporter.class), + CITYOBJECTGROUP_3(org.citydb.ade.iur.importer.urt.CityObjectGroupPropertiesImporter.class), + DESCRIPTION(DescriptionImporter.class), DEVELOPMENTPROJECT(DevelopmentProjectImporter.class), DISASTERDAMAGE(DisasterDamageImporter.class), + FAREATTRIBUTE(FareAttributeImporter.class), + FARERULE(FareRuleImporter.class), + FEEDINFO(FeedInfoImporter.class), + FREQUENCY(FrequencyImporter.class), HOUSEHOLDS(HouseholdsImporter.class), + KEYVALUEPAIR(org.citydb.ade.iur.importer.urg.KeyValuePairImporter.class), + KEYVALUEPAIR_1(org.citydb.ade.iur.importer.uro.KeyValuePairImporter.class), LAND_USE(LandUsePropertiesImporter.class), + LANDPRICE(LandPriceImporter.class), LANDPRICEPERLANDUSE(LandPricePerLandUseImporter.class), + LANDUSEDIVERSION(LandUseDiversionImporter.class), LARGECUSTOMERFACILITIE(LargeCustomerFacilitiesImporter.class), LEGALGROUNDS(LegalGroundsImporter.class), NUMBEROFANNUALDIVERSIO(NumberOfAnnualDiversionsImporter.class), - NUMBEROFHOUSEHOLDS(NumberOfHouseholdsImporter.class), + NUMBEROFHOUSEHOLDS(org.citydb.ade.iur.importer.urg.NumberOfHouseholdsImporter.class), NUMBEROFHOUSEHOLDS_1(org.citydb.ade.iur.importer.urf.NumberOfHouseholdsImporter.class), + OFFICE(OfficeImporter.class), OFFICESANDEMPLOYEES(OfficesAndEmployeesImporter.class), + PATHWAY(PathwayImporter.class), + POINT(PointImporter.class), POLLUTION(PollutionImporter.class), POPULATION(PopulationImporter.class), POPULATIONBYAGEANDSEX(PopulationByAgeAndSexImporter.class), PUBLICTRANSIT(PublicTransitImporter.class), + PUBLICTRANSITDATATYPE(PublicTransitDataTypeImporter.class), + PUBLICTRANSPORTATIONFA(PublicTransportationFacilityImporter.class), RECREATIONS(RecreationsImporter.class), + ROUTE(RouteImporter.class), STATISTICALGRID(StatisticalGridImporter.class), + STOP(StopImporter.class), + STOPTIME(StopTimeImporter.class), TRAFFICVOLUME(TrafficVolumeImporter.class), + TRANSFER(TransferImporter.class), + TRANSLATION(TranslationImporter.class), + TRANSLATIONJP(TranslationJPImporter.class), TRANSPORTATION_COMPLEX(TransportationComplexPropertiesImporter.class), + TRIP(TripImporter.class), URBANFUNC_TO_CITYOBJEC(UrbanFunctionToCityObjectImporter.class), URBANFUNCTION(UrbanFunctionImporter.class), URBANIZATION(UrbanizationImporter.class), - ZONE(UrbanFunctionImporter.class); + ZONE(ZoneImporter.class); - private Class importerClass; + private final Class importerClass; ADETable(Class importerClass) { this.importerClass = importerClass; diff --git a/src/main/java/org/citydb/ade/iur/schema/ADETableMapper.java b/src/main/java/org/citydb/ade/iur/schema/ADETableMapper.java index e8b0f33..65041b9 100644 --- a/src/main/java/org/citydb/ade/iur/schema/ADETableMapper.java +++ b/src/main/java/org/citydb/ade/iur/schema/ADETableMapper.java @@ -31,6 +31,43 @@ public class ADETableMapper { public void populateTableColumns(SchemaMapper schemaMapper) { tableColumns = new HashMap>() {{ + put(schemaMapper.getTableName(ADETable.AGENCY).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("ADDRESS"); + add("EMAIL"); + add("FAREURL"); + add("LANGUAGE"); + add("LANGUAGE_CODESPACE"); + add("NAME"); + add("OFFICIALNAME"); + add("PHONE"); + add("PRESIDENTNAME"); + add("PRESIDENTPOSITION"); + add("TIMEZONE"); + add("TIMEZONE_CODESPACE"); + add("URL"); + add("ZIPNUMBER"); + }}); + put(schemaMapper.getTableName(ADETable.AREAOFANNUALDIVERSIONS).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("AREA"); + add("AREA_UOM"); + add("LANDUSEDIVER_AREAOFANNUAL_ID"); + add("YEAR"); + }}); + put(schemaMapper.getTableName(ADETable.ATTRIBUTION).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("AGENCY_ID"); + add("EMAIL"); + add("ISAUTHORITY"); + add("ISOPERATOR"); + add("ISPRODUCER"); + add("ORGANIZATIONNAME"); + add("PHONENUMBER"); + add("ROUTE_ID"); + add("TRIP_ID"); + add("URL"); + }}); put(schemaMapper.getTableName(ADETable.BUILDING).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("BUILDINGDETAILS_ID"); @@ -70,6 +107,25 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("URBANPLANTYPE"); add("URBANPLANTYPE_CODESPACE"); }}); + put(schemaMapper.getTableName(ADETable.CALENDAR).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("ENDDATE"); + add("FRIDAY"); + add("MONDAY"); + add("SATURDAY"); + add("STARTDATE"); + add("SUNDAY"); + add("THURSDAY"); + add("TUESDAY"); + add("WEDNESDAY"); + }}); + put(schemaMapper.getTableName(ADETable.CALENDARDATE).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("CALENDAR_ID"); + add("DATE_"); + add("EXCEPTIONTYPE"); + add("EXCEPTIONTYPE_CODESPACE"); + }}); put(schemaMapper.getTableName(ADETable.CENSUSBLOCK).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("DAYTIMEPOPULATION"); @@ -83,6 +139,27 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("LANGUAGE"); add("LANGUAGE_CODESPACE"); }}); + put(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_1).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("FISCALYEAROFPUBLICATION"); + add("LANGUAGE"); + add("LANGUAGE_CODESPACE"); + }}); + put(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_2).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("FISCALYEAROFPUBLICATION"); + add("LANGUAGE"); + add("LANGUAGE_CODESPACE"); + }}); + put(schemaMapper.getTableName(ADETable.CITYOBJECTGROUP_3).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + }}); + put(schemaMapper.getTableName(ADETable.DESCRIPTION).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("DESCRIPTION"); + add("FREQUENCYOFSERVICE"); + add("NUMBEROFCUSTOMERS"); + }}); put(schemaMapper.getTableName(ADETable.DEVELOPMENTPROJECT).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("BENEFITAREA"); @@ -112,11 +189,88 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("NUMBEROFHOUSESFLOODEDBELOWFL"); add("TOTALRAINFALL"); }}); + put(schemaMapper.getTableName(ADETable.FAREATTRIBUTE).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("AGENCY_ID"); + add("CURRENCYTYPE"); + add("CURRENCYTYPE_CODESPACE"); + add("PAYMENTMETHOD"); + add("PAYMENTMETHOD_CODESPACE"); + add("PRICE"); + add("TRANSFERDURATION"); + add("TRANSFERS"); + add("TRANSFERS_CODESPACE"); + }}); + put(schemaMapper.getTableName(ADETable.FARERULE).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("CONTAINSID"); + add("CONTAINSID_CODESPACE"); + add("DESTINATIONID"); + add("DESTINATIONID_CODESPACE"); + add("FARE_ID"); + add("ORIGINID"); + add("ORIGINID_CODESPACE"); + add("ROUTE_ID"); + }}); + put(schemaMapper.getTableName(ADETable.FEEDINFO).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("CONTACTEMAIL"); + add("CONTACTURL"); + add("DEFAULTLANGUAGE"); + add("DEFAULTLANGUAGE_CODESPACE"); + add("DETAILEDINFO"); + add("ENDDATE"); + add("LANGUAGE"); + add("LANGUAGE_CODESPACE"); + add("PUBLISHERNAME"); + add("PUBLISHERURL"); + add("STARTDATE"); + add("VERSION"); + }}); + put(schemaMapper.getTableName(ADETable.FREQUENCY).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("ENDTIME"); + add("EXACTTIMES"); + add("EXACTTIMES_CODESPACE"); + add("HEADWAYSECS"); + add("STARTTIME"); + add("TRIP_ID"); + }}); put(schemaMapper.getTableName(ADETable.HOUSEHOLDS).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("NUMBEROFMAINHOUSEHOLD"); add("NUMBEROFORDINARYHOUSEHOLD"); }}); + put(schemaMapper.getTableName(ADETable.KEYVALUEPAIR).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("CODEVALUE"); + add("CODEVALUE_CODESPACE"); + add("DATEVALUE"); + add("DOUBLEVALUE"); + add("INTVALUE"); + add("KEY"); + add("KEY_CODESPACE"); + add("MEASUREDVALUE"); + add("MEASUREDVALUE_UOM"); + add("STATISTICALG_GENERICVALUE_ID"); + add("STRINGVALUE"); + add("URIVALUE"); + }}); + put(schemaMapper.getTableName(ADETable.KEYVALUEPAIR_1).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("BUILDING_EXTENDEDATTRIBUT_ID"); + add("CODEVALUE"); + add("CODEVALUE_CODESPACE"); + add("DATEVALUE"); + add("DOUBLEVALUE"); + add("INTVALUE"); + add("KEY"); + add("KEY_CODESPACE"); + add("MEASUREDVALUE"); + add("MEASUREDVALUE_UOM"); + add("STRINGVALUE"); + add("URIVALUE"); + }}); put(schemaMapper.getTableName(ADETable.LAND_USE).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("AREACLASSIFICATION_CODESPACE"); @@ -144,14 +298,20 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("URBANPLANTYPE"); add("URBANPLANTYPE_CODESPACE"); }}); - put(schemaMapper.getTableName(ADETable.LANDPRICEPERLANDUSE).toUpperCase(), new LinkedHashSet() {{ + put(schemaMapper.getTableName(ADETable.LANDPRICE).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("CURRENCYUNIT"); add("CURRENCYUNIT_CODESPACE"); + }}); + put(schemaMapper.getTableName(ADETable.LANDPRICEPERLANDUSE).toUpperCase(), new LinkedHashSet() {{ + add("ID"); add("LANDPRICE"); + add("LANDPRICE_LANDPRICE_ID"); add("LANDUSE"); add("LANDUSE_CODESPACE"); - add("STATISTICALGRID_LANDPRICE_ID"); + }}); + put(schemaMapper.getTableName(ADETable.LANDUSEDIVERSION).toUpperCase(), new LinkedHashSet() {{ + add("ID"); }}); put(schemaMapper.getTableName(ADETable.LARGECUSTOMERFACILITIE).toUpperCase(), new LinkedHashSet() {{ add("ID"); @@ -193,8 +353,6 @@ public void populateTableColumns(SchemaMapper schemaMapper) { }}); put(schemaMapper.getTableName(ADETable.NUMBEROFANNUALDIVERSIO).toUpperCase(), new LinkedHashSet() {{ add("ID"); - add("AREA"); - add("AREA_UOM"); add("COUNT"); add("STATISTICALG_NUMBEROFANNU_ID"); add("YEAR"); @@ -215,11 +373,44 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("CLASS_CODESPACE"); add("NUMBER_"); }}); + put(schemaMapper.getTableName(ADETable.OFFICE).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("NAME"); + add("PHONE"); + add("URL"); + }}); put(schemaMapper.getTableName(ADETable.OFFICESANDEMPLOYEES).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("NUMBEROFEMPLOYEES"); add("NUMBEROFOFFICES"); }}); + put(schemaMapper.getTableName(ADETable.PATHWAY).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("FROM_ID"); + add("ISBIDIRECTIONAL"); + add("ISBIDIRECTIONAL_CODESPACE"); + add("LENGTH"); + add("LENGTH_UOM"); + add("MAXSLOPE"); + add("MINWIDTH"); + add("MODE_"); + add("MODE_CODESPACE"); + add("REVERSEDSIGNPOSTEDAS"); + add("SIGNPOSTEDAS"); + add("STAIRCOUNT"); + add("TO_ID"); + add("TRAVERSALTIME"); + }}); + put(schemaMapper.getTableName(ADETable.POINT).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("LATITUDE"); + add("LONGITUDE"); + add("POINT"); + add("POINTDISTANCETRAVELED"); + add("POINTSEQUENCE"); + add("PUBLICTRANSIT_POINT_ID"); + }}); + put(schemaMapper.getTableName(ADETable.POLLUTION).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("CAUSE"); @@ -243,14 +434,24 @@ public void populateTableColumns(SchemaMapper schemaMapper) { }}); put(schemaMapper.getTableName(ADETable.POPULATIONBYAGEANDSEX).toUpperCase(), new LinkedHashSet() {{ add("ID"); - add("AGE"); - add("AGE_CODESPACE"); + add("AGEANDSEX"); + add("AGEANDSEX_CODESPACE"); add("NUMBER_"); add("POPULATION_POPULATIONBYAG_ID"); - add("SEX"); - add("SEX_CODESPACE"); }}); put(schemaMapper.getTableName(ADETable.PUBLICTRANSIT).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("INDEX_"); + add("OBJECTCLASS_ID"); + add("ORGID"); + add("TARGET_ID"); + }}); + put(schemaMapper.getTableName(ADETable.PUBLICTRANSITDATATYPE).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("CITYOBJECTGROUP_DATATYPE_ID"); + add("OBJECTCLASS_ID"); + }}); + put(schemaMapper.getTableName(ADETable.PUBLICTRANSPORTATIONFA).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("COMPANYNAME"); add("FREQUENCYOFSERVICE"); @@ -263,6 +464,29 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("CAPACITY"); add("NUMBEROFUSERS"); }}); + put(schemaMapper.getTableName(ADETable.ROUTE).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("AGENCY_ID"); + add("COLOR"); + add("CONTINUOUSDROPOFF"); + add("CONTINUOUSDROPOFF_CODESPACE"); + add("CONTINUOUSPICKUP"); + add("CONTINUOUSPICKUP_CODESPACE"); + add("DESCRIPTION_ID"); + add("DESTINATIONSTOP"); + add("LOD0MULTICURVE"); + add("LONGNAME"); + add("ORIGINSTOP"); + add("PARENTROUTE_ID"); + add("ROUTESORTORDER"); + add("SHORTNAME"); + add("TEXTCOLOR"); + add("TYPE"); + add("TYPE_CODESPACE"); + add("UPDATEDATE"); + add("URL"); + add("VIASTOP"); + }}); put(schemaMapper.getTableName(ADETable.STATISTICALGRID).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("AREACLASSIFICATION_CODESPACE"); @@ -282,6 +506,47 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("URBANPLANTYPE_CODESPACE"); add("VALUE"); }}); + put(schemaMapper.getTableName(ADETable.STOP).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("CODE"); + add("CODE_CODESPACE"); + add("LATITUDE"); + add("LEVEL_ID"); + add("LOCATIONTYPE"); + add("LOCATIONTYPE_CODESPACE"); + add("LONGITUDE"); + add("PARENTSTATION_ID"); + add("PLATFORMCODE"); + add("POINT"); + add("TIMEZONE"); + add("TIMEZONE_CODESPACE"); + add("TTSNAME"); + add("URL"); + add("WHEELCHAIRBOARDING"); + add("WHEELCHAIRBOARDING_CODESPACE"); + add("ZONEID"); + add("ZONEID_CODESPACE"); + }}); + put(schemaMapper.getTableName(ADETable.STOPTIME).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("ARRIVALTIME"); + add("CONTINUOUSDROPOFFT_CODESPACE"); + add("CONTINUOUSDROPOFFTYPE"); + add("CONTINUOUSPICKUPTY_CODESPACE"); + add("CONTINUOUSPICKUPTYPE"); + add("DEPARTURETIME"); + add("DROPOFFTYPE"); + add("DROPOFFTYPE_CODESPACE"); + add("HEADSIGN"); + add("PICKUPTYPE"); + add("PICKUPTYPE_CODESPACE"); + add("SHAPEDISTANCETRAVELED"); + add("STOP_ID"); + add("STOPSEQUENCE"); + add("TIMEPOINT"); + add("TIMEPOINT_CODESPACE"); + add("TRIP_ID"); + }}); put(schemaMapper.getTableName(ADETable.TRAFFICVOLUME).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("AREACLASSIFICATION_CODESPACE"); @@ -302,6 +567,32 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("WEEKDAY12HOURTRAFFICVOLUME"); add("WEEKDAY24HOURTRAFFICVOLUME"); }}); + put(schemaMapper.getTableName(ADETable.TRANSFER).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("FROM_ID"); + add("MINTRANSFERTIME"); + add("TO_ID"); + add("TRANSFERTYPE"); + add("TRANSFERTYPE_CODESPACE"); + }}); + put(schemaMapper.getTableName(ADETable.TRANSLATION).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("FIELDNAME"); + add("FIELDVALUE"); + add("LANGUAGE"); + add("LANGUAGE_CODESPACE"); + add("RECORDID_ID"); + add("RECORDSUBID"); + add("TABLENAME"); + add("TABLENAME_CODESPACE"); + add("TRANSLATION"); + }}); + put(schemaMapper.getTableName(ADETable.TRANSLATIONJP).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("LANGUAGE"); + add("LANGUAGE_CODESPACE"); + add("TRANSLATION"); + }}); put(schemaMapper.getTableName(ADETable.TRANSPORTATION_COMPLEX).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("TRAFFICVOLUME_ID"); @@ -310,6 +601,25 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("WIDTHTYPE"); add("WIDTHTYPE_CODESPACE"); }}); + put(schemaMapper.getTableName(ADETable.TRIP).toUpperCase(), new LinkedHashSet() {{ + add("ID"); + add("BIKEALLOWED"); + add("BIKEALLOWED_CODESPACE"); + add("BLOCKID"); + add("CALENDAR_ID"); + add("CALENDARDATE_ID"); + add("DIRECTIONID"); + add("DIRECTIONID_CODESPACE"); + add("HEADSIGN"); + add("LOD0MULTICURVE"); + add("OFFICE_ID"); + add("ROUTE_ID"); + add("SHAPE_ID"); + add("SHORTNAME"); + add("SYMBOL"); + add("WHEELCHAIRACCESSIB_CODESPACE"); + add("WHEELCHAIRACCESSIBLE"); + }}); put(schemaMapper.getTableName(ADETable.URBANFUNC_TO_CITYOBJEC).toUpperCase(), new LinkedHashSet() {{ add("CITYOBJECT_ID"); add("URBANFUNCTION_ID"); @@ -317,10 +627,8 @@ public void populateTableColumns(SchemaMapper schemaMapper) { put(schemaMapper.getTableName(ADETable.URBANFUNCTION).toUpperCase(), new LinkedHashSet() {{ add("ID"); add("ABSTRACT"); - add("AREA_ID"); add("AREACLASSIFICATION_CODESPACE"); add("AREACLASSIFICATIONTYPE"); - add("BOUNDARY"); add("CAPACITY"); add("CITY"); add("CITY_CODESPACE"); @@ -334,7 +642,15 @@ public void populateTableColumns(SchemaMapper schemaMapper) { add("FUNCTION"); add("FUNCTION_CODESPACE"); add("LEGALGROUNDS_ID"); - add("LOCATION"); + add("LOD0MULTICURVE"); + add("LOD0MULTIPOINT"); + add("LOD0MULTISURFACE_ID"); + add("LOD_1MULTICURVE"); + add("LOD_1MULTIPOINT"); + add("LOD_1MULTISURFACE_ID"); + add("LOD_2MULTICURVE"); + add("LOD_2MULTIPOINT"); + add("LOD_2MULTISURFACE_ID"); add("NOMINALAREA"); add("NOMINALAREA_UOM"); add("NOTE"); diff --git a/src/main/java/org/citydb/ade/iur/schema/ObjectMapper.java b/src/main/java/org/citydb/ade/iur/schema/ObjectMapper.java index beb3bfe..dbe9d8e 100644 --- a/src/main/java/org/citydb/ade/iur/schema/ObjectMapper.java +++ b/src/main/java/org/citydb/ade/iur/schema/ObjectMapper.java @@ -25,10 +25,9 @@ import org.citydb.ade.ADEExtensionException; import org.citydb.ade.ADEObjectMapper; import org.citydb.database.schema.mapping.AbstractObjectType; +import org.citydb.database.schema.mapping.ComplexType; import org.citydb.database.schema.mapping.SchemaMapping; -import org.citygml4j.ade.iur.model.urg.LandUseDiversion; -import org.citygml4j.model.gml.base.AbstractGML; -import org.citygml4j.model.module.citygml.CityGMLVersion; +import org.citygml4j.ade.iur.model.common.AbstractDataType; import org.citygml4j.ade.iur.model.module.StatisticalGridModule; import org.citygml4j.ade.iur.model.module.UrbanFunctionModule; import org.citygml4j.ade.iur.model.urf.Administration; @@ -42,22 +41,46 @@ import org.citygml4j.ade.iur.model.urf.HubCity; import org.citygml4j.ade.iur.model.urf.LandUsePlan; import org.citygml4j.ade.iur.model.urf.Pollution; -import org.citygml4j.ade.iur.model.urf.PublicTransit; +import org.citygml4j.ade.iur.model.urf.PublicTransportationFacility; import org.citygml4j.ade.iur.model.urf.Recreations; import org.citygml4j.ade.iur.model.urf.Regulation; import org.citygml4j.ade.iur.model.urf.UrbanPlan; import org.citygml4j.ade.iur.model.urf.Urbanization; +import org.citygml4j.ade.iur.model.urg.GenericGridCell; import org.citygml4j.ade.iur.model.urg.Households; import org.citygml4j.ade.iur.model.urg.LandPrice; +import org.citygml4j.ade.iur.model.urg.LandUseDiversion; import org.citygml4j.ade.iur.model.urg.OfficesAndEmployees; import org.citygml4j.ade.iur.model.urg.Population; -import org.citygml4j.ade.iur.model.urg.PublicTransportationAccessibility; +import org.citygml4j.ade.iur.model.urg.PublicTransitAccessibility; +import org.citygml4j.ade.iur.model.urt.Agency; +import org.citygml4j.ade.iur.model.urt.Attribution; +import org.citygml4j.ade.iur.model.urt.Calendar; +import org.citygml4j.ade.iur.model.urt.CalendarDate; +import org.citygml4j.ade.iur.model.urt.FareAttribute; +import org.citygml4j.ade.iur.model.urt.FareRule; +import org.citygml4j.ade.iur.model.urt.FeedInfo; +import org.citygml4j.ade.iur.model.urt.Frequency; +import org.citygml4j.ade.iur.model.urt.Level; +import org.citygml4j.ade.iur.model.urt.Office; +import org.citygml4j.ade.iur.model.urt.Pathway; +import org.citygml4j.ade.iur.model.urt.Route; +import org.citygml4j.ade.iur.model.urt.Shape; +import org.citygml4j.ade.iur.model.urt.Stop; +import org.citygml4j.ade.iur.model.urt.StopTime; +import org.citygml4j.ade.iur.model.urt.Transfer; +import org.citygml4j.ade.iur.model.urt.Translation; +import org.citygml4j.ade.iur.model.urt.TranslationJP; +import org.citygml4j.ade.iur.model.urt.Trip; +import org.citygml4j.model.gml.base.AbstractGML; +import org.citygml4j.model.module.citygml.CityGMLVersion; import java.util.HashMap; import java.util.Map; public class ObjectMapper implements ADEObjectMapper { - private Map, Integer> objectClassIds = new HashMap<>(); + private final Map, Integer> objectClassIds = new HashMap<>(); + private final Map, Integer> typeClassIds = new HashMap<>(); public void populateObjectClassIds(SchemaMapping schemaMapping) throws ADEExtensionException { for (AbstractObjectType type : schemaMapping.getAbstractObjectTypes()) { @@ -67,16 +90,16 @@ public void populateObjectClassIds(SchemaMapping schemaMapping) throws ADEExtens case "Population": objectClassIds.put(Population.class, objectClassId); break; - case "PublicTransportationAccessibility": - objectClassIds.put(PublicTransportationAccessibility.class, objectClassId); + case "PublicTransitAccessibility": + objectClassIds.put(PublicTransitAccessibility.class, objectClassId); break; case "LandPrice": objectClassIds.put(LandPrice.class, objectClassId); break; case "LandUseDiversion": - if (type.getSchema().matchesNamespaceURI(StatisticalGridModule.v1_3.getNamespaceURI())) + if (type.getSchema().matchesNamespaceURI(StatisticalGridModule.v1_4.getNamespaceURI())) objectClassIds.put(LandUseDiversion.class, objectClassId); - else if (type.getSchema().matchesNamespaceURI(UrbanFunctionModule.v1_3.getNamespaceURI())) + else if (type.getSchema().matchesNamespaceURI(UrbanFunctionModule.v1_4.getNamespaceURI())) objectClassIds.put(org.citygml4j.ade.iur.model.urf.LandUseDiversion.class, objectClassId); break; case "Households": @@ -85,6 +108,9 @@ else if (type.getSchema().matchesNamespaceURI(UrbanFunctionModule.v1_3.getNamesp case "OfficesAndEmployees": objectClassIds.put(OfficesAndEmployees.class, objectClassId); break; + case "GenericGridCell": + objectClassIds.put(GenericGridCell.class, objectClassId); + break; case "Administration": objectClassIds.put(Administration.class, objectClassId); break; @@ -130,8 +156,72 @@ else if (type.getSchema().matchesNamespaceURI(UrbanFunctionModule.v1_3.getNamesp case "Urbanization": objectClassIds.put(Urbanization.class, objectClassId); break; - case "PublicTransit": - objectClassIds.put(PublicTransit.class, objectClassId); + case "PublicTransportationFacility": + objectClassIds.put(PublicTransportationFacility.class, objectClassId); + break; + case "Route": + objectClassIds.put(Route.class, objectClassId); + break; + case "Agency": + objectClassIds.put(Agency.class, objectClassId); + break; + case "Stop": + objectClassIds.put(Stop.class, objectClassId); + break; + case "Level": + objectClassIds.put(Level.class, objectClassId); + break; + case "Trip": + objectClassIds.put(Trip.class, objectClassId); + break; + case "Calendar": + objectClassIds.put(Calendar.class, objectClassId); + break; + case "CalendarDate": + objectClassIds.put(CalendarDate.class, objectClassId); + break; + case "Office": + objectClassIds.put(Office.class, objectClassId); + break; + case "Shape": + objectClassIds.put(Shape.class, objectClassId); + break; + case "FareAttribute": + objectClassIds.put(FareAttribute.class, objectClassId); + break; + case "Pathway": + objectClassIds.put(Pathway.class, objectClassId); + break; + case "TranslationJP": + objectClassIds.put(TranslationJP.class, objectClassId); + break; + case "Attribution": + objectClassIds.put(Attribution.class, objectClassId); + break; + } + } + + for (ComplexType type : schemaMapping.getComplexTypes()) { + int typeClassId = type.getObjectClassId(); + + switch (type.getPath()) { + case "FeedInfo": + typeClassIds.put(FeedInfo.class, typeClassId); + break; + case "Translation": + typeClassIds.put(Translation.class, typeClassId); + break; + case "Transfer": + typeClassIds.put(Transfer.class, typeClassId); + break; + case "Frequency": + typeClassIds.put(Frequency.class, typeClassId); + break; + case "StopTime": + typeClassIds.put(StopTime.class, typeClassId); + break; + case "FareRule": + typeClassIds.put(FareRule.class, typeClassId); break; } } @@ -159,4 +249,24 @@ public int getObjectClassId(Class adeObjectClass) { Integer objectClassId = objectClassIds.get(adeObjectClass); return objectClassId != null ? objectClassId : 0; } + + public T createType(int objectClassId, Class type) { + for (Map.Entry, Integer> entry : typeClassIds.entrySet()) { + if (entry.getValue() == objectClassId) { + try { + AbstractDataType dataType = entry.getKey().getDeclaredConstructor().newInstance(); + return type.isInstance(dataType) ? type.cast(dataType) : null; + } catch (Exception e) { + // + } + } + } + + return null; + } + + public int getTypeClassId(Class adeObjectClass) { + Integer objectClassId = typeClassIds.get(adeObjectClass); + return objectClassId != null ? objectClassId : 0; + } } diff --git a/src/main/java/org/citydb/ade/iur/schema/SchemaMapper.java b/src/main/java/org/citydb/ade/iur/schema/SchemaMapper.java index 2213610..7e3b07d 100644 --- a/src/main/java/org/citydb/ade/iur/schema/SchemaMapper.java +++ b/src/main/java/org/citydb/ade/iur/schema/SchemaMapper.java @@ -26,8 +26,8 @@ import java.util.Map; public class SchemaMapper { - private EnumMap tableNames = new EnumMap<>(ADETable.class); - private EnumMap sequenceNames = new EnumMap<>(ADESequence.class); + private final EnumMap tableNames = new EnumMap<>(ADETable.class); + private final EnumMap sequenceNames = new EnumMap<>(ADESequence.class); public void populateSchemaNames(String prefix) { for (ADETable table : ADETable.values())