本文整理汇总了Java中org.geotools.feature.DefaultFeatureCollection.add方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultFeatureCollection.add方法的具体用法?Java DefaultFeatureCollection.add怎么用?Java DefaultFeatureCollection.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.feature.DefaultFeatureCollection
的用法示例。
在下文中一共展示了DefaultFeatureCollection.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: correctFeatures
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
public static SimpleFeatureCollection correctFeatures(SimpleFeatureCollection fc){
SimpleFeatureIterator iterator=fc.features();
DefaultFeatureCollection outVector = new DefaultFeatureCollection();
while(iterator.hasNext()){
SimpleFeature sf=iterator.next();
Geometry gm=(Geometry)sf.getDefaultGeometry();
if(!gm.isValid()){
gm=JTSUtil.repair(gm);
System.out.println(gm.isValid());
}
sf.setDefaultGeometry(gm);
outVector.add(sf);
}
return fc;
}
示例2: addDeleteNewFeature
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
public static void addDeleteNewFeature(SimpleFeatureType sft, FeatureStore producerFS)
throws InterruptedException, IOException {
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(sft);
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
final Random random = new Random();
String id = "1000";
builder.add("Antoninus"); // name
builder.add((int) Math.round(random.nextDouble()*110)); // age
builder.add(new Date()); // dtg
builder.add(WKTUtils$.MODULE$.read("POINT(-1 -1)")); // geom
SimpleFeature feature = builder.buildFeature(id);
featureCollection.add(feature);
producerFS.addFeatures(featureCollection);
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
Filter idFilter = ff.id(ff.featureId(id));
producerFS.removeFeatures(idFilter);
}
示例3: createFeatureLayerFromMapObject
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
/**
* Creates a feature layer based on a map object.
*/
public static Layer createFeatureLayerFromMapObject( InternalMapObject mapObject )
{
Style style = mapObject.getStyle();
SimpleFeatureType featureType = mapObject.getFeatureType();
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder( featureType );
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
featureBuilder.add( mapObject.getGeometry() );
SimpleFeature feature = featureBuilder.buildFeature( null );
featureCollection.add( feature );
return new FeatureLayer( featureCollection, style );
}
示例4: storeStatements
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
@Override
public void storeStatements(final Collection<RyaStatement> ryaStatements) throws IOException {
// create a feature collection
final DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
for (final RyaStatement ryaStatement : ryaStatements) {
final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
// if the predicate list is empty, accept all predicates.
// Otherwise, make sure the predicate is on the "valid" list
final boolean isValidPredicate = validPredicates.isEmpty() || validPredicates.contains(statement.getPredicate());
if (isValidPredicate && (statement.getObject() instanceof Literal)) {
try {
final SimpleFeature feature = createFeature(featureType, statement);
featureCollection.add(feature);
} catch (final ParseException e) {
logger.warn("Error getting geo from statement: " + statement.toString(), e);
}
}
}
// write this feature collection to the store
if (!featureCollection.isEmpty()) {
featureStore.addFeatures(featureCollection);
}
}
示例5: doCollection
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
private SimpleFeatureCollection doCollection( RegionMap envelopeParams ) {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("typename");
b.setCRS(crs);
b.add("the_geom", Polygon.class);
b.add("cat", Double.class);
SimpleFeatureType type = b.buildFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
Object[] values = new Object[]{polygon, 1.0};
builder.addAll(values);
SimpleFeature feature = builder.buildFeature(null);
DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
newCollection.add(feature);
return newCollection;
}
示例6: toFeatureCollectionOthers
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
public SimpleFeatureCollection toFeatureCollectionOthers() {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("points");
b.setCRS(crs);
DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
b.add("the_geom", Point.class);
b.add("elev", Double.class);
SimpleFeatureType type = b.buildFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
for( Coordinate c : leftOverCoordinateList ) {
Object[] values = new Object[]{gf.createPoint(c), c.z};
builder.addAll(values);
SimpleFeature feature = builder.buildFeature(null);
newCollection.add(feature);
}
return newCollection;
}
示例7: getProblemPoints
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
private DefaultFeatureCollection getProblemPoints( CoordinateReferenceSystem crs,
LinkedHashMap<SimpleFeature, String> problemPointsMap ) throws Exception {
FeatureExtender ext = null;
DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
Set<Entry<SimpleFeature, String>> entrySet = problemPointsMap.entrySet();
for( Entry<SimpleFeature, String> entry : entrySet ) {
SimpleFeature pointFeature = entry.getKey();
String notes = entry.getValue();
if (ext == null) {
ext = new FeatureExtender(pointFeature.getFeatureType(), new String[]{NOTES}, new Class[]{String.class});
}
SimpleFeature extendedFeature = ext.extendFeature(pointFeature, new Object[]{notes});
newCollection.add(extendedFeature);
}
return newCollection;
}
示例8: getWidthLines
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
private DefaultFeatureCollection getWidthLines( CoordinateReferenceSystem crs,
ConcurrentLinkedQueue<Object[]> validPointsLineList ) throws Exception {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("net");
b.setCRS(crs);
b.add("the_geom", LineString.class);
b.add(PFAF, String.class);
b.add(LINKID, Integer.class);
b.add(ARiverSectionsExtractor.FIELD_SECTION_ID, Integer.class);
b.add(ARiverSectionsExtractor.FIELD_PROGRESSIVE, Double.class);
SimpleFeatureType type = b.buildFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
for( Object[] objects : validPointsLineList ) {
builder.addAll(objects);
SimpleFeature feature = builder.buildFeature(null);
newCollection.add(feature);
}
return newCollection;
}
示例9: featureCollectionFromNonGroundCoordinates
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
private SimpleFeatureCollection featureCollectionFromNonGroundCoordinates( CoordinateReferenceSystem crs,
List<Coordinate> nonGroundCoordinateList ) {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("nongroundpoints");
b.setCRS(crs);
DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
b.add("the_geom", Point.class);
b.add("elev", Double.class);
SimpleFeatureType type = b.buildFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
for( Coordinate c : nonGroundCoordinateList ) {
Point g = gf.createPoint(c);
Object[] values = new Object[]{g, c.z};
builder.addAll(values);
SimpleFeature feature = builder.buildFeature(null);
newCollection.add(feature);
}
return newCollection;
}
示例10: createPolygonShapefile
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
protected File createPolygonShapefile() throws IOException
{
final SimpleFeatureType featureType = getSimpleFeatureType(Polygon.class);
final SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
final DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(null, featureType);
final Coordinate[] coordinates = new Coordinate[]{
new Coordinate(0, 0),
new Coordinate(10, 0),
new Coordinate(10, 10),
new Coordinate(5, 5),
new Coordinate(0, 10),
new Coordinate(0, 0)
};
featureBuilder.reset();
featureBuilder.add(m_geometryFactory.createPolygon(coordinates));
featureBuilder.add(1234.5);
featureCollection.add(featureBuilder.buildFeature("FID"));
return getFile(featureType, featureCollection);
}
示例11: createPointShapefile
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
protected File createPointShapefile() throws IOException
{
final SimpleFeatureType featureType = getSimpleFeatureType(Point.class);
final SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
final DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(null, featureType);
featureBuilder.reset();
featureBuilder.add(m_geometryFactory.createPoint(new Coordinate(-1.0, -1.0)));
featureBuilder.add(1.0);
featureCollection.add(featureBuilder.buildFeature("FID-1"));
featureBuilder.reset();
featureBuilder.add(m_geometryFactory.createPoint(new Coordinate(1.0, 1.0)));
featureBuilder.add(1.0);
featureCollection.add(featureBuilder.buildFeature("FID-2"));
return getFile(featureType, featureCollection);
}
示例12: makeContourFeatures
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
private SimpleFeatureCollection makeContourFeatures() throws Exception {
Map<Integer, Geometry> contours = makeContours();
/* Stage the features in memory, in order from bottom to top, biggest to smallest */
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(null, contourSchema);
SimpleFeatureBuilder fbuilder = new SimpleFeatureBuilder(contourSchema);
List<Integer> thresholds = new ArrayList<Integer>(contours.keySet());
Collections.sort(thresholds);
// Collections.reverse(thresholds);
for (Integer threshold : thresholds) {
Geometry contour = contours.get(threshold);
fbuilder.add(contour);
fbuilder.add(threshold);
featureCollection.add(fbuilder.buildFeature(null));
}
return featureCollection;
}
示例13: createTabFeatures
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
/**
*
* @param ft
* @param glayer
* @param projection
* @param gt
* @return
* @throws Exception
*/
public static FeatureCollection createTabFeatures(SimpleFeatureType ft, Object[] values) throws Exception {
DefaultFeatureCollection collection = new DefaultFeatureCollection();
Object[] data = new Object[ft.getDescriptors().size()];
System.arraycopy(values, 1, data, 0, data.length);
SimpleFeature simplefeature = SimpleFeatureBuilder.build(ft, data, null);
collection.add(simplefeature);
return collection;
}
示例14: createFeatures
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
/**
*
* @param ft
* @param glayer
* @param projection
* @param gt
* @return
* @throws Exception
*/
public static FeatureCollection<SimpleFeatureType,SimpleFeature> createFeatures(SimpleFeatureType ft, GeometryImage glayer, String projection) throws Exception {
DefaultFeatureCollection collection = new DefaultFeatureCollection();
int id=0;
for (Geometry geom : glayer.getGeometries()) {
Object[] data = new Object[ft.getDescriptors().size()];
System.arraycopy(glayer.getAttributes(geom).getValues(), 0, data, 1, data.length-1);
data[0] = geom;
SimpleFeature simplefeature = SimpleFeatureBuilder.build(ft, data, ""+id);
collection.add(simplefeature);
/*if (geom instanceof Point) {
Object[] data = new Object[ft.getDescriptors().size()];
System.arraycopy(glayer.getAttributes(geom).getValues(), 0, data, 1, data.length-1);
data[0] = geom;
SimpleFeature simplefeature = SimpleFeatureBuilder.build(ft, data, ""+id);
collection.add(simplefeature);
} else if (geom instanceof Polygon) {
Object[] data = new Object[glayer.getSchema().length];
System.arraycopy(glayer.getAttributes(geom).getValues(), 0, data, 0, data.length );
SimpleFeature simplefeature = SimpleFeatureBuilder.build(ft, data, ""+id);
collection.add(simplefeature);
data = null;
} else if (geom instanceof LineString) {
Object[] data = new Object[glayer.getSchema().length + 1];
data[0] = geom;
System.arraycopy(glayer.getAttributes(geom).getValues(), 0, data, 1, data.length - 1);
SimpleFeature simplefeature = SimpleFeatureBuilder.build(ft, data, ""+id);
collection.add(simplefeature);
}*/
id++;
}
return collection;
}
示例15: deleteStatements
import org.geotools.feature.DefaultFeatureCollection; //导入方法依赖的package包/类
private void deleteStatements(final Collection<RyaStatement> ryaStatements) throws IOException {
// create a feature collection
final DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
for (final RyaStatement ryaStatement : ryaStatements) {
final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
// if the predicate list is empty, accept all predicates.
// Otherwise, make sure the predicate is on the "valid" list
final boolean isValidPredicate = validPredicates.isEmpty() || validPredicates.contains(statement.getPredicate());
if (isValidPredicate && (statement.getObject() instanceof Literal)) {
try {
final SimpleFeature feature = createFeature(featureType, statement);
featureCollection.add(feature);
} catch (final ParseException e) {
logger.warn("Error getting geo from statement: " + statement.toString(), e);
}
}
}
// remove this feature collection from the store
if (!featureCollection.isEmpty()) {
final Set<Identifier> featureIds = new HashSet<Identifier>();
final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null);
final Set<String> stringIds = DataUtilities.fidSet(featureCollection);
for (final String id : stringIds) {
featureIds.add(filterFactory.featureId(id));
}
final Filter filter = filterFactory.id(featureIds);
featureStore.removeFeatures(filter);
}
}