org.geotools.feature.AttributeTypeBuilder Java Examples

The following examples show how to use org.geotools.feature.AttributeTypeBuilder. 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: SchemaConverter.java    From geowave with Apache License 2.0 6 votes vote down vote up
private static AttributeDescriptor attrDescFromStructField(
    final AttributeTypeBuilder attrBuilder,
    final StructField field) {
  if (field.name().equals("geom")) {
    return attrBuilder.binding(Geometry.class).nillable(false).buildDescriptor("geom");
  }
  if (field.dataType() == DataTypes.StringType) {
    return attrBuilder.binding(String.class).buildDescriptor(field.name());
  } else if (field.dataType() == DataTypes.DoubleType) {
    return attrBuilder.binding(Double.class).buildDescriptor(field.name());
  } else if (field.dataType() == DataTypes.FloatType) {
    return attrBuilder.binding(Float.class).buildDescriptor(field.name());
  } else if (field.dataType() == DataTypes.LongType) {
    return attrBuilder.binding(Long.class).buildDescriptor(field.name());
  } else if (field.dataType() == DataTypes.IntegerType) {
    return attrBuilder.binding(Integer.class).buildDescriptor(field.name());
  } else if (field.dataType() == DataTypes.BooleanType) {
    return attrBuilder.binding(Boolean.class).buildDescriptor(field.name());
  } else if (field.dataType() == DataTypes.TimestampType) {
    return attrBuilder.binding(Date.class).buildDescriptor(field.name());
  }

  return null;
}
 
Example #2
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 #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: 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 #5
Source File: GeoLifeUtils.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static SimpleFeatureType createGeoLifeTrackDataType() {

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

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Geometry.class).nillable(true).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).nillable(true).buildDescriptor("StartTimeStamp"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).nillable(true).buildDescriptor("EndTimeStamp"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Long.class).nillable(true).buildDescriptor("Duration"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Long.class).nillable(true).buildDescriptor("NumberPoints"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("TrackId"));
    return simpleFeatureTypeBuilder.buildFeatureType();
  }
 
Example #6
Source File: GeoLifeUtils.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static SimpleFeatureType createGeoLifePointDataType() {

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

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Geometry.class).nillable(false).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(false).buildDescriptor("trackid"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.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"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Elevation"));

    return simpleFeatureTypeBuilder.buildFeatureType();
  }
 
Example #7
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
private void addDateWithFormatToFeatureType(String format) {
    SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
    typeBuilder.init(featureType);

    AttributeDescriptor dateAtt;
    AttributeTypeBuilder dateAttBuilder = new AttributeTypeBuilder();
    dateAttBuilder.setName("dateAttrWithFormat");
    dateAttBuilder.setBinding(Date.class);
    dateAtt = dateAttBuilder.buildDescriptor("dateAttrWithFormat", dateAttBuilder.buildType());
    dateAtt.getUserData().put(DATE_FORMAT, format);
    typeBuilder.add(dateAtt);

    featureType = typeBuilder.buildFeatureType();
    setFilterBuilder();
}
 
Example #8
Source File: AbstractVectorAggregationTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
public List<SimpleFeature> generateFeatures() {
  final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
  final AttributeTypeBuilder ab = new AttributeTypeBuilder();

  typeBuilder.setName("features");
  typeBuilder.add(ab.binding(Geometry.class).nillable(false).buildDescriptor(GEOMETRY_COLUMN));
  typeBuilder.add(ab.binding(Date.class).nillable(true).buildDescriptor(TIMESTAMP_COLUMN));
  typeBuilder.add(ab.binding(Double.class).nillable(false).buildDescriptor(LATITUDE_COLUMN));
  typeBuilder.add(ab.binding(Double.class).nillable(false).buildDescriptor(LONGITUDE_COLUMN));
  typeBuilder.add(ab.binding(Long.class).nillable(false).buildDescriptor(VALUE_COLUMN));
  typeBuilder.add(ab.binding(String.class).nillable(true).buildDescriptor(ODDS_NULL_COLUMN));
  typeBuilder.add(ab.binding(String.class).nillable(true).buildDescriptor(ALL_NULL_COLUMN));

  List<SimpleFeature> features = Lists.newArrayList();
  final SimpleFeatureBuilder featureBuilder =
      new SimpleFeatureBuilder(typeBuilder.buildFeatureType());

  int featureId = 0;
  for (int longitude = -180; longitude <= 180; longitude += 1) {
    for (int latitude = -90; latitude <= 90; latitude += 1) {
      featureBuilder.set(
          GEOMETRY_COLUMN,
          GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(longitude, latitude)));
      featureBuilder.set(TIMESTAMP_COLUMN, new Date());
      featureBuilder.set(LATITUDE_COLUMN, latitude);
      featureBuilder.set(LONGITUDE_COLUMN, longitude);
      featureBuilder.set(VALUE_COLUMN, (long) featureId);
      if (featureId % 2 == 0) {
        featureBuilder.set(ODDS_NULL_COLUMN, "NotNull");
      }

      features.add(featureBuilder.buildFeature(String.valueOf(featureId)));
      featureId++;
    }
  }
  return features;
}
 
Example #9
Source File: GeoWaveVisibilityIT.java    From geowave with Apache License 2.0 5 votes vote down vote up
private static SimpleFeatureType getType() {
  final SimpleFeatureTypeBuilder bldr = new SimpleFeatureTypeBuilder();
  bldr.setName("testvis");
  final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();
  bldr.add(attributeTypeBuilder.binding(String.class).buildDescriptor("a"));
  bldr.add(attributeTypeBuilder.binding(String.class).buildDescriptor("b"));
  bldr.add(attributeTypeBuilder.binding(String.class).buildDescriptor("c"));
  bldr.add(attributeTypeBuilder.binding(Point.class).nillable(false).buildDescriptor("geometry"));
  return bldr.buildFeatureType();
}
 
Example #10
Source File: GeoWaveGeometryPrecisionIT.java    From geowave with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void createFeatureType() {
  final SimpleFeatureTypeBuilder sftBuilder = new SimpleFeatureTypeBuilder();
  final AttributeTypeBuilder ab = new AttributeTypeBuilder();

  sftBuilder.setName(FEATURE_TYPE_NAME);

  sftBuilder.add(
      ab.binding(Geometry.class).nillable(false).buildDescriptor(GEOMETRY_ATTRIBUTE_NAME));
  sftBuilder.add(ab.binding(Date.class).nillable(true).buildDescriptor(TIME_ATTRIBUTE_NAME));

  featureType = sftBuilder.buildFeatureType();
}
 
Example #11
Source File: FeatureDefinitionSet.java    From geowave with Apache License 2.0 5 votes vote down vote up
private static void parseFeatureDefinition(final FeatureDefinition fd) {
  final SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder();
  sftb.setName(fd.name);
  final AttributeTypeBuilder atb = new AttributeTypeBuilder();
  // Class geomClass = null;
  // switch (fd.Type) {
  // case Geometry: {
  // geomClass = Geometry.class;
  // break;
  // }
  // case Point: {
  // geomClass = Point.class;
  // break;
  // }
  // case LineString: {
  // geomClass = LineString.class;
  // break;
  // }
  // case Polygon: {
  // geomClass = Polygon.class;
  // }
  // }
  // sftb.add(atb.binding(geomClass).nillable(false).buildDescriptor("geometry"));
  for (final AttributeDefinition ad : fd.attributes) {
    final AttributeType at = AttributeTypes.getAttributeType(ad.type);
    if (ad.name == null) {
      System.out.println("yo");
    }
    if (at != null) {
      sftb.add(
          atb.binding(at.getClassType()).nillable(true).buildDescriptor(
              normalizeOsmNames(ad.name)));
    }
  }
  final SimpleFeatureType sft = sftb.buildFeatureType();
  featureTypes.put(fd.name, sft);
  featureAdapters.put(fd.name, new FeatureDataAdapter(sft));
}
 
Example #12
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 #13
Source File: GpxUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static SimpleFeatureType createGPXTrackDataType() {

    final SimpleFeatureTypeBuilder simpleFeatureTypeBuilder = new SimpleFeatureTypeBuilder();
    simpleFeatureTypeBuilder.setName(GPX_TRACK_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(Date.class).nillable(true).buildDescriptor("StartTimeStamp"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).nillable(true).buildDescriptor("EndTimeStamp"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Long.class).nillable(true).buildDescriptor("Duration"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Long.class).nillable(true).buildDescriptor("NumberPoints"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("TrackId"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Long.class).nillable(true).buildDescriptor("UserId"));
    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("Tags"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Source"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Comment"));

    return simpleFeatureTypeBuilder.buildFeatureType();
  }
 
Example #14
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 #15
Source File: CustomIndexExample.java    From geowave with Apache License 2.0 5 votes vote down vote up
private SimpleFeatureType getSimpleFeatureType() {
  final String NAME = "ExampleType";
  final SimpleFeatureTypeBuilder sftBuilder = new SimpleFeatureTypeBuilder();
  final AttributeTypeBuilder atBuilder = new AttributeTypeBuilder();
  sftBuilder.setName(NAME);
  sftBuilder.add(atBuilder.binding(Geometry.class).nillable(false).buildDescriptor("geometry"));
  sftBuilder.add(atBuilder.binding(String.class).nillable(false).buildDescriptor("uuid"));

  return sftBuilder.buildFeatureType();
}
 
Example #16
Source File: TwitterUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static SimpleFeatureType createTwitterEventDataType() {

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

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
            TWITTER_USERID_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
            TWITTER_USERNAME_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
            TWITTER_TEXT_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
            TWITTER_INREPLYTOUSER_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
            TWITTER_INREPLYTOSTATUS_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).nillable(true).buildDescriptor(
            TWITTER_RETWEETCOUNT_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
            TWITTER_LANG_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).nillable(false).buildDescriptor(
            TWITTER_DTG_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Point.class).nillable(false).buildDescriptor(
            TWITTER_GEOMETRY_ATTRIBUTE));

    return simpleFeatureTypeBuilder.buildFeatureType();
  }
 
Example #17
Source File: GeoWaveGTQueryTest.java    From rya 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"));

    return sftBuilder.buildFeatureType();
}
 
Example #18
Source File: FeatureExtender.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param oldFeatureType the {@link FeatureType} of the existing features.
 * @param fieldArray the list of the names of new fields. 
 * @param classesArray the list of classes of the new fields.
 * @throws FactoryRegistryException 
 * @throws SchemaException
 */
public FeatureExtender( SimpleFeatureType oldFeatureType, String[] fieldArray,
        Class<?>[] classesArray ) throws FactoryRegistryException, SchemaException {

    List<AttributeDescriptor> oldAttributeDescriptors = oldFeatureType
            .getAttributeDescriptors();
    List<AttributeDescriptor> addedAttributeDescriptors = new ArrayList<AttributeDescriptor>();
    for( int i = 0; i < fieldArray.length; i++ ) {
        AttributeTypeBuilder build = new AttributeTypeBuilder();
        build.setNillable(true);
        build.setBinding(classesArray[i]);
        AttributeDescriptor descriptor = build.buildDescriptor(fieldArray[i]);
        addedAttributeDescriptors.add(descriptor);
    }

    List<AttributeDescriptor> newAttributesTypesList = new ArrayList<AttributeDescriptor>();
    for( AttributeDescriptor attributeDescriptor : oldAttributeDescriptors ) {
        newAttributesTypesList.add(attributeDescriptor);
    }
    newAttributesTypesList.addAll(addedAttributeDescriptors);

    // create the feature type
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(oldFeatureType.getName());
    b.setCRS(oldFeatureType.getCoordinateReferenceSystem());
    b.addAll(newAttributesTypesList);
    newFeatureType = b.buildFeatureType();
}
 
Example #19
Source File: GeonamesSimpleFeatureType.java    From geowave with Apache License 2.0 5 votes vote down vote up
private static SimpleFeatureType createGeonamesPointType() {

    final SimpleFeatureTypeBuilder sftBuilder = new SimpleFeatureTypeBuilder();
    final AttributeTypeBuilder atBuilder = new AttributeTypeBuilder();

    sftBuilder.setName(FEATURE_NAME);

    sftBuilder.add(atBuilder.binding(Geometry.class).nillable(false).buildDescriptor("geometry"));
    sftBuilder.add(atBuilder.binding(Double.class).nillable(false).buildDescriptor("Latitude"));
    sftBuilder.add(atBuilder.binding(Double.class).nillable(false).buildDescriptor("Longitude"));
    sftBuilder.add(atBuilder.binding(String.class).nillable(false).buildDescriptor("Location"));

    return sftBuilder.buildFeatureType();
  }
 
Example #20
Source File: SimpleIngest.java    From geowave with Apache License 2.0 5 votes vote down vote up
/**
 * * A simple feature is just a mechanism for defining attributes (a feature is just a collection
 * of attributes + some metadata) We need to describe what our data looks like so the serializer
 * (FeatureDataAdapter for this case) can know how to store it. Features/Attributes are also a
 * general convention of GIS systems in general.
 *
 * @return Simple Feature definition for our demo point feature
 */
public static SimpleFeatureType createPointFeatureType() {

  final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
  final AttributeTypeBuilder ab = new AttributeTypeBuilder();

  // Names should be unique (at least for a given GeoWave namespace) -
  // think about names in the same sense as a full classname
  // The value you set here will also persist through discovery - so when
  // people are looking at a dataset they will see the
  // type names associated with the data.
  builder.setName(FEATURE_NAME);

  // The data is persisted in a sparse format, so if data is nullable it
  // will not take up any space if no values are persisted.
  // Data which is included in the primary index (in this example
  // lattitude/longtiude) can not be null
  // Calling out latitude an longitude separately is not strictly needed,
  // as the geometry contains that information. But it's
  // convienent in many use cases to get a text representation without
  // having to handle geometries.
  builder.add(ab.binding(Geometry.class).nillable(false).buildDescriptor("geometry"));
  builder.add(ab.binding(Date.class).nillable(true).buildDescriptor("TimeStamp"));
  builder.add(ab.binding(Double.class).nillable(false).buildDescriptor("Latitude"));
  builder.add(ab.binding(Double.class).nillable(false).buildDescriptor("Longitude"));
  builder.add(ab.binding(String.class).nillable(true).buildDescriptor("TrajectoryID"));
  builder.add(ab.binding(String.class).nillable(true).buildDescriptor("Comment"));

  return builder.buildFeatureType();
}
 
Example #21
Source File: CQLQueryExample.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"));

    return sftBuilder.buildFeatureType();
  }
 
Example #22
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 #23
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 4 votes vote down vote up
@Before
public void setUp() {
    ff = CommonFactoryFinder.getFilterFactory2();

    SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
    typeBuilder.setName("test");
    typeBuilder.add("stringAttr", String.class);
    typeBuilder.add("integerAttr", Integer.class);
    typeBuilder.add("longAttr", Long.class);
    typeBuilder.add("booleanAttr", Boolean.class);
    typeBuilder.add("doubleAttr", Double.class);
    typeBuilder.add("floatAttr", Float.class);
    typeBuilder.add("dateAttr", Date.class);

    AttributeDescriptor geoPointAtt;
    AttributeTypeBuilder geoPointAttBuilder = new AttributeTypeBuilder();
    geoPointAttBuilder.setName("geo_point");
    geoPointAttBuilder.setBinding(Point.class);
    geoPointAtt = geoPointAttBuilder.buildDescriptor("geo_point", geoPointAttBuilder.buildType());
    geoPointAtt.getUserData().put(GEOMETRY_TYPE, ElasticGeometryType.GEO_POINT);
    typeBuilder.add(geoPointAtt);

    AttributeDescriptor geoShapeAtt;
    AttributeTypeBuilder geoShapeAttBuilder = new AttributeTypeBuilder();
    geoShapeAttBuilder.setName("geom");
    geoShapeAttBuilder.setBinding(Geometry.class);
    geoShapeAtt = geoShapeAttBuilder.buildDescriptor("geom", geoShapeAttBuilder.buildType());
    geoShapeAtt.getUserData().put(GEOMETRY_TYPE, ElasticGeometryType.GEO_SHAPE);
    typeBuilder.add(geoShapeAtt);

    AttributeDescriptor analyzedAtt;
    AttributeTypeBuilder analyzedAttBuilder = new AttributeTypeBuilder();
    analyzedAttBuilder.setName("analyzed");
    analyzedAttBuilder.setBinding(String.class);
    analyzedAtt = analyzedAttBuilder.buildDescriptor("analyzed", analyzedAttBuilder.buildType());
    analyzedAtt.getUserData().put(ANALYZED, true);
    typeBuilder.add(analyzedAtt);

    AttributeDescriptor netsedAtt;
    AttributeTypeBuilder nestedAttBuilder = new AttributeTypeBuilder();
    nestedAttBuilder.setName("nested.hej");
    nestedAttBuilder.setBinding(String.class);
    netsedAtt = nestedAttBuilder.buildDescriptor("nested.hej", nestedAttBuilder.buildType());
    netsedAtt.getUserData().put(NESTED, true);
    netsedAtt.getUserData().put(ANALYZED, true);
    typeBuilder.add(netsedAtt);

    AttributeDescriptor netsedDateAtt;
    AttributeTypeBuilder nestedDateAttBuilder = new AttributeTypeBuilder();
    nestedDateAttBuilder.setName("nested.datehej");
    nestedDateAttBuilder.setBinding(Date.class);
    netsedDateAtt = nestedDateAttBuilder.buildDescriptor("nested.datehej", nestedDateAttBuilder.buildType());
    netsedDateAtt.getUserData().put(NESTED, true);
    typeBuilder.add(netsedDateAtt);

    featureType = typeBuilder.buildFeatureType();
    setFilterBuilder();

    parameters = new HashMap<>();
    final Hints hints = new Hints();
    hints.put(Hints.VIRTUAL_TABLE_PARAMETERS, parameters);
    query = new Query();
    query.setHints(hints);

    dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    gf = new GeometryFactory();
}
 
Example #24
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 #25
Source File: SpatialQueryExample.java    From geowave with Apache License 2.0 4 votes vote down vote up
private void ingestPointBasicFeature() {
  // First, we'll build our first kind of SimpleFeature, which we'll call
  // "basic-feature"
  // We need the type builder to build the feature type
  final SimpleFeatureTypeBuilder sftBuilder = new SimpleFeatureTypeBuilder();
  // AttributeTypeBuilder for the attributes of the SimpleFeature
  final AttributeTypeBuilder attrBuilder = new AttributeTypeBuilder();
  // Here we're setting the SimpleFeature name. Later on, we'll be able to
  // query GW just by this particular feature.
  sftBuilder.setName("basic-feature");
  // Add the attributes to the feature
  // Add the geometry attribute, which is mandatory for GeoWave to be able
  // to construct an index out of the SimpleFeature
  sftBuilder.add(attrBuilder.binding(Point.class).nillable(false).buildDescriptor("geometry"));
  // Add another attribute just to be able to filter by it in CQL
  sftBuilder.add(attrBuilder.binding(String.class).nillable(false).buildDescriptor("filter"));

  // Create the SimpleFeatureType
  final SimpleFeatureType sfType = sftBuilder.buildFeatureType();
  // We need the adapter for all our operations with GeoWave
  final FeatureDataAdapter sfAdapter = new FeatureDataAdapter(sfType);

  // Now we build the actual features. We'll create two points.
  // First point
  final SimpleFeatureBuilder sfBuilder = new SimpleFeatureBuilder(sfType);
  sfBuilder.set(
      "geometry",
      GeometryUtils.GEOMETRY_FACTORY.createPoint(
          new Coordinate(-80.211181640625, 25.848101000701597)));
  sfBuilder.set("filter", "Basic-Stadium");
  // When calling buildFeature, we need to pass an unique id for that
  // feature, or it will be overwritten.
  final SimpleFeature basicPoint1 = sfBuilder.buildFeature("1");

  // Construct the second feature.
  sfBuilder.set(
      "geometry",
      GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(-80.191360, 25.777804)));
  sfBuilder.set("filter", "Basic-College");
  final SimpleFeature basicPoint2 = sfBuilder.buildFeature("2");

  final ArrayList<SimpleFeature> features = new ArrayList<>();
  features.add(basicPoint1);
  features.add(basicPoint2);

  // Ingest the data. For that purpose, we need the feature adapter,
  // the index type (the default spatial index is used here),
  // and an iterator of SimpleFeature
  ingest(sfAdapter, new SpatialIndexBuilder().createIndex(), features);
}
 
Example #26
Source File: ShapefileQueryOutputFormat.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public void output(final ResultSet results) {
  int geometryColumn = -1;
  for (int i = 0; i < results.columnCount(); i++) {
    if (Geometry.class.isAssignableFrom(results.columnType(i))) {
      geometryColumn = i;
      break;
    }
  }
  if (geometryColumn < 0) {
    throw new RuntimeException(
        "Unable to output results to a shapefile without a geometry column.");
  }

  final SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder();
  ftb.setCRS(results.getCRS());
  ftb.setName(typeName);
  for (int i = 0; i < results.columnCount(); i++) {
    final AttributeTypeBuilder atb = new AttributeTypeBuilder();
    atb.setBinding(results.columnType(i));
    atb.nillable(true);
    if (i == geometryColumn) {
      ftb.add(atb.buildDescriptor("the_geom"));
    } else {
      ftb.add(atb.buildDescriptor(results.columnName(i)));
    }
  }
  final SimpleFeatureType sft = ftb.buildFeatureType();

  final SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(sft);
  final AtomicLong nextId = new AtomicLong(0L);
  final Iterator<SimpleFeature> features = Iterators.transform(results, r -> {
    sfb.reset();
    for (int i = 0; i < results.columnCount(); i++) {
      sfb.add(r.columnValue(i));
    }
    final SimpleFeature feature = sfb.buildFeature(Long.toString(nextId.incrementAndGet()));
    return feature;
  });

  final FileDataStoreFactorySpi factory = FileDataStoreFinder.getDataStoreFactory("shp");
  final File file = new File(outputFile);
  final Map<String, Serializable> params = Maps.newHashMap();
  final Transaction transaction = new DefaultTransaction("Write Results");
  try {
    params.put("url", file.toURI().toURL());
    final DataStore dataStore = factory.createNewDataStore(params);
    dataStore.createSchema(sft);
    final SimpleFeatureStore store =
        (SimpleFeatureStore) dataStore.getFeatureSource(dataStore.getTypeNames()[0]);
    store.setTransaction(transaction);
    final SimpleFeatureCollection featureCollection =
        DataUtilities.collection(new SimpleFeatureIterator() {
          @Override
          public boolean hasNext() {
            return features.hasNext();
          }

          @Override
          public SimpleFeature next() throws NoSuchElementException {
            return features.next();
          }

          @Override
          public void close() {}
        });
    store.addFeatures(featureCollection);
    transaction.commit();
  } catch (final Exception e) {
    try {
      transaction.rollback();
    } catch (final IOException ioe) {
      throw new RuntimeException("Encountered an error when rolling back transaction", ioe);
    }
    throw new RuntimeException(
        "Encountered an error when writing the features to the file: " + e.getMessage(),
        e);
  }
}
 
Example #27
Source File: GeoJsonQueryOutputFormat.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public void output(ResultSet results) {
  int geometryColumn = -1;
  for (int i = 0; i < results.columnCount(); i++) {
    if (Geometry.class.isAssignableFrom(results.columnType(i))) {
      geometryColumn = i;
      break;
    }
  }
  if (geometryColumn < 0) {
    throw new RuntimeException(
        "Unable to output results to a geojson without a geometry column.");
  }

  SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder();
  ftb.setName(typeName);
  ftb.setCRS(results.getCRS());
  for (int i = 0; i < results.columnCount(); i++) {
    AttributeTypeBuilder atb = new AttributeTypeBuilder();
    atb.setBinding(results.columnType(i));
    atb.nillable(true);
    ftb.add(atb.buildDescriptor(results.columnName(i)));
  }
  SimpleFeatureType sft = ftb.buildFeatureType();
  final SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(sft);
  final AtomicLong nextId = new AtomicLong(0L);
  Iterator<SimpleFeature> features = Iterators.transform(results, r -> {
    sfb.reset();
    for (int i = 0; i < results.columnCount(); i++) {
      sfb.add(r.columnValue(i));
    }
    SimpleFeature feature = sfb.buildFeature(Long.toString(nextId.incrementAndGet()));
    return feature;
  });


  try {
    SimpleFeatureCollection featureCollection =
        DataUtilities.collection(new SimpleFeatureIterator() {
          @Override
          public boolean hasNext() {
            return features.hasNext();
          }

          @Override
          public SimpleFeature next() throws NoSuchElementException {
            return features.next();
          }

          @Override
          public void close() {}
        });
    FeatureJSON io = new FeatureJSON();
    io.writeFeatureCollection(featureCollection, outputFile);
  } catch (IOException e) {
    throw new RuntimeException(
        "Encountered exception when writing geojson file: " + e.getMessage(),
        e);
  }
}
 
Example #28
Source File: GDELTUtils.java    From geowave with Apache License 2.0 4 votes vote down vote up
public static SimpleFeatureType createGDELTEventDataType(
    final boolean includeSupplementalFields) {

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

  final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

  simpleFeatureTypeBuilder.add(
      attributeTypeBuilder.binding(Point.class).nillable(false).buildDescriptor(
          GDELT_GEOMETRY_ATTRIBUTE));
  simpleFeatureTypeBuilder.add(
      attributeTypeBuilder.binding(Integer.class).nillable(false).buildDescriptor(
          GDELT_EVENT_ID_ATTRIBUTE));
  simpleFeatureTypeBuilder.add(
      attributeTypeBuilder.binding(Date.class).nillable(false).buildDescriptor(
          GDELT_TIMESTAMP_ATTRIBUTE));
  simpleFeatureTypeBuilder.add(
      attributeTypeBuilder.binding(Double.class).nillable(false).buildDescriptor(
          GDELT_LATITUDE_ATTRIBUTE));
  simpleFeatureTypeBuilder.add(
      attributeTypeBuilder.binding(Double.class).nillable(false).buildDescriptor(
          GDELT_LONGITUDE_ATTRIBUTE));
  simpleFeatureTypeBuilder.add(
      attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
          ACTOR_1_NAME_ATTRIBUTE));
  simpleFeatureTypeBuilder.add(
      attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
          ACTOR_2_NAME_ATTRIBUTE));
  simpleFeatureTypeBuilder.add(
      attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
          ACTION_COUNTRY_CODE_ATTRIBUTE));
  simpleFeatureTypeBuilder.add(
      attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
          SOURCE_URL_ATTRIBUTE));
  if (includeSupplementalFields) {
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
            ACTOR_1_COUNTRY_CODE_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
            ACTOR_2_COUNTRY_CODE_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).nillable(false).buildDescriptor(
            NUM_MENTIONS_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).nillable(false).buildDescriptor(
            NUM_SOURCES_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).nillable(false).buildDescriptor(
            NUM_ARTICLES_ATTRIBUTE));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(false).buildDescriptor(
            AVG_TONE_ATTRIBUTE));
  }

  return simpleFeatureTypeBuilder.buildFeatureType();
}
 
Example #29
Source File: GpxUtils.java    From geowave with Apache License 2.0 4 votes vote down vote up
public static SimpleFeatureType createGPXWaypointDataType() {

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

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Geometry.class).nillable(true).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Latitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Longitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Elevation"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Name"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Comment"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Description"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Symbol"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Link"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Source"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).nillable(true).buildDescriptor("Station"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("URL"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("URLName"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Fix"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor(
            "MagneticVariation"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("GeoHeight"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Elevation"));

    return simpleFeatureTypeBuilder.buildFeatureType();
  }
 
Example #30
Source File: GpxUtils.java    From geowave with Apache License 2.0 4 votes vote down vote up
public static SimpleFeatureType createGPXPointDataType() {

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

    final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();

    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Geometry.class).nillable(true).buildDescriptor("geometry"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Latitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Longitude"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Elevation"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Date.class).nillable(true).buildDescriptor("Timestamp"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Comment"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).nillable(true).buildDescriptor("Satellites"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("VDOP"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("HDOP"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("PDOP"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Symbol"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor(
            "Classification"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("GeoHeight"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor("Course"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Double.class).nillable(true).buildDescriptor(
            "MagneticVariation"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Source"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Link"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("Fix"));
    simpleFeatureTypeBuilder.add(
        attributeTypeBuilder.binding(Integer.class).nillable(true).buildDescriptor("Station"));

    return simpleFeatureTypeBuilder.buildFeatureType();
  }