Issues with units in epsg-hsql?

Environment

None

Activity

Show:
codehaus
April 10, 2015, 3:12 PM

CodeHaus Comment From: desruisseaux - Time: Thu, 3 May 2007 03:07:12 -0500
---------------------
No, the 3 above-cited hints applies on SQL-backed EPSG database only.

I will set FORCE_STANDARD_AXIS_UNITS to false by default in a few minutes, will comment out the GeoTIFF test and will commit to trunk. Will post to the devel mailing list to let peoples know.

codehaus
April 10, 2015, 3:12 PM

CodeHaus Comment From: desruisseaux - Time: Thu, 3 May 2007 03:18:05 -0500
---------------------
As a side note, peoples can test FORCE_STANDARD_AXIS_UNITS to FALSE by editing org.geotools.referencing.factory.epsg.LongitudeFirstFactory (revision 25399 on trunk) and search for "TODO" flags, especially the one at line 123.

codehaus
April 10, 2015, 3:12 PM

CodeHaus Comment From: aaime - Time: Thu, 3 May 2007 04:33:07 -0500
---------------------
I did the following test. Commented out FORCE_STANDARD_UNITS in LongitudeFirstFactory, then run the following little app:

package org.geotools.referencing;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Collections;

import java.util.Iterator;

import java.util.List;

import java.util.Properties;

import org.opengis.referencing.FactoryException;

import org.opengis.referencing.NoSuchAuthorityCodeException;

import org.opengis.referencing.crs.CoordinateReferenceSystem;

import org.opengis.referencing.cs.CoordinateSystem;

public class CRSCompare {

    public static void main(String[] args) throws FileNotFoundException, IOException,

            NoSuchAuthorityCodeException, FactoryException {

        Properties espgWkt = new Properties();

        espgWkt

                .load(new FileInputStream(

                        "C:/progetti/geotools/trunk/modules/plugin/epsg-wkt/src/main/resources/org/geotools/referencing/crs/epsg.properties&quot);

        List keys = new ArrayList(espgWkt.keySet());

        Collections.sort(keys);

        int axisEqual = 0;

        int equal = 0;

        int lost = 0;

        int undecodableWkt = 0;

        for (Iterator it = keys.iterator(); it.hasNext() {

            String key = (String) it.next();

            String wkt = espgWkt.getProperty(key);

            CoordinateReferenceSystem crsWkt;

            CoordinateReferenceSystem crsHsql;

            try {

                crsWkt = CRS.parseWKT(wkt);

            } catch (Exception e) {

                undecodableWkt++;

                continue;

            }

            try {

                // forced lon/lat here to avoid CRS crash setting the system property

                crsHsql = CRS.decode("EPSG:" + key, true);

            } catch (Exception e) {

                lost++;

                System.out.println("Issues decoding hsql form for epsg:" + key);

                System.out.println(e.getMessage());

                System.out.println("Wkt was: " + wkt);

                continue;

            }

            CoordinateSystem csWkt = crsWkt.getCoordinateSystem();

            CoordinateSystem csHsql = crsHsql.getCoordinateSystem();

            if (!CRS.equalsIgnoreMetadata(csWkt, csHsql)) {

                if (csWkt.getDimension() != csHsql.getDimension()) {

                    System.out.println("Different dimensions for " + key);

                } else if (CRS.equalsIgnoreMetadata(csWkt.getAxis(0), csHsql.getAxis(0))) {

                    System.out.println("Different axis(0) for " + key);

                    System.out.println(crsWkt.toString().replaceAll("
s", "&quot);

                    System.out.println(crsHsql.toString().replaceAll("
s", "&quot);

                } else if (CRS.equalsIgnoreMetadata(csWkt.getAxis(1), csHsql.getAxis(1))) {

                    System.out.println("Different axis(1) for " + key);

                    System.out.println(crsWkt.toString().replaceAll("
s", "&quot);

                    System.out.println(crsHsql.toString().replaceAll("
s", "&quot);

                } else {

                    axisEqual++;

                    // System.out.println("Code " + key + " soft mismatch"

                }

            } else {

                equal++;

            }

        }

        System.out.println("Undecodable wkts: " + undecodableWkt + "/" + keys.size());

        System.out.println("Lost: " + lost + "/" + keys.size());

        System.out.println("Axis wise equal: " + axisEqual + "/" + keys.size());

        System.out.println("Totally equal: " + equal + "/" + keys.size());

    }

}

The result is:

Undecodable wkts: 39/2798

Lost: 80/2798

Axis wise equal: 2373/2798

Totally equal: 306/2798

Now, checking for equality axis wise is very shallow, but at least confirms that once x/y order is forced and standard units are not forced, axis are equal on all CRS that we can compare.

Still, only 306 pass the CRS.equalsIgnoreMetadata tests, thought I think most of the mismatch are due to slightly differently named datums.

Long story short, +1 on not setting FORCE_STANDARD_UNITS in LongitudeFirstFactory.

codehaus
April 10, 2015, 3:12 PM

CodeHaus Comment From: desruisseaux - Time: Thu, 3 May 2007 05:02:39 -0500
---------------------
Commited on trunk as of revision 25400.

codehaus
April 10, 2015, 3:12 PM

CodeHaus Comment From: aaime - Time: Sun, 28 Nov 2010 02:56:20 -0600
---------------------
Mass closing all issues that have been in "resolved" state for 2 months or more without any feedback or update

Assignee

Unassigned

Reporter

codehaus

Triage

None

Components

Fix versions

Affects versions

Priority

Highest
Configure