本文整理汇总了Java中org.geotools.feature.simple.SimpleFeatureBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureBuilder.build方法的具体用法?Java SimpleFeatureBuilder.build怎么用?Java SimpleFeatureBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.feature.simple.SimpleFeatureBuilder
的用法示例。
在下文中一共展示了SimpleFeatureBuilder.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: createFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private SimpleFeature createFeature() {
final SimpleFeature instance = SimpleFeatureBuilder.build(
type,
defaults,
UUID.randomUUID().toString());
instance.setAttribute(
"pop",
Long.valueOf(100));
instance.setAttribute(
"pid",
"a89dhd-123-abc");
instance.setAttribute(
"geom",
factory.createPoint(new Coordinate(
27.25,
41.25)));
return instance;
}
示例3: createGeoFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private SimpleFeature createGeoFeature(
final Geometry geo ) {
final SimpleFeature instance = SimpleFeatureBuilder.build(
geoType,
geoDefaults,
UUID.randomUUID().toString());
instance.setAttribute(
"pop",
Long.valueOf(100));
instance.setAttribute(
"pid",
UUID.randomUUID().toString());
instance.setAttribute(
"geometry",
geo);
return instance;
}
示例4: createGeoMercFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private SimpleFeature createGeoMercFeature(
final Geometry geo ) {
final SimpleFeature instance = SimpleFeatureBuilder.build(
geoMercType,
geoDefaults,
UUID.randomUUID().toString());
instance.setAttribute(
"pop",
Long.valueOf(100));
instance.setAttribute(
"pid",
UUID.randomUUID().toString());
instance.setAttribute(
"geometry",
geo);
return instance;
}
示例5: createSingleTimeFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private SimpleFeature createSingleTimeFeature(
final Date time ) {
final SimpleFeature instance = SimpleFeatureBuilder.build(
singleType,
singleDefaults,
UUID.randomUUID().toString());
instance.setAttribute(
"pop",
Long.valueOf(100));
instance.setAttribute(
"pid",
UUID.randomUUID().toString());
instance.setAttribute(
"when",
time);
instance.setAttribute(
"geometry",
factory.createPoint(new Coordinate(
27.25,
41.25)));
return instance;
}
示例6: createFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private SimpleFeature createFeature(
final Date sTime,
final Date eTime ) {
final SimpleFeature instance = SimpleFeatureBuilder.build(
rangeType,
rangeDefaults,
UUID.randomUUID().toString());
instance.setAttribute(
"pop",
Long.valueOf(100));
instance.setAttribute(
"pid",
UUID.randomUUID().toString());
instance.setAttribute(
"start",
sTime);
instance.setAttribute(
"end",
eTime);
instance.setAttribute(
"geometry",
factory.createPoint(new Coordinate(
27.25,
41.25)));
return instance;
}
示例7: create
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private SimpleFeature create(
final String pid ) {
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);
return newFeature;
}
示例8: 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;
}
示例9: createTabFeatures
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的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;
}
示例10: createFeatures
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的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;
}
示例11: createFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static SimpleFeature createFeature(final SimpleFeatureType featureType, final Statement statement) throws ParseException {
final String subject = StatementSerializer.writeSubject(statement);
final String predicate = StatementSerializer.writePredicate(statement);
final String object = StatementSerializer.writeObject(statement);
final String context = StatementSerializer.writeContext(statement);
// create the feature
final Object[] noValues = {};
// create the hash
final String statementId = Md5Hash.md5Base64(StatementSerializer.writeStatement(statement));
final SimpleFeature newFeature = SimpleFeatureBuilder.build(featureType, noValues, statementId);
// write the statement data to the fields
final Geometry geom = GeoParseUtils.getGeometry(statement, new GmlParser());
if(geom == null || geom.isEmpty() || !geom.isValid()) {
throw new ParseException("Could not create geometry for statement " + statement);
}
newFeature.setDefaultGeometry(geom);
newFeature.setAttribute(SUBJECT_ATTRIBUTE, subject);
newFeature.setAttribute(PREDICATE_ATTRIBUTE, predicate);
newFeature.setAttribute(OBJECT_ATTRIBUTE, object);
newFeature.setAttribute(CONTEXT_ATTRIBUTE, context);
// GeoWave does not support querying based on a user generated feature ID
// So, we create a separate ID attribute that it can query on.
newFeature.setAttribute(GEO_ID_ATTRIBUTE, statementId);
// preserve the ID that we created for this feature
// (set the hint to FALSE to have GeoTools generate IDs)
newFeature.getUserData().put(Hints.USE_PROVIDED_FID, java.lang.Boolean.TRUE);
return newFeature;
}
示例12: createFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static SimpleFeature createFeature(final SimpleFeatureType featureType, final Statement statement) throws ParseException {
final String subject = StatementSerializer.writeSubject(statement);
final String predicate = StatementSerializer.writePredicate(statement);
final String object = StatementSerializer.writeObject(statement);
final String context = StatementSerializer.writeContext(statement);
// create the feature
final Object[] noValues = {};
// create the hash
final String statementId = Md5Hash.md5Base64(StatementSerializer.writeStatement(statement));
final SimpleFeature newFeature = SimpleFeatureBuilder.build(featureType, noValues, statementId);
// write the statement data to the fields
final Geometry geom = GeoParseUtils.getGeometry(statement, new GmlParser());
if(geom == null || geom.isEmpty() || !geom.isValid()) {
throw new ParseException("Could not create geometry for statement " + statement);
}
newFeature.setDefaultGeometry(geom);
newFeature.setAttribute(SUBJECT_ATTRIBUTE, subject);
newFeature.setAttribute(PREDICATE_ATTRIBUTE, predicate);
newFeature.setAttribute(OBJECT_ATTRIBUTE, object);
newFeature.setAttribute(CONTEXT_ATTRIBUTE, context);
// preserve the ID that we created for this feature
// (set the hint to FALSE to have GeoTools generate IDs)
newFeature.getUserData().put(Hints.USE_PROVIDED_FID, java.lang.Boolean.TRUE);
return newFeature;
}
示例13: setup
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
@Before
public void setup()
throws SchemaException,
CQLException {
type = DataUtilities.createType(
"geostuff",
"geometry:Geometry:srid=4326,vis:java.lang.String,pop:java.lang.Long,pid:String");
descriptors = type.getAttributeDescriptors();
defaults = new Object[descriptors.size()];
int p = 0;
for (final AttributeDescriptor descriptor : descriptors) {
defaults[p++] = descriptor.getDefaultValue();
}
newFeature = SimpleFeatureBuilder.build(
type,
defaults,
UUID.randomUUID().toString());
newFeature.setAttribute(
"pop",
Long.valueOf(100));
newFeature.setAttribute(
"pid",
UUID.randomUUID().toString());
newFeature.setAttribute(
"vis",
"{\"pid\":\"TS\", \"geo.*\":\"S\"}");
newFeature.setAttribute(
"geometry",
factory.createPoint(new Coordinate(
43.454,
128.232)));
}
示例14: create
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private SimpleFeature create(
final Double val ) {
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(
"pop",
val);
newFeature.setAttribute(
"pid",
UUID.randomUUID().toString());
newFeature.setAttribute(
"when",
new Date());
newFeature.setAttribute(
"whennot",
new Date());
newFeature.setAttribute(
"geometry",
factory.createPoint(new Coordinate(
27.25,
41.25)));
return newFeature;
}
示例15: toSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
@Override
public SimpleFeature toSimpleFeature(
final AnalyticItemWrapper<T> item ) {
final SimpleFeature newFeature = SimpleFeatureBuilder.build(
type,
defaults,
item.getID());
int i = 0;
for (final Object value : ((SimpleFeature) item.getWrappedItem()).getAttributes()) {
if (value instanceof Geometry) {
final Geometry newValue = convert(
(Geometry) value,
shapeClass);
if (newValue == null) {
return null;
}
newFeature.setAttribute(
i++,
newValue);
}
else {
newFeature.setAttribute(
i++,
value);
}
}
return newFeature;
}