Commit f8ac427e authored by Matthias Betz's avatar Matthias Betz
Browse files

validation changes to support healing streaming

parent c1c27a52
Pipeline #1288 failed with stage
in 1 minute and 49 seconds
......@@ -220,7 +220,9 @@ public class CityGmlParser {
CityGMLBuilder builder = context.createCityGMLBuilder(CityGmlParser.class.getClassLoader());
CityGMLInputFactory inputFactory = builder.createCityGMLInputFactory();
inputFactory.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.SPLIT_PER_FEATURE);
inputFactory.setProperty(CityGMLInputFactory.USE_VALIDATION, config.getValidate());
if (config != null) {
inputFactory.setProperty(CityGMLInputFactory.USE_VALIDATION, config.getValidate());
}
inputFactory.setProperty(CityGMLInputFactory.FAIL_ON_MISSING_ADE_SCHEMA, false);
inputFactory.setProperty(CityGMLInputFactory.EXCLUDE_FROM_SPLITTING,
new QName[] { new QName("WallSurface"), new QName("RoofSurface"), new QName("GroundSurface"),
......@@ -359,6 +361,25 @@ public class CityGmlParser {
}
return null;
}
public static CityModel parseOnlyCityModel(File inputFile) throws CityGmlParseException {
try {
CityGMLInputFactory inputFactory = setupGmlReader(null);
try (CityGMLReader reader = inputFactory.createCityGMLReader(inputFile)) {
while (reader.hasNext()) {
CityGML chunk = reader.nextFeature();
if (chunk instanceof CityModel) {
CityModel cModel = (CityModel) chunk;
cModel.unsetCityObjectMember();
return cModel;
}
}
}
} catch (CityGMLBuilderException | CityGMLReadException | ADEException e) {
throw new CityGmlParseException(e);
}
throw new CityGmlParseException("Did not find any CityModel in CityGML file");
}
private static void readFeatures(File file, ParserConfiguration config, CityGMLInputFactory inputFactory,
ArrayBlockingQueue<CityObject> queue, ObservedInputStream ois, FeatureStream stream) {
......
......@@ -210,8 +210,12 @@ public class Checker {
}
isValidated = true;
}
public ValidationConfiguration getConfig() {
return config;
}
private static SvrlContentHandler executeSchematronValidationIfAvailable(ValidationConfiguration config,
public static SvrlContentHandler executeSchematronValidationIfAvailable(ValidationConfiguration config,
File file) {
if (config.getSchematronFilePath() != null && !config.getSchematronFilePath().isEmpty()) {
if (logger.isInfoEnabled()) {
......@@ -493,11 +497,11 @@ public class Checker {
try (BufferedOutputStream xmlBos = getXmlOutputMaybe(xmlOutput);
BufferedOutputStream pdfBos = getPdfOutputMaybe(pdfOutput)) {
XmlStreamReporter xmlReporter = null;
if (xmlOutput != null) {
if (xmlBos != null) {
xmlReporter = new XmlStreamReporter(xmlBos, stream.getFileName(), config);
}
PdfStreamReporter pdfReporter = null;
if (pdfOutput != null) {
if (pdfBos != null) {
pdfReporter = new PdfStreamReporter(pdfBos, stream.getFileName(), config, logoLocation);
}
CityObject co = null;
......@@ -515,7 +519,7 @@ public class Checker {
}
}
private static void writeReport(StreamReporter reporter, SvrlContentHandler handler)
public static void writeReport(StreamReporter reporter, SvrlContentHandler handler)
throws CheckReportWriteException {
if (reporter != null) {
if (handler != null) {
......@@ -530,15 +534,15 @@ public class Checker {
}
}
private static BufferedOutputStream getPdfOutputMaybe(String pdfOutput) throws FileNotFoundException {
public static BufferedOutputStream getPdfOutputMaybe(String pdfOutput) throws FileNotFoundException {
return pdfOutput != null ? new BufferedOutputStream(new FileOutputStream(pdfOutput)) : null;
}
private static BufferedOutputStream getXmlOutputMaybe(String xmlOutput) throws FileNotFoundException {
public static BufferedOutputStream getXmlOutputMaybe(String xmlOutput) throws FileNotFoundException {
return xmlOutput != null ? new BufferedOutputStream(new FileOutputStream(xmlOutput)) : null;
}
private void checkFeature(XmlStreamReporter xmlReporter, PdfStreamReporter pdfReporter, CityObject co) {
public void checkFeature(XmlStreamReporter xmlReporter, PdfStreamReporter pdfReporter, CityObject co) {
if (logger.isDebugEnabled()) {
logger.debug(Localization.getText("Checker.checkFeature"), co);
}
......
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