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

The following examples show how to use org.geotools.feature.simple.SimpleFeatureTypeBuilder#setNamespaceURI() . 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: 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 2
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 3
Source File: SchemaConverter.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static SimpleFeatureType schemaToFeatureType(
    final StructType schema,
    final String typeName) {
  final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
  typeBuilder.setName(typeName);
  typeBuilder.setNamespaceURI(BasicFeatureTypes.DEFAULT_NAMESPACE);
  try {
    typeBuilder.setCRS(CRS.decode("EPSG:4326", true));
  } catch (final FactoryException e) {
    LOGGER.error(e.getMessage(), e);
  }

  final AttributeTypeBuilder attrBuilder = new AttributeTypeBuilder();

  for (final StructField field : schema.fields()) {
    final AttributeDescriptor attrDesc = attrDescFromStructField(attrBuilder, field);

    typeBuilder.add(attrDesc);
  }

  return typeBuilder.buildFeatureType();
}
 
Example 4
Source File: Stanag4676Utils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static SimpleFeatureType createMissionSummaryDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(MISSION_SUMMARY);
    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("StartTime"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).buildDescriptor("EndTime"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("NumberOfFrames"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("Name"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("Security"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("ActiveObjectClass"));

    final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration();
    timeConfig.setStartRangeName("StartTime");
    timeConfig.setEndRangeName("EndTime");
    final SimpleFeatureType type = simpleFeatureTypeBuilder.buildFeatureType();
    timeConfig.updateType(type);
    return type;
  }
 
Example 5
Source File: FeatureDataAdapter.java    From geowave with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the namespace of the reprojected feature type associated with this data adapter
 *
 * @param namespaceURI - new namespace URI
 */
@Override
public void setNamespace(final String namespaceURI) {
  final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
  builder.init(reprojectedFeatureType);
  builder.setNamespaceURI(namespaceURI);
  reprojectedFeatureType = builder.buildFeatureType();
}
 
Example 6
Source File: AnalyticFeature.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static FeatureDataAdapter createFeatureAdapter(
    final String centroidDataTypeId,
    final String[] extraNumericDimensions,
    final String namespaceURI,
    final String SRID,
    final ClusterFeatureAttribute[] attributes,
    final Class<? extends Geometry> geometryClass) {
  try {
    final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    builder.setName(centroidDataTypeId);
    builder.setNamespaceURI(
        namespaceURI == null ? BasicFeatureTypes.DEFAULT_NAMESPACE : namespaceURI);
    builder.setSRS(SRID);
    builder.setCRS(CRS.decode(SRID, true));

    for (final ClusterFeatureAttribute attrVal : attributes) {
      builder.add(
          attrVal.name,
          attrVal.equals(ClusterFeatureAttribute.GEOMETRY) ? geometryClass : attrVal.type);
    }
    for (final String extraDim : extraNumericDimensions) {
      builder.add(extraDim, Double.class);
    }
    final FeatureDataAdapter adapter = new FeatureDataAdapter(builder.buildFeatureType());
    // TODO any consumers of this method will not be able to utilize
    // custom CRS
    adapter.init(new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions()));
    return adapter;
  } catch (final Exception e) {
    LOGGER.warn("Schema Creation Error.  Hint: Check the SRID.", e);
  }

  return null;
}
 
Example 7
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;
  }
 
Example 8
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 9
Source File: Stanag4676Utils.java    From geowave with Apache License 2.0 4 votes vote down vote up
public static SimpleFeatureType createTrackDataType() {

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

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(LineString.class).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(LineString.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(Date.class).buildDescriptor("StartTime"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).buildDescriptor("EndTime"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Duration"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("MinSpeed"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("MaxSpeed"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("AvgSpeed"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("Distance"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("StartLatitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("StartLongitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("EndLatitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("EndLongitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailStartLatitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailStartLongitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailEndLatitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("DetailEndLongitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("PointCount"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("EventCount"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("TrackStatus"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("TurnCount"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("UTurnCount"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).buildDescriptor("StopCount"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("StopDuration"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).buildDescriptor("AvgStopDuration"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("Classification"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("ObjectClass"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("ObjectClassConf"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("ObjectClassRel"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).buildDescriptor("ObjectClassTime"));

    simpleFeatureTypeBuilder.setDefaultGeometry("geometry");

    final TimeDescriptorConfiguration timeConfig = new TimeDescriptorConfiguration();
    timeConfig.setStartRangeName("StartTime");
    timeConfig.setEndRangeName("EndTime");
    final SimpleFeatureType type = simpleFeatureTypeBuilder.buildFeatureType();
    timeConfig.updateType(type);
    return type;
  }
 
Example 10
Source File: KMeansUtils.java    From geowave with Apache License 2.0 4 votes vote down vote up
public static DataTypeAdapter writeClusterCentroids(
    final KMeansModel clusterModel,
    final DataStorePluginOptions outputDataStore,
    final String centroidAdapterName,
    final ScaledTemporalRange scaledRange) {
  final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
  typeBuilder.setName(centroidAdapterName);
  typeBuilder.setNamespaceURI(BasicFeatureTypes.DEFAULT_NAMESPACE);

  try {
    typeBuilder.setCRS(CRS.decode("EPSG:4326", true));
  } catch (final FactoryException fex) {
    LOGGER.error(fex.getMessage(), fex);
  }

  final AttributeTypeBuilder attrBuilder = new AttributeTypeBuilder();

  typeBuilder.add(
      attrBuilder.binding(Geometry.class).nillable(false).buildDescriptor(
          Geometry.class.getName().toString()));

  if (scaledRange != null) {
    typeBuilder.add(attrBuilder.binding(Date.class).nillable(false).buildDescriptor("Time"));
  }

  typeBuilder.add(
      attrBuilder.binding(Integer.class).nillable(false).buildDescriptor("ClusterIndex"));

  final SimpleFeatureType sfType = typeBuilder.buildFeatureType();
  final SimpleFeatureBuilder sfBuilder = new SimpleFeatureBuilder(sfType);

  final FeatureDataAdapter featureAdapter = new FeatureDataAdapter(sfType);

  final DataStore featureStore = outputDataStore.createDataStore();
  final Index featureIndex =
      new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions());
  featureStore.addType(featureAdapter, featureIndex);
  try (Writer writer = featureStore.createWriter(featureAdapter.getTypeName())) {
    for (final Vector center : clusterModel.clusterCenters()) {
      final int index = clusterModel.predict(center);

      final double lon = center.apply(0);
      final double lat = center.apply(1);

      sfBuilder.set(
          Geometry.class.getName(),
          GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(lon, lat)));

      if ((scaledRange != null) && (center.size() > 2)) {
        final double timeVal = center.apply(2);

        final Date time = scaledRange.valueToTime(timeVal);

        sfBuilder.set("Time", time);

        LOGGER.warn("Write time: " + time);
      }

      sfBuilder.set("ClusterIndex", index);

      final SimpleFeature sf = sfBuilder.buildFeature("Centroid-" + index);

      writer.write(sf);
    }
  }

  return featureAdapter;
}
 
Example 11
Source File: CreateSampleDataTest.java    From sldeditor with GNU General Public License v3.0 3 votes vote down vote up
/** Test method for {@link com.sldeditor.datasource.impl.CreateSampleData#getDataStore()}. */
@Test
public void testGetDataStore() {

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();

    String typeName = "test type name";
    b.setName(typeName);

    String namespace = null;
    b.setNamespaceURI(namespace);

    // add a geometry property
    b.setCRS(DefaultGeographicCRS.WGS84); // set crs first

    b.add("the_geom", Polygon.class);

    b.setDefaultGeometry("the_geom");

    // Build the feature type
    SimpleFeatureType schema = b.buildFeatureType();

    CreateSampleData sampleData = new CreateSampleData();
    sampleData.create(null, null);
    sampleData.create(schema, null);

    DataStore dataStore = sampleData.getDataStore();

    assertTrue(dataStore != null);
    assertEquals(GeometryTypeEnum.POLYGON, sampleData.getGeometryType());
}