Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.1.M0, 2.1.M1, 2.1.M2
-
Fix Version/s: 2.1.M3
-
Component/s: referencing
-
Labels:None
Description
The current snapshot of GeoAPI has included a collection of new constants in org.opengis.referencing.cs.AxisDirection. Several existing constants have been deprecated. Geotools is failing to create new CoordinateOperation instances due to being unable to handle the new constants or at least tell that the GeoAPI created value is directly equivalent to the internal constant version..
For example, the following code:
import org.opengis.referencing.cs.*;
import org.opengis.referencing.datum.*;
import java.util.HashMap;
import javax.units.SI;
import javax.units.Unit;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.CRSFactory;
import org.opengis.referencing.operation.CoordinateOperationFactory;
import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.referencing.operation.MathTransform;
import org.geotools.referencing.FactoryFinder;
...
csFactory = FactoryFinder.getCSFactory();
map = new HashMap();
map.put("name", "Cartesian X axis");
CoordinateSystemAxis x_axis =
csFactory.createCoordinateSystemAxis(map,
"X",
AxisDirection.GEOCENTRIC_X,
SI.METER);
...
map = new HashMap();
map.put("name", "Rendered Cartesian CS");
CartesianCS world_cs = csFactory.createCartesianCS(map,
x_axis,
y_axis,
z_axis);
...
wgs84EllipsoidHD = datumFactory.createGeodeticDatum(map,
wgs84Ellipsoid,
greenwichMeridian);
map = new HashMap();
map.put("name", "Output Cartesian CS");
outputCoordSystem =
crsFactory.createGeocentricCRS(map,
wgs84EllipsoidHD,
world_cs);
is a valid construct. Calling
CoordinateOperation cst =
transformFactory.createOperation(src_cs, outputCoordSystem);
results in the following exception:
Caused by: java.lang.IllegalArgumentException: No source axis match GEOCENTRIC_X.
at org.geotools.referencing.operation.GeneralMatrix.<init>(GeneralMatrix.java:296)
at org.geotools.referencing.operation.GeneralMatrix.<init>(GeneralMatrix.java:202)
at org.geotools.referencing.cs.CoordinateSystem.swapAndScaleAxis(CoordinateSystem.java:206)
at org.geotools.referencing.operation.CoordinateOperationFactory.swapAndScaleAxis(CoordinateOperationFactory.java:680)
However, changing the creation of the CartesianCS to use the Geotools predefined constants in org.geotools.referencing.cs.CoordinateSystemAxis will result in correctly functioning code (ie no exception). For example, this works:
map = new HashMap();
map.put("name", "Rendered Cartesian CS");
CartesianCS world_cs = csFactory.createCartesianCS(map,
org.geotools.referencing.cs.CoordinateSystemAxis.GEOCENTRIC_X,
org.geotools.referencing.cs.CoordinateSystemAxis.GEOCENTRIC_Y,
org.geotools.referencing.cs.CoordinateSystemAxis.GEOCENTRIC_Z);
Issue Links
- is depended upon by
-
GEOT-403
Failures in OpenGIS test scripts
-
Fixed on SVN, revision 11138. Closing as "resolved"; please reopen this bug report if a problem still present.