Search in sources :

Example 1 with GpxIngestPlugin

use of org.locationtech.geowave.format.gpx.GpxIngestPlugin in project geowave by locationtech.

the class BasicMapReduceIT method testIngestOsmGpxMultipleIndices.

@Test
public void testIngestOsmGpxMultipleIndices() throws Exception {
    TestUtils.deleteAll(dataStorePluginOptions);
    // ingest the data set into multiple indices and then try several query
    // methods, by adapter and by index
    MapReduceTestUtils.testMapReduceIngest(dataStorePluginOptions, DimensionalityType.SPATIAL_AND_SPATIAL_TEMPORAL, OSM_GPX_INPUT_DIR);
    final DataTypeAdapter<SimpleFeature>[] adapters = new GpxIngestPlugin().getDataAdapters(null);
    final org.locationtech.geowave.core.store.api.DataStore geowaveStore = dataStorePluginOptions.createDataStore();
    final Map<String, ExpectedResults> adapterIdToResultsMap = new HashMap<>();
    for (final DataTypeAdapter<SimpleFeature> adapter : adapters) {
        adapterIdToResultsMap.put(adapter.getTypeName(), TestUtils.getExpectedResults(geowaveStore.query(QueryBuilder.newBuilder().addTypeName(adapter.getTypeName()).build())));
    }
    final List<DataTypeAdapter<?>> firstTwoAdapters = new ArrayList<>();
    firstTwoAdapters.add(adapters[0]);
    firstTwoAdapters.add(adapters[1]);
    final ExpectedResults firstTwoAdaptersResults = TestUtils.getExpectedResults(geowaveStore.query(QueryBuilder.newBuilder().addTypeName(adapters[0].getTypeName()).addTypeName(adapters[1].getTypeName()).build()));
    final ExpectedResults fullDataSetResults = TestUtils.getExpectedResults(geowaveStore.query(QueryBuilder.newBuilder().build()));
    // just for sanity verify its greater than 0 (ie. that data was actually
    // ingested in the first place)
    Assert.assertTrue("There is no data ingested from OSM GPX test files", fullDataSetResults.count > 0);
    // now that we have expected results, run map-reduce export and
    // re-ingest it
    testMapReduceExportAndReingest(DimensionalityType.SPATIAL_AND_SPATIAL_TEMPORAL);
    // first try each adapter individually
    for (final DataTypeAdapter<SimpleFeature> adapter : adapters) {
        final ExpectedResults expResults = adapterIdToResultsMap.get(adapter.getTypeName());
        if (expResults.count > 0) {
            LOGGER.error("Running test for adapter " + adapter.getTypeName());
            runTestJob(expResults, null, new DataTypeAdapter[] { adapter }, null);
        }
    }
    // then try the first 2 adapters, and may as well try with both indices
    // set (should be the default behavior anyways)
    runTestJob(firstTwoAdaptersResults, null, new DataTypeAdapter[] { adapters[0], adapters[1] }, null);
    // now try all adapters and the spatial temporal index, the result
    // should be the full data set
    runTestJob(fullDataSetResults, null, adapters, TestUtils.DEFAULT_SPATIAL_TEMPORAL_INDEX);
    // and finally run with nothing set, should be the full data set
    runTestJob(fullDataSetResults, null, null, null);
}
Also used : HashMap(java.util.HashMap) DataTypeAdapter(org.locationtech.geowave.core.store.api.DataTypeAdapter) ArrayList(java.util.ArrayList) ExpectedResults(org.locationtech.geowave.test.TestUtils.ExpectedResults) GpxIngestPlugin(org.locationtech.geowave.format.gpx.GpxIngestPlugin) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Example 2 with GpxIngestPlugin

use of org.locationtech.geowave.format.gpx.GpxIngestPlugin in project geowave by locationtech.

the class BasicMapReduceIT method testIngestAndQueryGeneralGpx.

@Test
public void testIngestAndQueryGeneralGpx() throws Exception {
    TestUtils.deleteAll(dataStorePluginOptions);
    MapReduceTestUtils.testMapReduceIngest(dataStorePluginOptions, DimensionalityType.SPATIAL, GENERAL_GPX_INPUT_GPX_DIR);
    final File gpxInputDir = new File(GENERAL_GPX_INPUT_GPX_DIR);
    final File expectedResultsDir = new File(GENERAL_GPX_EXPECTED_RESULTS_DIR);
    final List<URL> expectedResultsResources = new ArrayList<>();
    final Map<String, URL> baseNameToExpectedResultURL = new HashMap<>();
    for (final File file : expectedResultsDir.listFiles(new FileFilter() {

        @Override
        public boolean accept(final File pathname) {
            final Map<String, Object> map = new HashMap<>();
            try {
                map.put("url", pathname.toURI().toURL());
                return DataStoreFinder.getDataStore(map) != null;
            } catch (final IOException e) {
                LOGGER.warn("Cannot read file as GeoTools data store", e);
            }
            return false;
        }
    })) {
        baseNameToExpectedResultURL.put(FilenameUtils.getBaseName(file.getName()).replaceAll("_filtered", ""), file.toURI().toURL());
    }
    for (final String filename : gpxInputDir.list(new FilenameFilter() {

        @Override
        public boolean accept(final File dir, final String name) {
            return FilenameUtils.isExtension(name, new GpxIngestPlugin().getFileExtensionFilters());
        }
    })) {
        final URL url = baseNameToExpectedResultURL.get(FilenameUtils.getBaseName(filename));
        Assert.assertNotNull(url);
        expectedResultsResources.add(url);
    }
    final ExpectedResults expectedResults = TestUtils.getExpectedResults(expectedResultsResources.toArray(new URL[expectedResultsResources.size()]));
    runTestJob(expectedResults, TestUtils.resourceToQuery(new File(GENERAL_GPX_FILTER_FILE).toURI().toURL()), null, null);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExpectedResults(org.locationtech.geowave.test.TestUtils.ExpectedResults) IOException(java.io.IOException) GpxIngestPlugin(org.locationtech.geowave.format.gpx.GpxIngestPlugin) URL(java.net.URL) FilenameFilter(java.io.FilenameFilter) FileFilter(java.io.FileFilter) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 3 with GpxIngestPlugin

use of org.locationtech.geowave.format.gpx.GpxIngestPlugin in project geowave by locationtech.

the class GPXIngestPluginTest method test.

@Test
public void test() throws IOException {
    final Set<String> expectedSet = HelperClass.buildSet(expectedResults);
    final GpxIngestPlugin pluggin = new GpxIngestPlugin();
    pluggin.init(new File(this.getClass().getClassLoader().getResource("metadata.xml").getPath()).getParentFile().toURI().toURL());
    final CloseableIterator<GeoWaveData<SimpleFeature>> consumer = pluggin.toGeoWaveData(this.getClass().getClassLoader().getResource("12345.xml"), new String[] { "123" });
    int totalCount = 0;
    while (consumer.hasNext()) {
        final GeoWaveData<SimpleFeature> data = consumer.next();
        expectedSet.remove(data.getValue().getID());
        final ValidateObject<SimpleFeature> tester = expectedResults.get(data.getValue().getID());
        if (tester != null) {
            assertTrue(data.getValue().toString(), tester.validate(data.getValue()));
        }
        totalCount++;
    }
    consumer.close();
    assertEquals(9, totalCount);
    // did everything get validated?
    if (expectedSet.size() > 0) {
        System.out.println("Failed matches:");
        System.out.println(expectedSet);
    }
    assertEquals("All expected data set should be matched; zero unmatched data expected", 0, expectedSet.size());
}
Also used : GeoWaveData(org.locationtech.geowave.core.store.ingest.GeoWaveData) GpxIngestPlugin(org.locationtech.geowave.format.gpx.GpxIngestPlugin) File(java.io.File) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 GpxIngestPlugin (org.locationtech.geowave.format.gpx.GpxIngestPlugin)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ExpectedResults (org.locationtech.geowave.test.TestUtils.ExpectedResults)2 SimpleFeature (org.opengis.feature.simple.SimpleFeature)2 FileFilter (java.io.FileFilter)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 URL (java.net.URL)1 Map (java.util.Map)1 DataTypeAdapter (org.locationtech.geowave.core.store.api.DataTypeAdapter)1 GeoWaveData (org.locationtech.geowave.core.store.ingest.GeoWaveData)1