continue; if (feature.getDefaultGeometry() == null) { log.warn("feature has no geometry: " + feature.getIdentifier()); continue; LineString geom = toLineString((Geometry) feature.getDefaultGeometry());
@Override public String resolve(double x, double y) { System.out.println("x="+x+", y="+y); FeatureIterator<Feature> iterator = collection.features(); while( iterator.hasNext() ){ SimpleFeature feature = (SimpleFeature) iterator.next(); Geometry geom = (Geometry) feature.getDefaultGeometry(); GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); Coordinate coord = new Coordinate(x, y); Point point = geometryFactory.createPoint(coord); //System.out.println("checking "+point.toString()); if(geom.contains(point)) { return feature.getAttribute(this.nameField).toString(); } } return null; }
/** * The function is run periodically by the update manager. * The extending class should provide the getNote method. It is not implemented here * as the requirements for different updaters can be vastly different dependent on the data source. */ @Override protected void runPolling() throws IOException{ LOG.info("Run WFS polling updater with hashcode: {}", this.hashCode()); notesForEdge = HashMultimap.create(); uniqueMatchers = new HashMap<>(); FeatureIterator<SimpleFeature> features = featureSource.getFeatures(query).features(); while ( features.hasNext()){ SimpleFeature feature = features.next(); if (feature.getDefaultGeometry() == null) continue; Alert alert = getNote(feature); if (alert == null) continue; Geometry geom = (Geometry) feature.getDefaultGeometry(); Geometry searchArea = geom.buffer(SEARCH_RADIUS_DEG); Collection<Edge> edges = graph.streetIndex.getEdgesForEnvelope(searchArea.getEnvelopeInternal()); for(Edge edge: edges){ if (edge instanceof StreetEdge && !searchArea.disjoint(edge.getGeometry())) { addNote(edge, alert, NOTE_MATCHER); } } } updaterManager.execute(new WFSGraphWriter()); }
while (it.hasNext()) { SimpleFeature feature = it.next(); Geometry geom = (Geometry) feature.getDefaultGeometry(); Point point = null; if (geom instanceof Point) {
while (it.hasNext()) { SimpleFeature feature = it.next(); Geometry geom = (Geometry) feature.getDefaultGeometry();
if (feature.getDefaultGeometry() == null) { log.warn("feature has no geometry: " + feature.getIdentifier()); continue; LineString geom = toLineString((Geometry) feature.getDefaultGeometry());
public Object getProperty(Object object, QName name) throws Exception { SimpleFeature feature = (SimpleFeature) object; if (KML.Geometry.getLocalPart().equals(name.getLocalPart()) || org.geotools.kml.v22.KML.AbstractGeometryGroup.getLocalPart() .equals(name.getLocalPart())) { return feature.getDefaultGeometry(); } return null; } }
public Graphable get(Object obj) { SimpleFeature feature = (SimpleFeature) obj; return decorated.get(feature.getDefaultGeometry()); } }
public Graphable remove(Object obj) { SimpleFeature feature = (SimpleFeature) obj; return decorated.remove(feature.getDefaultGeometry()); }
.features() .next(); assertTrue(inlineFeature.getDefaultGeometry() instanceof Point); assertEquals( "POINT (115.741666667 -64.6583333333)", ((Point) inlineFeature.getDefaultGeometry()).toText()); assertTrue( styles.get(5)
@Override public MultiLevelROI getMultiScaleROI(SimpleFeature sf) throws IOException { Geometry footprint = geometryProvider.getFootprint(sf); if (footprint == null) { return null; } else { Geometry granuleBounds = defaultGranuleBounds != null ? defaultGranuleBounds : (Geometry) sf.getDefaultGeometry(); return new MultiLevelROIGeometry(footprint, granuleBounds, inset, insetPolicy); } }
public MultiLevelROIRaster(DatasetLayout layout, File file, SimpleFeature sf) throws IOException { // Initialization this.file = file; // Getting Feature Geometry Geometry geo = (Geometry) sf.getDefaultGeometry(); // Getting as envelope env = JTS.toEnvelope(geo); // Save envelope as Geometry footprint = JTS.toGeometry(env); // Getting the Mask provider maskOvrProvider = new MaskOverviewProvider(layout, file); }
public Graphable add(Object obj) { SimpleFeature feature = (SimpleFeature) obj; Graphable g = decorated.add(feature.getDefaultGeometry()); Geometry geom = (Geometry) g.getObject(); // Preserve geometry from Graphable, as it may be changed. feature.setDefaultGeometry(geom); g.setObject(feature); return g; }
protected void addToSpatialIndex(SimpleFeature f) { if (f.getDefaultGeometry() != null) { BoundingBox bounds = f.getBounds(); if (!bounds.isEmpty()) spatialIndex.insert(ReferencedEnvelope.reference(bounds), f); } }
private void writeToShapefile( SimpleFeature f, FeatureWriter<SimpleFeatureType, SimpleFeature> writer) throws IOException { SimpleFeature fw = writer.next(); // we cannot trust attribute order, shapefile changes the location and name of the geometry for (AttributeDescriptor d : fw.getFeatureType().getAttributeDescriptors()) { fw.setAttribute(d.getLocalName(), f.getAttribute(d.getLocalName())); } fw.setDefaultGeometry(f.getDefaultGeometry()); writer.write(); }
public void testWithoutGmlProperties() throws Exception { Element feature = GML3MockData.feature(document, document); feature.setAttributeNS(GML.NAMESPACE, "id", "fid.1"); SimpleFeature f = (SimpleFeature) parse(); assertNotNull(feature); assertEquals("fid.1", f.getID()); Point p = (Point) f.getDefaultGeometry(); assertNotNull(p); assertEquals(1.0, p.getX(), 0d); assertEquals(2.0, p.getY(), 0d); Integer i = (Integer) f.getAttribute("count"); assertNotNull(i); assertEquals(1, i.intValue()); }
public void testEqualsFilter() throws Exception { FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); // should match only "r3" GeometryFactory gf = new GeometryFactory(); Geometry g = gf.createGeometry((Geometry) td.roadFeatures[2].getDefaultGeometry()); Equals cs = ff.equal(ff.literal(g), ff.property(aname("geom"))); FeatureCollection features = dataStore.getFeatureSource(tname("road")).getFeatures(cs); checkSingleResult(features, "r3"); }
public void testReadPoint() throws Exception { SimpleFeatureCollection fc = dataStore.getFeatureSource(tname(getPoint3d())).getFeatures(); try (SimpleFeatureIterator fr = fc.features()) { assertTrue(fr.hasNext()); Point p = (Point) fr.next().getDefaultGeometry(); assertTrue(new Coordinate(1, 1, 1).equals(p.getCoordinate())); } }
public void testGeometryFactoryHintsGF() throws IOException { SimpleFeatureSource fs = dataStore.getFeatureSource(tname("road")); assertTrue(fs.getSupportedHints().contains(Hints.JTS_GEOMETRY_FACTORY)); Query q = new Query(tname("road")); GeometryFactory gf = new GeometryFactory(new LiteCoordinateSequenceFactory()); Hints hints = new Hints(Hints.JTS_GEOMETRY_FACTORY, gf); q.setHints(hints); try (SimpleFeatureIterator it = fs.getFeatures(q).features()) { it.hasNext(); SimpleFeature f = (SimpleFeature) it.next(); LineString ls = (LineString) f.getDefaultGeometry(); assertTrue(ls.getCoordinateSequence() instanceof LiteCoordinateSequence); } }
public void testReadLine() throws Exception { SimpleFeatureCollection fc = dataStore.getFeatureSource(tname(getLine3d())).getFeatures(); try (SimpleFeatureIterator fr = fc.features()) { assertTrue(fr.hasNext()); LineString ls = (LineString) fr.next().getDefaultGeometry(); // 1 1 0, 2 2 0, 4 2 1, 5 1 1 assertEquals(4, ls.getCoordinates().length); assertTrue(new Coordinate(1, 1, 0).equals3D(ls.getCoordinateN(0))); assertTrue(new Coordinate(2, 2, 0).equals3D(ls.getCoordinateN(1))); assertTrue(new Coordinate(4, 2, 1).equals3D(ls.getCoordinateN(2))); assertTrue(new Coordinate(5, 1, 1).equals3D(ls.getCoordinateN(3))); } }