本文整理汇总了Java中org.geotools.feature.simple.SimpleFeatureBuilder.set方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureBuilder.set方法的具体用法?Java SimpleFeatureBuilder.set怎么用?Java SimpleFeatureBuilder.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.feature.simple.SimpleFeatureBuilder
的用法示例。
在下文中一共展示了SimpleFeatureBuilder.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: buildSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static SimpleFeature buildSimpleFeature(
final String locationName,
final Coordinate coordinate,
final Date startTime,
final Date endTime ) {
final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(
getPointSimpleFeatureType());
builder.set(
"locationName",
locationName);
builder.set(
"geometry",
GeometryUtils.GEOMETRY_FACTORY.createPoint(coordinate));
builder.set(
"startTime",
startTime);
builder.set(
"endTime",
endTime);
return builder.buildFeature(locationName);
}
示例3: 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));
}
示例4: buildSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static SimpleFeature buildSimpleFeature(
final SimpleFeatureBuilder builder,
final String city,
final String state,
final double population,
final double landArea,
final Coordinate coordinate ) {
builder.set(
CITY_ATTRIBUTE,
city);
builder.set(
STATE_ATTRIBUTE,
state);
builder.set(
POPULATION_ATTRIBUTE,
population);
builder.set(
LAND_AREA_ATTRIBUTE,
landArea);
builder.set(
GEOMETRY_ATTRIBUTE,
GeometryUtils.GEOMETRY_FACTORY.createPoint(coordinate));
return builder.buildFeature(UUID.randomUUID().toString());
}
示例5: conditionalSetObjectArray
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private void conditionalSetObjectArray(SimpleFeatureBuilder builder,
JsonObject obj,
String feature,
String nestedAttribute) {
JsonElement object = obj.get(feature);
if (object != null && object != JsonNull.INSTANCE) {
List<String> values = new ArrayList<>();
for (Iterator<JsonElement> iter = ((JsonArray) object).iterator(); iter.hasNext();) {
JsonElement next = iter.next();
if (next != null && next != JsonNull.INSTANCE) {
JsonElement attribute = ((JsonObject) next).get(nestedAttribute);
if (attribute != null && attribute != JsonNull.INSTANCE) {
values.add(attribute.getAsString());
}
}
}
if (!values.isEmpty()) {
builder.set(feature, Joiner.on(",").join(values));
}
}
}
示例6: buildSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static SimpleFeature buildSimpleFeature(final String locationName, final Coordinate coordinate) {
final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(getPointSimpleFeatureType());
builder.set("locationName", locationName);
builder.set("geometry", GeometryUtils.GEOMETRY_FACTORY.createPoint(coordinate));
return builder.buildFeature(locationName);
}
示例7: createTissotLayer
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
/**
* A method to create Tissot Indicatrices based on Whuber's answer to
* http://gis
* .stackexchange.com/questions/5068/how-to-create-an-accurate-tissot
* -indicatrix
*
* @param style
* - the style to draw the circles with
* @param gridBounds
* - the bounds of the map (may be increased in the method)
* @return a layer of Tissot Indicatrices (scaled for visibility).
*/
private Layer createTissotLayer(Style style, ReferencedEnvelope gridBounds) {
FeatureType type = createFeatureType(null,
gridBounds.getCoordinateReferenceSystem());
SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(
(SimpleFeatureType) type);
double step = 20.0;
GeometryFactory geomFac = new GeometryFactory();
double width = gridBounds.getWidth();
double height = gridBounds.getHeight();
int id = 0;
final ListFeatureCollection fc = new ListFeatureCollection(
(SimpleFeatureType) type);
double y = gridBounds.getMinY();
for (int iy = 0; iy < (height / step); iy++) {
double x = gridBounds.getMinX();
for (int ix = 0; ix < (width / step); ix++) {
Point p = geomFac.createPoint(new Coordinate(x, y));
sfb.set("the_geom", p);
SimpleFeature f = sfb.buildFeature("tissot2" + id);
fc.add(f);
x += step;
}
y += step;
}
Layer layer = new FeatureLayer(fc, style);
return layer;
}
示例8: buildSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static SimpleFeature buildSimpleFeature(
final String locationName,
final Coordinate coordinate ) {
final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(
getPointSimpleFeatureType());
builder.set(
"locationName",
locationName);
builder.set(
"geometry",
GeometryUtils.GEOMETRY_FACTORY.createPoint(coordinate));
return builder.buildFeature(locationName);
}
示例9: getGriddedFeatures
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
public static List<SimpleFeature> getGriddedFeatures(
final SimpleFeatureBuilder pointBuilder,
final int firstFeatureId ) {
int featureId = firstFeatureId;
final List<SimpleFeature> feats = new ArrayList<>();
for (int longitude = -180; longitude <= 180; longitude += 5) {
for (int latitude = -90; latitude <= 90; latitude += 5) {
pointBuilder.set(
"geometry",
GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(
longitude,
latitude)));
pointBuilder.set(
"TimeStamp",
new Date());
pointBuilder.set(
"Latitude",
latitude);
pointBuilder.set(
"Longitude",
longitude);
// Note since trajectoryID and comment are marked as nillable we
// don't need to set them (they default ot null).
final SimpleFeature sft = pointBuilder.buildFeature(String.valueOf(featureId));
feats.add(sft);
featureId++;
}
}
return feats;
}
示例10: setAttribute
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static void setAttribute(
final SimpleFeatureBuilder builder,
final String name,
final Object obj ) {
if ((builder.getFeatureType().getDescriptor(
name) != null) && (obj != null)) {
builder.set(
name,
obj);
}
}
示例11: writeScene
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
public static void writeScene(
final SimpleFeatureType sceneType,
final SimpleFeature firstBandOfScene,
final IndexWriter sceneWriter ) {
final SimpleFeatureBuilder bldr = new SimpleFeatureBuilder(
sceneType);
String fid = null;
for (int i = 0; i < sceneType.getAttributeCount(); i++) {
final AttributeDescriptor attr = sceneType.getDescriptor(i);
final String attrName = attr.getLocalName();
final Object attrValue = firstBandOfScene.getAttribute(attrName);
if (attrValue != null) {
bldr.set(
i,
attrValue);
if (attrName.equals(SceneFeatureIterator.ENTITY_ID_ATTRIBUTE_NAME)) {
fid = attrValue.toString();
}
}
}
if (fid != null) {
try {
sceneWriter.write(bldr.buildFeature(fid));
}
catch (IOException e) {
LOGGER.error(
"Unable to write scene",
e);
}
}
}
示例12: buildSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static SimpleFeature buildSimpleFeature(
final String city,
final String state,
final double population,
final double landArea,
final Coordinate coordinate ) {
final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(
simpleFeatureType);
builder.set(
CITY_ATTRIBUTE,
city);
builder.set(
STATE_ATTRIBUTE,
state);
builder.set(
POPULATION_ATTRIBUTE,
population);
builder.set(
LAND_AREA_ATTRIBUTE,
landArea);
builder.set(
GEOMETRY_ATTRIBUTE,
GeometryUtils.GEOMETRY_FACTORY.createPoint(coordinate));
return builder.buildFeature(UUID.randomUUID().toString());
}
示例13: buildSimpleFeature
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private static SimpleFeature buildSimpleFeature(
final String dataId,
final Geometry geo ) {
final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(
simpleFeatureType);
builder.set(
GEOMETRY_ATTRIBUTE,
geo);
return builder.buildFeature(dataId);
}
示例14: conditionalSetArray
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
private void conditionalSetArray(SimpleFeatureBuilder builder, JsonObject obj, String feature) {
JsonElement a = obj.get(feature);
if (a != null && a != JsonNull.INSTANCE) {
for (Iterator<JsonElement> i = ((JsonArray) a).iterator(); i.hasNext(); ) {
JsonElement e = i.next();
if (e != null && e != JsonNull.INSTANCE) {
builder.set(feature, e.getAsString());
}
}
}
}
示例15: createFeatureList
import org.geotools.feature.simple.SimpleFeatureBuilder; //导入方法依赖的package包/类
/**
* Create list of {@link SimpleFeature} based on a given {@link SimpleFeatureCollection}
* - for geometries that are not <code>null</code>
* - for new before constructed feature type
*
* @param featureCollection {@link FeatureCollection} to be transformed
* @return {@link SimpleFeature} list
* @throws IOException
* @throws FactoryException
*/
public List<SimpleFeature> createFeatureList(SimpleFeatureCollection featureCollection) throws IOException, FactoryException{
ArrayList<SimpleFeature> featureList = new ArrayList<SimpleFeature>();
SimpleFeatureIterator sfi = featureCollection.features();
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(this.sft_database);
int sridDecoded = -1;
while (sfi.hasNext()){
SimpleFeature sd = sfi.next();
if (sd == null){
LOG.warn("SimpleFeature is null => ignored");
continue;
}
String id = sd.getID();
for (String oldKey : this.hashMapAttributeNamesOrig_After.keySet()){
String newKey = this.hashMapAttributeNamesOrig_After.get(oldKey);
if (! newKey.equalsIgnoreCase("the_geom")){
Object objCurrent = sd.getAttribute(oldKey);
if (objCurrent != null){
featureBuilder.set(newKey, objCurrent);
}else{
LOG.warn("Attribute (old key: " + oldKey + ") null / not found => ignored");
continue;
}
}else{
Geometry gOld = (Geometry) sd.getDefaultGeometry();
if (gOld == null){
LOG.warn("Geometry of feature " + sd + " is null / not found => feature ignored");
continue;
}
// Check if SRID is set
if (gOld.getSRID() == 0){
if (sridDecoded == -1){
Integer srid = CRS.lookupEpsgCode(this.sft_original
.getCoordinateReferenceSystem(), true);
if (srid != null){
sridDecoded = srid.intValue();
}else{
assert(DEFAULT_SRID > 0);
sridDecoded = DEFAULT_SRID;
}
}
gOld.setSRID(sridDecoded);
}
featureBuilder.set(newKey, gOld);
}
}
SimpleFeature featureNew = featureBuilder.buildFeature(id);
featureList.add(featureNew);
}
sfi.close();
return featureList;
}