Examples of SimpleFeatureBuilder


Examples of org.geotools.feature.simple.SimpleFeatureBuilder

            protected String transformFeatureTypeName(String originalName) {
                return "oaks";
            }
        };

        SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(type);
        WKTReader reader = new WKTReader();
        sfb.set("the_geom", reader.read("POINT (0.002 0.0008)"));
        sfb.set("FID", "023");
        sfb.set("NAME", "Old oak");
        SimpleFeature feature = sfb.buildFeature(null);
        FeatureCollection<SimpleFeatureType, SimpleFeature> fc = DataUtilities.collection(feature);

        FeatureStore<SimpleFeatureType, SimpleFeature> store = (FeatureStore) rts.getFeatureSource("oaks");
        List<FeatureId> ids = store.addFeatures(fc);
        assertEquals(1, ids.size());
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureBuilder

          attrList[unionAttrPosition] = attrValue;
        }
      }
    }
    // creates the new feature
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(
        unionFeatureType);
    builder.addAll(attrList);
    // SimpleFeature product = unionFeatureType.create(attrList);
    SimpleFeature product = builder.buildFeature(null);
    product.setDefaultGeometry(this.geometry);

    return product;
  }
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureBuilder

        b.setName(kml.getName());
        b.setCRS(crs);
        b.add("name", String.class);
        b.add("the_geom", Geometry.class); //$NON-NLS-1$
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

        while( (f = (SimpleFeature) parser.parse()) != null ) {
            Geometry geometry = (Geometry) f.getDefaultGeometry();
            Object nameAttribute = null;
            try {
                nameAttribute = f.getAttribute("name");
            } catch (Exception e){
                // ignore name attribute
            }
            builder.addAll(new Object[]{nameAttribute, geometry });
            SimpleFeature feature = builder.buildFeature(type.getTypeName() + "." + index++); //$NON-NLS-1$
            newCollection.add(feature);
        }

        return newCollection;
    }
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureBuilder

        simpleFeatureTypeBuilder.setCRS(sourceCRS);
        simpleFeatureTypeBuilder.add("GEOM", binding);
        simpleFeatureTypeBuilder.addAll(featureSchema);
        SimpleFeatureType simpleFeatureTypeWithCRS = simpleFeatureTypeBuilder
            .buildFeatureType();
        SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
            simpleFeatureTypeWithCRS);
        featureBuilder.add(JTSGeometry);

        for (String hNodeId : geomHNodeIdList) {
          Node node = row.getNode(hNodeId);
          if (node.hasNestedTable())
            featureBuilder.add("Nested table");
          else {
            String colValue = node.getValue().asString();
            featureBuilder.add(colValue);
          }
        }
        SimpleFeature feature = featureBuilder.buildFeature(null);
        features.add(feature);
      } catch (Exception e) {
        logger.error("Error creating geometry! Skipping it.", e);
        continue;
      }
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureBuilder

  public static SimpleFeature json2Feature(String feature,
      SimpleFeatureType featureType) throws JSONException {
    SimpleFeature result = null;

    JSONObject objFeature = new JSONObject(feature);
    SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
        featureType);

    result = jsonObject2Feature(objFeature, featureBuilder);

    return result;
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureBuilder

        .newCollection();

    if (features != null && !"".equals(features)) {
      JSONArray arrayFeatures = new JSONArray(features);

      SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
          featureType);

      for (int i = 0, count = arrayFeatures.length(); i < count; i++) {
        JSONObject objFeature = arrayFeatures.getJSONObject(i);
        SimpleFeature featureResult = jsonObject2Feature(objFeature,
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureBuilder

                typeBuilder.add(Constants.Style.Grid.ATT_X_DISPLACEMENT, Double.class);
                typeBuilder.add(Constants.Style.Grid.ATT_Y_DISPLACEMENT, Double.class);
                typeBuilder.setName(Constants.Style.Grid.NAME);

                SimpleFeatureType featureType = typeBuilder.buildFeatureType();
                SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
                final DefaultFeatureCollection features;
                if (layerData.numberOfLines != null) {
                    features = createFeaturesFromNumberOfLines(mapContext, featureBuilder, layerData);
                } else {
                    features = createFeaturesFromSpacing(mapContext, featureBuilder, layerData);
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureBuilder

            SimpleFeatureType dstSchema = dstDs.getSchema(layer);
            featureStoreData.setTransaction(tx);
            SimpleFeatureType srcSchema = sourceFC.getSchema();
            List<AttributeDescriptor> srcAttributeDescriptor = srcSchema.getAttributeDescriptors();

            SimpleFeatureBuilder featureBuilderData = new SimpleFeatureBuilder(dstSchema);
            SimpleFeatureIterator featureIterator = sourceFC.features();
            boolean hasFinished = false;
            int i = 0;
            Set<String> loggedMissingAttrib = new HashSet<String>();
            while (!hasFinished) { // TODO: refacotr this nested loop!!!

              //DamianoGiampaoli 03/11/2014
              //TEST IT!!!
              // Due to the upgrade needed from the Geotools 8-SNAPSHOT to geotools 10.8 in order to support GeoBatch 1.4.x
              // The add(SimpleFeature) method of SimpleFeatureCollection cannot be used anymore so a List<SimpleFeature> must be used.
                //SimpleFeatureCollection sfcData = FeatureCollections.newCollection();
                List<SimpleFeature> sfcData = new ArrayList<SimpleFeature>();
               
                boolean exitForIntermediateSaving = false;

                while (featureIterator.hasNext() && !exitForIntermediateSaving) {
                    i++;

                    exitForIntermediateSaving = ((i % ITEM_X_PAGE) == 0);

                    SimpleFeature sf = featureIterator.next();
                    SimpleFeature data = featureBuilderData.buildFeature(sf.getID());
                    for (int j = 0; j < srcAttributeDescriptor.size(); j++) {
                        String srcName = srcAttributeDescriptor.get(j).getLocalName();
                        String dstName = srcName.toLowerCase(); // FIXME: this is a worksroung for SHP 2 PG attrib name conversion. make it general!

                        Property p = sf.getProperty(srcName);
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureBuilder

            } else {
                throw ScriptRuntime.constructError("Error", "Feature config must include schema or properties.");
            }
        }

        SimpleFeatureBuilder builder = new SimpleFeatureBuilder((SimpleFeatureType) schema.unwrap());

        if (properties != null) {
            Object[] names = properties.getIds();
            for (Object nameObj : names) {
                String name = (String) nameObj;
                if (schema.get(name) == null) {
                    throw ScriptRuntime.constructError("Error", "Feature schema has no field with the given name: " + name);
                }
                Object value = properties.get(name, properties);
                builder.set(name, jsToJava(value));
            }
        }
       
        String id = null;
        if (config.has("id", config)) {
            id = Context.toString(config.get("id", config));
        }

        feature = builder.buildFeature(id);
    }
View Full Code Here

Examples of org.geotools.feature.simple.SimpleFeatureBuilder

            ImmutableList<Optional<Object>> values = feature.getValues();
            ImmutableList<PropertyDescriptor> oldDescriptors = oldRevFeatureType
                    .sortedDescriptors();
            ImmutableList<PropertyDescriptor> newDescriptors = newRevFeatureType
                    .sortedDescriptors();
            SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(
                    (SimpleFeatureType) newRevFeatureType.type());
            Map<Name, Optional<?>> attrs = Maps.newHashMap();
            for (int i = 0; i < oldDescriptors.size(); i++) {
                PropertyDescriptor descriptor = oldDescriptors.get(i);
                if (newDescriptors.contains(descriptor)) {
                    Optional<Object> value = values.get(i);
                    attrs.put(descriptor.getName(), value);
                }
            }
            Set<Entry<PropertyDescriptor, AttributeDiff>> featureDiffs = diff.getDiffs().entrySet();
            for (Iterator<Entry<PropertyDescriptor, AttributeDiff>> iterator = featureDiffs
                    .iterator(); iterator.hasNext();) {
                Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next();
                if (!entry.getValue().getType().equals(TYPE.REMOVED)) {
                    Optional<?> oldValue = attrs.get(entry.getKey().getName());
                    attrs.put(entry.getKey().getName(), entry.getValue().applyOn(oldValue));
                }
            }
            Set<Entry<Name, Optional<?>>> entries = attrs.entrySet();
            for (Iterator<Entry<Name, Optional<?>>> iterator = entries.iterator(); iterator
                    .hasNext();) {
                Entry<Name, Optional<?>> entry = iterator.next();
                featureBuilder.set(entry.getKey(), entry.getValue().orNull());

            }

            SimpleFeature featureToInsert = featureBuilder.buildFeature(NodeRef.nodeFromPath(path));
            workTree.insert(NodeRef.parentPath(path), featureToInsert);

        }
        ImmutableList<FeatureTypeDiff> alteredTrees = patch.getAlteredTrees();
        for (FeatureTypeDiff diff : alteredTrees) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.