@Override
 public DataStorePluginOptions getDataStoreOptions(final String namespace) {
   final DataStorePluginOptions pluginOptions = new DataStorePluginOptions();
   final HBaseRequiredOptions opts = new HBaseRequiredOptions();
   opts.setGeowaveNamespace(namespace);
   opts.setZookeeper(zookeeper);
   pluginOptions.selectPlugin(new HBaseDataStoreFactory().getName());
   pluginOptions.setFactoryOptions(opts);
   return pluginOptions;
 }
Esempio n. 2
0
  @Override
  protected void processParameters(final OperationParams params)
      throws Exception { // Ensure we have all the required
    // arguments
    super.processParameters(params);

    final DataStore vectorStore;
    final PrimaryIndex[] vectorIndices;
    // Config file
    final File configFile = (File) params.getContext().get(ConfigOptions.PROPERTIES_FILE_CONTEXT);
    if ((vectorOverrideOptions.getVectorStore() != null)
        && !vectorOverrideOptions.getVectorStore().trim().isEmpty()) {
      String vectorStoreName = vectorOverrideOptions.getVectorStore();
      final StoreLoader vectorStoreLoader = new StoreLoader(vectorStoreName);
      if (!vectorStoreLoader.loadFromConfig(configFile)) {
        throw new ParameterException(
            "Cannot find vector store name: " + vectorStoreLoader.getStoreName());
      }
      final DataStorePluginOptions vectorStoreOptions = vectorStoreLoader.getDataStorePlugin();
      vectorStore = vectorStoreOptions.createDataStore();
    } else {
      vectorStore = store;
    }
    if ((vectorOverrideOptions.getVectorIndex() != null)
        && !vectorOverrideOptions.getVectorIndex().trim().isEmpty()) {
      String vectorIndexList = vectorOverrideOptions.getVectorIndex();

      // Load the Indices
      final IndexLoader indexLoader = new IndexLoader(vectorIndexList);
      if (!indexLoader.loadFromConfig(configFile)) {
        throw new ParameterException("Cannot find index(s) by name: " + vectorIndexList);
      }
      final List<IndexPluginOptions> indexOptions = indexLoader.getLoadedIndexes();

      vectorIndices = new PrimaryIndex[indexOptions.size()];
      int i = 0;
      for (final IndexPluginOptions dimensionType : indexOptions) {
        final PrimaryIndex primaryIndex = dimensionType.createPrimaryIndex();
        if (primaryIndex == null) {
          LOGGER.error("Could not get index instance, getIndex() returned null;");
          throw new IOException("Could not get index instance, getIndex() returned null");
        }
        vectorIndices[i++] = primaryIndex;
      }
    } else {
      vectorIndices = indices;
    }
    sceneType = SceneFeatureIterator.createFeatureType();
    final FeatureDataAdapter sceneAdapter = new FeatureDataAdapter(sceneType);
    sceneWriter = vectorStore.createWriter(sceneAdapter, vectorIndices);
    final SimpleFeatureType bandType = BandFeatureIterator.createFeatureType(sceneType);
    final FeatureDataAdapter bandAdapter = new FeatureDataAdapter(bandType);
    bandWriter = vectorStore.createWriter(bandAdapter, vectorIndices);
  }
Esempio n. 3
0
 @Test
 public void testNN() throws Exception {
   TestUtils.deleteAll(dataStorePluginOptions);
   dataGenerator.setIncludePolygons(false);
   ingest(dataStorePluginOptions.createDataStore());
   runNN(new SpatialQuery(dataGenerator.getBoundingRegion()));
   TestUtils.deleteAll(dataStorePluginOptions);
 }
Esempio n. 4
0
  private void queryNoDataMergeStrategy(final String coverageName, final int tileSize)
      throws AccumuloException, AccumuloSecurityException, IOException {
    final DataStore dataStore = dataStoreOptions.createDataStore();

    try (CloseableIterator<?> it =
        dataStore.query(
            new QueryOptions(new ByteArrayId(coverageName), null), new EverythingQuery())) {

      // the expected outcome is:
      // band 1,2,3,4,5,6 has every value set correctly, band 0 has every
      // even row set correctly and every odd row should be NaN, and band
      // 7 has the upper quadrant as NaN and the rest set
      final GridCoverage coverage = (GridCoverage) it.next();
      final Raster raster = coverage.getRenderedImage().getData();

      Assert.assertEquals(tileSize, raster.getWidth());
      Assert.assertEquals(tileSize, raster.getHeight());
      for (int x = 0; x < tileSize; x++) {
        for (int y = 0; y < tileSize; y++) {

          for (int b = 1; b < 7; b++) {
            Assert.assertEquals(
                "x=" + x + ",y=" + y + ",b=" + b,
                getValue(x, y, b, tileSize),
                raster.getSampleDouble(x, y, b));
          }
          if ((y % 2) == 0) {
            Assert.assertEquals(
                "x=" + x + ",y=" + y + ",b=0",
                getValue(x, y, 0, tileSize),
                raster.getSampleDouble(x, y, 0));
          } else {
            Assert.assertEquals(
                "x=" + x + ",y=" + y + ",b=0", Double.NaN, raster.getSampleDouble(x, y, 0));
          }
          if ((x > ((tileSize * 3) / 4)) && (y > ((tileSize * 3) / 4))) {
            Assert.assertEquals(
                "x=" + x + ",y=" + y + ",b=7", Double.NaN, raster.getSampleDouble(x, y, 7));
          } else {
            Assert.assertEquals(
                "x=" + x + ",y=" + y + ",b=7",
                getValue(x, y, 7, tileSize),
                raster.getSampleDouble(x, y, 7));
          }
        }
      }

      // there should be exactly one
      Assert.assertFalse(it.hasNext());
    }
  }
Esempio n. 5
0
  private void queryGeneralPurpose(
      final String coverageName,
      final int tileSize,
      final double westLon,
      final double eastLon,
      final double southLat,
      final double northLat,
      final int numBands,
      final int numRasters,
      final ExpectedValue expectedValue)
      throws AccumuloException, AccumuloSecurityException, IOException {
    final DataStore dataStore = dataStoreOptions.createDataStore();

    try (CloseableIterator<?> it =
        dataStore.query(
            new QueryOptions(new ByteArrayId(coverageName), null),
            new IndexOnlySpatialQuery(
                new GeometryFactory()
                    .toGeometry(new Envelope(westLon, eastLon, southLat, northLat))))) {
      // the expected outcome is:
      // band 1,2,3,4,5,6 has every value set correctly, band 0 has every
      // even row set correctly and every odd row should be NaN, and band
      // 7 has the upper quadrant as NaN and the rest set
      final GridCoverage coverage = (GridCoverage) it.next();
      final Raster raster = coverage.getRenderedImage().getData();

      Assert.assertEquals(tileSize, raster.getWidth());
      Assert.assertEquals(tileSize, raster.getHeight());
      for (int x = 0; x < tileSize; x++) {
        for (int y = 0; y < tileSize; y++) {
          for (int b = 0; b < numBands; b++) {
            Assert.assertEquals(
                "x=" + x + ",y=" + y + ",b=" + b,
                expectedValue.getExpectedValue(x, y, b, numRasters, tileSize),
                raster.getSampleDouble(x, y, b),
                DOUBLE_TOLERANCE);
          }
        }
      }

      // there should be exactly one
      Assert.assertFalse(it.hasNext());
    }
  }
Esempio n. 6
0
  private void ingestGeneralPurpose(
      final String coverageName,
      final int tileSize,
      final double westLon,
      final double eastLon,
      final double southLat,
      final double northLat,
      final int numBands,
      final int numRasters,
      final RasterTileMergeStrategy<?> mergeStrategy)
      throws IOException {

    // just ingest a number of rasters
    final DataStore dataStore = dataStoreOptions.createDataStore();
    final RasterDataAdapter basicAdapter =
        RasterUtils.createDataAdapterTypeDouble(
            coverageName, numBands, tileSize, new NoDataMergeStrategy());
    final RasterDataAdapter mergeStrategyOverriddenAdapter =
        new RasterDataAdapter(basicAdapter, coverageName, mergeStrategy);
    basicAdapter.getMetadata().put("test-key", "test-value");
    try (IndexWriter writer =
        dataStore.createWriter(mergeStrategyOverriddenAdapter, TestUtils.DEFAULT_SPATIAL_INDEX)) {
      for (int r = 0; r < numRasters; r++) {
        final WritableRaster raster = RasterUtils.createRasterTypeDouble(numBands, tileSize);
        for (int x = 0; x < tileSize; x++) {
          for (int y = 0; y < tileSize; y++) {
            for (int b = 0; b < numBands; b++) {
              raster.setSample(x, y, b, getValue(x, y, b, r, tileSize));
            }
          }
        }
        writer.write(
            RasterUtils.createCoverageTypeDouble(
                coverageName, westLon, eastLon, southLat, northLat, raster));
      }
    }
  }
Esempio n. 7
0
  private void ingestNoDataMergeStrategy(
      final String coverageName,
      final int tileSize,
      final double westLon,
      final double eastLon,
      final double southLat,
      final double northLat)
      throws IOException {
    final int numBands = 8;
    final DataStore dataStore = dataStoreOptions.createDataStore();
    final RasterDataAdapter adapter =
        RasterUtils.createDataAdapterTypeDouble(
            coverageName, numBands, tileSize, new NoDataMergeStrategy());
    final WritableRaster raster1 = RasterUtils.createRasterTypeDouble(numBands, tileSize);
    final WritableRaster raster2 = RasterUtils.createRasterTypeDouble(numBands, tileSize);
    // for raster1 do the following:
    // set every even row in bands 0 and 1
    // set every value incorrectly in band 2
    // set no values in band 3 and set every value in 4

    // for raster2 do the following:
    // set no value in band 0 and 4
    // set every odd row in band 1
    // set every value in bands 2 and 3

    // for band 5, set the lower 2x2 samples for raster 1 and the rest for
    // raster 2
    // for band 6, set the upper quadrant samples for raster 1 and the rest
    // for raster 2
    // for band 7, set the lower 2x2 samples to the wrong value for raster 1
    // and the expected value for raster 2 and set everything but the upper
    // quadrant for raster 2
    for (int x = 0; x < tileSize; x++) {
      for (int y = 0; y < tileSize; y++) {

        // just use x and y to arbitrarily end up with some wrong value
        // that can be ingested
        final double wrongValue = (getValue(y, x, y, tileSize) * 3) + 1;
        if ((x < 2) && (y < 2)) {
          raster1.setSample(x, y, 5, getValue(x, y, 5, tileSize));
          raster1.setSample(x, y, 7, wrongValue);
          raster2.setSample(x, y, 7, getValue(x, y, 7, tileSize));
        } else {
          raster2.setSample(x, y, 5, getValue(x, y, 5, tileSize));
        }
        if ((x > ((tileSize * 3) / 4)) && (y > ((tileSize * 3) / 4))) {
          raster1.setSample(x, y, 6, getValue(x, y, 6, tileSize));
        } else {
          raster2.setSample(x, y, 6, getValue(x, y, 6, tileSize));
          raster2.setSample(x, y, 7, getValue(x, y, 7, tileSize));
        }
        if ((y % 2) == 0) {
          raster1.setSample(x, y, 0, getValue(x, y, 0, tileSize));
          raster1.setSample(x, y, 1, getValue(x, y, 1, tileSize));
        }
        raster1.setSample(x, y, 2, wrongValue);

        raster1.setSample(x, y, 4, getValue(x, y, 4, tileSize));
        if ((y % 2) == 1) {
          raster2.setSample(x, y, 1, getValue(x, y, 1, tileSize));
        }
        raster2.setSample(x, y, 2, getValue(x, y, 2, tileSize));

        raster2.setSample(x, y, 3, getValue(x, y, 3, tileSize));
      }
    }

    try (IndexWriter writer = dataStore.createWriter(adapter, TestUtils.DEFAULT_SPATIAL_INDEX)) {
      writer.write(
          RasterUtils.createCoverageTypeDouble(
              coverageName, westLon, eastLon, southLat, northLat, raster1));
      writer.write(
          RasterUtils.createCoverageTypeDouble(
              coverageName, westLon, eastLon, southLat, northLat, raster2));
    }
  }