本文整理汇总了Java中org.geotools.feature.simple.SimpleFeatureBuilder.add方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureBuilder.add方法的具体用法?Java SimpleFeatureBuilder.add怎么用?Java SimpleFeatureBuilder.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.feature.simple.SimpleFeatureBuilder
的用法示例。
在下文中一共展示了SimpleFeatureBuilder.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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 );
}
示例4: 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;
}
示例5: 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());
}
示例6: 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;
}
示例7: createExtraFeatures
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static Layer createExtraFeatures() {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("Location");
b.setCRS(DefaultGeographicCRS.WGS84);
// picture location
b.add("geom", Point.class);
final SimpleFeatureType TYPE = b.buildFeatureType();
GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
Point point = gf.createPoint(new Coordinate(CANBERRA_LONG, CANBERRA_LAT));
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(TYPE);
builder.add(point);
SimpleFeature feature = builder.buildFeature("Canberra");
DefaultFeatureCollection features = new DefaultFeatureCollection(null, null);
features.add(feature);
Style style = SLD.createPointStyle("Star", Color.BLUE, Color.BLUE, 0.3f, 10);
return new FeatureLayer(features, style);
}
示例8: getInstanceOfCountry
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
public static SimpleFeature getInstanceOfCountry() throws Exception {
if (COUNTRY != null) {
return COUNTRY;
}
final SimpleFeatureType type = DataUtilities.createType("Location",
"geometry:Polygon:srid=4326," + "countryName:String," + "population:Integer,"
+ "principalMineralResource:String");
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(type);
WKTReader reader = new WKTReader();
MultiPolygon geometry = (MultiPolygon) reader.read(usaGeometry());
featureBuilder.add(geometry);
featureBuilder.add("USA");
featureBuilder.add(307006550);
featureBuilder.add("oil");
COUNTRY = featureBuilder.buildFeature(null);
return COUNTRY;
}
示例9: createSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static SimpleFeature createSimpleFeature(SimpleFeatureType schema) {
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(schema);
double latitude = (Math.random() * 180.0) - 90.0;
double longitude = (Math.random() * 360.0) - 180.0;
String name = "thing" + Math.random();
int number = (int) Math.round(Math.random() * 10.0);
GeometryFactory geometryFactory = new GeometryFactory();
/* Longitude (= x coord) first ! */
com.vividsolutions.jts.geom.Point point = geometryFactory
.createPoint(new Coordinate(longitude, latitude));
featureBuilder.add(point);
featureBuilder.add(name);
featureBuilder.add(number);
SimpleFeature feature = featureBuilder.buildFeature(null);
return feature;
}
示例10: addSomeExtraStates
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private void addSomeExtraStates() {
SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
typeBuilder.setName( "states" );
typeBuilder.add( "STATE_NAME", String.class );
typeBuilder.add( "FIPS", Integer.class );
SimpleFeatureType type = typeBuilder.buildFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
builder.add("Hawaii");
builder.add(51);
SimpleFeature feature2 = builder.buildFeature("states.5051");
builder.add("Alaska");
builder.add(52);
SimpleFeature feature3 = builder.buildFeature("states.5052");
m_features.put(feature2.getIdentifier(), new FeatureAccessorImpl(feature2));
m_features.put(feature3.getIdentifier(), new FeatureAccessorImpl(feature3));
}
示例11: convert
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
@Override
public SimpleFeature convert( Facility facility )
{
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder( featureType );
if ( facility.getCoordinates() != null && !facility.getCoordinates().isEmpty() )
{
Double lng = facility.getCoordinates().get( 0 );
Double lat = facility.getCoordinates().get( 1 );
if ( lng == null || lat == null )
{
return null;
}
Coordinate coordinate = new Coordinate( lng, lat );
Point point = geometryFactory.createPoint( coordinate );
featureBuilder.add( point );
featureBuilder.add( facility.getUuid() );
featureBuilder.add( facility.getName() );
featureBuilder.add( facility.getActive() );
return featureBuilder.buildFeature( null );
}
return null;
}
示例12: cloneFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
/**
* Clones the given SimpleFeature using a DataStore fetch schema.
*
* @param store
* @param typeName
* @param feature
* @return
* @throws IOException
*/
public static SimpleFeature cloneFeature(DataStore store, String typeName,
SimpleFeature feature, Map<String, String> attributeMappings) throws IOException {
SimpleFeatureType schema = store.getSchema(typeName);
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(schema);
for(AttributeDescriptor attribute : schema.getAttributeDescriptors()) {
String sourceAttributeName = mapAttributeName(attributeMappings,
attribute.getLocalName());
builder.add(feature.getAttribute(sourceAttributeName));
}
return builder.buildFeature(null);
}
示例13: createPolygon
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
public static void createPolygon(List<Coordinate> coords, File output) {
List<SimpleFeature> features = new ArrayList<>();
final SimpleFeatureType type = createFeatureType();
// final SimpleFeatureType type = BasicFeatureTypes.POLYGON;
GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
SimpleFeatureBuilder f = new SimpleFeatureBuilder(type);
f.add(gf.createPolygon(coords.toArray(new Coordinate[] {})));
SimpleFeature feature = f.buildFeature(null);
features.add(feature);
saveFeaturesToShapefile(features, type, output);
}
示例14: readFields
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
@Override
public void readFields(
final DataInput input )
throws IOException {
try {
String ns = input.readUTF();
featureType = FeatureDataUtils.decodeType(
"-".equals(ns) ? "" : ns,
input.readUTF(),
input.readUTF(),
input.readUTF());
}
catch (final SchemaException e) {
throw new IOException(
"Failed to parse the encoded feature type",
e);
}
final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(
featureType);
// read the fid
final String fid = input.readUTF();
// read the other attributes, build the feature
for (final AttributeDescriptor ad : featureType.getAttributeDescriptors()) {
final Object att = readAttribute(
ad,
input);
builder.add(att);
}
// build the feature
feature = builder.buildFeature(fid);
}
示例15: buildSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
public Feature buildSimpleFeature(String fid, int classification) throws ParseException {
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(m_flagType);
builder.add("US");
builder.add(classification);
builder.add(20.5);
builder.add(Samples.makePoint("POINT(1 2)"));
return builder.buildFeature(fid);
}