public KMLRawFeatureReader(InputStream inputStream, SimpleFeatureType featureType) { this.inputStream = inputStream; this.featureType = featureType; reader = new KMLRawReader(inputStream, KMLRawReader.ReadType.FEATURES, featureType); }
@Override public boolean hasNext() { if (next != null) { return true; } try { next = read(); } catch (IOException e) { next = null; } return next != null; }
@Override public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { return (SimpleFeature) reader.next(); }
public void testParseFeatureTypeNoPlacemarks() throws IOException { String kmlInput = DOC_EL + "</kml>"; try { kmlFileFormat.parseFeatureTypes("foo", IOUtils.toInputStream(kmlInput)); } catch (IllegalArgumentException e) { assertTrue(true); return; } fail("Expected Illegal Argument Exception for no features"); }
public void testParseFeatureTypeMinimal() throws Exception { String kmlInput = DOC_EL + "<Placemark></Placemark></kml>"; List<SimpleFeatureType> featureTypes = kmlFileFormat.parseFeatureTypes("foo", IOUtils.toInputStream(kmlInput)); assertEquals("Unexpected number of feature types", 1, featureTypes.size()); SimpleFeatureType featureType = featureTypes.get(0); assertEquals( "Unexpected number of feature type attributes", 10, featureType.getAttributeCount()); }
public FeatureReader<SimpleFeatureType, SimpleFeature> read( SimpleFeatureType featureType, InputStream inputStream) { return new KMLTransformingFeatureReader(featureType, inputStream); }
@Override public boolean hasNext() throws IOException { return reader.hasNext(); }
public KMLTransformingFeatureReader(SimpleFeatureType featureType, InputStream inputStream) { this(featureType, new KMLRawFeatureReader(inputStream, featureType)); }
@Override public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { if (!hasNext()) { throw new NoSuchElementException(); } else { SimpleFeature result = next; next = null; return result; } }
@Override protected void setUp() throws Exception { kmlFileFormat = new KMLFileFormat(); }
@Before public void setUp() throws Exception { System.setProperty("org.geotools.referencing.forceXY", "true"); gmlFileFormat = new GMLFileFormat(); }
public FeatureReader<SimpleFeatureType, SimpleFeature> read(SimpleFeatureType featureType, InputStream inputStream) { return new KMLTransformingFeatureReader(featureType, inputStream); }
public KMLRawFeatureReader(InputStream inputStream, SimpleFeatureType featureType) { this.inputStream = inputStream; this.featureType = featureType; reader = new KMLRawReader(inputStream, KMLRawReader.ReadType.FEATURES, featureType); }
@Override public boolean hasNext() { if (next != null) { return true; } try { next = read(); } catch (IOException e) { next = null; } return next != null; }
@Override public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { return (SimpleFeature) reader.next(); }
@Override public boolean hasNext() throws IOException { return reader.hasNext(); }
public KMLTransformingFeatureReader(SimpleFeatureType featureType, InputStream inputStream) { this(featureType, new KMLRawFeatureReader(inputStream, featureType)); }
public FeatureReader<SimpleFeatureType, SimpleFeature> read(SimpleFeatureType featureType, File file) { try { return new KMLTransformingFeatureReader(featureType, new FileInputStream(file)); } catch (Exception e) { throw new RuntimeException(e); } }