Sure thing here are the patches. And this is only at the gt level, I did
not do the work to expose it through GeoServer.
The first patch (imageio-ext-gdal) simply checks the hints map when
trying to infer its CRS, the same way some of the other readers do.
The second patch (imagemosaic) basically all I did was carry hints
passed into ImageMosaicReader down the chain of classes necessary to
have them relayed across to any delegate readers that get created.
No idea if it is a silly idea to have the same hints passed to the
mosaic reader be applied directly to a delegate reader... so the patch
might not be all that valuable but here it is regardless.
-Justin
On 3/17/10 11:34 AM, Simone Giannecchini wrote:
Ciao Justin,
can you send your patch over?
Question, did you play only at the GT level or also at the GS level?
can you elaborate a bit on what you did?
Ciao,
Simone.
-------------------------------------------------------
Ing. Simone Giannecchini
GeoSolutions S.A.S.
Founder - Software Engineer
Via Carignoni 51
55041 Camaiore (LU)
Italy
phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/simonegiannecchini
http://twitter.com/simogeo
-------------------------------------------------------
On Sat, Mar 13, 2010 at 10:13 PM, Justin Deoliveira
<[email protected]> wrote:
Hi all,
Playing with some mrsid files I have run into a situation in which the
coordinate system of the data is not being read properly and is falling
back onto 4326. This results from the fact that (a) i have no .prj file
and (b) the referencing info is not encoded as metadata directly in the
file.
I notice that most of the other non gdal based grid readers accept the
hint DEFAULT_COORDINATE_REFERENCE_SYSTEM to allow the crs to be
explicitly set. But I don't see the same function in the gdal based readers.
So my question is is this intentional or just something not supported as
of yet? I have a trivial patch that does the check and it seems to work
well for me but I have no idea if that is the right way to proceed.
Which brings me to the experts :)
-Justin
--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel
--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
diff --git
a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java
b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java
index 70a86be..191701f 100644
---
a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java
+++
b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java
@@ -181,7 +181,7 @@ public final class ImageMosaicReader extends
AbstractGridCoverage2DReader implem
throw new DataSourceException(ex);
}
this.source = source;
- this.sourceURL=Utils.checkSource(source);
+ this.sourceURL=Utils.checkSource(source, this.hints);
if(this.sourceURL==null)
throw new DataSourceException("This plugin accepts
File, URL or String. The string may describe a File or an URL");
diff --git
a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java
b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java
index 4fa076b..fcf578a 100644
---
a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java
+++
b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java
@@ -59,6 +59,7 @@ import org.geotools.data.DataAccessFactory.Param;
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
import org.geotools.factory.CommonFactoryFinder;
import org.geotools.factory.GeoTools;
+import org.geotools.factory.Hints;
import org.geotools.gce.imagemosaic.index.GranuleIndex;
import org.geotools.gce.imagemosaic.index.GranuleIndexFactory;
import org.geotools.gce.imagemosaic.indexbuilder.IndexBuilder;
@@ -129,6 +130,12 @@ public class Utils {
*/
private static ImageInputStreamSpi cachedStreamSPI = new
URLImageInputStreamSpi();
+
+ static boolean createMosaic(final String location, final String
indexName,
+ final String wildcard, final boolean absolutePath) {
+ return createMosaic(location, indexName, wildcard, absolutePath,
null);
+ }
+
/**
* Creates a mosaic for the provided input parameters.
*
@@ -140,20 +147,24 @@ public class Utils {
* @param wildcard
* wildcard to use for walking through files. We are using
* commonsIO for this task
+ * @param hints
+ * Hints to pass into delegate coverage readers.
+ *
* @return <code>true</code> if everything is right,
<code>false</code>if
* something bad happens, in which case the reason should be
logged
* to the logger.
*/
static boolean createMosaic(final String location, final String
indexName,
- final String wildcard, final boolean absolutePath) {
-
+ final String wildcard, final boolean absolutePath,
Hints hints) {
+
// create a mosaic index builder and set the relevant elements
final IndexBuilderConfiguration configuration = new
IndexBuilderConfiguration();
configuration.setAbsolute(absolutePath);
configuration.setRootMosaicDirectory(location);
configuration.setIndexingDirectories(Arrays.asList(location));
configuration.setIndexName(indexName);
-
+ configuration.setHints(hints);
+
// look for and indexed.properties file
final File parent = new File(location);
final File indexerProperties = new File(parent,
"indexer.properties");
@@ -245,7 +256,11 @@ public class Utils {
return exception.getMessage();
}
- static URL checkSource(Object source) throws MalformedURLException,
+ static URL checkSource(Object source) throws MalformedURLException,
DataSourceException {
+ return checkSource(source, null);
+ }
+
+ static URL checkSource(Object source, Hints hints) throws
MalformedURLException,
DataSourceException {
URL sourceURL = null;
File sourceFile = null;
@@ -380,7 +395,7 @@ public class Utils {
if (buildMosaic) {
// try to build a mosaic inside this
directory and see what
// happens
- createMosaic(locationPath,
defaultIndexName,DEFAULT_WILCARD, DEFAULT_PATH_BEHAVIOR);
+ createMosaic(locationPath,
defaultIndexName,DEFAULT_WILCARD, DEFAULT_PATH_BEHAVIOR, hints);
// check that the mosaic properties
file was created
final File propertiesFile = new
File(locationPath,
diff --git
a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/indexbuilder/IndexBuilder.java
b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/indexbuilder/IndexBuilder.java
index 179b298..709e977 100644
---
a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/indexbuilder/IndexBuilder.java
+++
b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/indexbuilder/IndexBuilder.java
@@ -453,7 +453,8 @@ public class IndexBuilder implements Runnable {
return;
}
cachedFormat=format;
- coverageReader = (AbstractGridCoverage2DReader)
format.getReader(fileBeingProcessed);
+ coverageReader = (AbstractGridCoverage2DReader)
+ format.getReader(fileBeingProcessed,
runConfiguration.getHints());
GeneralEnvelope envelope = (GeneralEnvelope)
coverageReader.getOriginalEnvelope();
CoordinateReferenceSystem actualCRS =
coverageReader.getCrs();
diff --git
a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/indexbuilder/IndexBuilderConfiguration.java
b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/indexbuilder/IndexBuilderConfiguration.java
index d710a13..7424fed 100644
---
a/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/indexbuilder/IndexBuilderConfiguration.java
+++
b/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/indexbuilder/IndexBuilderConfiguration.java
@@ -7,6 +7,7 @@ import java.util.List;
import org.apache.commons.beanutils.BeanUtils;
import org.geotools.console.Option;
+import org.geotools.factory.Hints;
import org.geotools.gce.imagemosaic.Utils;
import org.geotools.util.Utilities;
@@ -79,6 +80,8 @@ public class IndexBuilderConfiguration{
private String propertyCollectors;
+ private Hints hints;
+
public String getPropertyCollectors() {
return propertyCollectors;
}
@@ -198,6 +201,14 @@ public class IndexBuilderConfiguration{
this.wildcard = wildcardString;
}
+ public void setHints(Hints hints) {
+ this.hints = hints;
+ }
+
+ public Hints getHints() {
+ return hints;
+ }
+
@Override
public IndexBuilderConfiguration clone() throws
CloneNotSupportedException {
return new IndexBuilderConfiguration(this);
diff --git
a/modules/plugin/imageio-ext-gdal/src/main/java/org/geotools/coverageio/gdal/BaseGDALGridCoverage2DReader.java
b/modules/plugin/imageio-ext-gdal/src/main/java/org/geotools/coverageio/gdal/BaseGDALGridCoverage2DReader.java
index c45a2bb..afa67b9 100644
---
a/modules/plugin/imageio-ext-gdal/src/main/java/org/geotools/coverageio/gdal/BaseGDALGridCoverage2DReader.java
+++
b/modules/plugin/imageio-ext-gdal/src/main/java/org/geotools/coverageio/gdal/BaseGDALGridCoverage2DReader.java
@@ -40,6 +40,7 @@ import
org.geotools.referencing.operation.transform.ProjectiveTransform;
import org.opengis.coverage.grid.GridCoverageReader;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.operation.TransformException;
@@ -109,8 +110,15 @@ public abstract class BaseGDALGridCoverage2DReader extends
//
// //
if (getCoverageCRS() == null) {
- LOGGER.info("crs not found, proceeding with EPSG:4326");
- setCoverageCRS(AbstractGridFormat.getDefaultCRS());
+ //look for a hint
+ if (hints.containsKey(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM)) {
+ setCoverageCRS(
+
(CoordinateReferenceSystem)hints.get(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM));
+ }
+ else {
+ LOGGER.info("crs not found, proceeding with EPSG:4326");
+ setCoverageCRS(AbstractGridFormat.getDefaultCRS());
+ }
}
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel