[Geoserver-devel] Serious axis ordering issue in current GeoServer trunk

Hi,
it seems the more we try to play ok with CRS, the more
we trip into troubles. This time a fix to handle the
versioning demo (have the bbox and geometries expressed
in 900913 reprojected on the fly to the native CRS
before querying) made one of our demo request don't work
anymore. The request is the simple:

  >wfs:GetFeature service="WFS" version="1.0.0"
    outputFormat="GML2" maxFeatures="2"
    xmlns:topp="http://www.openplans.org/topp"
    xmlns:wfs="http://www.opengis.net/wfs"
    xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:gml="http://www.opengis.net/gml"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.opengis.net/wfs
                        http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
    <wfs:Query typeName="topp:states">
      <ogc:Filter>
        <ogc:BBOX>
          <ogc:PropertyName>the_geom</ogc:PropertyName>
          <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
             <gml:coordinates>-130,24 -66,50</gml:coordinates>
          </gml:Box>
        </ogc:BBOX>
     </ogc:Filter>
    </wfs:Query>
</wfs:GetFeature>

and it does not work anymore (does not return anything) because for the
first time in GeoServer history we're reading the srsName attribute and
use it.

Now the explaination:
Calling CRS.decode("EPSG:4326") in GeoServer returns:
   (org.geotools.referencing.crs.DefaultGeographicCRS) 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 longitude", EAST],
    AXIS["Geodetic latitude", NORTH],
    AUTHORITY["EPSG","4326"]]

but doing the following, again in GeoServer:
CRS.decode("http://www.opengis.net/gml/srs/epsg.xml#4326&quot;\)
   (org.geotools.referencing.crs.DefaultGeographicCRS) 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"]]

(notice the axis order in the two).

So, it seems GeoTools CRS subsystem tries to respect the authority
axis ordering no matter what even for "http://…" srs versions (it
does it already for the "urn:x-ogc:..." version).

This is a little problematic because there is current debate with
OGC folks on how this one should be handled. In any case, we all
know that no current wfs client uses lat/lon ordering so the
above is wrong from a practical point of view (it may be ok from
a theoretical point of view, but we have to work in the real world).

To recap the situation with OGC (I'm currently speaking to Raj
and other folks alongside Frank Stegging from Bentley software):
* EPSG:XXXX was dubious from the beginning, OGC is going to deprecate
    it are remove it from all standard, and it's safe to treat it
    as lon/lat ordered since everybody is doing it.
* urn:x-ogc:def:crs:EPSG:6.11.2:XXXX is clearly lat/lon since it has
    been published after the clarification on what the expected axis
    order is (the one specified in the authority, in case of EPSG,
    it's lat/lon)
* http://www.opengis.net/gml/srs/epsg.xml#XXXX is problematic, there
    is no clear assumption. The only thing I could say is that all
    WFS 1.0 are bound to use it and they react by treating it as
    lon/lat, so I guess we should do the same.

Long story short, we need GeoTools to respect the
"org.geotools.referencing.forceXY" hint for the
"http://www.opengis.net/gml/srs/epsg.xml#XXXX&quot; form as well
   (or give us another hint to influence the interpretation of it).

A possible workaround on the GeoServer side would be to kill all
CRS.decode(...) calls, create our utility class that does the same,
but that works with the above specified issues, calling
CRS.decode(id, forceXY) under covers and forcing the crs depending
on how the id looks like (id.startsWith("http") -> force xy).
The drawback is that there is no guarantee things will go smoothly,
because the GeoTools datastores will happily keep on doing
CRS.decode(srsSpec).

Opinions?
Cheers
Andrea

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

!DSPAM:4022,47175f307011336712104!

Andrea Aime a écrit :

Long story short, we need GeoTools to respect the
"org.geotools.referencing.forceXY" hint for the
"http://www.opengis.net/gml/srs/epsg.xml#XXXX&quot; form as well

I have no objection to that. The http://jira.codehaus.org/browse/GEOT-1388 task
is still open. I just want to be compliant with what we are supposed to do, and
avoid adding our contribution to the "standardization" of bugs (like what
Microsoft is trying to do with OpenXML: they have a bug in the way Excel handles
dates around 1900 which introduce an offset of 1 day in date calculation.
Instead of fixing their bugs, Microsoft wants them to be frozen in ISO standard
for Excel compatibility: http://www.robweir.com/blog/2006/10/leap-back.html).

So if honoring FORCE_LONGITUDE_FIRST_AXIS_ORDER is what we should do for http://
code, either as OGC direction or as common practice, then lets comment on
GEOT-1388 so we update the referencing module accordingly. I have never done a
review on what other software does, so I don't know what the common practice is.

  Martin

Martin Desruisseaux ha scritto:

Andrea Aime a écrit :

Long story short, we need GeoTools to respect the
"org.geotools.referencing.forceXY" hint for the
"http://www.opengis.net/gml/srs/epsg.xml#XXXX&quot; form as well

I have no objection to that. The http://jira.codehaus.org/browse/GEOT-1388 task
is still open. I just want to be compliant with what we are supposed to do, and
avoid adding our contribution to the "standardization" of bugs (like what
Microsoft is trying to do with OpenXML: they have a bug in the way Excel handles
dates around 1900 which introduce an offset of 1 day in date calculation.
Instead of fixing their bugs, Microsoft wants them to be frozen in ISO standard
for Excel compatibility: http://www.robweir.com/blog/2006/10/leap-back.html).

So if honoring FORCE_LONGITUDE_FIRST_AXIS_ORDER is what we should do for http://
code, either as OGC direction or as common practice, then lets comment on
GEOT-1388 so we update the referencing module accordingly. I have never done a
review on what other software does, so I don't know what the common practice is.

Frank Stegging has done quite a review on the servers he could find
on the internet and it seems basically no server in production around
the internet today is using lat/lon axis ordering (most servers are WFS 1.0).
OGC is going to create a recommendation paper on this issue, but the
paper itself is months away.
Maybe the safe approach would be to have a separate config so that
people can choose what they want "a la carte"?

Cheers
Andrea

Andrea Aime a écrit :

Maybe the safe approach would be to have a separate config so that
people can choose what they want "a la carte"?

A new Hints or system property? I'm fine with that. Any proposal for the Hint or
property name? What about:

    Hints.FORCE_AXIS_ORDER_HONORING

Values would be a space or comma-separated String (or maybe an array String)
of authority space that should honor the FORCE_LONGITUDE_AXIS_ORDER hints, even
if they usually don't. Example:

    hints.put(FORCE_LONGITUDE_FIRST_AXIS_ORDER, true);
    hints.put(FORCE_AXIS_ORDER_HONORING, "http");

means that longitude-first axis order should be forced for "http://…" codes as
well (in addition of "EPSG", which is always implicit).

    hints.put(FORCE_LONGITUDE_FIRST_AXIS_ORDER, true);
    hints.put(FORCE_AXIS_ORDER_HONORING, "http, urn");

means that longitude-first axis order should be forced for "http://…" and
"urn:..." codes.

Does it sound like raisonable?

  Martin

Martin Desruisseaux ha scritto:

Andrea Aime a écrit :

Maybe the safe approach would be to have a separate config so that
people can choose what they want "a la carte"?

A new Hints or system property? I'm fine with that. Any proposal for the Hint or
property name? What about:

    Hints.FORCE_AXIS_ORDER_HONORING

Values would be a space or comma-separated String (or maybe an array String)
of authority space that should honor the FORCE_LONGITUDE_AXIS_ORDER hints, even
if they usually don't. Example:

    hints.put(FORCE_LONGITUDE_FIRST_AXIS_ORDER, true);
    hints.put(FORCE_AXIS_ORDER_HONORING, "http");

means that longitude-first axis order should be forced for "http://…" codes as
well (in addition of "EPSG", which is always implicit).

    hints.put(FORCE_LONGITUDE_FIRST_AXIS_ORDER, true);
    hints.put(FORCE_AXIS_ORDER_HONORING, "http, urn");

means that longitude-first axis order should be forced for "http://…" and
"urn:..." codes.

Does it sound like raisonable?

Looks good to me :slight_smile:
Cheers
Andrea

Martin Desruisseaux ha scritto:

Andrea Aime a écrit :

Maybe the safe approach would be to have a separate config so that
people can choose what they want "a la carte"?

A new Hints or system property? I'm fine with that. Any proposal for the Hint or
property name? What about:

And oh, I'm confortable using a system property, not sure how to
set a hint so that it'll influence all CRS.decode(xxxx) operations.

Cheers
Andrea

Andrea Aime a écrit :

And oh, I'm confortable using a system property, not sure how to
set a hint so that it'll influence all CRS.decode(xxxx) operations.

Following should work:

http://javadoc.geotools.fr/snapshot/org/geotools/factory/GeoTools.html#init(org.geotools.factory.Hints)

but I can add a system property as well.

  Martin

Added a FORCE_AXIS_ORDER_HONORING hint on GeoTools 2.4 branch as of revision
27544. Set this hint to "http" in order to get (longitude,latitude) axis order
for "http://www.opengis.net/&quot; namespace as well as EPSG. Set this hint to "http,
urn" in order to force that axis order for URN too.

You can set it system-wide using Hints.putSystemHint(...) method (or
Geotools.init(...), at your choice). I have not yet done a system property for that.

I didn't tested this hint in the context of gt2-epsg-hsql yet. Please let me
know if it fixes your issues.

  Martin

Martin Desruisseaux ha scritto:

Added a FORCE_AXIS_ORDER_HONORING hint on GeoTools 2.4 branch as of revision
27544. Set this hint to "http" in order to get (longitude,latitude) axis order
for "http://www.opengis.net/&quot; namespace as well as EPSG. Set this hint to "http,
urn" in order to force that axis order for URN too.

You can set it system-wide using Hints.putSystemHint(...) method (or
Geotools.init(...), at your choice). I have not yet done a system property for that.

I didn't tested this hint in the context of gt2-epsg-hsql yet. Please let me
know if it fixes your issues.

I just added it to GeoServer trunk and it seems to be working fine.
Thank you :slight_smile:
Cheers
Andrea