Search in sources :

Example 6 with FeatureIndexingException

use of org.codice.ddf.spatial.geocoding.FeatureIndexingException in project ddf by codice.

the class GazetteerUpdateCommand method executeWithSubject.

@Override
protected Object executeWithSubject() throws Exception {
    final PrintStream console = System.out;
    final ProgressCallback progressCallback = progress -> {
        console.printf("\r%d%%", progress);
        console.flush();
    };
    final FeatureIndexer.IndexCallback featureIndexCallback = count -> {
        console.printf("\r%d features indexed", count);
        console.flush();
    };
    console.println("Updating...");
    try {
        if (isResourceGeoJSON()) {
            featureIndexer.updateIndex(resource, featureExtractor, create, featureIndexCallback);
        } else {
            geoEntryIndexer.updateIndex(resource, geoEntryExtractor, create, progressCallback);
        }
        console.println("\nDone.");
    } catch (GeoEntryExtractionException | FeatureExtractionException e) {
        LOGGER.info("Error extracting data from resource {}", resource, e);
        console.printf("Could not extract data from resource %s.%n Message: %s%n Check the logs for more details.%n", resource, e.getMessage());
    } catch (GeoEntryIndexingException | FeatureIndexingException e) {
        LOGGER.info("Error indexing data", e);
        console.printf("Could not index the  data.%n Message: %s%n Check the logs for more details.%n", e.getMessage());
    } catch (GeoNamesRemoteDownloadException e) {
        LOGGER.info("Error downloading resource from remote source {}", resource, e);
        console.printf("Could not download the GeoNames file %s.%n  Message: %s%n Check the logs for more details.%n", resource, e.getMessage());
    }
    return null;
}
Also used : PrintStream(java.io.PrintStream) GeoEntryExtractor(org.codice.ddf.spatial.geocoding.GeoEntryExtractor) Logger(org.slf4j.Logger) GeoEntryExtractionException(org.codice.ddf.spatial.geocoding.GeoEntryExtractionException) GeoEntryIndexer(org.codice.ddf.spatial.geocoding.GeoEntryIndexer) FeatureIndexer(org.codice.ddf.spatial.geocoding.FeatureIndexer) LoggerFactory(org.slf4j.LoggerFactory) Argument(org.apache.karaf.shell.api.action.Argument) FeatureExtractor(org.codice.ddf.spatial.geocoding.FeatureExtractor) ProgressCallback(org.codice.ddf.spatial.geocoding.ProgressCallback) Command(org.apache.karaf.shell.api.action.Command) Reference(org.apache.karaf.shell.api.action.lifecycle.Reference) GeoEntryIndexingException(org.codice.ddf.spatial.geocoding.GeoEntryIndexingException) GeoNamesRemoteDownloadException(org.codice.ddf.spatial.geocoding.GeoNamesRemoteDownloadException) Locale(java.util.Locale) FeatureIndexingException(org.codice.ddf.spatial.geocoding.FeatureIndexingException) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Option(org.apache.karaf.shell.api.action.Option) FeatureExtractionException(org.codice.ddf.spatial.geocoding.FeatureExtractionException) SubjectCommands(org.codice.ddf.commands.catalog.SubjectCommands) GeoNamesRemoteDownloadException(org.codice.ddf.spatial.geocoding.GeoNamesRemoteDownloadException) PrintStream(java.io.PrintStream) GeoEntryExtractionException(org.codice.ddf.spatial.geocoding.GeoEntryExtractionException) FeatureIndexingException(org.codice.ddf.spatial.geocoding.FeatureIndexingException) ProgressCallback(org.codice.ddf.spatial.geocoding.ProgressCallback) FeatureExtractionException(org.codice.ddf.spatial.geocoding.FeatureExtractionException) FeatureIndexer(org.codice.ddf.spatial.geocoding.FeatureIndexer) GeoEntryIndexingException(org.codice.ddf.spatial.geocoding.GeoEntryIndexingException)

Aggregations

FeatureIndexingException (org.codice.ddf.spatial.geocoding.FeatureIndexingException)6 FeatureExtractionException (org.codice.ddf.spatial.geocoding.FeatureExtractionException)3 Metacard (ddf.catalog.data.Metacard)2 FeatureExtractor (org.codice.ddf.spatial.geocoding.FeatureExtractor)2 FeatureIndexer (org.codice.ddf.spatial.geocoding.FeatureIndexer)2 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 FederationException (ddf.catalog.federation.FederationException)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 SourceResponse (ddf.catalog.operation.SourceResponse)1 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)1 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)1 UpdateRequestImpl (ddf.catalog.operation.impl.UpdateRequestImpl)1 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)1 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)1 SecurityServiceException (ddf.security.service.SecurityServiceException)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1