diff --git a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicConfigHandler.java b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicConfigHandler.java index 4a60603a2a5..63b4ad60671 100644 --- a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicConfigHandler.java +++ b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicConfigHandler.java @@ -87,10 +87,10 @@ import org.geotools.gce.imagemosaic.catalog.index.SchemasType; import org.geotools.gce.imagemosaic.catalogbuilder.CatalogBuilderConfiguration; import org.geotools.gce.imagemosaic.catalogbuilder.MosaicBeanBuilder; -import org.geotools.gce.imagemosaic.geomhandler.DefaultGranuleGeometryHandler; -import org.geotools.gce.imagemosaic.geomhandler.GranuleGeometryHandler; -import org.geotools.gce.imagemosaic.geomhandler.GranuleGeometryHandlerFactoryFinder; -import org.geotools.gce.imagemosaic.geomhandler.GranuleGeometryHandlerFactorySPI; +import org.geotools.gce.imagemosaic.geomhandler.DefaultGranuleHandler; +import org.geotools.gce.imagemosaic.geomhandler.GranuleHandler; +import org.geotools.gce.imagemosaic.geomhandler.GranuleHandlerFactoryFinder; +import org.geotools.gce.imagemosaic.geomhandler.GranuleHandlerFactorySPI; import org.geotools.gce.imagemosaic.properties.DefaultPropertiesCollectorSPI; import org.geotools.gce.imagemosaic.properties.PropertiesCollector; import org.geotools.gce.imagemosaic.properties.PropertiesCollectorFinder; @@ -161,7 +161,7 @@ public class ImageMosaicConfigHandler { private List granuleAcceptors; - private GranuleGeometryHandler granuleGeomHandler; + private GranuleHandler granuleGeomHandler; /** * Default constructor @@ -271,13 +271,13 @@ private List initializeGranuleAcceptors(Indexer indexer) { return finalGranuleAcceptors; } - private GranuleGeometryHandler initializeGeometryHandler(Indexer indexer) { + private GranuleHandler initializeGeometryHandler(Indexer indexer) { - GranuleGeometryHandler geomHandler = null; + GranuleHandler geomHandler = null; if (indexer != null) { String geometryHandlerString = IndexerUtils.getParameter(Prop.GEOMETRY_HANDLER, indexer); - GranuleGeometryHandlerFactorySPI factory = - GranuleGeometryHandlerFactoryFinder.getGeometryHandlersSPI() + GranuleHandlerFactorySPI factory = + GranuleHandlerFactoryFinder.getGeometryHandlersSPI() .get(geometryHandlerString); if (factory != null) { geomHandler = factory.create(); @@ -285,7 +285,7 @@ private GranuleGeometryHandler initializeGeometryHandler(Indexer indexer) { } if (geomHandler == null) { - geomHandler = new DefaultGranuleGeometryHandler(); + geomHandler = new DefaultGranuleHandler(); } @@ -530,7 +530,7 @@ private void updateCatalog( final String fileLocation = prepareLocation(configuration, fileBeingProcessed); final String locationAttribute = configuration.getParameter(Prop.LOCATION_ATTRIBUTE); MosaicConfigurationBean mosaicConfiguration = this.getConfigurations().get(coverageName); - GranuleGeometryHandler geometryHandler = this.getGeometryHandler(); + GranuleHandler geometryHandler = this.getGeometryHandler(); // getting input granules if (inputReader instanceof StructuredGridCoverage2DReader) { @@ -540,15 +540,14 @@ private void updateCatalog( handleStructuredGridCoverage( ((StructuredGridCoverage2DReader) inputReader).getGranules(coverageName, true), fileBeingProcessed, inputReader, propertiesCollectors, indexSchema, feature, - collection, fileLocation, locationAttribute, mosaicConfiguration, - geometryHandler); + collection, fileLocation, locationAttribute, mosaicConfiguration); } else { // // Case B: old style reader, proceed with classic way, using properties collectors // geometryHandler.handleGeometry( - inputReader, feature, indexSchema, mosaicConfiguration); + inputReader, feature, indexSchema,null,null, mosaicConfiguration); feature.setAttribute(locationAttribute, fileLocation); updateAttributesFromCollectors(feature, fileBeingProcessed, inputReader, propertiesCollectors); @@ -569,8 +568,7 @@ private void handleStructuredGridCoverage(GranuleSource granules, final File fil final List propertiesCollectors, final SimpleFeatureType indexSchema, SimpleFeature feature, final ListFeatureCollection collection, final String fileLocation, - final String locationAttribute, final MosaicConfigurationBean mosaicConfiguration, - final GranuleGeometryHandler geometryHandler) throws IOException + final String locationAttribute, final MosaicConfigurationBean mosaicConfiguration) throws IOException { // Getting granule source and its input granules @@ -586,6 +584,7 @@ private void handleStructuredGridCoverage(GranuleSource granules, final File fil } // Collecting granules + final GranuleHandler geometryHandler=this.granuleGeomHandler; originCollection.accepts( new AbstractFeatureVisitor(){ public void visit( Feature feature ) { if(feature instanceof SimpleFeature) @@ -640,7 +639,7 @@ public void visit( Feature feature ) { }, listener); } - private GranuleGeometryHandler getGeometryHandler() { + private GranuleHandler getGeometryHandler() { return this.granuleGeomHandler; } diff --git a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/acceptors/DefaultGranuleAcceptor.java b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/acceptors/DefaultGranuleAcceptor.java index d4dc9599361..fad0d9284d5 100644 --- a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/acceptors/DefaultGranuleAcceptor.java +++ b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/acceptors/DefaultGranuleAcceptor.java @@ -20,15 +20,12 @@ import java.awt.image.ColorModel; import java.io.File; import java.io.IOException; -import java.util.logging.Level; import org.geotools.coverage.grid.io.GridCoverage2DReader; import org.geotools.gce.imagemosaic.ImageMosaicConfigHandler; -import org.geotools.gce.imagemosaic.ImageMosaicEventHandlers; import org.geotools.gce.imagemosaic.MosaicConfigurationBean; import org.geotools.gce.imagemosaic.RasterManager; import org.geotools.gce.imagemosaic.Utils; -import org.geotools.gce.imagemosaic.catalogbuilder.CatalogBuilderConfiguration; import org.geotools.referencing.CRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; diff --git a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/acceptors/GranuleAcceptor.java b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/acceptors/GranuleAcceptor.java index 2270aafd545..18386ee7ac9 100644 --- a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/acceptors/GranuleAcceptor.java +++ b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/acceptors/GranuleAcceptor.java @@ -22,10 +22,6 @@ import org.geotools.coverage.grid.io.GridCoverage2DReader; import org.geotools.gce.imagemosaic.ImageMosaicConfigHandler; -import org.geotools.gce.imagemosaic.ImageMosaicEventHandlers; -import org.geotools.gce.imagemosaic.MosaicConfigurationBean; -import org.geotools.gce.imagemosaic.catalogbuilder.CatalogBuilderConfiguration; -import org.opengis.coverage.grid.GridCoverageReader; /** * Class responsible for determining whether a given coverage should or should not be part of the diff --git a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGranuleGeometryHandler.java b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGranuleHandler.java similarity index 64% rename from modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGranuleGeometryHandler.java rename to modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGranuleHandler.java index 29d5dc1edd1..6d3eeeaf81f 100644 --- a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGranuleGeometryHandler.java +++ b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGranuleHandler.java @@ -29,28 +29,27 @@ import com.vividsolutions.jts.geom.PrecisionModel; /** - * Default granule geometry handling + * Default granule handling */ -public class DefaultGranuleGeometryHandler implements GranuleGeometryHandler { +public class DefaultGranuleHandler implements GranuleHandler { private final static PrecisionModel PRECISION_MODEL = new PrecisionModel(PrecisionModel.FLOATING); private final static GeometryFactory GEOM_FACTORY = new GeometryFactory(PRECISION_MODEL); @Override - public void handleGeometry(GridCoverage2DReader inputReader, SimpleFeature feature, - SimpleFeatureType indexSchema, MosaicConfigurationBean mosaicConfigurationBean) { - Envelope coverageEnvelope = inputReader.getOriginalEnvelope(); - feature.setAttribute(indexSchema.getGeometryDescriptor().getLocalName(), - GEOM_FACTORY.toGeometry(new ReferencedEnvelope(coverageEnvelope))); - } - - @Override - public void handleGeometry(StructuredGridCoverage2DReader inputReader, + public void handleGeometry(GridCoverage2DReader inputReader, SimpleFeature targetFeature, SimpleFeatureType targetFeatureType, - SimpleFeature inputFeature, SimpleFeatureType inputFeatureType, + SimpleFeature feature, SimpleFeatureType inputFeatureType, MosaicConfigurationBean mosaicConfiguration) { - Object geometryAttribute = inputFeature.getAttribute(inputFeatureType.getGeometryDescriptor().getName()); - targetFeature.setAttribute(targetFeatureType.getGeometryDescriptor().getName(), geometryAttribute); + if(inputReader instanceof StructuredGridCoverage2DReader){ + Object geometryAttribute = feature.getAttribute(inputFeatureType.getGeometryDescriptor().getName()); + targetFeature.setAttribute(targetFeatureType.getGeometryDescriptor().getName(), geometryAttribute); + }else { + Envelope coverageEnvelope = inputReader.getOriginalEnvelope(); + feature.setAttribute(inputFeatureType.getGeometryDescriptor().getLocalName(), + GEOM_FACTORY.toGeometry(new ReferencedEnvelope(coverageEnvelope))); + } + } } diff --git a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGeometryHandlerFactory.java b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGranuleHandlerFactory.java similarity index 79% rename from modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGeometryHandlerFactory.java rename to modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGranuleHandlerFactory.java index d82b23ef1c7..c96a7b3af86 100644 --- a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGeometryHandlerFactory.java +++ b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/DefaultGranuleHandlerFactory.java @@ -20,9 +20,9 @@ /** * Default factory for geometry handler */ -public class DefaultGeometryHandlerFactory implements GranuleGeometryHandlerFactorySPI { +public class DefaultGranuleHandlerFactory implements GranuleHandlerFactorySPI { @Override - public GranuleGeometryHandler create() { - return new DefaultGranuleGeometryHandler(); + public GranuleHandler create() { + return new DefaultGranuleHandler(); } } diff --git a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleGeometryHandler.java b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleHandler.java similarity index 69% rename from modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleGeometryHandler.java rename to modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleHandler.java index abd2185dace..10b55ee8eb4 100644 --- a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleGeometryHandler.java +++ b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleHandler.java @@ -18,7 +18,6 @@ package org.geotools.gce.imagemosaic.geomhandler; import org.geotools.coverage.grid.io.GridCoverage2DReader; -import org.geotools.coverage.grid.io.StructuredGridCoverage2DReader; import org.geotools.gce.imagemosaic.MosaicConfigurationBean; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; @@ -26,19 +25,10 @@ /** * Handle setting the geometry of the index feature for incoming granules */ -public interface GranuleGeometryHandler { +public interface GranuleHandler { + + - /** - * Handle the case of a regular grid coverage being added to the mosaic. In the default case - * this is generally just taking the envelope from the coverage and adding it to the target - * feature. - * @param inputReader input reader of the incoming granule - * @param feature target index feature - * @param indexSchema schema of the index - * @param mosaicConfigurationBean the mosaic configuration - */ - void handleGeometry(GridCoverage2DReader inputReader, SimpleFeature feature, - SimpleFeatureType indexSchema, MosaicConfigurationBean mosaicConfigurationBean); /** * Handle the case of a structured grid coverage being added to the mosaic. In the default case @@ -52,7 +42,7 @@ void handleGeometry(GridCoverage2DReader inputReader, SimpleFeature feature, * @param mosaicConfiguration the mosaic configuration */ void handleGeometry( - StructuredGridCoverage2DReader inputReader, + GridCoverage2DReader inputReader, SimpleFeature targetFeature, SimpleFeatureType targetFeatureType, SimpleFeature inputFeature, diff --git a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleGeometryHandlerFactoryFinder.java b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleHandlerFactoryFinder.java similarity index 71% rename from modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleGeometryHandlerFactoryFinder.java rename to modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleHandlerFactoryFinder.java index d4dac0e95bb..290972143be 100644 --- a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleGeometryHandlerFactoryFinder.java +++ b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleHandlerFactoryFinder.java @@ -26,17 +26,17 @@ import org.geotools.factory.FactoryRegistry; /** - * Access the granule geometry handler factories + * Access the granule handler factories */ -public class GranuleGeometryHandlerFactoryFinder { +public class GranuleHandlerFactoryFinder { private static FactoryCreator registry; - public static synchronized Map getGeometryHandlersSPI() { + public static synchronized Map getGeometryHandlersSPI() { // get all GridFormatFactorySpi implementations - final Iterator it = getServiceRegistry().getServiceProviders(GranuleGeometryHandlerFactorySPI.class, true); - Map acceptorFactorySPIMap = new HashMap<>(); + final Iterator it = getServiceRegistry().getServiceProviders(GranuleHandlerFactorySPI.class, true); + Map acceptorFactorySPIMap = new HashMap<>(); while (it.hasNext()) { - GranuleGeometryHandlerFactorySPI GranuleGeometryHandlerFactorySPI = it.next(); + GranuleHandlerFactorySPI GranuleGeometryHandlerFactorySPI = it.next(); acceptorFactorySPIMap.put(GranuleGeometryHandlerFactorySPI.getClass().getName(), GranuleGeometryHandlerFactorySPI); } @@ -49,7 +49,7 @@ public static synchronized Map getGeom */ private static FactoryRegistry getServiceRegistry() { if (registry == null) { - registry = new FactoryCreator(Arrays.asList(new Class[] { GranuleGeometryHandlerFactorySPI.class })); + registry = new FactoryCreator(Arrays.asList(new Class[] { GranuleHandlerFactorySPI.class })); } return registry; } diff --git a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleGeometryHandlerFactorySPI.java b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleHandlerFactorySPI.java similarity index 88% rename from modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleGeometryHandlerFactorySPI.java rename to modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleHandlerFactorySPI.java index d5fd2d15a72..002266760d4 100644 --- a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleGeometryHandlerFactorySPI.java +++ b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/geomhandler/GranuleHandlerFactorySPI.java @@ -20,6 +20,6 @@ /** * Simple factory for GranuleGeometryHandlers */ -public interface GranuleGeometryHandlerFactorySPI { - GranuleGeometryHandler create(); +public interface GranuleHandlerFactorySPI { + GranuleHandler create(); } diff --git a/modules/plugin/imagemosaic/src/main/resources/META-INF/services/org.geotools.gce.imagemosaic.geomhandler.GranuleGeometryHandlerFactorySPI b/modules/plugin/imagemosaic/src/main/resources/META-INF/services/org.geotools.gce.imagemosaic.geomhandler.GranuleGeometryHandlerFactorySPI deleted file mode 100644 index de2f853a674..00000000000 --- a/modules/plugin/imagemosaic/src/main/resources/META-INF/services/org.geotools.gce.imagemosaic.geomhandler.GranuleGeometryHandlerFactorySPI +++ /dev/null @@ -1 +0,0 @@ -org.geotools.gce.imagemosaic.geomhandler.DefaultGeometryHandlerFactory \ No newline at end of file diff --git a/modules/plugin/imagemosaic/src/main/resources/META-INF/services/org.geotools.gce.imagemosaic.geomhandler.GranuleHandlerFactorySPI b/modules/plugin/imagemosaic/src/main/resources/META-INF/services/org.geotools.gce.imagemosaic.geomhandler.GranuleHandlerFactorySPI new file mode 100644 index 00000000000..77f2fab5805 --- /dev/null +++ b/modules/plugin/imagemosaic/src/main/resources/META-INF/services/org.geotools.gce.imagemosaic.geomhandler.GranuleHandlerFactorySPI @@ -0,0 +1 @@ +org.geotools.gce.imagemosaic.geomhandler.DefaultHandlerFactory \ No newline at end of file