Search in sources :

Example 1 with IngestOptions

use of org.locationtech.geowave.core.store.api.IngestOptions in project geowave by locationtech.

the class CustomIngestPluginExample method run.

public void run() throws URISyntaxException {
    // Create an in-memory data store to use with this example
    dataStore = DataStoreFactory.createDataStore(new MemoryRequiredOptions());
    // Create the spatial index
    spatialIndex = new SpatialIndexBuilder().createIndex();
    // Configure ingest options to use our custom plugin
    final IngestOptions.Builder<SimpleFeature> ingestOptions = IngestOptions.newBuilder();
    // Set our custom ingest plugin as the format to use for the ingest
    ingestOptions.format(new CustomIngestPlugin());
    // Get the path of the geonames text file from the example resources
    final File geonamesFile = new File(CustomIngestPlugin.class.getClassLoader().getResource("geonames.txt").toURI());
    // Ingest the data
    dataStore.ingest(geonamesFile.getAbsolutePath(), ingestOptions.build(), spatialIndex);
    // Perform a query on the data
    try (final CloseableIterator<SimpleFeature> iterator = dataStore.query(null)) {
        while (iterator.hasNext()) {
            System.out.println("Query match: " + iterator.next().getAttribute("Location"));
        }
    }
}
Also used : SpatialIndexBuilder(org.locationtech.geowave.core.geotime.index.api.SpatialIndexBuilder) MemoryRequiredOptions(org.locationtech.geowave.core.store.memory.MemoryRequiredOptions) File(java.io.File) IngestOptions(org.locationtech.geowave.core.store.api.IngestOptions) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Aggregations

File (java.io.File)1 SpatialIndexBuilder (org.locationtech.geowave.core.geotime.index.api.SpatialIndexBuilder)1 IngestOptions (org.locationtech.geowave.core.store.api.IngestOptions)1 MemoryRequiredOptions (org.locationtech.geowave.core.store.memory.MemoryRequiredOptions)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1