Commit 8b6cdd3b authored by Luna Riegel's avatar Luna Riegel
Browse files

Merge branch 'dev_embedded_geodb' into 'dev'

!Geodatabase implementation

See merge request !36
parents 2fe401b3 e2cce980
Pipeline #12243 passed with stage
in 2 minutes and 14 seconds
package de.hft.stuttgart.citydoctor2.zip;
import java.util.zip.ZipException;
/**
* Signals that a ZIP-file is corrupted and couldn't be parsed.
*/
public class MalformedZipFileException extends ZipException {
public MalformedZipFileException() {
super();
}
public MalformedZipFileException(String message) {
super(message);
}
}
package de.hft.stuttgart.citydoctor2.zip;
/**
* Error types for {@link CityGmlZipEntry} objects.
*/
public enum ZipEntryErrorType {
INVALID_CITY_GML_FILE, EXCESSIVE_FILESIZE, IO_ERROR
}
package de.hft.stuttgart.citydoctor2.zip;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class ZipParser {
private static final Logger logger = LogManager.getLogger(ZipParser.class);
}
CityDoctorValidation.Version=${versionString}
DistanceError.distanceFromPlane=distance from plane
AboutDialog.developedBy=Developed by
AboutDialog.closeBtn=Close
AboutDialog.contact=Contact
AboutDialog.developedBy=Developed by
AboutDialog.title=CityDoctor 3 - About
AboutDialog.closeBtn=Close
CheckDialog.title=Check Configuration
CheckDialog.schematronFiles=Schematron Files
CheckDialog.schematronChooserTitle=Choose schematron file..
CheckDialog.validationConfiguration=Validation Configuration
CheckDialog.startingChecks=Starting checks
CheckDialog.checksDone=Checks done
CheckDialog.failedChecks=Failed to execute checks
CheckDialog.schematronFileNotExisting=Schematron file does not exist, ignoring
CheckContainer.error=Unexpected exception while executing check: {}
CheckDialog.availableChecksLabel=Available Checks
CheckDialog.cancelBtn=Cancel
CheckDialog.checkBtn=Check
CheckDialog.checkEnabled=Enabled
CheckDialog.checkName=Name
CheckDialog.parameterValue=Value
CheckDialog.checksDone=Checks done
CheckDialog.checksReenabledAlert=Some checks have been reenabled so that other wanted checks can be executed\nSee the log for more information.
CheckDialog.checksTab=Checks
CheckDialog.failedChecks=Failed to execute checks
CheckDialog.filterTab=Filter
CheckDialog.geometricChecksLabel=Geometric Checks
CheckDialog.globalParametersLabel=Global Parameters
CheckDialog.noPathError=Output path is missing!
CheckDialog.outputPathBtn=Select
CheckDialog.outputPathLabel=Output directory (Required):
CheckDialog.parameterUnit=Unit
CheckDialog.parameterValue=Value
CheckDialog.pdfReportsOption=Create PDF reports
CheckDialog.schematronChooserTitle=Choose schematron file ...
CheckDialog.schematronFileLabel=Schematron File:
CheckDialog.schematronFileNotExisting=Schematron file does not exist, Schematron will be skipped
CheckDialog.schematronFiles=Schematron Files
CheckDialog.selectBtn=Select
CheckDialog.semanticChecksLabel=Semantic Checks
CheckDialog.startingChecks=Starting checks
CheckDialog.streamCheckLabel=Citymodels are not loaded and kept in memory. Check results are saved to the QualityADE in copies of the input files.
CheckDialog.streamCheckOption=Use low memory mode
CheckDialog.title=Check Configuration
CheckDialog.validationConfiguration=Validation Configuration
CheckDialog.xmlReportsOption=Create XML reports
Checker.checkFeature=Checking feature: {}
Checker.checksFinished=Finished executing checks. Total time: {0}
Checker.dbStillUnresponsive=Checker still unable to load some CityObjects from database!
Checker.dbUnresponsive=Checker could not load some CityObjects from database!
Checker.executeCheck=Executing check: {}
Checker.failPdf=Failed to write PDF Report.
Checker.failReports=Failed to write reports.
Checker.failXml=Failed to write XML Error Report.
Checker.finishedSchematron=Finished Schematron validation
Checker.futuresCheckFailures=Encountered check failures due to the following errors:
Checker.noCheckSatisfiesRequirement=Could not find any check that satisfies requirement {}, it will not be checked
Checker.schematronCompleted=Schematron completed
Checker.schematronFileNotFound=Schematron file {} could not be found
Checker.schematronInterrupted=Main Thread was interrupted while waiting for Schematron
Checker.schematronStillRunning=Schematron is still running. Waiting for completion, this may take some time
Checker.schematronValidation=Schematron-validation thread started
Checker.shutdownInterrupted=Main Thread got interrupted during ThreadPool shutdown
Checker.validationInterrupted=Validation aborted: Checker got interrupted
Checker.waitAndRetry=Waiting a second before retrying...
Checks.missingCheck=Could not find check for id: {}
CityDoctorController.exportSuccess=Successfully exported feature
CityDoctorController.noDatamodel=Datamodel is null, no checks could be done
CityDoctorController.noSourceFile=Source file is null, no checks could be done
CityDoctorController.noZipFile=ZIP archive is null, no checks could be done
CityDoctorController.exportSuccess=Successfully exported feature
CityDoctorController.saveZipArchiveReports=Successfully exported validation reports!
CityDoctorValidation.Version=${versionString}
CityDoctorValidation.inputFileNotExisting= Input file '{}' does not exist.
CityDoctorValidation.loadingDefaultConfig=No configuration file given, loading default configuration
CityDoctorValidation.noConfig=No configuration file specified with -config [FILE]
CityDoctorValidation.noInputFile=No input file specified. (-in [FILE])
CityDoctorValidation.noOutputFile=No output file specified. (-out [FILE])
CityDoctorValidation.notExactlyOneConfigFile=Specify exactly one file as configuration
CityDoctorValidation.notExactlyOneInputFile=Specify exactly one file as input.
CityDoctorValidation.notExactlyOneOutputFile=Specify exactly one file as output.
CityDoctorValidation.notExactlyOnePDFOutput=Specify exactly one file as pdfReport
CityDoctorValidation.notExactlyOneXMLOutput=Specify exactly one file as xmlReport
CityDoctorValidation.wrongInputFileFormat=Input file '{}' does not end with .gml or .xml
CityGmlParser.chunkReadFailed=Failed to read GML file in chunks, falling back to reading the complete file
CityGmlParser.convertCrsToUtmZoneN=Converting coordinate system to UTM zone {}N
CityGmlParser.convertCrsToUtmZoneS=Converting coordinate system to UTM zone {}S
CityGmlParser.creating4jContextFailed=Unable to create citygml4j context
CityGmlParser.creatingAdePluginsFailed=Unable to add ADE plugins to citygml4j
CityGmlParser.errorReadingGmlFile=Error while reading city gml file\n{}
CityGmlParser.errorWritingGmlFile=Error while writing city gml file\n{}
CityGmlParser.failedEPSGParse=Could not read EPSG code, fallback to metric system
CityGmlParser.missingCityModel=File does not contain a CityModel definition! Temporary CityModel will be created.
CityGmlParser.missingEPSGCode=No EPSG code found, assuming metric system
CityGmlParser.noConversionNeeded=Coordinate system is in meters, no conversion done
CityGmlParser.notValidGmlFile=This is not a valid GML-File\n
CityGmlParser.parsedObjects=Parsed model with {} objects
CityGmlWriterUtils.unknownADEError= Found error {} that cannot be converted to ADE error. It will not be written
CityGmlZipArchive.generalException=Encountered an unexpected error while reading the ZIP archive
CityGmlZipArchive.ioError=Accessing the ZIP archive failed
CityGmlZipArchive.malformedZipFile=Parsing of ZIP archive aborted, ZIP file is malformed!
DatabaseHandler.batchCommitFailure=Batch-commit aborted: Critical failure while trying to write CityObject {} to database!
DatabaseHandler.connectionFailure=Connection to embedded database could not be opened!
DatabaseHandler.fetchErrorIdsFailure=Fetching list of GmlIDs of CityObjects with errors failed!
DatabaseHandler.getAllCityObjectsFailure=Fetching of all CityObjects failed!
DatabaseHandler.getBBoxIntersectFailure= Connection to database failed while trying to fetch bbox intersecting objects of CityObject {}
DatabaseHandler.getBufferIntersectFailure=Connection to database failed while trying to fetch buffer intersecting objects of CityObject {}
DatabaseHandler.getFeatureCountFailure=Connection to database failed while trying to get count of CityObjects!
DatabaseHandler.marshallingFailure=Writing CityObject {} to database failed!
DatabaseHandler.serializationFailure=Serialization of CityObject {} failed!
DatabaseHandler.setupFailure=FATAL ERROR: Creation of embedded database failed!
DatabaseHandler.tableFailure=FATAL ERROR: Creation of features table failed!
DatabaseHandler.unmarshallingFailure=Loading of CityObject {} from embedded database failed!
DistanceError.distanceFromPlane=distance from plane
ErrorItemVisitor.childId=Child id
ErrorItemVisitor.component=Component
ErrorItemVisitor.degeneratedRing=Degenerated ring
ErrorItemVisitor.deviation=Deviation
ErrorItemVisitor.distance=Distance
ErrorItemVisitor.intersection=Intersection
ErrorItemVisitor.nameOfAttribute=Name of attribute
ErrorItemVisitor.pointTouchesEdge=Point touches edge
ErrorItemVisitor.triangles=Triangles
ExceptionDialog.stacktrace=The exception stacktrace was:
FilterPane.buildings=Buildings
FeatureMapper.polygonUnreferenced=Polygon {} is referenced but not found in feature polygons
FilterPane.bridges=Bridges
FilterPane.buildings=Buildings
FilterPane.landUse=Land Use
FilterPane.transportation=Transportation
FilterPane.vegetation=Vegetation
FilterPane.water=Water
MainToolBar.wireframe=Show/Hide Wireframe
GeometryMapper.emptyPolygon=Found polygon without exterior ring, ignoring
LibraryObject.fileMissing=Implicit geometry references non-existing library object file {}
LibraryObject.parsingError=Encountered an error while parsing library object {}
MainToolBar.culling=Enable/Disable Culling
MainToolBar.writeReports=Write Reports
MainToolBar.executeChecks=Execute Checks
MainToolBar.showWorld=Show entire city model
MainToolBar.resetCamera=Reset view
MainToolBar.hideRoof=Show/Hide roof BoundarySurfaces
MainToolBar.resetCamera=Reset view
MainToolBar.showWorld=Show entire city model
MainToolBar.wireframe=Show/Hide Wireframe
MainToolBar.writeReports=Write Reports
MainToolBar.zip=Open zip-entry selection window
MainWindow.missingConfig=Could not find configuration file.
MainWindow.loadGivenFile=Loading given file, please wait
MainWindow.finishedLoading=Finished loading
MainWindow.checking=Checking, please wait
MainWindow.writeXml=Writing xml report
MainWindow.finishedXml=Finished xml report
MainWindow.writePdf=Writing pdf report
MainWindow.finishedPdf=Finished pdf report
MainWindow.loadFailed=Failed to load given gml file: {}
MainWindow.all=All
MainWindow.withErrors=With errors
MainWindow.export=Export feature
MainWindow.attributeTab=Attributes
MainWindow.availableLabel=Available:
MainWindow.bridgeTab=Bridges
MainWindow.buildingsTab=Buildings
MainWindow.checking=Checking, please wait
MainWindow.cityfurnitureTab=CityFurniture
MainWindow.clearBtn=Clear
MainWindow.copyId=Copy GML-ID
MainWindow.delete=Delete feature
MainWindow.infoTopLevelExport=Only top-level object can be exported!
MainWindow.edgesTab=Edges
MainWindow.errorsTab=Errors
MainWindow.export=Export feature
MainWindow.finishedLoading=Finished loading
MainWindow.finishedPdf=Finished pdf report
MainWindow.finishedXml=Finished xml report
MainWindow.focusCityObject=Focus object
MainWindow.globalErrorsTab=Global Errors
MainWindow.infoTopLevelCopyID=GML-ID can only be copied from top-level object!
mainWindow.warnCopyIdFailed=Could not copy GML-ID!
OpenFileDialog.select=Select CityGML file
MainWindow.infoTopLevelExport=Only top-level object can be exported!
MainWindow.languageChange=For the change in language to apply, restart CityDoctor2.
MainWindow.buildingsTab=Buildings
MainWindow.vegetationTab=Vegetation
MainWindow.transportationTab=Transportation
MainWindow.tunnelTab=Tunnels
MainWindow.bridgeTab=Bridges
MainWindow.waterTab=Water
MainWindow.terrainTab=Terrain
MainWindow.cityfurnitureTab=CityFurniture
MainWindow.loadFailed=Failed to load given gml file: {}
MainWindow.loadGivenFile=Loading given file, please wait
MainWindow.logTab=Log
MainWindow.memoryLabel=Memory:
MainWindow.missingConfig=Could not find configuration file.
MainWindow.otherObjectsTab=Other
MainWindow.viewLabel=View
MainWindow.showLabel=Show:
MainWindow.searchLabel=Search:
MainWindow.searchBtn=Search
MainWindow.clearBtn=Clear
MainWindow.errorsTab=Errors
MainWindow.polygonsTab=Polygons
MainWindow.edgesTab=Edges
MainWindow.searchBtn=Search
MainWindow.searchLabel=Search:
MainWindow.showLabel=Show:
MainWindow.terrainTab=Terrain
MainWindow.transportationTab=Transportation
MainWindow.tunnelTab=Tunnels
MainWindow.vegetationTab=Vegetation
MainWindow.verticesTab=Vertices
MainWindow.attributeTab=Attributes
MainWindow.logTab=Log
MainWindow.globalErrorsTab=Global Errors
MainWindow.focusCityObject=Focus object
MainWindow.viewLabel=View
MainWindow.warnCopyIdFailed=Could not copy GML-ID!
MainWindow.waterTab=Water
MainWindow.withErrors=With errors
MainWindow.writePdf=Writing pdf report
MainWindow.writeXml=Writing xml report
OpenFileDialog.cancelBtn=Cancel
OpenFileDialog.fileLabel=File:
OpenFileDialog.selectBtn=Select
OpenFileDialog.loadBtn=Load
OpenFileDialog.settingsPane=Parser Preferences
OpenFileDialog.loadFailed=Failed to load CityGML File
OpenFileDialog.lowMemoryLabel=Low Memory Consumption Mode
OpenFileDialog.roundingPlacesLabel=NumberOfRoundingPlaces
OpenFileDialog.select=Select CityGML file
OpenFileDialog.selectBtn=Select
OpenFileDialog.settingsPane=Parser Preferences
OpenFileDialog.xmlValidationLabel=Use XML Validation
Checker.failXml=Failed to write XML Error Report.
Checker.failPdf=Failed to write PDF Report.
Checker.checksFinished=Finished executing checks
Checker.schematronValidation=Starting Schematron validation
Checker.finishedSchematron=Finished Schematron validation
Checker.failReports=Failed to write reports.
Checker.checkFeature=Checking feature: {}
Checker.executeCheck=Executing check: {}
ValidationConfiguration.reenable={} has been disabled but {} depends on it, reenabling
TimeFormatter.hours={0} hours
TimeFormatter.lessThanASecond=< 1 second
TimeFormatter.minutes={0} minutes
TimeFormatter.oneHour=1 hour
TimeFormatter.oneMinute=1 minute
TimeFormatter.oneSecond=1 second
TimeFormatter.seconds={0} seconds
Unit.Degree=Degree
Unit.Radian=Radian
ValidationConfiguration.missingSchematron={} is not an existing file, disabling schematron check
CheckContainer.error=Unexpected exception while executing check: {}
Checks.missingCheck=Could not find check for id: {}
OpenFileDialog.cancelBtn=Cancel
CheckDialog.checksTab=Checks
CheckDialog.filterTab=Filter
CheckDialog.globalParametersLabel=Global Parameters
CheckDialog.availableChecksLabel=Available Checks
CheckDialog.geometricChecksLabel=Geometric Checks
CheckDialog.semanticChecksLabel=Semantic Checks
CheckDialog.schematronFileLabel=Schematron File:
CheckDialog.selectBtn=Select
CheckDialog.checkBtn=Check
CheckDialog.cancelBtn=Cancel
CheckDialog.streamCheckOption=Use low memory mode
CheckDialog.streamCheckLabel=Citymodels are not loaded and kept in memory. Check results are saved to the QualityADE in copies of the input files.
CheckDialog.outputPathLabel=Output directory (Required):
CheckDialog.outputPathBtn=Select
CheckDialog.pdfReportsOption=Create PDF reports
CheckDialog.xmlReportsOption=Create XML reports
CheckDialog.noPathError=Output path is missing!
ZipEntryManager.title=Zip-entry manager
ZipEntryManager.entryListTitle=Zip-entries
ZipEntryManager.metadata=Metadata
ZipEntryManager.subpathLbl=Subpath:
ZipEntryManager.erroneousLbl=Erroneous:
ZipEntryManager.excessiveFileSize=Filesize exceeds memory
ZipEntryManager.invalidCityGml=Invalid CityGML file
ZipEntryManager.ioError=Unable to access file
ZipEntryManager.filesizeLbl=Filesize:
ZipEntryManager.validatedLbl=Validated:
ZipEntryManager.objectCountLbl=Object count:
ZipEntryManager.loadBtn=Load CityGML model
ZipEntryManager.decompressBtn=Unpack file
ZipEntryManager.decompressAllBtn=Unpack all files
ZipEntryManager.checkAllBtn=Check all files
ZipEntryManager.showReportBtn=Show error statistic
ZipEntryManager.saveBtn=Export validation results
ZipEntryManager.cancelBtn=Cancel
ZipEntryManager.unknownValue=N/A
ZipEntryManager.yes=Yes
ZipEntryManager.no=No
CityGmlZipArchive.ioError=Accessing the ZIP archive failed
CityGmlZipArchive.malformedZipFile=Parsing of ZIP archive aborted, ZIP file is malformed!
CityGmlZipArchive.generalException=Encountered an unexpected error while reading the ZIP archive
WriteReportDialog.writeBtn=Save
ValidationConfiguration.reenable={} has been disabled but {} depends on it, reenabling
WriteReportDialog.cancelBtn=Cancel
WriteReportDialog.errorStatisticsLabel=Error Statistics
WriteReportDialog.saveImageBtn=Save Image...
WriteReportDialog.selectPdfBtn=Select
WriteReportDialog.selectXmlFile=Select
WriteReportDialog.writeBtn=Save
WriteReportDialog.xAxisLabel=Error
WriteReportDialog.yAxisLabel=Count
Unit.Radian=Radian
Unit.Degree=Degree
FeatureMapper.polygonUnreferenced=Polygon {} is referenced but not found in feature polygons
GeometryMapper.emptyPolygon=Found polygon without exterior ring, ignoring
CityGmlParser.parsedObjects=Parsed model with {} objects
CityGmlParser.chunkReadFailed=Failed to read GML file in chunks, falling back to reading the complete file
CityGmlParser.notValidGmlFile=This is not a valid GML-File\n
CityGmlParser.errorReadingGmlFile=Error while reading city gml file\n{}
CityGmlParser.errorWritingGmlFile=Error while writing city gml file\n{}
CityGmlParser.noConversionNeeded=Coordinate system is in meters, no conversion done
CityGmlParser.failedEPSGParse=Could not read EPSG code, fallback to metric system
CityGmlParser.missingEPSGCode=No EPSG code found, assuming metric system
OpenFileDialog.loadFailed=Failed to load CityGML File
MainWindow.memoryLabel=Memory:
CheckDialog.checksReenabledAlert=Some checks have been reenabled so that other wanted checks can be executed\nSee the log for more information.
MainWindow.availableLabel=Available:
OpenFileDialog.lowMemoryLabel=Low Memory Consumption Mode
ErrorItemVisitor.intersection=Intersection
ErrorItemVisitor.component=Component
ErrorItemVisitor.nameOfAttribute=Name of attribute
ErrorItemVisitor.childId=Child id
ErrorItemVisitor.distance=Distance
ErrorItemVisitor.pointTouchesEdge=Point touches edge
ErrorItemVisitor.degeneratedRing=Degenerated ring
ErrorItemVisitor.deviation=Deviation
ErrorItemVisitor.triangles=Triangles
\ No newline at end of file
WriteReportDialog.yAxisLabel=Count
\ No newline at end of file
......@@ -14,5 +14,8 @@
<Logger name="org.apache.fop" level="INFO">
<AppenderRef ref="console" />
</Logger>
<Logger name="com.zaxxer.hikari" level="INFO" additivity="false">
<AppenderRef ref="console"/>
</Logger>
</Loggers>
</Configuration>
\ No newline at end of file
package de.hft.stuttgart.citydoctor2.database;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryTestUtils;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import org.citygml4j.core.model.building.AbstractBuilding;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import java.util.List;
import static de.hft.stuttgart.citydoctor2.database.SerializationTest.assertCityObjectEquality;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
public class EmbeddedDataBaseHandlerTest {
private EmbeddedDatabaseHandler handler;
@Before
public void resetDatabase() {
try {
handler = new EmbeddedDatabaseHandler();
handler.setupFeaturesTable();
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testGetBboxIntersectingObjects() {
Building b = new Building();
Building b2 = new Building();
b2.setGmlObject(Mockito.mock(AbstractBuilding.class));
Building b3 = new Building();
Building b4 = new Building();
b4.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.SOLID, Lod.LOD0));
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD0, Geometry.Orientation.OUTWARD);
ConcretePolygon polygon = new ConcretePolygon();
geom.getPolygons().add(polygon);
polygon.setParent(geom);
LinearRing lr = new LinearRing(LinearRing.LinearRingType.EXTERIOR);
polygon.setExteriorRing(lr);
Vertex v1 = new Vertex(10, 10, 8);
lr.getVertices().add(v1);
Vertex v2 = new Vertex(14, 15, 7);
lr.getVertices().add(v2);
Vertex v3 = new Vertex(14, 15, 3);
lr.getVertices().add(v3);
Vertex v4 = new Vertex(10, 10, 3);
lr.getVertices().add(v4);
lr.getVertices().add(v1);
geom.updateEdgesAndVertices();
b.addGeometry(geom);
Geometry geom2 = new Geometry(GeometryType.SOLID, Lod.LOD0, Geometry.Orientation.OUTWARD);
ConcretePolygon polygon2 = new ConcretePolygon();
geom2.getPolygons().add(polygon2);
polygon2.setParent(geom2);
LinearRing lr2 = new LinearRing(LinearRing.LinearRingType.EXTERIOR);
polygon2.setExteriorRing(lr2);
Vertex v1b2 = new Vertex(6, 6, 8);
lr2.getVertices().add(v1b2);
Vertex v2b2 = new Vertex(11, 13, 7);
lr2.getVertices().add(v2b2);
Vertex v3b2 = new Vertex(11, 13, 3);
lr2.getVertices().add(v3b2);
Vertex v4b2 = new Vertex(6, 6, 3);
lr2.getVertices().add(v4b2);
lr2.getVertices().add(v1b2);
geom2.updateEdgesAndVertices();
b2.addGeometry(geom2);
Geometry geom3 = new Geometry(GeometryType.SOLID, Lod.LOD0, Geometry.Orientation.OUTWARD);
ConcretePolygon polygon3 = new ConcretePolygon();
geom3.getPolygons().add(polygon3);
polygon3.setParent(geom3);
LinearRing lr3 = new LinearRing(LinearRing.LinearRingType.EXTERIOR);
polygon3.setExteriorRing(lr3);
Vertex v1b3 = new Vertex(6, 6, 8);
lr3.getVertices().add(v1b3);
Vertex v2b3 = new Vertex(10, 9.999, 7);
lr3.getVertices().add(v2b3);
Vertex v3b3 = new Vertex(10, 9.999, 3);
lr3.getVertices().add(v3b3);
Vertex v4b3 = new Vertex(6, 6, 3);
lr3.getVertices().add(v4b3);
lr3.getVertices().add(v1b3);
geom3.updateEdgesAndVertices();
b3.addGeometry(geom3);
handler.marshallCityObject(b);
handler.marshallCityObject(b2);
handler.marshallCityObject(b3);
handler.marshallCityObject(b4);
assertEquals(4, handler.getFeatureCount());
List<GmlId> objects = handler.getGeometryCollisionCandidates(b);
assertEquals(1, objects.size());
assertEquals(4, handler.getFeatureCount());
CityObject co = handler.unmarshallCityObject(objects.get(0));
assertNotNull(co);
assertCityObjectEquality(b2, co);
}
@Test
public void testGetBboxBufferIntersectingObjects() {
Building b = new Building();
Building b2 = new Building();
b2.setGmlObject(Mockito.mock(AbstractBuilding.class));
Building b3 = new Building();
Building b4 = new Building();
b4.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.SOLID, Lod.LOD0));
Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD0, Geometry.Orientation.OUTWARD);
ConcretePolygon polygon = new ConcretePolygon();
geom.getPolygons().add(polygon);
polygon.setParent(geom);
LinearRing lr = new LinearRing(LinearRing.LinearRingType.EXTERIOR);
polygon.setExteriorRing(lr);
Vertex v1 = new Vertex(10, 10, 8);
lr.getVertices().add(v1);
Vertex v2 = new Vertex(14, 15, 7);
lr.getVertices().add(v2);
Vertex v3 = new Vertex(14, 15, 3);
lr.getVertices().add(v3);
Vertex v4 = new Vertex(10, 10, 3);
lr.getVertices().add(v4);
lr.getVertices().add(v1);
geom.updateEdgesAndVertices();
b.addGeometry(geom);
Geometry geom2 = new Geometry(GeometryType.SOLID, Lod.LOD0, Geometry.Orientation.OUTWARD);
ConcretePolygon polygon2 = new ConcretePolygon();
geom2.getPolygons().add(polygon2);
polygon2.setParent(geom2);
LinearRing lr2 = new LinearRing(LinearRing.LinearRingType.EXTERIOR);
polygon2.setExteriorRing(lr2);
Vertex v1b2 = new Vertex(6, 6, 8);
lr2.getVertices().add(v1b2);
Vertex v2b2 = new Vertex(9, 9, 7);
lr2.getVertices().add(v2b2);
Vertex v3b2 = new Vertex(9, 9, 3);
lr2.getVertices().add(v3b2);
Vertex v4b2 = new Vertex(6, 6, 3);
lr2.getVertices().add(v4b2);
lr2.getVertices().add(v1b2);
geom2.updateEdgesAndVertices();
b2.addGeometry(geom2);
Geometry geom3 = new Geometry(GeometryType.SOLID, Lod.LOD0, Geometry.Orientation.OUTWARD);
ConcretePolygon polygon3 = new ConcretePolygon();
geom3.getPolygons().add(polygon3);
polygon3.setParent(geom3);
LinearRing lr3 = new LinearRing(LinearRing.LinearRingType.EXTERIOR);
polygon3.setExteriorRing(lr3);
Vertex v1b3 = new Vertex(4, 4, 8);
lr3.getVertices().add(v1b3);
Vertex v2b3 = new Vertex(8.999, 8.999, 7);
lr3.getVertices().add(v2b3);
Vertex v3b3 = new Vertex(8.999, 8.999, 3);
lr3.getVertices().add(v3b3);
Vertex v4b3 = new Vertex(4, 4, 3);
lr3.getVertices().add(v4b3);
lr3.getVertices().add(v1b3);
geom3.updateEdgesAndVertices();
b3.addGeometry(geom3);
handler.marshallCityObject(b);
handler.marshallCityObject(b2);
handler.marshallCityObject(b3);
handler.marshallCityObject(b4);
assertEquals(4, handler.getFeatureCount());
List<GmlId> objects = handler.getBufferCollisionCandidates(b, Math.sqrt(2));
assertEquals(1, objects.size());
assertEquals(4, handler.getFeatureCount());
CityObject co = handler.unmarshallCityObject(objects.get(0));
assertNotNull(co);
assertCityObjectEquality(b2, co);
}
@Test
public void testMarshallingRoundTripSimpleSolid() throws InvalidGmlFileException, CityGmlParseException {
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = CityGmlParser.parseCityGmlFile("src/test/resources/SimpleSolid_SrefBS.gml", config);
Building b = model.getBuildings().toList().get(0);
assertNotNull(b);
handler.marshallCityObject(b);
assertEquals(1, handler.getFeatureCount());
CityObject b2 = handler.unmarshallCityObject(b.getGmlId());
assertNotNull(b2);
assertEquals(1, handler.getFeatureCount());
assertCityObjectEquality(b, b2);
}
@Test
public void testMarshallingRoundTripFzk() throws InvalidGmlFileException, CityGmlParseException {
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = CityGmlParser.parseCityGmlFile("src/test/resources/FZK_haus.gml", config);
Building b = model.getBuildings().toList().get(0);
assertNotNull(b);
assertEquals(1, handler.getFeatureCount());
handler.marshallCityObject(b);
assertEquals(1, handler.getFeatureCount());
CityObject b2 = handler.unmarshallCityObject(b.getGmlId());
assertNotNull(b2);
assertEquals(1, handler.getFeatureCount());
assertCityObjectEquality(b, b2);
}
}
package de.hft.stuttgart.citydoctor2.database;
import de.hft.stuttgart.citydoctor2.datastructure.*;
import org.citygml4j.core.model.building.AbstractBuilding;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
public class FeatureCacheTest {
@Test
public void testPut(){
FeatureCache cache = new FeatureCache();
Building b = new Building();
b.setGmlObject(mock(AbstractBuilding.class));
b.setGmlId(new GmlId("test"));
b.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.SOLID, Lod.LOD0));
assertEquals(0, cache.getTotalFeatureCount());
cache.put(b);
cache.synchronize();
assertEquals(1, cache.getTotalFeatureCount());
}
@Test
public void testGet(){
FeatureCache cache = new FeatureCache();
assertNull(cache.get(new GmlId("test")));
Building b = new Building();
b.setGmlObject(mock(AbstractBuilding.class));
b.setGmlId(new GmlId("test"));
b.addGeometry(GeometryTestUtils.createDummyGeometry(GeometryType.SOLID, Lod.LOD0));
assertEquals(0, cache.getTotalFeatureCount());
cache.put(b);
cache.synchronize();
CityObject b2 = cache.get(new GmlId("test"));
assertEquals(b.getGmlId(), b2.getGmlId());
}
@Test
public void testStateHandlingFromIdle(){
FeatureCache cache = new FeatureCache();
assertEquals(FeatureCache.CacheState.IDLE, cache.getState());
AutoCloseable parsingContext = cache.startParsingMode();
try(parsingContext){
assertEquals(FeatureCache.CacheState.PARSING, cache.getState());
} catch (Exception e){
throw new RuntimeException(e);
}
assertEquals(FeatureCache.CacheState.IDLE, cache.getState());
AutoCloseable checkingContext = cache.startCheckingMode();
try(checkingContext){
assertEquals(FeatureCache.CacheState.CHECKING, cache.getState());
} catch (Exception e){
throw new RuntimeException(e);
}
assertEquals(FeatureCache.CacheState.IDLE, cache.getState());
}
@Test
public void testCheckingModeStateCollision(){
FeatureCache cache = new FeatureCache();
assertEquals(FeatureCache.CacheState.IDLE, cache.getState());
AutoCloseable checkingContext = cache.startCheckingMode();
try(checkingContext){
assertEquals(FeatureCache.CacheState.CHECKING, cache.getState());
assertThrows(IllegalStateException.class, cache::startParsingMode);
} catch (Exception e){
throw new RuntimeException(e);
}
}
@Test
public void testParsingModeStateCollision(){
FeatureCache cache = new FeatureCache();
assertEquals(FeatureCache.CacheState.IDLE, cache.getState());
AutoCloseable parsingContext = cache.startParsingMode();
try(parsingContext){
assertEquals(FeatureCache.CacheState.PARSING, cache.getState());
assertThrows(IllegalStateException.class, cache::startCheckingMode);
} catch (Exception e){
throw new RuntimeException(e);
}
}
}
package de.hft.stuttgart.citydoctor2.database;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.visitors.CityObjectCollector;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.Test;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class SerializationTest {
static void assertCityObjectEquality(CityObject c1, CityObject c2) {
assertEquals(c1.getGmlId(), c2.getGmlId());
assertEquals(c1.getFeatureType(), c2.getFeatureType());
assertEquals(c1.getGmlObject().getId(), c2.getGmlObject().getId());
CityObjectCollector collector = new CityObjectCollector();
c1.accept(collector);
Set<CityObject> coB = collector.getCityObjects();
collector = new CityObjectCollector();
c2.accept(collector);
Set<CityObject> coB2 = collector.getCityObjects();
assertEquals(coB.size(), coB2.size());
}
@Test
public void testRoundtripSimpleSolid() throws CityGmlParseException, InvalidGmlFileException {
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = CityGmlParser.parseCityGmlFile("src/test/resources/SimpleSolid_SrefBS.gml", config);
Building b = model.getBuildings().toList().get(0);
assertNotNull(b);
Building b2 = SerializationUtils.roundtrip(b);
assertNotNull(b2);
assertCityObjectEquality(b, b2);
}
@Test
public void testRoundtripFzk() throws CityGmlParseException, InvalidGmlFileException {
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = CityGmlParser.parseCityGmlFile("src/test/resources/FZK_haus.gml", config);
Building b = model.getBuildings().toList().get(0);
assertNotNull(b);
Building b2 = SerializationUtils.roundtrip(b);
assertCityObjectEquality(b, b2);
}
}
......@@ -51,7 +51,6 @@ import de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor;
public class BridgeObjectTest {
//TODO: Rework this class with the new Visitors
@Test
public void testAccept() {
......
......@@ -64,7 +64,7 @@ public class BuildingTest {
b.setCityGmlBuilding(createCityGmlBuilding());
RoofSurface rs = new RoofSurface();
rs.setId("testRoof");
BoundarySurface surface = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.ROOF, rs);
BoundarySurface surface = new BoundarySurface(BoundarySurfaceType.ROOF, rs);
Geometry geomSurface = new Geometry(GeometryType.MULTI_SURFACE, Lod.LOD2, Orientation.OUTWARD);
geomSurface.addPolygon(new LinkedPolygon(p, geomSurface));
geomSurface.updateEdgesAndVertices();
......@@ -75,7 +75,8 @@ public class BuildingTest {
assertNotSame(b, copy);
assertEquals(b.getGmlId(), copy.getGmlId());
copy.prepareForChecking();
Geometry copyGeom = copy.getGeometries().get(0);
assertNotSame(geom, copyGeom);
......
......@@ -16,7 +16,7 @@ public class CompositePolygonTest {
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel m = CityGmlParser.parseCityGmlFile("src/test/resources/FZK_haus.gml", config);
Building b = m.getBuildings().get(0);
Building b = m.getBuildings().toList().get(0);
assertNotNull(b);
assertFalse(b.getBoundarySurfaces().isEmpty());
for (BoundarySurface bs : b.getBoundarySurfaces()) {
......
......@@ -96,7 +96,7 @@ public class GeometryTest {
public void testRemovePolygonConcreteWithLink() {
ParserConfiguration config = new ParserConfiguration(4, false);
AbstractConstructionSurface abs = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, abs);
BoundarySurface bs = new BoundarySurface(BoundarySurfaceType.WALL, abs);
var gmlBi = new org.citygml4j.core.model.building.BuildingInstallation();
Installation bi = new Installation();
bi.setGmlObject(gmlBi);
......@@ -133,7 +133,7 @@ public class GeometryTest {
public void testRemovePolygonOnlyConcrete() {
ParserConfiguration config = new ParserConfiguration(4, false);
AbstractConstructionSurface abs = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, abs);
BoundarySurface bs = new BoundarySurface(BoundarySurfaceType.WALL, abs);
Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, Lod.LOD2, Orientation.OUTWARD);
ConcretePolygon p = new ConcretePolygon();
......@@ -156,7 +156,7 @@ public class GeometryTest {
public void testRemovePolygonLinked() {
ParserConfiguration config = new ParserConfiguration(4, false);
AbstractConstructionSurface abs = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, abs);
BoundarySurface bs = new BoundarySurface(BoundarySurfaceType.WALL, abs);
var gmlBi = new org.citygml4j.core.model.building.BuildingInstallation();
Installation bi = new Installation();
bi.setGmlObject(gmlBi);
......@@ -193,7 +193,7 @@ public class GeometryTest {
public void testReplacePolygon() {
ParserConfiguration config = new ParserConfiguration(4, false);
AbstractConstructionSurface abs = new WallSurface();
BoundarySurface bs = new BoundarySurface(SurfaceFeatureType.BUILDING, BoundarySurfaceType.WALL, abs);
BoundarySurface bs = new BoundarySurface(BoundarySurfaceType.WALL, abs);
var gmlBi = new org.citygml4j.core.model.building.BuildingInstallation();
Installation bi = new Installation();
bi.setGmlObject(gmlBi);
......
......@@ -26,7 +26,6 @@ import static org.mockito.Mockito.mock;
public class VegetationTest {
//TODO: Recreate geometries tests
@Test
public void testContainsError() {
......
......@@ -49,7 +49,7 @@ public class CityGml3ParserTest {
ParserConfiguration config = new ParserConfiguration(8, false);
CityDoctorModel model = CityGmlParser.parseCityGmlFile("src/test/resources/SimpleSolid_SrefBS.gml", config);
assertNotNull(model);
List<Building> buildings = model.getBuildings();
List<Building> buildings = model.getBuildings().toList();
assertEquals(1, buildings.size());
Building building = buildings.get(0);
assertEquals("_Simple_BD.1", building.getGmlId().getGmlString());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment