Beispiel #1
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);
  }