org.opengis.feature.simple.SimpleFeatureType Java Examples

The following examples show how to use org.opengis.feature.simple.SimpleFeatureType. 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: GeoWaveFeatureReaderTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Test
public void testLike() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException {
    final Query query = new Query(
            "GeoWaveFeatureReaderTest",
            ECQL.toFilter("pid like '" + pids.get(
                    0).substring(
                    0,
                    1) + "%'"),
            new String[] {
                "geometry",
                "pid"
            });
    final FeatureReader<SimpleFeatureType, SimpleFeature> reader =
        dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
    int count = 0;
    while (reader.hasNext()) {
        final SimpleFeature feature = reader.next();
        assertTrue(fids.contains(feature.getID()));
        count++;
    }
    assertEquals(1, count);
}
 
Example #2
Source File: GeoToolsLayer.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Envelope getBounds(Filter filter) throws LayerException {
	FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
	if (source instanceof FeatureStore<?, ?>) {
		SimpleFeatureStore store = (SimpleFeatureStore) source;
		transactionSynchronization.synchTransaction(store);
	}
	try {
		FeatureCollection<SimpleFeatureType, SimpleFeature> fc;
		if (null == filter) {
			fc = source.getFeatures();
		} else {
			fc = source.getFeatures(filter);
		}
		FeatureIterator<SimpleFeature> it = fc.features();
		transactionSynchronization.addIterator(it);
		return fc.getBounds();
	} catch (Throwable t) { // NOSONAR avoid errors (like NPE) as well
		throw new LayerException(t, ExceptionCode.UNEXPECTED_PROBLEM);
	}
}
 
Example #3
Source File: FeatureElevationComparer.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param newGeometry new geometry to insert.
 */
public void substituteGeometry( Geometry newGeometry ) {
    if (toRemove) {
        return;
    }
    if (newGeometry.getLength() < lengthThreshold) {
        feature = null;
        geometry = null;
        toRemove = true;
        return;
    }

    Object[] attributes = feature.getAttributes().toArray();
    Object[] newAttributes = new Object[attributes.length];
    System.arraycopy(attributes, 0, newAttributes, 0, attributes.length);
    newAttributes[0] = newGeometry;

    SimpleFeatureType featureType = feature.getFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
    builder.addAll(newAttributes);
    feature = builder.buildFeature(feature.getID());
    geometry = newGeometry;
    bufferPolygon = geometry.buffer(buffer);
}
 
Example #4
Source File: DataSourceInfo.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the feature store.
 *
 * @return the feature store
 */
public FeatureStore<SimpleFeatureType, SimpleFeature> getFeatureStore() {
    FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = null;

    if(dataStore != null)
    {
        try
        {
            FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore.getFeatureSource(typeName);

            featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
        } catch (IOException e) {
            ConsoleManager.getInstance().exception(this, e);
        }
    }
    return featureStore;
}
 
Example #5
Source File: SerializableAdapterStoreTest.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Test
public void testSerialization() throws ClassNotFoundException, IOException {
  final SimpleFeatureType ftype =
      AnalyticFeature.createGeometryFeatureAdapter(
          "centroid",
          new String[] {"extra1"},
          BasicFeatureTypes.DEFAULT_NAMESPACE,
          ClusteringUtils.CLUSTERING_CRS).getFeatureType();

  final Index index = new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions());
  final FeatureDataAdapter adapter = new FeatureDataAdapter(ftype);
  adapter.init(index);
  final SerializableAdapterStore store =
      new SerializableAdapterStore(new MemoryAdapterStore(new DataTypeAdapter<?>[] {adapter}));

  final String id = "centroid";
  assertNotNull(checkSerialization(store).getAdapter(id));
}
 
Example #6
Source File: OmsGridsGenerator.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private void createPolygons( CoordinateReferenceSystem crs, GeometryFactory gf, List<Geometry> polygons ) {
    outMap = new DefaultFeatureCollection();
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(POLYGON);
    b.setCRS(crs);
    b.add("the_geom", Polygon.class);
    b.add("id", Long.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder fbuilder = new SimpleFeatureBuilder(type);

    long index = 0;
    int numGeometries = polygons.size();
    for( int i = 0; i < numGeometries; i++ ) {
        Geometry geometry = polygons.get(i);
        Object[] values = new Object[]{geometry, index++};
        fbuilder.addAll(values);
        SimpleFeature feature = fbuilder.buildFeature(null);
        ((DefaultFeatureCollection) outMap).add(feature);
    }
}
 
Example #7
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 #8
Source File: SimpleFeatureGeoWaveWrapper.java    From geowave with Apache License 2.0 6 votes vote down vote up
public InternalIterator(
    final SimpleFeatureCollection featureCollection,
    final String visibility,
    final Filter filter) {
  this.filter = filter;
  featureIterator = featureCollection.features();
  final SimpleFeatureType originalSchema = featureCollection.getSchema();
  SimpleFeatureType retypedSchema =
      SimpleFeatureUserDataConfigurationSet.configureType(originalSchema);
  if (retypingPlugin != null) {
    source = retypingPlugin.getRetypingSource(originalSchema);
    if (source != null) {
      retypedSchema = source.getRetypedSimpleFeatureType();
      builder = new SimpleFeatureBuilder(retypedSchema);
    }
  }
  if ((visibility == null) || visibility.isEmpty()) {
    dataAdapter = new FeatureDataAdapter(retypedSchema);
  } else {
    dataAdapter =
        new FeatureDataAdapter(
            retypedSchema,
            new GlobalVisibilityHandler<SimpleFeature, Object>(visibility));
  }
}
 
Example #9
Source File: GeoMesaGeoIndexer.java    From rya with Apache License 2.0 6 votes vote down vote up
private static SimpleFeatureType getStatementFeatureType(final DataStore dataStore) throws IOException, SchemaException {
    SimpleFeatureType featureType;

    final String[] datastoreFeatures = dataStore.getTypeNames();
    if (Arrays.asList(datastoreFeatures).contains(FEATURE_NAME)) {
        featureType = dataStore.getSchema(FEATURE_NAME);
    } else {
        final String featureSchema = SUBJECT_ATTRIBUTE + ":String," //
                + PREDICATE_ATTRIBUTE + ":String," //
                + OBJECT_ATTRIBUTE + ":String," //
                + CONTEXT_ATTRIBUTE + ":String," //
                + GEOMETRY_ATTRIBUTE + ":Geometry:srid=4326;geomesa.mixed.geometries='true'";
        featureType = SimpleFeatureTypes.createType(FEATURE_NAME, featureSchema);
        dataStore.createSchema(featureType);
    }
    return featureType;
}
 
Example #10
Source File: FeatureDataUtils.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static String getGeomField(final DataStorePluginOptions dataStore, final String typeName) {
  final PersistentAdapterStore adapterStore = dataStore.createAdapterStore();
  final InternalAdapterStore internalAdapterStore = dataStore.createInternalAdapterStore();

  final DataTypeAdapter<?> adapter =
      adapterStore.getAdapter(internalAdapterStore.getAdapterId(typeName)).getAdapter();

  if ((adapter != null) && (adapter instanceof GeotoolsFeatureDataAdapter)) {
    final GeotoolsFeatureDataAdapter gtAdapter = (GeotoolsFeatureDataAdapter) adapter;
    final SimpleFeatureType featureType = gtAdapter.getFeatureType();

    if (featureType.getGeometryDescriptor() != null) {
      return featureType.getGeometryDescriptor().getLocalName();
    }
  }

  return null;
}
 
Example #11
Source File: QueryOptionsIT.java    From geowave with Apache License 2.0 6 votes vote down vote up
private static SimpleFeatureType getSimpleFeatureType(final String typeName) {
  SimpleFeatureType type = null;
  try {
    type =
        DataUtilities.createType(
            typeName,
            CITY_ATTRIBUTE
                + ":String,"
                + STATE_ATTRIBUTE
                + ":String,"
                + POPULATION_ATTRIBUTE
                + ":Double,"
                + LAND_AREA_ATTRIBUTE
                + ":Double,"
                + GEOMETRY_ATTRIBUTE
                + ":Geometry");
  } catch (final SchemaException e) {
    System.out.println("Unable to create SimpleFeatureType");
  }
  return type;
}
 
Example #12
Source File: OmsLasConverter.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private void createBboxGeometry( CoordinateReferenceSystem crs, File lasFile, SimpleFeatureCollection outGeodata )
        throws Exception {
    final ReferencedEnvelope3D envelope = lasReader.getHeader().getDataEnvelope();
    ReferencedEnvelope env2d = new ReferencedEnvelope(envelope);
    final Polygon polygon = FeatureUtilities.envelopeToPolygon(new Envelope2D(env2d));

    final SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("lasdataenvelope");
    b.setCRS(crs);
    b.add("the_geom", Polygon.class);
    b.add("id", String.class);
    final SimpleFeatureType type = b.buildFeatureType();

    final SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    final Object[] values = new Object[]{polygon, lasFile.getName()};
    builder.addAll(values);
    final SimpleFeature feature = builder.buildFeature(null);
    ((DefaultFeatureCollection) outGeodata).add(feature);
    OmsVectorWriter.writeVector(outFile, outGeodata);
}
 
Example #13
Source File: GeoWaveFeatureReaderTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Test
public void testPidFilterQuery() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException {
    // Filter it so that it only queries for everything but the first pid.
    // There's only 2 pids total so it should just return the second one.
    final String pidsString = pids.subList(1, pids.size()).stream().collect(Collectors.joining("','", "'", "'"));
    final Filter filter = ECQL.toFilter("pid IN (" + pidsString + ")");
    final Query query = new Query(
            "GeoWaveFeatureReaderTest",
            filter,
            new String[] {
                "geometry",
                "pid"
            });
    final FeatureReader<SimpleFeatureType, SimpleFeature> reader =
        dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
    int count = 0;
    while (reader.hasNext()) {
        final SimpleFeature feature = reader.next();
        assertTrue(fids.contains(feature.getID()));
        count++;
    }
    assertTrue(count == pids.size() - 1);
}
 
Example #14
Source File: ExportGeometryActionTest.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testWritingShapeFile_Geometry() throws Exception {
    SimpleFeatureType sft = createPlainFeatureType("Polygon", Geometry.class, DefaultGeographicCRS.WGS84);

    GeometryFactory gf = new GeometryFactory();
    Polygon polygon = gf.createPolygon(gf.createLinearRing(new Coordinate[]{
            new Coordinate(0, 0),
            new Coordinate(1, 0),
            new Coordinate(0, 1),
            new Coordinate(0, 0),
    }), null);
    SimpleFeature polygonFeature = createPlainFeature(sft, "_1", polygon, "");


    ArrayList<SimpleFeature> features = new ArrayList<>();
    features.add(polygonFeature);
    Class<Polygon> geomType = Polygon.class;
    doExportImport(features, geomType);
}
 
Example #15
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 #16
Source File: SimpleFeatureShapeFigureTest.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testMixedGeometries_2() {

    SimpleFeatureType sft = createPlainFeatureType("Geometry", Geometry.class, DefaultGeographicCRS.WGS84);

    Geometry geometry;
    SimpleFeature feature;
    SimpleFeatureShapeFigure figure;

    geometry = createPoint();
    feature = createPlainFeature(sft, "_4", geometry, "");
    figure = new SimpleFeatureShapeFigure(feature, sceneTransformProvider, new DefaultFigureStyle());
    Assert.assertEquals(geometry, figure.getGeometry());
    Assert.assertNotNull(figure.getShape());
    Assert.assertEquals(Figure.Rank.POINT, figure.getRank());

    geometry = createGeometryCollection();
    feature = createPlainFeature(sft, "_5", geometry, "");
    figure = new SimpleFeatureShapeFigure(feature, sceneTransformProvider, new DefaultFigureStyle());
    Assert.assertEquals(geometry, figure.getGeometry());
    Assert.assertNotNull(figure.getShape());
    Assert.assertEquals(Figure.Rank.NOT_SPECIFIED, figure.getRank());
}
 
Example #17
Source File: GeoToolsFeatureModelTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Before
public void init() throws Exception {
	ClassLoader classloader = Thread.currentThread().getContextClassLoader();
	URL url = classloader.getResource(SHAPE_FILE);
	DataStore dataStore = new ShapefileDataStore(url);
	featureModel = new GeoToolsFeatureModel(dataStore, LAYER_NAME, 4326, converterService);
	featureModel.setLayerInfo(layerInfo);

	FeatureSource<SimpleFeatureType, SimpleFeature> fs = featureModel.getFeatureSource();
	FeatureIterator<SimpleFeature> fi = fs.getFeatures().features();
	feature = fi.next();
	feature = fi.next();
	feature = fi.next();
	feature = fi.next();
	feature = fi.next();
}
 
Example #18
Source File: PutStatisticsIntoVectorDataAction.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private void exchangeVDN(SimpleFeatureType featureType, FeatureStatisticsWriter featureStatisticsWriter) {
        final VectorDataNode originalVDN = featureType2VDN.get(featureType);
        final VectorDataNode vectorDataNode = createVectorDataNode(featureStatisticsWriter, originalVDN);
        final ProductNodeGroup<VectorDataNode> vectorDataNodeGroup = provider.getVectorDataNodeGroup();
        vectorDataNodeGroup.remove(originalVDN);
        originalVDN.dispose();
        vectorDataNodeGroup.add(vectorDataNode);
        //todo solve this one
//        final JInternalFrame internalFrame = VisatApp.getApp().findInternalFrame(originalVDN);
//        if (internalFrame != null) {
//            try {
//                internalFrame.setClosed(true);
//            } catch (PropertyVetoException ignored) {
//                 ok
//            }
//        }
        final ProductSceneView sceneView = SnapApp.getDefault().getSelectedProductSceneView();
        if (sceneView != null) {
            sceneView.setLayersVisible(vectorDataNode);
        }
    }
 
Example #19
Source File: DateFieldRetypingSource.java    From geowave with Apache License 2.0 6 votes vote down vote up
public DateFieldRetypingSource(
    final SimpleFeatureType typeIn,
    final Map<String, String> fieldNameToTimestampFormat) {
  this.typeIn = typeIn;
  this.fieldNameToTimestampFormat = fieldNameToTimestampFormat;

  fieldToFormatObjMap = new ThreadLocal<Map<String, SimpleDateFormat>>() {
    @Override
    protected Map<String, SimpleDateFormat> initialValue() {
      final Map<String, SimpleDateFormat> localFieldToFormat = new HashMap<>();
      for (final Entry<String, String> entry : fieldNameToTimestampFormat.entrySet()) {
        localFieldToFormat.put(entry.getKey(), new SimpleDateFormat(entry.getValue()));
      }
      return localFieldToFormat;
    }
  };
}
 
Example #20
Source File: GeoToolsConverterServiceImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public SimpleFeature toSimpleFeature(InternalFeature feature, SimpleFeatureType featureType) {
	SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
	List<Object> attr = new ArrayList<Object>();

	for (AttributeDescriptor ads : featureType.getAttributeDescriptors()) {
		if (!ads.equals(featureType.getGeometryDescriptor())) {
			Attribute a = feature.getAttributes().get(ads.getName().getLocalPart());
			if (null != a) {
				attr.add(a.getValue());
			} else {
				attr.add(null);
			}
		} else {
			attr.add(feature.getGeometry());
		}
	}

	return builder.buildFeature(feature.getId(), attr.toArray());

}
 
Example #21
Source File: Utility.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Verify the schema.
 * 
 * <p>
 * Verify if the FeatureCollection contains all the needed fields.
 * </p>
 * @param schema is yhe type for the project mode.
 * @param pm
 * @return true if there is the percentage of the area.
 */
public static boolean verifyProjectType( SimpleFeatureType schema, IHMProgressMonitor pm ) {
    String searchedField = PipesTrentoP.ID.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.DRAIN_AREA.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.INITIAL_ELEVATION.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.FINAL_ELEVATION.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.RUNOFF_COEFFICIENT.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.KS.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.MINIMUM_PIPE_SLOPE.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.AVERAGE_RESIDENCE_TIME.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.PIPE_SECTION_TYPE.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.AVERAGE_SLOPE.getAttributeName();
    verifyFeatureKey(findAttributeName(schema, searchedField), searchedField, pm);
    searchedField = PipesTrentoP.PER_AREA.getAttributeName();
    String attributeName = findAttributeName(schema, searchedField);
    if (attributeName != null) {
        return true;
    }

    return false;

}
 
Example #22
Source File: GeopaparazziUtilities.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public static SimpleFeatureType getGpsLogLinesFeatureType() {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("geopaparazzilogs");
    b.setCRS(DefaultGeographicCRS.WGS84);
    b.add("the_geom", MultiLineString.class);
    b.add(GPSLOG_startdateFN, String.class);
    b.add(GPSLOG_enddateFN, String.class);
    b.add(GPSLOG_descrFN, String.class);
    SimpleFeatureType featureType = b.buildFeatureType();
    return featureType;
}
 
Example #23
Source File: SLDs.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public static final boolean isPoint(final SimpleFeatureType featureType) {
	if (featureType == null) { return false; }
	final GeometryDescriptor geometryType = featureType.getGeometryDescriptor();
	if (geometryType == null) { return false; }
	final Class<?> type = geometryType.getType().getBinding();
	return Point.class.isAssignableFrom(type) || MultiPoint.class.isAssignableFrom(type);
}
 
Example #24
Source File: TimeUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
/**
 * Determine if a time or range descriptor is set. If so, then use it, otherwise infer.
 *
 * @param persistType - FeatureType that will be scanned for TimeAttributes
 * @return the time descriptors
 */
public static final TimeDescriptors inferTimeAttributeDescriptor(
    final SimpleFeatureType persistType) {

  final TimeDescriptorConfiguration config = new TimeDescriptorConfiguration(persistType);
  final TimeDescriptors timeDescriptors = new TimeDescriptors(persistType, config);

  // Up the meta-data so that it is clear and visible any inference that
  // has occurred here. Also, this is critical to
  // serialization/deserialization

  config.updateType(persistType);
  return timeDescriptors;
}
 
Example #25
Source File: PointClusterer.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
private SimpleFeatureBuilder getfeatureBuilder( CoordinateReferenceSystem crs ) {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("cluster");
    b.setCRS(crs);
    b.add("the_geom", Point.class);
    b.add("count", Integer.class);
    b.add("mass", Double.class);
    b.add("variance", Double.class);
    b.add("stdev", Double.class);
    b.add("elev", Double.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    return builder;
}
 
Example #26
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 #27
Source File: OmsDebrisVandre.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
private SimpleFeatureType createTriggersType() {
    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("indexedtriggers");
    b.setCRS(inFlow.getCoordinateReferenceSystem());
    b.add("the_geom", Point.class);
    b.add("PATHID", Integer.class);
    SimpleFeatureType type = b.buildFeatureType();
    return type;
}
 
Example #28
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 #29
Source File: FeatureDataUtilsTest.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithSRID() throws SchemaException {
  final SimpleFeatureType type =
      FeatureDataUtils.decodeType(
          "http://somens.org",
          "type1",
          "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,whennot:Date,pid:String",
          "east");
  assertEquals("type1", type.getName().getLocalPart());
}
 
Example #30
Source File: ShapeFile.java    From tutorials with MIT License 5 votes vote down vote up
static SimpleFeatureType createFeatureType() {

        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
        builder.setName("Location");
        builder.setCRS(DefaultGeographicCRS.WGS84);

        builder.add("Location", Point.class);
        builder.length(15)
          .add("Name", String.class);

        return builder.buildFeatureType();
    }