getFeature.setOutputFormat(outputFormat);
public void testCanHandle() { gft.setOutputFormat("OGR-KML"); assertTrue(ogr.canHandle(op)); gft.setOutputFormat("OGR-CSV"); assertTrue(ogr.canHandle(op)); gft.setOutputFormat("RANDOM_FORMAT"); assertTrue(ogr.canHandle(op)); }
public void testContentTypeZip() { gft.setOutputFormat("OGR-SHP"); assertEquals("application/zip", ogr.getMimeType(null, op)); }
public void testContentTypeKml() { gft.setOutputFormat("OGR-KML"); assertEquals("application/vnd.google-earth.kml", ogr.getMimeType(null, op)); }
@Test public void testCanHandle() { gft.setOutputFormat("OGR-KML"); assertTrue(ogr.canHandle(op)); gft.setOutputFormat("OGR-CSV"); assertTrue(ogr.canHandle(op)); gft.setOutputFormat("RANDOM_FORMAT"); assertTrue(ogr.canHandle(op)); }
public void testSimpleMIF() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-MIF"); ogr.write(fct, bos, op); // read back ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray())); // we should get two files at least, a .mif and a .mid Set<String> fileNames = new HashSet<String>(); ZipEntry entry = null; while((entry = zis.getNextEntry()) != null) { fileNames.add(entry.getName()); } assertTrue(fileNames.contains("Buildings.mif")); assertTrue(fileNames.contains("Buildings.mid")); }
@Test public void testSimpleMIF() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-MIF"); ogr.write(fct, bos, op); // read back ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray())); // we should get two files at least, a .mif and a .mid Set<String> fileNames = new HashSet<String>(); ZipEntry entry = null; while ((entry = zis.getNextEntry()) != null) { fileNames.add(entry.getName()); } assertTrue(fileNames.contains("Buildings.mif")); assertTrue(fileNames.contains("Buildings.mid")); }
public void testSimpleKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // parse the kml to check it's really xml... Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(2, dom.getElementsByTagName("Placemark").getLength()); }
public void testZippedKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML-ZIP"); ogr.write(fct, bos, op); // unzip the result ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray())); Document dom = null; ZipEntry entry = zis.getNextEntry(); assertEquals("Buildings.kml", entry.getName()); dom = dom(zis); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(2, dom.getElementsByTagName("Placemark").getLength()); }
public void testEmptyKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(Filter.EXCLUDE); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // parse the kml to check it's really xml... Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(0, dom.getElementsByTagName("Placemark").getLength()); }
public void testAllTypesKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("AllTypes").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // read back Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(6, dom.getElementsByTagName("Placemark").getLength()); }
@Test public void testContentTypeZip() { gft.setOutputFormat("OGR-SHP"); assertEquals("application/zip", ogr.getMimeType(null, op)); }
@Test public void testContentTypeKml() { gft.setOutputFormat("OGR-KML"); assertEquals("application/vnd.google-earth.kml", ogr.getMimeType(null, op)); }
@Test public void testEmptyKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(Filter.EXCLUDE); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // parse the kml to check it's really xml... Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(0, dom.getElementsByTagName("Placemark").getLength()); }
@Test public void testAllTypesKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("AllTypes").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // read back Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(6, dom.getElementsByTagName("Placemark").getLength()); }
public void testSimpleCSV() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-CSV"); ogr.write(fct, bos, op); // read back String csv = read(new ByteArrayInputStream(bos.toByteArray())); // couple simple checks String[] lines = csv.split("\n"); // headers and the two lines assertEquals(3, lines.length); assertTrue(csv.contains("123 Main Street")); }
public void testGeometrylessCSV() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Geometryless").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-CSV"); ogr.write(fct, bos, op); // read back String csv = read(new ByteArrayInputStream(bos.toByteArray())); // couple simple checks String[] lines = csv.split("\n"); // headers and the feature lines assertEquals(4, lines.length); // let's see if one of the expected lines is there assertTrue(csv.contains("Alessia")); }
@Test public void testSimpleKML() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-KML"); ogr.write(fct, bos, op); // parse the kml to check it's really xml... Document dom = dom(new ByteArrayInputStream(bos.toByteArray())); // print(dom); // some very light assumptions on the contents, since we // cannot control how ogr encodes the kml... let's just assess // it's kml with the proper number of features assertEquals("kml", dom.getDocumentElement().getTagName()); assertEquals(2, dom.getElementsByTagName("Placemark").getLength()); }
@Test public void testSimpleCSV() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Buildings").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-CSV"); ogr.write(fct, bos, op); // read back String csv = read(new ByteArrayInputStream(bos.toByteArray())); // couple simple checks String[] lines = csv.split("\n"); // headers and the two lines assertEquals(3, lines.length); assertTrue(csv.contains("123 Main Street")); }
@Test public void testGeometrylessCSV() throws Exception { // prepare input FeatureCollection fc = dataStore.getFeatureSource("Geometryless").getFeatures(); fct.getFeature().add(fc); // write out ByteArrayOutputStream bos = new ByteArrayOutputStream(); gft.setOutputFormat("OGR-CSV"); ogr.write(fct, bos, op); // read back String csv = read(new ByteArrayInputStream(bos.toByteArray())); // couple simple checks String[] lines = csv.split("\n"); // headers and the feature lines assertEquals(4, lines.length); // let's see if one of the expected lines is there assertTrue(csv.contains("Alessia")); }