Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Energy ADE
Energy ADE 3 3DCityDB
Commits
21bc60b1
Commit
21bc60b1
authored
Aug 08, 2025
by
Rushikesh Padsala
Browse files
Initial commit
parents
Changes
52
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/stuttgart/hft/ade/energy2/importer/ResourceImporter.java
0 → 100644
View file @
21bc60b1
package
de.stuttgart.hft.ade.energy2.importer
;
import
de.stuttgart.hft.ade.energy2.schema.ADETable
;
import
org.citydb.core.ade.importer.ADEImporter
;
import
org.citydb.core.ade.importer.CityGMLImportHelper
;
import
org.citydb.core.ade.importer.ForeignKeys
;
import
org.citydb.core.database.schema.mapping.AbstractObjectType
;
import
org.citydb.core.operation.importer.CityGMLImportException
;
import
org.citydb.core.operation.importer.util.GeometryConverter
;
import
org.citygml4j.ade.energy.model.core.AbstractResource
;
import
org.citygml4j.ade.energy.model.supportingClasses.*
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.Types
;
import
java.util.Collections
;
public
class
ResourceImporter
implements
ADEImporter
{
private
final
Connection
connection
;
private
final
CityGMLImportHelper
helper
;
private
GeometryConverter
geometryConverter
;
private
PreparedStatement
ps
;
private
int
batchCounter
;
public
ResourceImporter
(
Connection
connection
,
CityGMLImportHelper
helper
,
ImportManager
manager
)
throws
CityGMLImportException
,
SQLException
{
this
.
connection
=
connection
;
this
.
helper
=
helper
;
ps
=
connection
.
prepareStatement
(
"INSERT INTO "
+
helper
.
getTableNameWithSchema
(
manager
.
getSchemaMapper
().
getTableName
(
ADETable
.
RESOURCE
))
+
"(id, objectclass_id, type, type_codespace, enduse, enduse_codespace, status, "
+
"operation_type, operation_type_codespace, year, amount_type, amount_type_codespace, amount, "
+
"amount_uom, time_series_id, is_amount_normalized, normalization_param, normalization_value, "
+
"normalization_value_uom, co2_equivalent, co2_equivalent_uom, costs_money, costs_money_uom, "
+
"yields_money, yields_money_uom, energy_carrier, energy_carrier_codespace, maximum_load, "
+
"maximum_load_uom, source, source_codespace, is_dangerous, is_recyclable, cityobject_id) "
+
"VALUES ("
+
String
.
join
(
", "
,
Collections
.
nCopies
(
34
,
"?"
))
+
")"
);
geometryConverter
=
helper
.
getGeometryConverter
();
}
public
void
doImport
(
AbstractResource
abstractResource
,
long
objectId
,
AbstractObjectType
<?>
objectType
,
ForeignKeys
foreignKeys
)
throws
CityGMLImportException
,
SQLException
{
setResourceToNull
();
ps
.
setLong
(
1
,
objectId
);
ps
.
setLong
(
2
,
objectType
.
getObjectClassId
());
ps
.
setLong
(
34
,
foreignKeys
.
get
(
"cityObjectId"
));
setAbstractResourceProperties
(
abstractResource
);
if
(
abstractResource
instanceof
Energy
)
{
Energy
energy
=
(
Energy
)
abstractResource
;
if
(
energy
.
getEnergyTypeValue
()
!=
null
)
{
ps
.
setString
(
3
,
energy
.
getEnergyTypeValue
().
getValue
());
ps
.
setString
(
4
,
energy
.
getEnergyTypeValue
().
getCodeSpace
());
}
if
(
energy
.
getEnergyEndUseValue
()
!=
null
)
{
ps
.
setString
(
5
,
energy
.
getEnergyEndUseValue
().
getValue
());
ps
.
setString
(
6
,
energy
.
getEnergyEndUseValue
().
getCodeSpace
());
}
if
(
energy
.
getEnergyCarrierValue
()
!=
null
)
{
ps
.
setString
(
26
,
energy
.
getEnergyCarrierValue
().
getValue
());
ps
.
setString
(
27
,
energy
.
getEnergyCarrierValue
().
getCodeSpace
());
}
if
(
energy
.
getMaximumLoad
()
!=
null
)
{
ps
.
setDouble
(
28
,
energy
.
getMaximumLoad
().
getValue
());
ps
.
setString
(
29
,
energy
.
getMaximumLoad
().
getUom
());
}
if
(
energy
.
getEnergySourceValue
()
!=
null
)
{
ps
.
setString
(
30
,
energy
.
getEnergySourceValue
().
getValue
());
ps
.
setString
(
31
,
energy
.
getEnergySourceValue
().
getCodeSpace
());
}
}
else
if
(
abstractResource
instanceof
Water
)
{
Water
water
=
(
Water
)
abstractResource
;
if
(
water
.
getWaterTypeValue
()
!=
null
)
{
ps
.
setString
(
3
,
water
.
getWaterTypeValue
().
getValue
());
ps
.
setString
(
4
,
water
.
getWaterTypeValue
().
getCodeSpace
());
}
if
(
water
.
getWaterEndUseValue
()
!=
null
)
{
ps
.
setString
(
5
,
water
.
getWaterEndUseValue
().
getValue
());
ps
.
setString
(
6
,
water
.
getWaterEndUseValue
().
getCodeSpace
());
}
}
else
if
(
abstractResource
instanceof
Waste
)
{
Waste
waste
=
(
Waste
)
abstractResource
;
if
(
waste
.
getWasteTypeValue
()
!=
null
)
{
ps
.
setString
(
3
,
waste
.
getWasteTypeValue
().
getValue
());
ps
.
setString
(
4
,
waste
.
getWasteTypeValue
().
getCodeSpace
());
}
if
(
waste
.
getWasteEndUseValue
()
!=
null
)
{
ps
.
setString
(
5
,
waste
.
getWasteEndUseValue
().
getValue
());
ps
.
setString
(
6
,
waste
.
getWasteEndUseValue
().
getCodeSpace
());
}
if
(
waste
.
isSetAmountNormalized
())
{
ps
.
setInt
(
32
,
1
);
// True -> 1
}
if
(
waste
.
isRecyclable
())
{
ps
.
setInt
(
33
,
1
);
}
}
else
if
(
abstractResource
instanceof
Food
)
{
Food
food
=
(
Food
)
abstractResource
;
if
(
food
.
getFoodTypeValue
()
!=
null
)
{
ps
.
setString
(
3
,
food
.
getFoodTypeValue
().
getValue
());
ps
.
setString
(
4
,
food
.
getFoodTypeValue
().
getCodeSpace
());
}
if
(
food
.
getFoodEndUseValue
()
!=
null
)
{
ps
.
setString
(
5
,
food
.
getFoodEndUseValue
().
getValue
());
ps
.
setString
(
6
,
food
.
getFoodEndUseValue
().
getCodeSpace
());
}
}
else
if
(
abstractResource
instanceof
ConstructionMaterial
)
{
ConstructionMaterial
constructionMaterial
=
(
ConstructionMaterial
)
abstractResource
;
if
(
constructionMaterial
.
getConstructionMaterialTypeValue
()
!=
null
)
{
ps
.
setString
(
3
,
constructionMaterial
.
getConstructionMaterialTypeValue
().
getValue
());
ps
.
setString
(
4
,
constructionMaterial
.
getConstructionMaterialTypeValue
().
getCodeSpace
());
}
if
(
constructionMaterial
.
getConstructionMaterialEndUseValue
()
!=
null
)
{
ps
.
setString
(
5
,
constructionMaterial
.
getConstructionMaterialEndUseValue
().
getValue
());
ps
.
setString
(
6
,
constructionMaterial
.
getConstructionMaterialEndUseValue
().
getCodeSpace
());
}
}
else
if
(
abstractResource
instanceof
OtherResource
){
OtherResource
otherResource
=
(
OtherResource
)
abstractResource
;
if
(
otherResource
.
getOtherResourceTypeValue
()
!=
null
)
{
ps
.
setString
(
3
,
otherResource
.
getOtherResourceTypeValue
().
getValue
());
ps
.
setString
(
4
,
otherResource
.
getOtherResourceTypeValue
().
getCodeSpace
());
}
if
(
otherResource
.
getOtherResourceEndUseValue
()
!=
null
)
{
ps
.
setString
(
5
,
otherResource
.
getOtherResourceEndUseValue
().
getValue
());
ps
.
setString
(
6
,
otherResource
.
getOtherResourceEndUseValue
().
getCodeSpace
());
}
}
else
if
(
abstractResource
instanceof
UrbanSpace
){
UrbanSpace
urbanSpace
=
(
UrbanSpace
)
abstractResource
;
if
(
urbanSpace
.
isSetType
()){
ps
.
setString
(
3
,
urbanSpace
.
getType
().
getValue
());
ps
.
setString
(
4
,
urbanSpace
.
getType
().
getCodeSpace
());
}
if
(
urbanSpace
.
isSetEndUse
())
{
ps
.
setString
(
5
,
urbanSpace
.
getEndUse
().
getValue
());
ps
.
setString
(
6
,
urbanSpace
.
getEndUse
().
getCodeSpace
());
}
}
ps
.
addBatch
();
if
(++
batchCounter
==
helper
.
getDatabaseAdapter
().
getMaxBatchSize
())
helper
.
executeBatch
(
objectType
);
}
private
void
setAbstractResourceProperties
(
AbstractResource
abstractResource
)
throws
SQLException
,
CityGMLImportException
{
if
(
abstractResource
.
getStatus
()
!=
null
)
{
ps
.
setString
(
7
,
abstractResource
.
getStatus
().
value
());
}
if
(
abstractResource
.
getOperationType
()
!=
null
)
{
ps
.
setString
(
8
,
abstractResource
.
getOperationType
().
getValue
());
ps
.
setString
(
9
,
abstractResource
.
getOperationType
().
getCodeSpace
());
}
if
(
abstractResource
.
getAmountType
()
!=
null
)
{
ps
.
setString
(
11
,
abstractResource
.
getAmountType
().
getValue
());
ps
.
setString
(
12
,
abstractResource
.
getAmountType
().
getCodeSpace
());
}
if
(
abstractResource
.
getAmount
()
!=
null
)
{
ps
.
setDouble
(
13
,
abstractResource
.
getAmount
().
getValue
());
ps
.
setString
(
14
,
abstractResource
.
getAmount
().
getUom
());
}
if
(
abstractResource
.
isSetTimeDependentAmount
()){
long
timeSeriesId
=
helper
.
importObject
(
abstractResource
.
getTimeDependentAmount
().
getAbstractTimeSeries
(),
null
);
ps
.
setLong
(
15
,
timeSeriesId
);
}
// Handling boolean-to-numeric conversion
if
(
abstractResource
.
isSetAmountNormalized
())
{
ps
.
setInt
(
16
,
1
);
// True -> 1
}
else
{
ps
.
setInt
(
16
,
0
);
}
if
(
abstractResource
.
getNormalizationValue
()
!=
null
)
{
ps
.
setDouble
(
18
,
abstractResource
.
getNormalizationValue
().
getValue
());
ps
.
setString
(
19
,
abstractResource
.
getNormalizationValue
().
getUom
());
}
if
(
abstractResource
.
getNormalizationParameter
()
!=
null
)
{
ps
.
setString
(
17
,
abstractResource
.
getNormalizationParameter
());
}
if
(
abstractResource
.
getCo2Equivalent
()
!=
null
)
{
ps
.
setDouble
(
20
,
abstractResource
.
getCo2Equivalent
().
getValue
());
ps
.
setString
(
21
,
abstractResource
.
getCo2Equivalent
().
getUom
());
}
if
(
abstractResource
.
getYear
()
!=
null
)
{
ps
.
setInt
(
10
,
abstractResource
.
getYear
());
}
if
(
abstractResource
.
getCostsMoney
()
!=
null
)
{
ps
.
setDouble
(
22
,
abstractResource
.
getCostsMoney
().
getValue
());
ps
.
setString
(
23
,
abstractResource
.
getCostsMoney
().
getUom
());
}
if
(
abstractResource
.
getYieldsMoney
()
!=
null
)
{
ps
.
setDouble
(
24
,
abstractResource
.
getYieldsMoney
().
getValue
());
ps
.
setString
(
25
,
abstractResource
.
getYieldsMoney
().
getUom
());
}
}
private
void
setResourceToNull
()
throws
SQLException
{
ps
.
setNull
(
1
,
Types
.
BIGINT
);
// id
ps
.
setNull
(
2
,
Types
.
INTEGER
);
// objectclass_id
ps
.
setNull
(
3
,
Types
.
VARCHAR
);
// type
ps
.
setNull
(
4
,
Types
.
VARCHAR
);
// type_codespace
ps
.
setNull
(
5
,
Types
.
VARCHAR
);
// enduse
ps
.
setNull
(
6
,
Types
.
VARCHAR
);
// enduse_codespace
ps
.
setNull
(
7
,
Types
.
VARCHAR
);
// status
ps
.
setNull
(
8
,
Types
.
VARCHAR
);
// operation_type
ps
.
setNull
(
9
,
Types
.
VARCHAR
);
// operation_type_codespace
ps
.
setNull
(
10
,
Types
.
INTEGER
);
// year
ps
.
setNull
(
11
,
Types
.
VARCHAR
);
// amount_type
ps
.
setNull
(
12
,
Types
.
VARCHAR
);
// amount_type_codespace
ps
.
setNull
(
13
,
Types
.
NUMERIC
);
// amount
ps
.
setNull
(
14
,
Types
.
VARCHAR
);
// amount_uom
ps
.
setNull
(
15
,
Types
.
BIGINT
);
// time_series_id
ps
.
setNull
(
16
,
Types
.
NUMERIC
);
// is_amount_normalized
ps
.
setNull
(
17
,
Types
.
VARCHAR
);
// normalization_param
ps
.
setNull
(
18
,
Types
.
NUMERIC
);
// normalization_value
ps
.
setNull
(
19
,
Types
.
VARCHAR
);
// normalization_value_uom
ps
.
setNull
(
20
,
Types
.
NUMERIC
);
// co2_equivalent
ps
.
setNull
(
21
,
Types
.
VARCHAR
);
// co2_equivalent_uom
ps
.
setNull
(
22
,
Types
.
NUMERIC
);
// costs_money
ps
.
setNull
(
23
,
Types
.
VARCHAR
);
// costs_money_uom
ps
.
setNull
(
24
,
Types
.
NUMERIC
);
// yields_money
ps
.
setNull
(
25
,
Types
.
NUMERIC
);
// yields_money_uom
ps
.
setNull
(
26
,
Types
.
VARCHAR
);
// energy_carrier
ps
.
setNull
(
27
,
Types
.
VARCHAR
);
// energy_carrier_codespace
ps
.
setNull
(
28
,
Types
.
NUMERIC
);
// maximum_load
ps
.
setNull
(
29
,
Types
.
VARCHAR
);
// maximum_load_uom
ps
.
setNull
(
30
,
Types
.
VARCHAR
);
// source
ps
.
setNull
(
31
,
Types
.
VARCHAR
);
// source_codespace
ps
.
setNull
(
32
,
Types
.
NUMERIC
);
// is_dangerous
ps
.
setNull
(
33
,
Types
.
NUMERIC
);
// is_recyclable
ps
.
setNull
(
34
,
Types
.
BIGINT
);
// cityobject_id
}
@Override
public
void
executeBatch
()
throws
CityGMLImportException
,
SQLException
{
if
(
batchCounter
>
0
)
{
ps
.
executeBatch
();
batchCounter
=
0
;
}
}
@Override
public
void
close
()
throws
CityGMLImportException
,
SQLException
{
ps
.
close
();
}
}
src/main/java/de/stuttgart/hft/ade/energy2/importer/TimeSeriesImporter.java
0 → 100644
View file @
21bc60b1
package
de.stuttgart.hft.ade.energy2.importer
;
import
de.stuttgart.hft.ade.energy2.schema.ADETable
;
import
org.citydb.core.ade.importer.ADEImporter
;
import
org.citydb.core.ade.importer.CityGMLImportHelper
;
import
org.citydb.core.ade.importer.ForeignKeys
;
import
org.citydb.core.database.schema.mapping.AbstractObjectType
;
import
org.citydb.core.operation.importer.CityGMLImportException
;
import
org.citydb.core.operation.importer.util.AttributeValueJoiner
;
import
org.citygml4j.ade.energy.model.supportingClasses.*
;
import
java.sql.*
;
import
java.time.LocalTime
;
import
java.util.Collections
;
public
class
TimeSeriesImporter
implements
ADEImporter
{
private
final
Connection
connection
;
private
final
CityGMLImportHelper
helper
;
private
AttributeValueJoiner
valueJoiner
;
private
PreparedStatement
psTimeSeries
;
private
int
batchCounter
;
public
TimeSeriesImporter
(
Connection
connection
,
CityGMLImportHelper
helper
,
ImportManager
manager
)
throws
CityGMLImportException
,
SQLException
{
this
.
connection
=
connection
;
this
.
helper
=
helper
;
String
tableName
=
helper
.
getTableNameWithSchema
(
manager
.
getSchemaMapper
().
getTableName
(
ADETable
.
TIME_SERIES
));
String
sql
=
"INSERT INTO "
+
tableName
+
" ("
+
getColumnNames
()
+
") VALUES ("
+
getPlaceholders
(
38
)
+
") ON CONFLICT (id) DO NOTHING"
;
psTimeSeries
=
connection
.
prepareStatement
(
sql
);
valueJoiner
=
helper
.
getAttributeValueJoiner
();
}
public
void
doImport
(
AbstractTimeSeries
abstractTimeSeries
,
long
objectId
,
AbstractObjectType
<?>
objectType
,
ForeignKeys
foreignKeys
)
throws
CityGMLImportException
,
SQLException
{
setTimeSeriesToNull
();
psTimeSeries
.
setLong
(
1
,
objectId
);
psTimeSeries
.
setLong
(
2
,
objectType
.
getObjectClassId
());
setAbstractTimeseriesProperties
(
abstractTimeSeries
);
//contains weatherdata
if
(
abstractTimeSeries
instanceof
RegularTimeSeries
)
{
RegularTimeSeries
regularTimeSeries
=
(
RegularTimeSeries
)
abstractTimeSeries
;
if
(
regularTimeSeries
.
isSetValues
()
&&
regularTimeSeries
.
getValues
().
isSetValue
())
{
String
values
=
valueJoiner
.
join
(
" "
,
regularTimeSeries
.
getValues
().
getValue
());
psTimeSeries
.
setString
(
16
,
values
);
psTimeSeries
.
setString
(
17
,
regularTimeSeries
.
getValues
().
getUom
());
}
if
(
regularTimeSeries
.
isSetTemporalExtent
()){
Timestamp
beginPosition
=
Timestamp
.
from
(
regularTimeSeries
.
getTemporalExtent
().
getTimePeriod
().
getBeginPosition
().
toInstant
());
Timestamp
endPosition
=
Timestamp
.
from
(
regularTimeSeries
.
getTemporalExtent
().
getTimePeriod
().
getEndPosition
().
toInstant
());
psTimeSeries
.
setTimestamp
(
7
,
beginPosition
);
psTimeSeries
.
setTimestamp
(
8
,
endPosition
);
}
if
(
regularTimeSeries
.
isSetTimeInterval
())
{
psTimeSeries
.
setDouble
(
14
,
regularTimeSeries
.
getTimeInterval
().
getValue
());
psTimeSeries
.
setString
(
15
,
regularTimeSeries
.
getTimeInterval
().
getUnit
());
}
}
else
if
(
abstractTimeSeries
instanceof
RegularTimeSeriesFile
)
{
RegularTimeSeriesFile
timeSeriesFile
=
(
RegularTimeSeriesFile
)
abstractTimeSeries
;
if
(
timeSeriesFile
.
isSetUom
())
psTimeSeries
.
setString
(
18
,
timeSeriesFile
.
getUom
());
if
(
timeSeriesFile
.
isSetFileURI
())
psTimeSeries
.
setString
(
19
,
timeSeriesFile
.
getFileURI
().
toString
());
if
(
timeSeriesFile
.
isSetNumberOfHeaderLines
())
psTimeSeries
.
setLong
(
20
,
timeSeriesFile
.
getNumberOfHeaderLines
());
if
(
timeSeriesFile
.
isSetFieldSeparator
())
psTimeSeries
.
setString
(
21
,
timeSeriesFile
.
getFieldSeparator
());
if
(
timeSeriesFile
.
isSetRecordSeparator
()
)
psTimeSeries
.
setString
(
22
,
timeSeriesFile
.
getRecordSeparator
());
if
(
timeSeriesFile
.
isSetDecimalSymbol
()
)
psTimeSeries
.
setString
(
24
,
timeSeriesFile
.
getDecimalSymbol
());
if
(
timeSeriesFile
.
isSetValueColumnNumber
())
psTimeSeries
.
setLong
(
23
,
timeSeriesFile
.
getValueColumnNumber
());
if
(
timeSeriesFile
.
isSetTemporalExtent
()){
Timestamp
beginPosition
=
Timestamp
.
from
(
timeSeriesFile
.
getTemporalExtent
().
getTimePeriod
().
getBeginPosition
().
toInstant
());
Timestamp
endPosition
=
Timestamp
.
from
(
timeSeriesFile
.
getTemporalExtent
().
getTimePeriod
().
getEndPosition
().
toInstant
());
psTimeSeries
.
setTimestamp
(
7
,
beginPosition
);
psTimeSeries
.
setTimestamp
(
8
,
endPosition
);
}
if
(
timeSeriesFile
.
isSetTimeInterval
())
{
psTimeSeries
.
setDouble
(
14
,
timeSeriesFile
.
getTimeInterval
().
getValue
());
psTimeSeries
.
setString
(
15
,
timeSeriesFile
.
getTimeInterval
().
getUnit
());
}
}
else
if
(
abstractTimeSeries
instanceof
TypicalValuesTimeSeries
)
{
TypicalValuesTimeSeries
timeSeries
=
(
TypicalValuesTimeSeries
)
abstractTimeSeries
;
if
(
timeSeries
.
isSetStartTime
())
{
psTimeSeries
.
setObject
(
9
,
timeSeries
.
getStartTime
());
}
if
(
timeSeries
.
isSetStartDay
())
{
psTimeSeries
.
setInt
(
10
,
timeSeries
.
getStartDay
());
}
if
(
timeSeries
.
isSetStartMonth
())
{
psTimeSeries
.
setInt
(
11
,
timeSeries
.
getStartMonth
());
}
if
(
timeSeries
.
isSetValues
()
&&
timeSeries
.
getValues
().
isSetValue
())
{
String
values
=
valueJoiner
.
join
(
" "
,
timeSeries
.
getValues
().
getValue
());
psTimeSeries
.
setString
(
16
,
values
);
psTimeSeries
.
setString
(
17
,
timeSeries
.
getValues
().
getUom
());
}
if
(
timeSeries
.
isSetTemporalExtent
()){
psTimeSeries
.
setDouble
(
12
,
timeSeries
.
getTemporalExtent
().
getValue
());
psTimeSeries
.
setString
(
13
,
timeSeries
.
getTemporalExtent
().
getUnit
());
}
if
(
timeSeries
.
isSetTimeInterval
())
{
psTimeSeries
.
setDouble
(
14
,
timeSeries
.
getTimeInterval
().
getValue
());
psTimeSeries
.
setString
(
15
,
timeSeries
.
getTimeInterval
().
getUnit
());
}
}
else
if
(
abstractTimeSeries
instanceof
TypicalValuesTimeSeriesFile
)
{
TypicalValuesTimeSeriesFile
file
=
(
TypicalValuesTimeSeriesFile
)
abstractTimeSeries
;
if
(
file
.
isSetStartTime
())
{
LocalTime
localTime
=
file
.
getStartTime
().
toLocalTime
();
Time
sqlTime
=
Time
.
valueOf
(
localTime
);
psTimeSeries
.
setTime
(
9
,
sqlTime
);
}
if
(
file
.
isSetStartDay
())
{
psTimeSeries
.
setInt
(
10
,
file
.
getStartDay
());
}
if
(
file
.
isSetStartMonth
())
{
psTimeSeries
.
setInt
(
11
,
file
.
getStartMonth
());
}
if
(
file
.
isSetUom
())
psTimeSeries
.
setString
(
18
,
file
.
getUom
());
if
(
file
.
isSetFileURI
())
psTimeSeries
.
setString
(
19
,
file
.
getFileURI
().
toString
());
if
(
file
.
isSetTemporalExtent
()){
psTimeSeries
.
setDouble
(
12
,
file
.
getTemporalExtent
().
getValue
());
psTimeSeries
.
setString
(
13
,
file
.
getTemporalExtent
().
getUnit
());
}
if
(
file
.
isSetTimeInterval
())
{
psTimeSeries
.
setDouble
(
14
,
file
.
getTimeInterval
().
getValue
());
psTimeSeries
.
setString
(
15
,
file
.
getTimeInterval
().
getUnit
());
}
if
(
file
.
isSetNumberOfHeaderLines
())
psTimeSeries
.
setLong
(
20
,
file
.
getNumberOfHeaderLines
());
if
(
file
.
isSetFieldSeparator
())
psTimeSeries
.
setString
(
21
,
file
.
getFieldSeparator
());
if
(
file
.
isSetRecordSeparator
())
psTimeSeries
.
setString
(
22
,
file
.
getRecordSeparator
());
if
(
file
.
isSetDecimalSymbol
())
psTimeSeries
.
setString
(
24
,
file
.
getDecimalSymbol
());
if
(
file
.
isSetValueColumnNumber
())
psTimeSeries
.
setInt
(
23
,
file
.
getValueColumnNumber
());
}
else
if
(
abstractTimeSeries
instanceof
SensorConnection
)
{
SensorConnection
sensorConnection
=
(
SensorConnection
)
abstractTimeSeries
;
if
(
sensorConnection
.
isSetTemporalExtent
())
{
psTimeSeries
.
setDouble
(
12
,
sensorConnection
.
getTemporalExtent
().
getValue
());
psTimeSeries
.
setString
(
13
,
sensorConnection
.
getTemporalExtent
().
getUnit
());
}
if
(
sensorConnection
.
isSetConnectionType
())
{
psTimeSeries
.
setString
(
28
,
sensorConnection
.
getConnectionType
().
getValue
());
psTimeSeries
.
setString
(
27
,
sensorConnection
.
getConnectionType
().
getCodeSpace
());
}
if
(
sensorConnection
.
isSetObservationProperty
())
psTimeSeries
.
setString
(
36
,
sensorConnection
.
getObservationProperty
());
if
(
sensorConnection
.
isSetUom
())
psTimeSeries
.
setString
(
18
,
sensorConnection
.
getUom
());
if
(
sensorConnection
.
isSetSensorID
())
psTimeSeries
.
setString
(
37
,
sensorConnection
.
getSensorID
());
if
(
sensorConnection
.
isSetSensorName
())
psTimeSeries
.
setString
(
38
,
sensorConnection
.
getSensorName
());
if
(
sensorConnection
.
isSetObservationID
())
psTimeSeries
.
setString
(
35
,
sensorConnection
.
getObservationID
());
if
(
sensorConnection
.
isSetObservationProperty
())
psTimeSeries
.
setString
(
36
,
sensorConnection
.
getObservationProperty
());
if
(
sensorConnection
.
isSetDataStreamID
())
psTimeSeries
.
setString
(
30
,
sensorConnection
.
getDataStreamID
());
if
(
sensorConnection
.
isSetBaseURL
())
psTimeSeries
.
setString
(
27
,
sensorConnection
.
getBaseURL
().
toString
());
if
(
sensorConnection
.
isSetAuthType
())
psTimeSeries
.
setString
(
25
,
sensorConnection
.
getAuthType
().
getValue
());
psTimeSeries
.
setString
(
26
,
sensorConnection
.
getAuthType
().
getCodeSpace
());
if
(
sensorConnection
.
isSetMqtServer
())
psTimeSeries
.
setString
(
33
,
sensorConnection
.
getMqtServer
());
if
(
sensorConnection
.
isSetMqtTopic
())
psTimeSeries
.
setString
(
34
,
sensorConnection
.
getMqtTopic
());
if
(
sensorConnection
.
isSetLinkToObservation
())
psTimeSeries
.
setString
(
31
,
sensorConnection
.
getLinkToObservation
());
if
(
sensorConnection
.
isSetLinkToSensorDescription
())
psTimeSeries
.
setString
(
32
,
sensorConnection
.
getLinkToSensorDescription
());
}
psTimeSeries
.
addBatch
();
if
(++
batchCounter
==
helper
.
getDatabaseAdapter
().
getMaxBatchSize
())
helper
.
executeBatch
(
objectType
);
}
private
void
setTimeSeriesToNull
()
throws
SQLException
{
psTimeSeries
.
setNull
(
1
,
Types
.
INTEGER
);
// id
psTimeSeries
.
setNull
(
2
,
Types
.
INTEGER
);
// objectclass_id
psTimeSeries
.
setNull
(
3
,
Types
.
VARCHAR
);
// acquisition_method
psTimeSeries
.
setNull
(
4
,
Types
.
VARCHAR
);
// acquisition_method_codespace
psTimeSeries
.
setNull
(
5
,
Types
.
VARCHAR
);
// interpolation_type
psTimeSeries
.
setNull
(
6
,
Types
.
VARCHAR
);
// source
psTimeSeries
.
setNull
(
7
,
Types
.
TIMESTAMP
);
// period_begin
psTimeSeries
.
setNull
(
8
,
Types
.
TIMESTAMP
);
// period_end
psTimeSeries
.
setNull
(
9
,
Types
.
TIME
);
// start_time
psTimeSeries
.
setNull
(
10
,
Types
.
INTEGER
);
// start_day
psTimeSeries
.
setNull
(
11
,
Types
.
INTEGER
);
// start_month
psTimeSeries
.
setNull
(
12
,
Types
.
NUMERIC
);
// temporal_extent
psTimeSeries
.
setNull
(
13
,
Types
.
VARCHAR
);
// temporal_extent_unit
psTimeSeries
.
setNull
(
14
,
Types
.
NUMERIC
);
// time_interval
psTimeSeries
.
setNull
(
15
,
Types
.
VARCHAR
);
// time_interval_unit
psTimeSeries
.
setNull
(
16
,
Types
.
VARCHAR
);
// values_list
psTimeSeries
.
setNull
(
17
,
Types
.
VARCHAR
);
// values_list_uom
psTimeSeries
.
setNull
(
18
,
Types
.
VARCHAR
);
// uom
psTimeSeries
.
setNull
(
19
,
Types
.
VARCHAR
);
// file_uri
psTimeSeries
.
setNull
(
20
,
Types
.
INTEGER
);
// num_of_header_lines
psTimeSeries
.
setNull
(
21
,
Types
.
VARCHAR
);
// field_separator
psTimeSeries
.
setNull
(
22
,
Types
.
VARCHAR
);
// record_separator
psTimeSeries
.
setNull
(
23
,
Types
.
INTEGER
);
// value_column_number
psTimeSeries
.
setNull
(
24
,
Types
.
VARCHAR
);
// decimal_symbol
psTimeSeries
.
setNull
(
25
,
Types
.
VARCHAR
);
// auth_type
psTimeSeries
.
setNull
(
26
,
Types
.
VARCHAR
);
// auth_type_codespace
psTimeSeries
.
setNull
(
27
,
Types
.
VARCHAR
);
// base_url
psTimeSeries
.
setNull
(
28
,
Types
.
VARCHAR
);
// connection_type
psTimeSeries
.
setNull
(
29
,
Types
.
VARCHAR
);
// connection_type_codespace
psTimeSeries
.
setNull
(
30
,
Types
.
VARCHAR
);
// datastream_id
psTimeSeries
.
setNull
(
31
,
Types
.
VARCHAR
);
// link_to_observation
psTimeSeries
.
setNull
(
32
,
Types
.
VARCHAR
);
// link_to_sensor_description
psTimeSeries
.
setNull
(
33
,
Types
.
VARCHAR
);
// mqtt_server
psTimeSeries
.
setNull
(
34
,
Types
.
VARCHAR
);
// mqtt_topic
psTimeSeries
.
setNull
(
35
,
Types
.
VARCHAR
);
// observation_id
psTimeSeries
.
setNull
(
36
,
Types
.
VARCHAR
);
// observation_property
psTimeSeries
.
setNull
(
37
,
Types
.
VARCHAR
);
// sensor_id
psTimeSeries
.
setNull
(
38
,
Types
.
VARCHAR
);
// sensor_name
}
private
void
setAbstractTimeseriesProperties
(
AbstractTimeSeries
abstractTimeSeries
)
throws
SQLException
{
if
(
abstractTimeSeries
.
isSetAcquisitionMethod
())
{
psTimeSeries
.
setString
(
3
,
abstractTimeSeries
.
getAcquisitionMethod
().
getValue
());
psTimeSeries
.
setString
(
4
,
abstractTimeSeries
.
getAcquisitionMethod
().
getCodeSpace
());
}
if
(
abstractTimeSeries
.
isSetInterpolationTypeValue
())
psTimeSeries
.
setString
(
5
,
abstractTimeSeries
.
getInterpolationTypeValue
().
value
());
if
(
abstractTimeSeries
.
isSetSource
())
psTimeSeries
.
setString
(
6
,
abstractTimeSeries
.
getSource
());
}
@Override
public
void
executeBatch
()
throws
CityGMLImportException
,
SQLException
{
if
(
batchCounter
>
0
)
{
psTimeSeries
.
executeBatch
();
batchCounter
=
0
;
}
}
@Override
public
void
close
()
throws
CityGMLImportException
,
SQLException
{
psTimeSeries
.
close
();
}
private
String
getColumnNames
()
{
return
"id, objectclass_id, acquisition_method, acquisition_method_codespace, interpolation_type, source, "
+
"period_begin, period_end, start_time, start_day, start_month, temporal_extent, temporal_extent_unit, "
+
"time_interval, time_interval_unit, values_list, values_list_uom, uom, file_uri, num_of_header_lines, "
+
"field_separator, record_separator, value_column_number, decimal_symbol, auth_type, auth_type_codespace, "
+
"base_url, connection_type, connection_type_codespace, datastream_id, link_to_observation, "
+
"link_to_sensor_description, mqtt_server, mqtt_topic, observation_id, observation_property, "
+
"sensor_id, sensor_name"
;
}
private
String
getPlaceholders
(
int
count
)
{
return
String
.
join
(
","
,
Collections
.
nCopies
(
count
,
"?"
));
}
}
src/main/java/de/stuttgart/hft/ade/energy2/importer/UrbanFunctionAreaImporter.java
0 → 100644
View file @
21bc60b1
package
de.stuttgart.hft.ade.energy2.importer
;
import
de.stuttgart.hft.ade.energy2.schema.ADETable
;
import
org.citydb.config.geometry.GeometryObject
;
import
org.citydb.core.ade.importer.ADEImporter
;
import
org.citydb.core.ade.importer.CityGMLImportHelper
;
import
org.citydb.core.ade.importer.ForeignKeys
;
import
org.citydb.core.database.schema.mapping.AbstractObjectType
;
import
org.citydb.core.operation.importer.CityGMLImportException
;
import
org.citydb.core.operation.importer.util.GeometryConverter
;
import
org.citygml4j.ade.energy.model.supportingClasses.UrbanFunctionArea
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.Types
;
public
class
UrbanFunctionAreaImporter
implements
ADEImporter
{
private
final
Connection
connection
;
private
final
CityGMLImportHelper
helper
;
private
GeometryConverter
geometryConverter
;
private
PreparedStatement
ps
;
private
int
batchCounter
;
public
UrbanFunctionAreaImporter
(
Connection
connection
,
CityGMLImportHelper
helper
,
ImportManager
manager
)
throws
CityGMLImportException
,
SQLException
{
this
.
connection
=
connection
;
this
.
helper
=
helper
;
ps
=
connection
.
prepareStatement
(
"insert into "
+
helper
.
getTableNameWithSchema
(
manager
.
getSchemaMapper
().
getTableName
(
ADETable
.
URBAN_FUNCTION_AREA
))
+
" "
+
"(id, type, type_codespace, code, code_codespace) "
+
"values (?, ?, ?, ?, ?)"
);
geometryConverter
=
helper
.
getGeometryConverter
();
}
public
void
doImport
(
UrbanFunctionArea
urbanFunctionArea
,
long
objectId
,
AbstractObjectType
<?>
objectType
,
ForeignKeys
foreignKeys
)
throws
CityGMLImportException
,
SQLException
{
ps
.
setLong
(
1
,
objectId
);
setUrbanFunctionAreaNull
();
if
(
urbanFunctionArea
.
isSetType
())
{
ps
.
setString
(
2
,
urbanFunctionArea
.
getType
().
getValue
());
ps
.
setString
(
3
,
urbanFunctionArea
.
getType
().
getCodeSpace
());
}
if
(
urbanFunctionArea
.
isSetCode
()){
ps
.
setString
(
4
,
urbanFunctionArea
.
getCode
().
getValue
());
ps
.
setString
(
5
,
urbanFunctionArea
.
getCode
().
getCodeSpace
());
}
ps
.
addBatch
();
if
(++
batchCounter
==
helper
.
getDatabaseAdapter
().
getMaxBatchSize
())
helper
.
executeBatch
(
objectType
);
}
private
void
setUrbanFunctionAreaNull
()
throws
SQLException
{
ps
.
setNull
(
2
,
Types
.
VARCHAR
);
// type
ps
.
setNull
(
3
,
Types
.
VARCHAR
);
// type_codespace
ps
.
setNull
(
4
,
Types
.
VARCHAR
);
// code
ps
.
setNull
(
5
,
Types
.
VARCHAR
);
// code_codespace
}
@Override
public
void
executeBatch
()
throws
CityGMLImportException
,
SQLException
{
if
(
batchCounter
>
0
)
{
ps
.
executeBatch
();
batchCounter
=
0
;
}
}
@Override
public
void
close
()
throws
CityGMLImportException
,
SQLException
{
ps
.
close
();
}
}
src/main/java/de/stuttgart/hft/ade/energy2/importer/UtilityNetworkConnectionImporter.java
0 → 100644
View file @
21bc60b1
package
de.stuttgart.hft.ade.energy2.importer
;
import
de.stuttgart.hft.ade.energy2.schema.ADETable
;
import
org.citydb.core.ade.importer.ADEImporter
;
import
org.citydb.core.ade.importer.CityGMLImportHelper
;
import
org.citydb.core.ade.importer.ForeignKeys
;
import
org.citydb.core.database.schema.mapping.AbstractObjectType
;
import
org.citydb.core.operation.importer.CityGMLImportException
;
import
org.citydb.core.operation.importer.util.GeometryConverter
;
import
org.citygml4j.ade.energy.model.core.UtilityNetworkConnection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
public
class
UtilityNetworkConnectionImporter
implements
ADEImporter
{
private
final
Connection
connection
;
private
final
CityGMLImportHelper
helper
;
private
GeometryConverter
geometryConverter
;
private
PreparedStatement
ps
;
private
int
batchCounter
;
public
UtilityNetworkConnectionImporter
(
Connection
connection
,
CityGMLImportHelper
helper
,
ImportManager
manager
)
throws
CityGMLImportException
,
SQLException
{
this
.
connection
=
connection
;
this
.
helper
=
helper
;
ps
=
connection
.
prepareStatement
(
"INSERT INTO "
+
helper
.
getTableNameWithSchema
(
manager
.
getSchemaMapper
().
getTableName
(
ADETable
.
UTL_NTW_CONNECTION
))
+
" "
+
"(id, network_type, network_type_codespace, connection_status, function_in_network, "
+
"function_in_network_codespace, usage_in_network, usage_in_network_codespace, "
+
"network_id, network_node_id, cityobject_id) "
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
geometryConverter
=
helper
.
getGeometryConverter
();
}
public
void
doImport
(
UtilityNetworkConnection
networkConnection
,
long
objectId
,
AbstractObjectType
<?>
objectType
,
ForeignKeys
foreignKeys
)
throws
CityGMLImportException
,
SQLException
{
ps
.
setLong
(
1
,
objectId
);
if
(
networkConnection
.
isSetType
())
{
ps
.
setString
(
2
,
networkConnection
.
getNetworkType
().
getValue
());
ps
.
setString
(
3
,
networkConnection
.
getNetworkType
().
getCodeSpace
());
}
if
(
networkConnection
.
isSetConnectionStatus
())
{
ps
.
setString
(
4
,
networkConnection
.
getConnectionStatus
().
toString
());
}
if
(
networkConnection
.
isSetFunctionInNetwork
())
{
ps
.
setString
(
5
,
networkConnection
.
getFunctionInNetwork
().
getValue
());
ps
.
setString
(
6
,
networkConnection
.
getFunctionInNetwork
().
getCodeSpace
());
}
if
(
networkConnection
.
isSetUsageInNetwork
())
{
ps
.
setString
(
7
,
networkConnection
.
getUsageInNetwork
().
getValue
());
ps
.
setString
(
8
,
networkConnection
.
getUsageInNetwork
().
getCodeSpace
());
}
if
(
networkConnection
.
isSetNetworkID
())
{
ps
.
setString
(
9
,
networkConnection
.
getNetworkID
());
}
if
(
networkConnection
.
isSetNetworkNodeID
())
{
ps
.
setString
(
10
,
networkConnection
.
getNetworkNodeID
());
}
//set correctly
ps
.
setLong
(
11
,
objectType
.
getObjectClassId
());
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
();
}
}
src/main/java/de/stuttgart/hft/ade/energy2/importer/WeatherDataImporter.java
0 → 100644
View file @
21bc60b1
package
de.stuttgart.hft.ade.energy2.importer
;
import
de.stuttgart.hft.ade.energy2.schema.ADETable
;
import
org.citydb.config.geometry.GeometryObject
;
import
org.citydb.core.ade.importer.ADEImporter
;
import
org.citydb.core.ade.importer.CityGMLImportHelper
;
import
org.citydb.core.ade.importer.ForeignKeys
;
import
org.citydb.core.database.schema.mapping.AbstractObjectType
;
import
org.citydb.core.operation.importer.CityGMLImportException
;
import
org.citydb.core.operation.importer.util.GeometryConverter
;
import
org.citygml4j.ade.energy.model.core.ReferencePointProperty
;
import
org.citygml4j.ade.energy.model.core.WeatherData
;
import
org.citygml4j.ade.energy.model.supportingClasses.AbstractTimeSeries
;
import
org.citygml4j.ade.energy.model.supportingClasses.AbstractTimeSeriesProperty
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.Types
;
public
class
WeatherDataImporter
implements
ADEImporter
{
private
final
Connection
connection
;
private
final
CityGMLImportHelper
helper
;
private
GeometryConverter
geometryConverter
;
private
PreparedStatement
ps
;
private
int
batchCounter
;
public
WeatherDataImporter
(
Connection
connection
,
CityGMLImportHelper
helper
,
ImportManager
manager
)
throws
SQLException
{
this
.
connection
=
connection
;
this
.
helper
=
helper
;
ps
=
connection
.
prepareStatement
(
"insert into "
+
helper
.
getTableNameWithSchema
(
manager
.
getSchemaMapper
().
getTableName
(
ADETable
.
WEATHER_DATA
))
+
" "
+
"(id, type, type_codespace, value_type, value_type_codespace, yearly_value, yearly_value_uom, library_code, library_code_codespace, time_series_id, cityObject_id, position) "
+
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
geometryConverter
=
helper
.
getGeometryConverter
();
}
public
void
doImport
(
WeatherData
weatherData
,
long
objectId
,
AbstractObjectType
<?>
objectType
,
ForeignKeys
foreignKeys
)
throws
CityGMLImportException
,
SQLException
{
long
cityObjectId
=
foreignKeys
.
get
(
"cityObjectId"
);
setWeatherDataNull
(
weatherData
);
ps
.
setLong
(
1
,
objectId
);
if
(
weatherData
.
isSetType
()){
ps
.
setString
(
2
,
weatherData
.
getType
().
getValue
());
ps
.
setString
(
3
,
weatherData
.
getType
().
getCodeSpace
());
}
if
(
weatherData
.
isSetValueType
()){
ps
.
setString
(
4
,
weatherData
.
getValueType
().
getValue
());
ps
.
setString
(
5
,
weatherData
.
getValueType
().
getCodeSpace
());
}
if
(
weatherData
.
isSetYearlyValue
()){
ps
.
setDouble
(
6
,
weatherData
.
getYearlyValue
().
getValue
());
ps
.
setString
(
7
,
weatherData
.
getYearlyValue
().
getUom
());
}
if
(
weatherData
.
isSetLibraryCode
()){
ps
.
setString
(
8
,
weatherData
.
getLibraryCode
().
getValue
());
ps
.
setString
(
9
,
weatherData
.
getLibraryCode
().
getCodeSpace
());
}
if
(
cityObjectId
!=
0
)
{
ps
.
setLong
(
11
,
cityObjectId
);
}
if
(
weatherData
.
isSetPosition
()){
GeometryObject
geometryObject
=
null
;
ReferencePointProperty
referencePoint
=
weatherData
.
getPosition
();
if
(
referencePoint
!=
null
&&
referencePoint
.
isSetValue
())
geometryObject
=
helper
.
getGeometryConverter
().
getPoint
(
referencePoint
.
getValue
());
if
(
geometryObject
!=
null
)
ps
.
setObject
(
12
,
helper
.
getDatabaseAdapter
().
getGeometryConverter
().
getDatabaseObject
(
geometryObject
,
connection
));
else
ps
.
setNull
(
12
,
helper
.
getDatabaseAdapter
().
getGeometryConverter
().
getNullGeometryType
(),
helper
.
getDatabaseAdapter
().
getGeometryConverter
().
getNullGeometryTypeName
());
}
if
(
weatherData
.
getTimeDependentValues
()
!=
null
){
long
timeSeriesId
=
helper
.
importObject
(
weatherData
.
getTimeDependentValues
().
getAbstractTimeSeries
(),
null
);
ps
.
setLong
(
10
,
timeSeriesId
);
}
ps
.
addBatch
();
if
(++
batchCounter
==
helper
.
getDatabaseAdapter
().
getMaxBatchSize
())
helper
.
executeBatch
(
objectType
);
}
public
void
setWeatherDataNull
(
WeatherData
weatherData
)
throws
SQLException
{
ps
.
setNull
(
1
,
Types
.
INTEGER
);
ps
.
setNull
(
2
,
Types
.
VARCHAR
);
ps
.
setNull
(
3
,
Types
.
VARCHAR
);
ps
.
setNull
(
4
,
Types
.
VARCHAR
);
ps
.
setNull
(
5
,
Types
.
VARCHAR
);
ps
.
setNull
(
6
,
Types
.
BIGINT
);
ps
.
setNull
(
7
,
Types
.
VARCHAR
);
ps
.
setNull
(
8
,
Types
.
VARCHAR
);
ps
.
setNull
(
9
,
Types
.
VARCHAR
);
ps
.
setNull
(
10
,
Types
.
BIGINT
);
ps
.
setNull
(
11
,
Types
.
BIGINT
);
ps
.
setNull
(
12
,
Types
.
BINARY
);
}
@Override
public
void
executeBatch
()
throws
CityGMLImportException
,
SQLException
{
if
(
batchCounter
>
0
)
{
ps
.
executeBatch
();
batchCounter
=
0
;
}
}
@Override
public
void
close
()
throws
CityGMLImportException
,
SQLException
{
ps
.
close
();
}
}
src/main/java/de/stuttgart/hft/ade/energy2/importer/WeatherStationImporter.java
0 → 100644
View file @
21bc60b1
/*
* 3D City Database - The Open Source CityGML Database
* https://www.3dcitydb.org/
*
* Copyright 2013 - 2024
* Chair of Geoinformatics
* Technical University of Munich, Germany
* https://www.lrg.tum.de/gis/
*
* The 3D City Database is jointly developed with the following
* cooperation partners:
*
* Virtual City Systems, Berlin <https://vc.systems/>
* M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen <http://www.moss.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
de.stuttgart.hft.ade.energy2.importer
;
import
de.stuttgart.hft.ade.energy2.schema.ADETable
;
import
org.citydb.config.geometry.GeometryObject
;
import
org.citydb.core.ade.importer.ADEImporter
;
import
org.citydb.core.ade.importer.CityGMLImportHelper
;
import
org.citydb.core.ade.importer.ForeignKeys
;
import
org.citydb.core.database.schema.mapping.AbstractObjectType
;
import
org.citydb.core.operation.importer.CityGMLImportException
;
import
org.citydb.core.operation.importer.util.GeometryConverter
;
import
org.citygml4j.ade.energy.model.supportingClasses.WeatherStation
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
public
class
WeatherStationImporter
implements
ADEImporter
{
private
final
Connection
connection
;
private
final
CityGMLImportHelper
helper
;
private
GeometryConverter
geometryConverter
;
private
PreparedStatement
ps
;
private
int
batchCounter
;
public
WeatherStationImporter
(
Connection
connection
,
CityGMLImportHelper
helper
,
ImportManager
manager
)
throws
CityGMLImportException
,
SQLException
{
this
.
connection
=
connection
;
this
.
helper
=
helper
;
ps
=
connection
.
prepareStatement
(
"insert into "
+
helper
.
getTableNameWithSchema
(
manager
.
getSchemaMapper
().
getTableName
(
ADETable
.
CITYOBJECT
))
+
" "
+
"(id, ref_point) "
+
"values (?, ?)"
);
geometryConverter
=
helper
.
getGeometryConverter
();
}
public
void
doImport
(
WeatherStation
weatherStation
,
long
objectId
,
AbstractObjectType
<?>
objectType
,
ForeignKeys
foreignKeys
)
throws
CityGMLImportException
,
SQLException
{
ps
.
setLong
(
1
,
objectId
);
GeometryObject
geometryObject
=
null
;
if
(
geometryObject
!=
null
)
ps
.
setObject
(
2
,
helper
.
getDatabaseAdapter
().
getGeometryConverter
().
getDatabaseObject
(
geometryObject
,
connection
));
else
ps
.
setNull
(
2
,
helper
.
getDatabaseAdapter
().
getGeometryConverter
().
getNullGeometryType
(),
helper
.
getDatabaseAdapter
().
getGeometryConverter
().
getNullGeometryTypeName
());
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
();
}
}
src/main/java/de/stuttgart/hft/ade/energy2/schema/ADESequence.java
0 → 100644
View file @
21bc60b1
/*
* 3D City Database - The Open Source CityGML Database
* https://www.3dcitydb.org/
*
* Copyright 2013 - 2024
* Chair of Geoinformatics
* Technical University of Munich, Germany
* https://www.lrg.tum.de/gis/
*
* The 3D City Database is jointly developed with the following
* cooperation partners:
*
* Virtual City Systems, Berlin <https://vc.systems/>
* M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen <http://www.moss.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
de.stuttgart.hft.ade.energy2.schema
;
public
enum
ADESequence
{
VOLUMETYPE_SEQ
,
FLOORAREA_SEQ
,
QUALIFIED_ATTRIBUTE_SEQ
,
HEATEXCHANGETYPE_SEQ
,
TRANSMITTANCE_SEQ
,
OPTICALPROPERTIES_SEQ
,
REFLECTANCE_SEQ
,
TIMEVALUESPROPERTI_SEQ
,
PERIODOFYEAR_SEQ
,
DAILYSCHEDULE_SEQ
,
REFURBISHMENT_MEASURE_SEQ
}
src/main/java/de/stuttgart/hft/ade/energy2/schema/ADETable.java
0 → 100644
View file @
21bc60b1
/*
* 3D City Database - The Open Source CityGML Database
* https://www.3dcitydb.org/
*
* Copyright 2013 - 2024
* Chair of Geoinformatics
* Technical University of Munich, Germany
* https://www.lrg.tum.de/gis/
*
* The 3D City Database is jointly developed with the following
* cooperation partners:
*
* Virtual City Systems, Berlin <https://vc.systems/>
* M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen <http://www.moss.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
de.stuttgart.hft.ade.energy2.schema
;
import
de.stuttgart.hft.ade.energy2.importer.*
;
import
org.citydb.core.ade.importer.ADEImporter
;
import
org.citygml4j.ade.energy.model.core.AbstractQualifiedAttribute
;
public
enum
ADETable
{
ADDRESS_TO_BUILDING_UNIT
(
null
),
BUILDING
(
BuildingPropertiesImporter
.
class
),
BUILDING_PARTITION
(
null
),
CITYOBJECT
(
CityObjectPropertiesImporter
.
class
),
CTYOBJ_RELATION
(
null
),
DEVICE
(
AbstractDeviceImporter
.
class
),
DEVICE_OPERATION
(
DeviceOperationImporter
.
class
),
ENERGY_PERF_CERT
(
EnergyPerformanceCertificateImporter
.
class
),
FACILITIES
(
null
),
HEAT_EXCHANGE_TYPE
(
null
),
IMAGE_TEXTURE
(
null
),
LAYERED_CONSTRUCTION
(
null
),
LAYER_COMPONENT
(
null
),
LAYER
(
null
),
LIBRARY
(
null
),
MATERIAL
(
null
),
OCCUPANTS
(
null
),
OPENING
(
null
),
OPTICAL_PROPERTY
(
null
),
PERIOD_OF_YEAR
(
null
),
QUALIFIED_ATTRIBUTE
(
AbstractQualifiedAttributeImporter
.
class
),
RESOURCE
(
ResourceImporter
.
class
),
REFURBISHMENT_MEASURE
(
RefurbishmentMeasureImporter
.
class
),
SCHEDULE
(
null
),
SYSTEM_OPERATION
(
null
),
SOLAR_COLLECTOR
(
null
),
STORAGE_SYSTEM
(
null
),
STORAGE_DEVICE
(
null
),
SENSOR_CONNECTION
(
null
),
SOLAR_ENERGY_SYSTEM
(
null
),
SUITABILITY
(
null
),
SCHEDULE_COMPONENT
(
null
),
THERMAL_BOUNDARY
(
null
),
THERMAL_OPENING
(
null
),
THEM_SURF_TO_THERMAL_ZONE
(
null
),
THEMATIC_SURFACE
(
null
),
THERMAL_ZONE
(
null
),
TIME_SERIES
(
TimeSeriesImporter
.
class
),
URBAN_FUNCTION_AREA
(
UrbanFunctionAreaImporter
.
class
),
USAGE_ZONE
(
null
),
UTL_NTW_CONNECTION
(
UtilityNetworkConnectionImporter
.
class
),
WEATHER_DATA
(
WeatherDataImporter
.
class
);
private
Class
<?
extends
ADEImporter
>
importerClass
;
ADETable
(
Class
<?
extends
ADEImporter
>
importerClass
)
{
this
.
importerClass
=
importerClass
;
}
public
Class
<?
extends
ADEImporter
>
getImporterClass
()
{
return
importerClass
;
}
}
src/main/java/de/stuttgart/hft/ade/energy2/schema/ObjectMapper.java
0 → 100644
View file @
21bc60b1
/*
* 3D City Database - The Open Source CityGML Database
* https://www.3dcitydb.org/
*
* Copyright 2013 - 2024
* Chair of Geoinformatics
* Technical University of Munich, Germany
* https://www.lrg.tum.de/gis/
*
* The 3D City Database is jointly developed with the following
* cooperation partners:
*
* Virtual City Systems, Berlin <https://vc.systems/>
* M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen <http://www.moss.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
de.stuttgart.hft.ade.energy2.schema
;
import
org.citydb.core.ade.ADEExtensionException
;
import
org.citydb.core.ade.ADEObjectMapper
;
import
org.citydb.core.database.schema.mapping.AbstractObjectType
;
import
org.citydb.core.database.schema.mapping.SchemaMapping
;
import
org.citygml4j.ade.energy.model.core.*
;
import
org.citygml4j.ade.energy.model.supportingClasses.*
;
import
org.citygml4j.model.gml.base.AbstractGML
;
import
org.citygml4j.model.module.citygml.CityGMLVersion
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map.Entry
;
public
class
ObjectMapper
implements
ADEObjectMapper
{
private
Map
<
Class
<?
extends
AbstractGML
>,
Integer
>
objectClassIds
=
new
HashMap
<>();
public
void
populateObjectClassIds
(
SchemaMapping
schemaMapping
)
throws
ADEExtensionException
{
for
(
AbstractObjectType
<?>
type
:
schemaMapping
.
getAbstractObjectTypes
())
{
int
objectClassId
=
type
.
getObjectClassId
();
switch
(
type
.
getPath
())
{
case
"AbstractSchedule"
:
objectClassIds
.
put
(
AbstractSchedule
.
class
,
objectClassId
);
break
;
case
"AbstractTimeSeries"
:
objectClassIds
.
put
(
AbstractTimeSeries
.
class
,
objectClassId
);
break
;
case
"RegularTimeSeries"
:
objectClassIds
.
put
(
RegularTimeSeries
.
class
,
objectClassId
);
break
;
case
"RegularTimeSeriesFile"
:
objectClassIds
.
put
(
RegularTimeSeriesFile
.
class
,
objectClassId
);
break
;
case
"TypicalValuesTimeSeries"
:
objectClassIds
.
put
(
TypicalValuesTimeSeries
.
class
,
objectClassId
);
break
;
case
"TypicalValuesTimeSeriesFile"
:
objectClassIds
.
put
(
TypicalValuesTimeSeriesFile
.
class
,
objectClassId
);
break
;
case
"SensorConnection"
:
objectClassIds
.
put
(
SensorConnection
.
class
,
objectClassId
);
break
;
case
"AbstractResource"
:
objectClassIds
.
put
(
AbstractResource
.
class
,
objectClassId
);
case
"UrbanFunctionArea"
:
objectClassIds
.
put
(
UrbanFunctionArea
.
class
,
objectClassId
);
break
;
case
"RefurbishmentMeasure"
:
objectClassIds
.
put
(
RefurbishmentMeasure
.
class
,
objectClassId
);
break
;
case
"WeatherData"
:
objectClassIds
.
put
(
WeatherData
.
class
,
objectClassId
);
break
;
case
"WeatherStation"
:
objectClassIds
.
put
(
WeatherStation
.
class
,
objectClassId
);
break
;
case
"Water"
:
objectClassIds
.
put
(
Water
.
class
,
objectClassId
);
break
;
case
"Energy"
:
objectClassIds
.
put
(
Energy
.
class
,
objectClassId
);
break
;
case
"AbstractDevice"
:
objectClassIds
.
put
(
AbstractDevice
.
class
,
objectClassId
);
case
"DeviceOperation"
:
objectClassIds
.
put
(
DeviceOperation
.
class
,
objectClassId
);
break
;
case
"UtilityNetworkConnection"
:
objectClassIds
.
put
(
UtilityNetworkConnection
.
class
,
objectClassId
);
break
;
case
"AbstractBuilding"
:
objectClassIds
.
put
(
AbstractBuilding
.
class
,
objectClassId
);
break
;
case
"QualifiedVolume"
:
objectClassIds
.
put
(
QualifiedVolume
.
class
,
objectClassId
);
break
;
case
"QualifiedHeight"
:
objectClassIds
.
put
(
QualifiedHeight
.
class
,
objectClassId
);
break
;
case
"QualifiedArea"
:
objectClassIds
.
put
(
QualifiedArea
.
class
,
objectClassId
);
break
;
}
}
}
@Override
public
AbstractGML
createObject
(
int
objectClassId
,
CityGMLVersion
version
)
{
if
(
version
==
CityGMLVersion
.
v2_0_0
)
{
for
(
Entry
<
Class
<?
extends
AbstractGML
>,
Integer
>
entry
:
objectClassIds
.
entrySet
())
{
if
(
entry
.
getValue
()
==
objectClassId
)
{
try
{
return
entry
.
getKey
().
getDeclaredConstructor
().
newInstance
();
}
catch
(
InstantiationException
|
IllegalAccessException
|
NoSuchMethodException
|
InvocationTargetException
e
)
{
}
}
}
}
return
null
;
}
@Override
public
int
getObjectClassId
(
Class
<?
extends
AbstractGML
>
adeObjectClass
)
{
Integer
objectClassId
=
objectClassIds
.
get
(
adeObjectClass
);
return
objectClassId
!=
null
?
objectClassId
:
0
;
}
}
src/main/java/de/stuttgart/hft/ade/energy2/schema/SchemaMapper.java
0 → 100644
View file @
21bc60b1
/*
* 3D City Database - The Open Source CityGML Database
* https://www.3dcitydb.org/
*
* Copyright 2013 - 2024
* Chair of Geoinformatics
* Technical University of Munich, Germany
* https://www.lrg.tum.de/gis/
*
* The 3D City Database is jointly developed with the following
* cooperation partners:
*
* Virtual City Systems, Berlin <https://vc.systems/>
* M.O.S.S. Computer Grafik Systeme GmbH, Taufkirchen <http://www.moss.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
de.stuttgart.hft.ade.energy2.schema
;
import
java.util.EnumMap
;
import
java.util.Map
;
public
class
SchemaMapper
{
private
EnumMap
<
ADETable
,
String
>
tableNames
=
new
EnumMap
<>(
ADETable
.
class
);
private
EnumMap
<
ADESequence
,
String
>
sequenceNames
=
new
EnumMap
<>(
ADESequence
.
class
);
public
void
populateSchemaNames
(
String
prefix
)
{
for
(
ADETable
table
:
ADETable
.
values
())
tableNames
.
put
(
table
,
prefix
+
"_"
+
table
.
toString
().
toLowerCase
());
for
(
ADESequence
sequence
:
ADESequence
.
values
())
sequenceNames
.
put
(
sequence
,
prefix
+
"_"
+
sequence
.
toString
().
toLowerCase
());
}
public
String
getTableName
(
ADETable
table
)
{
return
tableNames
.
get
(
table
);
}
public
ADETable
fromTableName
(
String
tableName
)
{
tableName
=
tableName
.
toLowerCase
();
for
(
Map
.
Entry
<
ADETable
,
String
>
entry
:
tableNames
.
entrySet
())
{
if
(
entry
.
getValue
().
equals
(
tableName
))
return
entry
.
getKey
();
}
return
null
;
}
public
String
getSequenceName
(
ADESequence
sequence
)
{
return
sequenceNames
.
get
(
sequence
);
}
}
src/main/resources/META-INF/MANIFEST.MF
0 → 100644
View file @
21bc60b1
Manifest-Version: 1.0
Main-Class: de.stuttgart.hft.EnergyADEExtension
src/main/resources/services/org.citydb.core.ade.ADEExtension
0 → 100644
View file @
21bc60b1
de.stuttgart.hft.EnergyADEExtension
\ No newline at end of file
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment