public boolean matches(Feature feature) { if (feature == null) { return false; } return equalsExact(feature.getIdentifier()); }
protected Attributes encodeFeatureId(Feature f) { AttributesImpl fidAtts = new org.xml.sax.helpers.AttributesImpl(); String fid = f.getIdentifier().getID(); if (fid != null) { fidAtts.addAttribute("", "fid", "fid", "fids", fid); } return fidAtts; } }
public void visit(Feature feature) { fids.add(feature.getIdentifier().getID()); } },
protected void queryAdded() { while (addedIterator.hasNext() && next == null) { next = (F) addedIterator.next(); if (encounteredFids.contains(next.getIdentifier().getID()) || !filter.evaluate(next)) { next = null; } } }
protected void querySpatialIndex() { while (spatialIndexIterator.hasNext() && next == null) { F f = (F) spatialIndexIterator.next(); if (encounteredFids.contains(f.getIdentifier().getID()) || !filter.evaluate(f)) { continue; } next = f; } }
protected void queryModified() { while (modifiedIterator.hasNext() && next == null) { next = (F) modifiedIterator.next(); if (next == Diff.NULL || encounteredFids.contains(next.getIdentifier().getID()) || !filter.evaluate(next)) { next = null; } } }
/** Helper method or building fid filters. */ Filter idFilter(Feature feature) { FilterFactory ff = this.entry.dataStore.getFilterFactory(); Set<FeatureId> fids = new HashSet<FeatureId>(); fids.add(feature.getIdentifier()); return ff.id(fids); }
protected String extractIdForFeature(Feature feature) { if (mapping.getFeatureIdExpression().equals(Expression.NIL)) { if (feature.getIdentifier() == null) { return null; } else { return feature.getIdentifier().getID(); } } return mapping.getFeatureIdExpression().evaluate(feature, String.class); }
/** * Simplifies id value, cutting "typename." part if exists * * @param feature * @return */ protected String simplifyIndentifier(Feature feature) { String schemaPart = feature.getType().getName().getLocalPart() + "."; String fid = feature.getIdentifier().getID(); if (fid.startsWith(schemaPart)) { return fid.substring(schemaPart.length()); } return fid; } }
protected static void assertId(String expected, Feature f) { String actual = f.getIdentifier().toString(); assertEquals("Incorrect id: " + actual, expected, actual); }
/** * Helper method that checks that a feature that matches the provided id exists in the list of * provided features. */ private boolean checkExists(List<Feature> features, String id) { for (Feature feature : features) { if (feature.getIdentifier().getID().equals(id)) { // we found a match return true; } } // found not match return false; } }
public static Element AbstractFeatureType_encode( Object object, Document document, Element value) { Feature feature = (Feature) object; FeatureType featureType = feature.getType(); String namespace = featureType.getName().getNamespaceURI(); String typeName = featureType.getName().getLocalPart(); Element encoding = document.createElementNS(namespace, typeName); encoding.setAttributeNS(null, "fid", feature.getIdentifier().getID()); return encoding; }
@Override public void visit(Feature feature) { fb.init((SimpleFeature) feature); SimpleFeature f = fb.buildFeature(feature.getIdentifier().getID()); features.add(f); } },
@Test public void testSourcesFeatures() throws Exception { try (Stream<Feature> fstream = FeatureStreams.toFeatureStream(mappedSource.getFeatures())) { List<Feature> flist = fstream.collect(Collectors.toList()); assertTrue(flist.size() == 11); assertTrue(flist.get(2).getIdentifier().getID().equals("st.3")); } } }
private void next() { if (iterator.hasNext()) { this.currentFeature = iterator.next(); // update the current key for (int i = 0; i < sortBy.length; i++) { SortBy sb = sortBy[i]; if (sb == SortBy.NATURAL_ORDER || sb == SortBy.REVERSE_ORDER) { currentKey.components[i] = currentFeature.getIdentifier().getID(); } else { Object value = sb.getPropertyName().evaluate(currentFeature); currentKey.components[i] = value; } } } else { // mark as complete but don't close, we might have // other fts to paint complete = true; } }
@Test public void testGetValue() throws Exception { Object fid = feature.getIdentifier(); Object found = idExpr.evaluate(feature); assertNotNull(found); assertEquals(fid, found); }
/** * Test mapping multi-valued simple properties still works. * * @throws Exception */ @Test public void testMultiValuedSimpleProperties() throws Exception { FeatureIterator<Feature> iterator = ccFeatures.features(); while (iterator.hasNext()) { Feature next = iterator.next(); Collection<Property> names = next.getProperties("name"); // these are gml:name and gsml:name, so count twice if (next.getIdentifier().toString().equals("cc.1")) { // see ControlledConcept.properties where id = cc.1 assertEquals(6, names.size()); } else { // see ControlledConcept.properties where id = cc.2 assertEquals(2, names.size()); } } iterator.close(); }
private void assertThreeFeatures(MarkFeatureIterator iterator) { assertTrue(iterator.hasNext()); assertEquals("Line.1", iterator.next().getIdentifier().getID()); assertTrue(iterator.hasNext()); assertEquals("Line.2", iterator.next().getIdentifier().getID()); assertTrue(iterator.hasNext()); assertEquals("Line.3", iterator.next().getIdentifier().getID()); assertFalse(iterator.hasNext()); } }
@Test /* * Test Bbox function with no property name specified. The default geometry should be used. */ public void testBBoxWithNoPropertyName() throws IOException { // default geometry exists // in theory, when property name is not specified, the filter should apply to all the // geometry attributes, // but it wouldn't work until the bug in GeometryFilterImpl is fixed // and our test data only have 1 geometry, so it doesn't test multiple geometries case BBOX filter = ff.bbox(ff.property(""), -1.1, 52.5, -1.1, 52.6, null); FeatureCollection<FeatureType, Feature> features = fSource.getFeatures(filter); assertEquals(2, size(features)); FeatureIterator<Feature> iterator = features.features(); try { Feature f = iterator.next(); assertEquals(f.getIdentifier().toString(), "mf1"); f = iterator.next(); assertEquals(f.getIdentifier().toString(), "mf3"); } finally { iterator.close(); } }
@Test /* * Test BBox function with the property name specified. */ public void testBBoxWithPropertyName() throws Exception { // property name exists and is a geometry attribute BBOX filter = ff.bbox(ff.property("gsml:shape"), -1.1, 52.5, -1.1, 52.6, null); FeatureCollection<FeatureType, Feature> features = fSource.getFeatures(filter); assertEquals(2, size(features)); FeatureIterator<Feature> iterator = features.features(); try { Feature f = iterator.next(); assertEquals("mf1", f.getIdentifier().toString()); f = iterator.next(); assertEquals("mf3", f.getIdentifier().toString()); } finally { iterator.close(); } // prove that it would fail when property name is not a geometry attribute filter = ff.bbox(ff.property("gml:name[1]"), -1.2, 52.5, -1.1, 52.6, null); features = fSource.getFeatures(filter); assertEquals(0, size(features)); }