Commit dc73d98f authored by bruse's avatar bruse
Browse files

Task #314: Made it possible to specify the LODs to be exported. Also updated...

Task #314: Made it possible to specify the LODs to be exported. Also updated the unit test to ensure this feature works.
parent 8f1b75dc
......@@ -60,6 +60,8 @@ public class ExportJobDescription implements ExportJobDescriptor {
private static final String DEFAULT_JOBNUMBER = "GR_EXPORT_CITYGML_LOD1";
private static final String DEFAULT_INITIATOR = "2758";
private static final String DEFAULT_LODS = "12";
/** The version of the novaFACTORY XML export job format. */
public static final String EXPORT_JOB_VERSION = "1.0.0";
......@@ -144,6 +146,11 @@ public class ExportJobDescription implements ExportJobDescriptor {
/** The xmetadata attribute of the exportmetadata tag. */
private String xmetadata;
/** The LOD or LODs which should be exported. Set it to "1", if you want LOD1.
* Set it to "12", if you want the LOD1 and LOD2.
*/
private String lods;
public String getInitiator() {
return initiator;
......@@ -356,6 +363,14 @@ public String getXmetadata() {
public void setXmetadata(String xmetadata) {
this.xmetadata = xmetadata;
}
public String getLODs() {
return lods;
}
public void setLODs(String lods) {
this.lods = lods;
}
@Override
public String supportsJobVersion() {
......@@ -410,7 +425,8 @@ public boolean isValid() {
|| format.isEmpty()
|| exportmetadata.isEmpty()
|| col.isEmpty()
|| eck.isEmpty()){
|| eck.isEmpty()
|| lods.isEmpty()) {
return false;
} else {
return true;
......@@ -443,6 +459,7 @@ public static ExportJobDescription getDefaultDescriptor() {
descriptor.setZipresult(DEFAULT_ZIP_RESULT);
descriptor.setCalibration(DEFAULT_CALIBRATION);
descriptor.setXmetadata(DEFAULT_XMETA_DATA);
descriptor.setLODs(DEFAULT_LODS);
return descriptor;
}
......
......@@ -159,7 +159,7 @@ public File buildExportJobFile(ExportJobDescription jobDescriptor) throws Invali
format.setAttribute("citygml_apptheme", "");
format.setAttribute("citygml_elemclasses", "true");
format.setAttribute("citygml_lodmode", "all");
format.setAttribute("citygml_lods", "01234");
format.setAttribute("citygml_lods", jobDescriptor.getLODs());
format.setAttribute("citygml_metadata", "true");
format.setAttribute("citygml_outmode", "normal");
format.setAttribute("dtm", "false");
......
package eu.simstadt.nf4j.async.test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Scanner;
import java.util.zip.ZipInputStream;
import org.junit.Test;
import eu.simstadt.nf4j.FailedTransmissionException;
import eu.simstadt.nf4j.InvalidJobDescriptorException;
import eu.simstadt.nf4j.JobStatus;
......@@ -35,6 +46,7 @@ public void processJob() throws InterruptedException {
description.setAccount(userName);
description.setProduct("WU3");
description.setJobnumber(userName);
description.setLODs("2");
//FIXME: Zipped GMLs coming from nF don't have any defined srsName
//FIXME: Save files somewhere else
......@@ -138,11 +150,52 @@ public void jobStatusChanged(JobStatusEvent event) {
try {
File file = job.getResult();
assertTrue(file.canRead());
// System.out.println("CityGML at " + file.getAbsolutePath());
testForExistingLOD2AndMissingLOD1(file);
} catch (FailedTransmissionException ex) {
ex.printStackTrace();
}
}
}
/**
* These asserts ensure that only LOD2 has been loaded as specified in the job descriptor above.
*/
private void testForExistingLOD2AndMissingLOD1(File file) {
FileInputStream fileStream;
try {
fileStream = new FileInputStream(file);
ZipInputStream unzipStream = new ZipInputStream(fileStream);
unzipStream.getNextEntry(); // Skip the first entry, its the job description
unzipStream.getNextEntry();
File handle = Files.createTempDirectory("nfDownload").resolve("test.gml").toFile();
BufferedOutputStream bos =
new BufferedOutputStream(new FileOutputStream(handle));
byte[] in = new byte[4096];
int read = 0;
while ((read = unzipStream.read(in)) != -1) {
bos.write(in, 0, read);
}
unzipStream.closeEntry();
bos.close();
unzipStream.close();
Scanner scanner = new Scanner(handle);
boolean lod1Missing = true;
boolean lod2Found = false;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (line.contains("lod2")) {
lod2Found = true;
}
if (line.contains("lod1")) {
lod1Missing = false;
}
}
scanner.close();
assertTrue(lod1Missing);
assertTrue(lod2Found);
} catch (IOException ex) {
fail();
}
}
}
\ No newline at end of file
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