[Geoserver-devel] [jira] Created: (GEOS-2040) AbstractFeatureInfoResponse: WmsException may occurs if Bulsa Parameters are missing when evaluating a coverage providing a point in different CRS (with respect to the one of the coverage itself).

AbstractFeatureInfoResponse: WmsException may occurs if Bulsa Parameters are missing when evaluating a coverage providing a point in different CRS (with respect to the one of the coverage itself).
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: GEOS-2040
                 URL: http://jira.codehaus.org/browse/GEOS-2040
             Project: GeoServer
          Issue Type: Bug
          Components: WMS
    Affects Versions: 1.7.0-beta1
            Reporter: Daniele Romagnoli
            Assignee: Andrea Aime
             Fix For: 1.7.0-beta2

When trying to evaluate the coverage by providing a point that is in a different CRS with respect to the one of the coverage itself, problems may occurs when the bursa params are missing.
In such a case, WMS may cause a WmsException resulting in no value displayed in the OpenLayer client.

TRACE:
-----------

org.vfny.geoserver.wms.WmsException
  at org.vfny.geoserver.wms.responses.featureInfo.AbstractFeatureInfoResponse.execute(AbstractFeatureInfoResponse.java:279)
.....
Caused by: org.opengis.coverage.CannotEvaluateException: Can't evaluate a value for coordinate (28,593, 42,74).
  at org.geotools.coverage.grid.GridCoverage2D.toPoint2D(GridCoverage2D.java:561)
  at org.geotools.coverage.grid.GridCoverage2D.evaluate(GridCoverage2D.java:532)
  at org.vfny.geoserver.wms.responses.featureInfo.AbstractFeatureInfoResponse.execute(AbstractFeatureInfoResponse.java:268)
  ... 53 more
Caused by: org.opengis.referencing.operation.TransformException: Bursa wolf parameters required.
  at org.geotools.geometry.TransformedDirectPosition.setSourceCRS(TransformedDirectPosition.java:205)
  at org.geotools.geometry.TransformedDirectPosition.transform(TransformedDirectPosition.java:255)
  at org.geotools.coverage.grid.GridCoverage2D.toPoint2D(GridCoverage2D.java:559)
  ... 55 more
Caused by: org.opengis.referencing.operation.OperationNotFoundException: Bursa wolf parameters required.
  at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1072)
  at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1136)
  at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:881)
  at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:965)
  at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:243)
  at org.geotools.referencing.operation.BufferedCoordinateOperationFactory.createOperation(BufferedCoordinateOperationFactory.java:254)
  at org.geotools.geometry.TransformedDirectPosition.setSourceCRS(TransformedDirectPosition.java:203)
  ... 57 more
-----------------------------------

The workaround could be substituting this line of code in AbstractFeatureInfoResponse.execute method:

                        double pixelValues = coverage.evaluate(position, (double) null);

with this one:

                        double pixelValues = null;
                        if (requestedCRS != null) {
                            final CoordinateReferenceSystem targetCRS = coverage.getCoordinateReferenceSystem2D();
                            TransformedDirectPosition arbitraryToInternal = new TransformedDirectPosition(requestedCRS, targetCRS, new Hints(Hints.LENIENT_DATUM_SHIFT,Boolean.TRUE));
                                try {
                                    arbitraryToInternal.transform(position);
                                } catch (TransformException exception) {
                                    throw new CannotEvaluateException(exception.getLocalizedMessage());
                                }
                                Point2D point2D = arbitraryToInternal.toPoint2D();
                                pixelValues = coverage.evaluate(point2D, (double) null);
                        }
                        else
                            pixelValues = coverage.evaluate(position, (double) null);

This version allows to leverage on a LENIENT_DATUM_SHIFT Hint.

Daniele

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira