本文整理汇总了Java中org.geotools.feature.simple.SimpleFeatureBuilder类的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureBuilder类的具体用法?Java SimpleFeatureBuilder怎么用?Java SimpleFeatureBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleFeatureBuilder类属于org.geotools.feature.simple包,在下文中一共展示了SimpleFeatureBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSampleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
/**
* Creates a sample Feature instance in the hope that it can be used in the rendering of the
* legend graphic.
*
* @param schema the schema for which to create a sample Feature instance
*
*
*
* @throws ServiceException
*/
private Feature createSampleFeature(FeatureType schema) throws ServiceException {
Feature sampleFeature;
try {
if (schema instanceof SimpleFeatureType) {
if (hasMixedGeometry((SimpleFeatureType) schema)) {
// we can't create a sample for a generic Geometry type
sampleFeature = null;
} else {
sampleFeature = SimpleFeatureBuilder.template((SimpleFeatureType) schema, null);
}
} else {
sampleFeature = DataUtilities.templateFeature(schema);
}
} catch (IllegalAttributeException e) {
throw new ServiceException(e);
}
return sampleFeature;
}
示例2: createFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public static SimpleFeature createFeature(SimpleFeatureBuilder builder, int i, String visibility) {
final String[] PEOPLE_NAMES = {"James", "John", "Peter", "Hannah", "Claire", "Gabriel"};
final Random random = new Random();
Double lat = random.nextDouble() * 180 - 90;
builder.reset();
builder.add(PEOPLE_NAMES[i % PEOPLE_NAMES.length]); // name
builder.add((int) Math.round(random.nextDouble()*110)); // age
builder.add(random.nextDouble());
builder.add(lat);
builder.add(new Date()); // dtg
builder.add(WKTUtils$.MODULE$.read("POINT(" + -180.0 + " " + lat + ")")); // geom
SimpleFeature feat = builder.buildFeature(Integer.toString(i));
if (visibility != null) {
feat.getUserData().put("geomesa.feature.visibility", visibility);
}
return feat;
}
示例3: addDeleteNewFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的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);
}
示例4: createFeatureLayerFromMapObject
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的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 );
}
示例5: convert
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
@Override
public SimpleFeature convert( OrganisationUnit organisationUnit )
{
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder( featureType );
if ( organisationUnit.getCoordinates() != null && !organisationUnit.getCoordinates().isEmpty() )
{
GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( organisationUnit.getCoordinates(), GeoUtils.CoordinateOrder.COORDINATE_LNGLAT );
if ( coordinates.lng == null || coordinates.lat == null )
{
return null;
}
Coordinate coordinate = new Coordinate( coordinates.lng, coordinates.lat );
Point point = geometryFactory.createPoint( coordinate );
featureBuilder.add( point );
featureBuilder.add( organisationUnit.getUid() );
featureBuilder.add( organisationUnit.getName() );
return featureBuilder.buildFeature( null );
}
return null;
}
示例6: buildSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
/**
* The purpose of this method is to build a SimpleFeature by assigning
* properties from the FitActivity to the properties defined in the SimpleFeatureType.
* @param fitActivity
* @return
*/
public SimpleFeature buildSimpleFeature(final FitActivity fitActivity) {
final SimpleFeatureType featureSchema = getFeatureSchema();
final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureSchema);
builder.set("activityId", fitActivity.getActivityId());
builder.set("name", fitActivity.getName());
builder.set("sport", fitActivity.getSport());
builder.set("startTime", fitActivity.getStartTime());
builder.set("totalMeters", fitActivity.getTotalMeters());
builder.set("totalSeconds", fitActivity.getTotalSeconds());
final Coordinate[] polyline = fitActivity.getPolyline().toArray(new Coordinate[fitActivity.getPolyline().size()]);
final Geometry geometry = simplifyLineString(polyline);
builder.add(geometry);
final Coordinate[] boundingBox = generateBoundingBox(geometry);
builder.set("minLat", boundingBox[0].y);
builder.set("minLon", boundingBox[0].x);
builder.set("maxLat", boundingBox[1].y);
builder.set("maxLon", boundingBox[1].x);
return builder.buildFeature(fitActivity.getActivityId().toString());
}
示例7: OSMInfo
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public OSMInfo(final URL url, final long modificationStamp) {
super(modificationStamp);
CoordinateReferenceSystem crs = null;
ReferencedEnvelope env2 = new ReferencedEnvelope();
int number = 0;
try {
final File f = new File(url.toURI());
final GamaOsmFile osmfile = new GamaOsmFile(null, f.getAbsolutePath());
attributes.putAll(osmfile.getOSMAttributes(GAMA.getRuntimeScope()));
final SimpleFeatureType TYPE = DataUtilities.createType("geometries", "geom:LineString");
final ArrayList<SimpleFeature> list = new ArrayList<SimpleFeature>();
for (final IShape shape : osmfile.iterable(null)) {
list.add(SimpleFeatureBuilder.build(TYPE, new Object[] { shape.getInnerGeometry() }, null));
}
final SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, list);
final SimpleFeatureSource featureSource = DataUtilities.source(collection);
env2 = featureSource.getBounds();
number = osmfile.nbObjects;
crs = osmfile.getOwnCRS(null);
} catch (final Exception e) {
System.out.println("Error in reading metadata of " + url);
hasFailed = true;
} finally {
// approximation of the width and height in meters.
width = env2 != null ? env2.getWidth() * (FastMath.PI / 180) * 6378137 : 0;
height = env2 != null ? env2.getHeight() * (FastMath.PI / 180) * 6378137 : 0;
itemNumber = number;
this.crs = crs;
}
}
示例8: createAggregationFeatures
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public static SimpleFeatureCollection createAggregationFeatures(List<Map<String,Object>> data) {
final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName( "testType" );
builder.add("_aggregation", HashMap.class );
builder.add("aString", String.class );
final SimpleFeatureType featureType = builder.buildFeatureType();
final DefaultFeatureCollection collection = new DefaultFeatureCollection();
final SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
data.stream().forEach(item -> {
item.keySet().stream().forEach(key -> {
featureBuilder.set(key, item.get(key));
});
collection.add(featureBuilder.buildFeature(null));
});
return collection;
}
示例9: createCollection
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
/**
* Create a SimpleFeatureCollection with a Geometry
*
* @param all
* @return
* @throws SchemaException
*/
public static SimpleFeatureCollection createCollection(Geometry g) throws SchemaException {
SimpleFeatureCollection collection = FeatureCollections.newCollection();
SimpleFeatureType TYPE = DataUtilities.createType("MBB", "location:Polygon:srid=4326"); // 4326
// =
// srid
// of
// wgs84
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE);
featureBuilder.add(g);
SimpleFeature feature = featureBuilder.buildFeature(null);
collection.add(feature);
return collection;
}
示例10: getBuilder
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
private SimpleFeatureBuilder getBuilder() {
final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
typeBuilder.setName("test");
typeBuilder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate
// reference
// add attributes in order
typeBuilder.add(
"geom",
Geometry.class);
typeBuilder.add(
"name",
String.class);
typeBuilder.add(
"count",
Long.class);
// build the type
return new SimpleFeatureBuilder(
typeBuilder.buildFeatureType());
}
示例11: createFeatureBuilder
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public static SimpleFeatureBuilder createFeatureBuilder( CoordinateReferenceSystem crs, boolean hasUserTotalMean ) {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("stats");
b.setCRS(crs);
b.add("the_geom", Polygon.class);
b.add(MIN, Double.class);
b.add(MAX, Double.class);
b.add(AVG, Double.class);
b.add(VAR, Double.class);
b.add(SDEV, Double.class);
if (hasUserTotalMean)
b.add(AVGABSDEV, Double.class);
b.add(ACTCELLS, Integer.class);
b.add(INVCELLS, Integer.class);
SimpleFeatureType type = b.buildFeatureType();
return new SimpleFeatureBuilder(type);
}
示例12: substituteGeometry
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
/**
* @param newGeometry new geometry to insert.
*/
public void substituteGeometry( Geometry newGeometry ) {
if (toRemove) {
return;
}
if (newGeometry.getLength() < lengthThreshold) {
feature = null;
geometry = null;
toRemove = true;
return;
}
Object[] attributes = feature.getAttributes().toArray();
Object[] newAttributes = new Object[attributes.length];
System.arraycopy(attributes, 0, newAttributes, 0, attributes.length);
newAttributes[0] = newGeometry;
SimpleFeatureType featureType = feature.getFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
builder.addAll(newAttributes);
feature = builder.buildFeature(feature.getID());
geometry = newGeometry;
bufferPolygon = geometry.buffer(buffer);
}
示例13: buildGeoWaveDataInstance
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
private static GeoWaveData<SimpleFeature> buildGeoWaveDataInstance(
final String id,
final Collection<ByteArrayId> primaryIndexIds,
final ByteArrayId key,
final SimpleFeatureBuilder builder,
final Map<String, String> additionalDataSet ) {
if (additionalDataSet != null) {
for (final Map.Entry<String, String> entry : additionalDataSet.entrySet()) {
builder.set(
entry.getKey(),
entry.getValue());
}
}
return new GeoWaveData<SimpleFeature>(
key,
primaryIndexIds,
builder.buildFeature(id));
}
示例14: create
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
private SimpleFeature create(
final String pid,
final Set<String> set ) {
final List<AttributeDescriptor> descriptors = schema.getAttributeDescriptors();
final Object[] defaults = new Object[descriptors.size()];
int p = 0;
for (final AttributeDescriptor descriptor : descriptors) {
defaults[p++] = descriptor.getDefaultValue();
}
final SimpleFeature newFeature = SimpleFeatureBuilder.build(
schema,
defaults,
UUID.randomUUID().toString());
newFeature.setAttribute(
"pid",
pid);
set.add(pid);
return newFeature;
}
示例15: buildFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入依赖的package包/类
public static SimpleFeature buildFeature(
final SimpleFeatureType featureType,
final Pair<String, Object>[] entries ) {
final List<AttributeDescriptor> descriptors = featureType.getAttributeDescriptors();
final Object[] defaults = new Object[descriptors.size()];
int p = 0;
for (final AttributeDescriptor descriptor : descriptors) {
defaults[p++] = descriptor.getDefaultValue();
}
final SimpleFeature newFeature = SimpleFeatureBuilder.build(
featureType,
defaults,
UUID.randomUUID().toString());
for (final Pair<String, Object> entry : entries) {
newFeature.setAttribute(
entry.getKey(),
entry.getValue());
}
return newFeature;
}