Java Code Examples for org.geotools.feature.simple.SimpleFeatureTypeBuilder#add()

The following examples show how to use org.geotools.feature.simple.SimpleFeatureTypeBuilder#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Shape.java    From constellation with Apache License 2.0 6 votes vote down vote up
private static SimpleFeatureType generateFeatureType(final String uuid, final String srs,
        final String geometryName, final Class<? extends Geometry> geometryClass,
        final Map<String, Class<?>> attributes) {
    final SimpleFeatureTypeBuilder featureTypeBuilder = new SimpleFeatureTypeBuilder();
    featureTypeBuilder.setName(uuid);
    featureTypeBuilder.setSRS(srs);
    featureTypeBuilder.add(geometryName, geometryClass);
    featureTypeBuilder.add(NAME_ATTRIBUTE, String.class);
    featureTypeBuilder.add(CENTROID_LATITUDE_ATTRIBUTE, Double.class);
    featureTypeBuilder.add(CENTROID_LONGITUDE_ATTRIBUTE, Double.class);
    featureTypeBuilder.add(RADIUS_ATTRIBUTE, Double.class);
    if (attributes != null) {
        attributes.forEach(featureTypeBuilder::add);
    }
    return featureTypeBuilder.buildFeatureType();
}
 
Example 2
Source File: TinHandler.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
public SimpleFeatureCollection toFeatureCollectionOthers() {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("points");
    b.setCRS(crs);

    DefaultFeatureCollection newCollection = new DefaultFeatureCollection();
    b.add("the_geom", Point.class);
    b.add("elev", Double.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    for( Coordinate c : leftOverCoordinateList ) {
        Object[] values = new Object[]{gf.createPoint(c), c.z};
        builder.addAll(values);
        SimpleFeature feature = builder.buildFeature(null);
        newCollection.add(feature);
    }
    return newCollection;
}
 
Example 3
Source File: Stanag4676Utils.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static SimpleFeatureType createMissionFrameDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(MISSION_FRAME);
    simpleFeatureTypeBuilder.setNamespaceURI(NAMESPACE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Polygon.class).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("Mission"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).buildDescriptor("TimeStamp"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("FrameNumber"));

    final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration();
    timeConfig.setTimeName("TimeStamp");
    final SimpleFeatureType type = simpleFeatureTypeBuilder.buildFeatureType();
    timeConfig.updateType(type);
    return type;
  }
 
Example 4
Source File: CentroidManagerGeoWave.java    From geowave with Apache License 2.0 6 votes vote down vote up
private static SimpleFeatureType createFeatureType(
    final SimpleFeatureType featureType,
    final Class<? extends Geometry> shapeClass) {
  try {
    final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    builder.setName(featureType.getName().getLocalPart());
    builder.setNamespaceURI(featureType.getName().getNamespaceURI());
    builder.setCRS(featureType.getCoordinateReferenceSystem());
    for (final AttributeDescriptor attr : featureType.getAttributeDescriptors()) {
      if (attr.getType() instanceof GeometryType) {
        builder.add(attr.getLocalName(), shapeClass);
      } else {
        builder.add(attr.getLocalName(), attr.getType().getBinding());
      }
    }
    return builder.buildFeatureType();
  } catch (final Exception e) {
    LOGGER.warn("Schema Creation Error.  Hint: Check the SRID.", e);
  }

  return null;
}
 
Example 5
Source File: TdriveUtils.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static SimpleFeatureType createTdrivePointDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(TDRIVE_POINT_FEATURE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Geometry.class).nillable(false).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(false).buildDescriptor("taxiid"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("pointinstance"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).nillable(true).buildDescriptor("Timestamp"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Latitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Longitude"));

    return simpleFeatureTypeBuilder.buildFeatureType();
  }
 
Example 6
Source File: OmsZonalStats.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
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);
    b.add(SUM, 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);
}
 
Example 7
Source File: GeopaparazziUtilities.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public static SimpleFeatureType getMediaFeaturetype() {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("geopaparazzimediapoints");
    b.setCRS(DefaultGeographicCRS.WGS84);
    b.add("the_geom", Point.class);

    b.add(IMAGES_altimFN, String.class);
    b.add(IMAGES_tsFN, String.class);
    b.add(IMAGES_azimFN, Double.class);
    b.add(IMAGES_imageidFN, Long.class);
    SimpleFeatureType featureType = b.buildFeatureType();
    return featureType;
}
 
Example 8
Source File: GeometryDataSetGeneratorTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 9
Source File: LasUtils.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Dump an overview shapefile for a las folder.
 * 
 * @param folder the folder.
 * @param crs the crs to use.
 * @throws Exception
 */
public static void dumpLasFolderOverview( String folder, CoordinateReferenceSystem crs ) throws Exception {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("overview");
    b.setCRS(crs);
    b.add("the_geom", Polygon.class);
    b.add("name", String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

    DefaultFeatureCollection newCollection = new DefaultFeatureCollection();

    OmsFileIterator iter = new OmsFileIterator();
    iter.inFolder = folder;
    iter.fileFilter = new FileFilter(){
        public boolean accept( File pathname ) {
            return pathname.getName().endsWith(".las");
        }
    };
    iter.process();

    List<File> filesList = iter.filesList;

    for( File file : filesList ) {
        try (ALasReader r = new LasReaderBuffered(file, crs)) {
            r.open();
            ReferencedEnvelope3D envelope = r.getHeader().getDataEnvelope();
            Polygon polygon = GeometryUtilities.createPolygonFromEnvelope(envelope);
            Object[] objs = new Object[]{polygon, r.getLasFile().getName()};
            builder.addAll(objs);
            SimpleFeature feature = builder.buildFeature(null);
            newCollection.add(feature);
        }
    }

    File folderFile = new File(folder);
    File outFile = new File(folder, "overview_" + folderFile.getName() + ".shp");
    OmsVectorWriter.writeVector(outFile.getAbsolutePath(), newCollection);
}
 
Example 10
Source File: GpxUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static SimpleFeatureType createGPXRouteDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(GPX_ROUTE_FEATURE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Geometry.class).nillable(true).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Name"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Long.class).nillable(true).buildDescriptor("NumberPoints"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("TrackId"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Symbol"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("User"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Description"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Source"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Comment"));

    return simpleFeatureTypeBuilder.buildFeatureType();
  }
 
Example 11
Source File: GeometryTranslator.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
private SimpleFeature createPointTextFeature( String typeName, String layerName, int id,
        Coordinate coord, String textString ) {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(typeName);
    b.setCRS(crs);
    b.add(THE_GEOM, Point.class);
    b.add("text", String.class);
    b.add(LAYER, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Geometry point = gF.createPoint(coord);
    Object[] values = new Object[]{point, textString, layerName};
    builder.addAll(values);
    return builder.buildFeature(typeName + "." + id);
}
 
Example 12
Source File: FeatureFigureEditorApp.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private SimpleFeatureType createSimpleFeatureType(String typeName, Class<?> geometryType, SimpleFeatureType defaults) {
    SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder();
    if (defaults != null) {
        //sftb.init(defaults);
    }
    DefaultGeographicCRS crs = DefaultGeographicCRS.WGS84;
    sftb.setCRS(crs);
    sftb.setName(typeName);
    sftb.add("geom", geometryType);
    sftb.add("style", String.class);
    sftb.setDefaultGeometry("geom");
    return sftb.buildFeatureType();
}
 
Example 13
Source File: ShapefileTool.java    From geowave with Apache License 2.0 5 votes vote down vote up
private static SimpleFeatureType createFeatureType(final String typeName, final boolean isPoint) {

    final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    builder.setName(typeName);
    builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate reference
    // system

    // add attributes in order
    builder.add("the_geom", isPoint ? Point.class : Polygon.class);
    builder.length(15).add("Name", String.class); // <- 15 chars width for name field

    // build the type

    return builder.buildFeatureType();
  }
 
Example 14
Source File: SpatialTemporalQueryExample.java    From geowave with Apache License 2.0 5 votes vote down vote up
private static SimpleFeatureType getPointSimpleFeatureType() {
  final String NAME = "PointSimpleFeatureType";
  final SimpleFeatureTypeBuilder sftBuilder = new SimpleFeatureTypeBuilder();
  final AttributeTypeBuilder atBuilder = new AttributeTypeBuilder();
  sftBuilder.setName(NAME);
  sftBuilder.add(atBuilder.binding(String.class).nillable(false).buildDescriptor("locationName"));
  sftBuilder.add(atBuilder.binding(Geometry.class).nillable(false).buildDescriptor("geometry"));
  sftBuilder.add(atBuilder.binding(Date.class).nillable(false).buildDescriptor("startTime"));
  sftBuilder.add(atBuilder.binding(Date.class).nillable(false).buildDescriptor("endTime"));

  return sftBuilder.buildFeatureType();
}
 
Example 15
Source File: GeometryTranslator.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Builds a line feature from a dwg arc.
 */
public SimpleFeature convertDwgArc( String typeName, String layerName, DwgArc arc, int id ) {
    double[] c = arc.getCenter();
    Point2D center = new Point2D.Double(c[0], c[1]);
    double radius = (arc).getRadius();
    double initAngle = Math.toDegrees((arc).getInitAngle());
    double endAngle = Math.toDegrees((arc).getEndAngle());
    Point2D[] ptos = GisModelCurveCalculator.calculateGisModelArc(center, radius, initAngle,
            endAngle);
    CoordinateList coordList = new CoordinateList();
    for( int j = 0; j < ptos.length; j++ ) {
        Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY(), 0.0);
        coordList.add(coord);
    }

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(typeName);
    b.setCRS(crs);
    b.add(THE_GEOM, LineString.class);
    b.add(LAYER, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Geometry lineString = gF.createLineString(coordList.toCoordinateArray());
    Object[] values = new Object[]{lineString, layerName};
    builder.addAll(values);
    return builder.buildFeature(typeName + "." + id);
}
 
Example 16
Source File: Stanag4676Utils.java    From geowave with Apache License 2.0 4 votes vote down vote up
public static SimpleFeatureType createMotionDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(MOTION_POINT);
    simpleFeatureTypeBuilder.setNamespaceURI(NAMESPACE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Point.class).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("Mission"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("TrackNumber"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("TrackUUID"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("TrackItemUUID"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("MotionEvent"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).buildDescriptor("StartTime"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).buildDescriptor("EndTime"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("Classification"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Latitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Longitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Elevation"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("FrameNumber"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("PixelRow"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("PixelColumn"));

    final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration();
    timeConfig.setStartRangeName("StartTime");
    timeConfig.setEndRangeName("EndTime");
    final SimpleFeatureType type = simpleFeatureTypeBuilder.buildFeatureType();
    timeConfig.updateType(type);
    return type;
  }
 
Example 17
Source File: FeatureWritableTest.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Test
public void test() throws IOException {

  final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
  typeBuilder.setName("test");
  typeBuilder.setCRS(GeometryUtils.getDefaultCRS()); // <- Coordinate
  // reference
  // add attributes in order
  typeBuilder.add("geom", Point.class);
  typeBuilder.add("name", String.class);
  typeBuilder.add("count", Long.class);

  // build the type
  final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(typeBuilder.buildFeatureType());

  final SimpleFeatureType featureType = builder.getFeatureType();

  @SuppressWarnings("unchecked")
  final SimpleFeature newFeature =
      FeatureDataUtils.buildFeature(
          featureType,
          new Pair[] {
              Pair.of("geom", factory.createPoint(new Coordinate(27.25, 41.25))),
              Pair.of("count", Long.valueOf(100))});

  final FeatureWritable writable = new FeatureWritable(featureType, newFeature);

  final ByteArrayOutputStream bos = new ByteArrayOutputStream();
  try (DataOutputStream dos = new DataOutputStream(bos)) {
    writable.write(dos);
    dos.flush();
  }

  final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
  try (DataInputStream is = new DataInputStream(bis)) {
    writable.readFields(is);
  }

  assertEquals(newFeature.getDefaultGeometry(), writable.getFeature().getDefaultGeometry());
  assertEquals(
      featureType.getCoordinateReferenceSystem().getCoordinateSystem(),
      writable.getFeature().getFeatureType().getCoordinateReferenceSystem().getCoordinateSystem());
}
 
Example 18
Source File: OmsLinesPolygonizer.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
@Execute
public void process() throws Exception {
    checkNull(inMap);

    outMap = new DefaultFeatureCollection();

    EGeometryType geometryType = EGeometryType.forGeometryDescriptor(inMap.getSchema().getGeometryDescriptor());
    switch( geometryType ) {
    case LINESTRING:
    case MULTILINESTRING:
        break;
    default:
        throw new ModelsIllegalargumentException("The module only works with line layers.", this, pm);
    }

    List<Geometry> linesList = FeatureUtilities.featureCollectionToGeometriesList(inMap, true, null);

    // Polygonization
    final Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(linesList);
    @SuppressWarnings("unchecked")
    final Collection<Polygon> polygonizedLines = polygonizer.getPolygons();

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("polygonized");
    b.setCRS(inMap.getSchema().getCoordinateReferenceSystem());
    b.add("the_geom", Polygon.class);
    b.add(fNewId, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);

    List<Geometry> pointGeometries = new ArrayList<Geometry>();
    if (inPoints != null) {
        fId = FeatureUtilities.findAttributeName(inPoints.getSchema(), fId);
        pointGeometries = FeatureUtilities.featureCollectionToGeometriesList(inPoints, false, fId);
    }

    pm.beginTask("Generating polygon features...", polygonizedLines.size());
    int index = 0;
    for( Polygon polygon : polygonizedLines ) {
        String attribute = String.valueOf(index++);
        if (inPoints != null) {
            attribute = "-";
            for( Geometry point : pointGeometries ) {
                if (polygon.contains(point)) {
                    attribute = point.getUserData().toString();
                    break;
                }
            }
        }

        Object[] values = new Object[]{polygon, attribute};
        builder.addAll(values);
        SimpleFeature feature = builder.buildFeature(null);
        ((DefaultFeatureCollection) outMap).add(feature);

        pm.worked(1);
    }
    pm.done();
}
 
Example 19
Source File: InLineFeatureModel.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/** Adds the new column. */
public void addNewColumn() {
    if (featureCollection != null) {
        String attributeName = getUniqueAttributeName();

        columnList.add(attributeName);

        // Populate field names
        SimpleFeatureTypeBuilder featureTypeBuilder = new SimpleFeatureTypeBuilder();
        featureTypeBuilder.init(featureCollection.getSchema());
        featureTypeBuilder.add(attributeName, String.class);

        SimpleFeatureType newFeatureType = featureTypeBuilder.buildFeatureType();

        String typeName = userLayer.getInlineFeatureType().getTypeName();
        try {
            SimpleFeatureSource featureSource =
                    userLayer.getInlineFeatureDatastore().getFeatureSource(typeName);

            SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(newFeatureType);

            ArrayList<SimpleFeature> featureList = new ArrayList<>();

            SimpleFeatureIterator it = featureSource.getFeatures().features();
            try {
                while (it.hasNext()) {
                    SimpleFeature sf = it.next();
                    sfb.addAll(sf.getAttributes());
                    sfb.add(new String(""));
                    featureList.add(sfb.buildFeature(null));
                }
            } finally {
                it.close();
            }

            SimpleFeatureCollection collection =
                    new ListFeatureCollection(newFeatureType, featureList);

            featureCollection = collection;
            cachedFeature = null;
            lastRow = -1;
            DataStore dataStore = DataUtilities.dataStore(collection);
            userLayer.setInlineFeatureDatastore(dataStore);
            userLayer.setInlineFeatureType(newFeatureType);

        } catch (IOException e) {
            ConsoleManager.getInstance().exception(this, e);
        }

        this.fireTableStructureChanged();
        this.fireTableDataChanged();

        if (parentObj != null) {
            parentObj.inlineFeatureUpdated();
        }
    }
}
 
Example 20
Source File: Stanag4676Utils.java    From geowave with Apache License 2.0 4 votes vote down vote up
public static SimpleFeatureType createPointDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(TRACK_POINT);
    simpleFeatureTypeBuilder.setNamespaceURI(NAMESPACE);

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Point.class).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Point.class).buildDescriptor("DetailGeometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("Mission"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("TrackNumber"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("TrackUUID"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("TrackItemUUID"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("TrackPointSource"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).buildDescriptor("TimeStamp"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Speed"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Course"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("Classification"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Latitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Longitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Elevation"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailLatitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailLongitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailElevation"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("FrameNumber"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("PixelRow"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("PixelColumn"));

    simpleFeatureTypeBuilder.setDefaultGeometry("geometry");

    final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration();
    timeConfig.setTimeName("TimeStamp");
    final SimpleFeatureType type = simpleFeatureTypeBuilder.buildFeatureType();
    timeConfig.updateType(type);
    return type;
  }