public FeatureType getFeatureType() { return features[0].getFeatureType(); }
/** * Create a new instance. * * @param featuresArg an of features. <b>All features must be of the same FeatureType</b> */ public CollectionFeatureReader(Feature[] featuresArg) { assert featuresArg.length > 0; this.features = Arrays.asList(featuresArg).iterator(); type = featuresArg[0].getFeatureType(); }
/** * Like contain but based on match rather than equals * * @param array DOCUMENT ME! * @param expected DOCUMENT ME! * * @return DOCUMENT ME! */ boolean containsLax(Feature[] array, Feature expected) { if ((array == null) || (array.length == 0)) { return false; } FeatureType type = expected.getFeatureType(); for (int i = 0; i < array.length; i++) { if (match(array[i], expected)) { return true; } } return false; }
/** * Sends sax for the ending of a feature. * * @param f DOCUMENT ME! * * @throws RuntimeException DOCUMENT ME! */ public void endFeature(Feature f) { try { String name = f.getFeatureType().getTypeName(); if (currentPrefix != null) { name = currentPrefix + ":" + name; } contentHandler.endElement("", "", name); contentHandler.endElement("", "", memberString); } catch (Exception e) { throw new RuntimeException(e); } }
/** * @return {@link Boolean#TRUE} if the <code>feature</code>'s * {@link FeatureType} contains an attribute named as the property * name passed as this function argument, {@link Boolean#FALSE} * otherwise. */ public Object evaluate(Feature feature) { String propName = getPropertyName(); AttributeType attributeType = feature.getFeatureType().getAttributeType(propName); return Boolean.valueOf(attributeType != null); }
public Element encode(Object object, Document document, Element value) throws Exception { Feature feature = (Feature) object; FeatureType featureType = feature.getFeatureType(); String namespace = featureType.getNamespace().toString(); String typeName = featureType.getTypeName(); Element encoding = document.createElementNS(namespace, typeName); encoding.setAttributeNS(GML.NAMESPACE, "id", feature.getID()); return encoding; }
protected boolean add(Feature feature, boolean fire) { // This cast is neccessary to keep with the contract of Set! if( feature == null ) return false; // cannot add null! final String ID = feature.getID(); if( ID == null ) return false; // ID is required! if( contents.containsKey( ID ) ) return false; // feature all ready present if ( childType==null ){ childType=feature.getFeatureType(); }else{ if( !feature.getFeatureType().equals(childType) ) Logging.getLogger("org.geotools.feature.collections").warning("Feature Collection contains a heterogeneous" + " mix of features"); } //TODO check inheritance with FeatureType here!!! contents.put( ID, feature ); if(fire) { fireChange(feature, CollectionEvent.FEATURES_ADDED); } return true; }
public boolean canHandle(Object object) { try { if (!(object instanceof Feature) || object instanceof FeatureCollection) return false; Feature f = (Feature) object; FeatureTypeInfo info = catalog.getFeatureTypeInfo(f .getFeatureType().getTypeName(), f.getFeatureType() .getNamespace().toString()); return info != null && info.getFeatureSource() instanceof VersioningFeatureSource; } catch (Exception e) { LOGGER .log( Level.FINE, "Error occurred trying to determine versioning status of a feature type", e); return false; } }
private void addFeatureInternal(Feature feature) { if (feature == null) { throw new IllegalArgumentException("Provided Feature is empty"); } FeatureType featureType; featureType = feature.getFeatureType(); String typeName = featureType.getTypeName(); Map featuresMap; if (!memory.containsKey(typeName)) { try { createSchema(featureType); } catch (IOException e) { // this should not of happened ?!? // only happens if typeNames is taken and // we just checked } } featuresMap = (Map) memory.get(typeName); featuresMap.put(feature.getID(), feature); }
public void remove() throws IOException { if( live == null){ throw new IOException( "No current feature to remove"); } if( origional != null ){ store.listenerManager.fireFeaturesRemoved(live.getFeatureType().getTypeName(), Transaction.AUTO_COMMIT, origional.getBounds(), false); } origional = null; live = null; // prevent live and remove from being written out } public void close() throws IOException {
public void remove() throws IOException { if( live == null){ throw new IOException( "No current feature to remove"); } if( origional != null ){ store.listenerManager.fireFeaturesRemoved(live.getFeatureType().getTypeName(), Transaction.AUTO_COMMIT, origional.getBounds(), false); } origional = null; live = null; // prevent live and remove from being written out } public void close() throws IOException {
public String[] getPropertyNames(Object object) { Feature feature = (Feature) object; FeatureType featureType = feature.getFeatureType(); //set is ok because jxpath ignores order String[] propertyNames = new String[featureType.getAttributeCount()]; for (int i = 0; i < propertyNames.length; i++) { propertyNames[i] = featureType.getAttributeType(i).getLocalName(); } return propertyNames; }
public String[] getPropertyNames(Object object) { Feature feature = (Feature) object; FeatureType featureType = feature.getFeatureType(); //set is ok because jxpath ignores order String[] propertyNames = new String[ featureType.getAttributeCount() ]; for ( int i = 0; i < propertyNames.length; i++ ) { propertyNames[ i ] = featureType.getAttributeType( i ).getName(); } return propertyNames; }
/** * Returns the qname with prefix as <code>null</code>, and local part the name of the * feature attribute. */ public QName getName() { return index != -1 ? new QName( null, feature.getFeatureType().getAttributeType( index ).getName() ) : new QName( null, "fid" ); }
/** * Returns the qname with prefix as <code>null</code>, and local part the name of the * feature attribute. */ public QName getName() { return (index != -1) ? new QName(null, feature.getFeatureType().getAttributeType(index).getLocalName()) : new QName(null, "fid"); }
public FeatureCollection collection() throws IOException { FeatureCollection copy = new DefaultFeatureCollection( null, featureType ); List list = new ArrayList( contents.size() ); for( FeatureIterator iterator = features(); iterator.hasNext(); ){ Feature feature = iterator.next(); Feature duplicate; try { duplicate = feature.getFeatureType().duplicate( feature ); } catch (IllegalAttributeException e) { throw new DataSourceException( "Unable to copy "+feature.getID(), e ); } list.add( duplicate ); } copy.addAll( list ); return copy; }
public Feature duplicate(Feature original) throws IllegalAttributeException{ if( original == null ) return null; FeatureType featureType = original.getFeatureType(); if (!featureType.equals(this)) { throw new IllegalAttributeException("Feature type " + featureType + " does not match " + this); } String id = original.getID(); int numAtts = featureType.getAttributeCount(); Object attributes[] = new Object[numAtts]; for (int i = 0; i < numAtts; i++) { AttributeType curAttType = getAttributeType(i); attributes[i] = curAttType.duplicate(original.getAttribute(i)); } return featureType.create(attributes, id ); } /**
/** * Gets the name of a specified column. * * @param col the index of the column to get the name of. * @return the name of {@code col}. * * @todo Just gets first feature type - should use typed feature * collection. Revisit when we have FeatureDocument. */ public String getColumnName(int col) { if (featureTable==null || featureTable.isEmpty()) { return null; } Feature firstFeature = featureTable.features().next(); FeatureType firstType = firstFeature.getFeatureType(); return firstType.getAttributeType(col).getName(); }
public void handleFeatureReader(FeatureReader reader) throws IOException { try { while (reader.hasNext() && running) { Feature f = reader.next(); handleFeature(f); FeatureType t = f.getFeatureType(); for (int i = 0, ii = f.getNumberOfAttributes(); i < ii; i++) { handleAttribute(t.getAttributeType(i), f.getAttribute(i)); } endFeature(f); } } catch (Exception ioe) { throw new RuntimeException("Error reading Features", ioe); } finally { if (reader != null) { LOGGER.finer("closing reader " + reader); reader.close(); } } }
public void fireChanged( Feature before, Feature after, Transaction transaction ){ String typeName = after.getFeatureType().getTypeName(); Envelope bounds = new Envelope(); bounds.expandToInclude( before.getBounds() ); bounds.expandToInclude( after.getBounds() ); listenerManager.fireFeaturesChanged( typeName, transaction, bounds, false ); } //