A DB2 sample program that displays a map based on spatial data in a DB2
table used to work but no longer works when I tried it recently. It just
fails to display anything.

It seems to be related to the AXIS ordering in the CRS which is different
depending on whether one uses CRS.decode("EPSG:4326) or CRS.parseWKT(wkt)
where wkt is the string representation of EPSG 4326. I fixed the problem by
changing the DB2 code to use CRS.parseWKT instead of  CRS.decode with "org"
and "orgid". Shouldn't it work both ways?

The following is my analysis of the problem:

Using CRS.decode("EPSG:4326")
results in
GEOGCS["WGS 84",
  DATUM["World Geodetic System 1984",
    SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],
    AUTHORITY["EPSG","6326"]],
  PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
  UNIT["degree", 0.017453292519943295],
  AXIS["Geodetic latitude", NORTH],
  AXIS["Geodetic longitude", EAST],
  AUTHORITY["EPSG","4326"]]

In StreamingRenderer.paint
CRS.getAxisOrder(mapCRS) returns CRS.AxisOrder.NORTH_EAST
which executes the following code which flips the AffineTransform in
WorldToScreen which completely messes up the subsequent transformation
from world to screen coordinates, causing them to be outside the
clip area.
        if (CRS.getAxisOrder(mapCRS) == CRS.AxisOrder.NORTH_EAST) {
            try {
                // sanitize, having flipped axis causes slowdowns, the
rendering
                // subsystem has to go from data to rendering to screen
flipping axis order
                // twice when advanced projection handling is enabled
                Integer code = CRS.lookupEpsgCode(mapCRS, false);
                if (code != null) {
                    String srs = "EPSG:" + code;
                    CoordinateReferenceSystem earthNorthCRS =
CRS.decode(srs, true);
                    mapArea =
                            new ReferencedEnvelope(
                                    mapArea.getMinY(),
                                    mapArea.getMaxY(),
                                    mapArea.getMinX(),
                                    mapArea.getMaxX(),
                                    earthNorthCRS);
                }

                // flip world to screen too
                worldToScreen =
                        new AffineTransform(
                                worldToScreen.getShearX(),
                                worldToScreen.getScaleX(),
                                worldToScreen.getScaleY(),
                                worldToScreen.getShearY(),
                                worldToScreen.getTranslateX(),
                                worldToScreen.getTranslateY());
            } catch (Exception e) {
                LOGGER.log(
                        Level.FINER,
                        "Failed to turn the requested bbox in east/north
order, map rendering "
                                + "should work anyways, but pay a
performance price");
            }

Creating the CRS from WKT, everything works fine.
CRS from CRS.decodeWKT(wkt)
GEOGCS["GCS_WGS_1984",
  DATUM["D_WGS_1984",
    SPHEROID["WGS_1984", 6378137.0, 298.257223563]],
  PRIMEM["Greenwich", 0.0],
  UNIT["degree", 0.017453292519943295],
  AXIS["Longitude", EAST],
  AXIS["Latitude", NORTH]]
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to