public FeatureTypeMap(SimpleFeatureType originalFeatureType, SimpleFeatureType featureType) { this.originalFeatureType = originalFeatureType; this.featureType = featureType; this.originalName = originalFeatureType.getTypeName(); this.name = featureType.getTypeName(); }
@Override public String convert(SimpleFeature feature) { return feature.getID(); }
@Override public Boolean convert(SimpleFeature feature) { Object value = feature.getAttribute(attributeName); if (value == null || value.equals("")) { return nullIsTrue; } else { return !nullIsTrue; } }
public void write() throws IOException { try { SimpleFeatureType target = getFeatureType(); for (int i = 0; i < target.getAttributeCount(); i++) { AttributeDescriptor at = target.getDescriptor(i); Object value = retyped.getAttribute(i); current.setAttribute(at.getLocalName(), value); } delegate.write(); } catch (IllegalAttributeException e) { throw (IOException) new IOException("Error occurred while retyping feature").initCause(e); } } }
@Test public void testGetFeaturesReader() throws Exception { FeatureReader<SimpleFeatureType, SimpleFeature> fr; fr = rts.getFeatureReader(new Query(RENAMED), Transaction.AUTO_COMMIT); SimpleFeature sf = fr.next(); fr.close(); assertEquals(RENAMED, sf.getFeatureType().getName().getLocalPart()); // check the feature ids have been renamed as well assertTrue( "Feature id has not been renamed, it's still " + sf.getID(), sf.getID().startsWith(RENAMED)); }
public void modifyFeatures(String[] names, Object[] attributeValues, Filter filter) throws IOException { AttributeDescriptor[] descriptors = new AttributeDescriptor[names.length]; for (int i = 0; i < names.length; i++) { descriptors[i] = getSchema().getDescriptor(names[i]); } modifyFeatures(descriptors, attributeValues, filter); }
@Test public void testFeautureReaderFidFilter() throws Exception { FeatureReader<SimpleFeatureType, SimpleFeature> fr; fr = rts.getFeatureReader(new Query(RENAMED, fidFilter), Transaction.AUTO_COMMIT); assertEquals(RENAMED, fr.getFeatureType().getName().getLocalPart()); assertTrue(fr.hasNext()); SimpleFeature sf = fr.next(); assertFalse(fr.hasNext()); fr.close(); assertEquals(fid, sf.getID()); }
/** * Returns the same name than the feature type (ie, {@code getSchema().getName()} to honor the * simple feature land common practice of calling the same both the Features produces and their * types * * @since 1.7 * @see FeatureSource#getName() */ public Name getName() { return getSchema().getName(); }
@Override public Boolean convert(SimpleFeature feature) { String key = feature.getAttribute(attributeName).toString(); Boolean value = values.get(key); if (value == null) { value = defaultValue; } return value; } }
public SimpleFeatureCollection getFeatures(Filter filter) throws IOException { return getFeatures(new Query(schema.getTypeName(), filter)); }
public void modifyFeatures(Name[] names, Object[] attributeValues, Filter filter) throws IOException { AttributeDescriptor[] descriptors = new AttributeDescriptor[names.length]; for (int i = 0; i < names.length; i++) { descriptors[i] = getSchema().getDescriptor(names[i]); } modifyFeatures(descriptors, attributeValues, filter); }
/** * Returns the same name than the feature type (ie, {@code getSchema().getName()} to honor the * simple feature land common practice of calling the same both the Features produces and their * types * * @since 1.7 * @see FeatureSource#getName() */ public Name getName() { return getSchema().getName(); }
@Override public SimpleFeature next() throws NoSuchElementException { SimpleFeature next = delegate.next(); accumulateAttributes(next); return builder.buildFeature(next.getID()); }
@Override public P2<Double> convert(SimpleFeature feature) { Double d = (Double) feature.getAttribute(safetyAttributeName); if (d == null) { return oneone; } return new P2<Double>(d, d); }
@Override protected String transformFeatureTypeName(String originalName) { if (originalName.equals(MockData.PRIMITIVEGEOFEATURE.getLocalPart())) return primitive.getTypeName(); else return super.transformFeatureTypeName(originalName); } };
public void modifyFeatures(Name attributeName, Object attributeValue, Filter filter) throws IOException { modifyFeatures(getSchema().getDescriptor(attributeName), attributeValue, filter); } }
/** * Sets the feature type in which templates are loaded against. * * @deprecated use {@link #setFeatureType(FeatureTypeInfo)} */ public void setFeatureType(SimpleFeatureType featureType) { this.featureType = featureType; FeatureTypeInfo ft = catalog.getFeatureTypeByName(featureType.getName()); if (ft == null) { return; // throw new IllegalArgumentException("No feature type named " + featureType.getName() + // " in catalog"); } setFeatureType(ft); }
@Override public String convert(SimpleFeature feature) { String attr = (String) feature.getAttribute(getAttributeName()); // Since dBase (used in shapefiles) has poor/no null support, null strings are sometimes // stored as a single space " " if (attr == null || attr.equals(" ")) { attr = defaultValue; } return attr; }
@Override protected SimpleFeatureType transformFeatureType(SimpleFeatureType original) throws IOException { if (original.getTypeName() .equals(MockData.PRIMITIVEGEOFEATURE.getLocalPart())) return primitive; else return super.transformFeatureType(original); }
public void modifyFeatures(String name, Object attributeValue, Filter filter) throws IOException { modifyFeatures(getSchema().getDescriptor(name), attributeValue, filter); }