GeoTools
  1. GeoTools
  2. GEOT-358

Current GeoAPI snapshot AxisDirection has new, unhandled constants

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major 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

          Activity

          Hide
          Martin Desruisseaux added a comment -
          CoordinateSystemAxis.GEOCENTRIC_* constants in Geotools used wrong directions. It was (EAST,NORTH,UP) (the "UP" make no-sence) when it should have been (OTHER,EAST,NORTH) (the "OTHER" it toward prime meridian). Concequently, any code using their own axis with standard directions fails, since Geotools was expecting bogus directions. It also explain why a code using Geotools constant worked, since those constants defines the (bogus) direction expected by Geotools.

          Fixed on SVN, revision 11138. Closing as "resolved"; please reopen this bug report if a problem still present.
          Show
          Martin Desruisseaux added a comment - CoordinateSystemAxis.GEOCENTRIC_* constants in Geotools used wrong directions. It was (EAST,NORTH,UP) (the "UP" make no-sence) when it should have been (OTHER,EAST,NORTH) (the "OTHER" it toward prime meridian). Concequently, any code using their own axis with standard directions fails, since Geotools was expecting bogus directions. It also explain why a code using Geotools constant worked, since those constants defines the (bogus) direction expected by Geotools. Fixed on SVN, revision 11138. Closing as "resolved"; please reopen this bug report if a problem still present.

            People

            • Assignee:
              Martin Desruisseaux
              Reporter:
              Justin Couch
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: