/** * @see org.geotools.data.FeatureReader#next() */ public Feature next() throws IOException, IllegalAttributeException, NoSuchElementException { if (reader == null) { throw new IllegalStateException("Reader has already been closed"); } Feature next = reader.next(); if( schema==null ) return next; return schema.create(next.getAttributes(null), next.getID()); }
/** * @see org.geotools.data.FeatureReader#next() */ public Object next() throws NoSuchElementException { if (reader == null) { throw new IllegalStateException("Reader has already been closed"); } Feature next = reader.next(); if( schema==null ) return next; try { return schema.create(next.getAttributes(null), next.getID()); } catch( IllegalAttributeException eep){ throw (IllegalStateException) new IllegalStateException(eep.getMessage()).initCause(eep ); } }
Object[] attributes = next.getAttributes(null);
Feature reproject(Feature feature) throws IOException { Object[] attributes = feature.getAttributes(null); for (int i = 0; i < attributes.length; i++) { Object object = attributes[i]; if (object instanceof Geometry) { // do the transformation Geometry geometry = (Geometry) object; try { attributes[i] = tx.transform(geometry); } catch (TransformException e) { String msg = "Error occured transforming " + geometry.toString(); throw (IOException) new IOException(msg).initCause(e); } } } try { return schema.create(attributes, feature.getID()); } catch (IllegalAttributeException e) { String msg = "Error creating reprojeced feature"; throw (IOException) new IOException(msg).initCause(e); } }
public Feature next() throws IOException, IllegalAttributeException, NoSuchElementException { Feature feature = wrapped.next(); FeatureType featureType = wrapped.getFeatureType(); String id = feature.getID(); return featureType.create(feature .getAttributes(new Object[featureType.getAttributeCount()]), fidMapper .getUnversionedFid(id)); } }
Object[] attributes = next.getAttributes(null);
Object values[] = feature.getAttributes( null ); for( int a=0; a<values.length; a++){ newFeature.setAttribute( a, values[a] );
live.setAttributes(current.getAttributes(null)); } catch (IllegalAttributeException e) { throw new DataSourceException("Unable to accept modifications to "
public Set addFeatures(FeatureCollection collection) throws IOException { Set addedFids = new HashSet(); String typeName = getSchema().getTypeName(); Feature feature = null; SimpleFeature newFeature; FeatureWriter writer = getDataStore().getFeatureWriterAppend(typeName, getTransaction()); Iterator iterator = collection.iterator(); try { while (iterator.hasNext()) { feature = (Feature) iterator.next(); newFeature = (SimpleFeature)writer.next(); try { newFeature.setAttributes(feature.getAttributes(null)); } catch (IllegalAttributeException writeProblem) { throw new DataSourceException("Could not create " + typeName + " out of provided feature: " + feature.getID(), writeProblem); } writer.write(); addedFids.add(newFeature.getID()); } } finally { collection.close( iterator ); writer.close(); } return addedFids; }
Object[] attributes = feature.getAttributes(null);
/** * Applies transform to all geometry attribute. * * @param feature Feature to be transformed * @param schema Schema for target transformation - transform( schema, crs ) * @param transform MathTransform used to transform coordinates - reproject( crs, crs ) * @return transformed Feature of type schema * @throws TransformException * @throws MismatchedDimensionException * @throws IllegalAttributeException */ public static Feature transform( Feature feature, FeatureType schema, MathTransform transform ) throws MismatchedDimensionException, TransformException, IllegalAttributeException { feature = schema.create(feature.getAttributes(null), feature.getID()); GeometryAttributeType geomType = schema.getDefaultGeometry(); Geometry geom = (Geometry) feature.getAttribute(geomType.getName()); geom = JTS.transform(geom, transform); try { feature.setAttribute(geomType.getName(), geom); } catch (IllegalAttributeException shouldNotHappen) { // we are expecting the transform to return the same geometry type } return feature; }
temp.getAttributes( new Object[temp.getNumberOfAttributes()]), null);
} else { try { feature.setAttributes(update.getAttributes(null)); writer.write(); try { nextFeature.setAttributes(addedFeature .getAttributes(null)); writer.write();
public void testGetFeaturesWriterAdd() throws IOException, IllegalAttributeException { FeatureWriter writer = data.getFeatureWriter("ROAD", Transaction.AUTO_COMMIT); SimpleFeature feature; while (writer.hasNext()) { feature = (SimpleFeature) writer.next(); } assertFalse(writer.hasNext()); feature = (SimpleFeature) writer.next(); feature.setAttributes(newRoad.getAttributes(null)); writer.write(); assertFalse(writer.hasNext()); writer = data.getFeatureWriter("ROAD", Transaction.AUTO_COMMIT); assertEquals(roadFeatures.length + 1, count(writer)); }
newFeature.setAttributes(feature.getAttributes(null)); } catch (IllegalAttributeException writeProblem) { throw new DataSourceException("Could not create "
newFeature.setAttributes(feature.getAttributes(null)); } catch (IllegalAttributeException writeProblem) { throw new DataSourceException("Could not create "
newFeature.setAttributes(feature.getAttributes(null)); } catch (IllegalAttributeException writeProblem) { throw new DataSourceException("Could not create "
public Feature next() throws IOException { Feature original = null; if (updateWriter != null && updateWriter.hasNext()) { oldFeature = updateWriter.next(); newFeature = appendWriter.next(); original = oldFeature; state.expandDirtyBounds(getLatLonFeatureEnvelope(oldFeature)); } else { oldFeature = null; newFeature = appendWriter.next(); original = newFeature; } try { liveFeature = DataUtilities.reType(featureType, original); // if the feature it brand new, it'll have a random fid, not a // proper one, keep using // it, we cannot un-version it String unversionedId = liveFeature.getID(); if (oldFeature != null) unversionedId = mapper.getUnversionedFid(liveFeature.getID()); liveFeature = new MutableFIDFeature((DefaultFeatureType) featureType, liveFeature .getAttributes(new Object[featureType.getAttributeCount()]), unversionedId); return liveFeature; } catch (IllegalAttributeException e) { throw new DataSourceException("Error casting versioned feature to external one. " + "Should not happen, there's a bug at work", e); } }
Object[] attributes = current.getAttributes(null); AttributeType[] attributeTypes = current.getFeatureType() .getAttributeTypes();
newFeature.setAttributes(feature.getAttributes(null)); } catch (IllegalAttributeException writeProblem) { throw new DataSourceException("Could not create "