Hi,
there's an issue with the EPSG database that has been bothering
me for quite some time: the DMS unit.

The EPSG guidance defines the DMS unit as follow:

----------------------------------------------------------------------

To allow coordinate operation parameter values given by their information source in the compound unit sexagesimal degrees to be stored in the Dataset in a single numeric field but retaining the given values, an EPSG artificial unit "sexagesimal DMS" (UoM code 9110) has been created. The general format is: signed degrees - period - minutes (two digits) - integer seconds (two digits) - fraction of seconds (any precision). The value must include a leading zero for minutes or seconds less than 10 and exclude the decimal point for seconds. For example, 35°24'06.42" = 35.240642 sexagesimal DMS. This ‘unit’ allows storage of sexagesimal values to any precision, including integer minute or integer second, for example 35°24' = 35.24 sexagesimal DMS and 35°24'06" = 35.2406 sexagesimal DMS. When minute or second unit is a multiple of ten, the trailing zero will not be included if there is no further resolution, for example 35°20' = 35.2 sexagesimal DMS and 35°24'10" = 35.241 sexagesimal DMS. Conversely, 35.3 sexagesimal DMS = 35°30' = 35.5°. Parameters which are angles may be stored in the Dataset as real numbers or sexagesimal
DMS. The Dataset includes identification of the unit.

----------------------------------------------------------------------

This unit is used in quite a bit of EPSG codes, and we cannot use any
of them, because the referencing subsystem cannot handle the above
non linear unit transformation when setting up a map projection.
You get this:

Exception in thread "main" org.opengis.referencing.FactoryException: Unit conversion from "DMS" to "°" is non-linear. at org.geotools.referencing.operation.DefaultMathTransformFactory.createBaseToDerived(DefaultMathTransformFactory.java:394) at org.geotools.referencing.operation.DefaultMathTransformFactory.createBaseToDerived(DefaultMathTransformFactory.java:352) at org.geotools.referencing.factory.ReferencingObjectFactory.createProjectedCRS(ReferencingObjectFactory.java:1019) at org.geotools.referencing.factory.epsg.DirectEpsgFactory.createCoordinateReferenceSystem(DirectEpsgFactory.java:1939) at org.geotools.referencing.factory.BufferedAuthorityFactory.createCoordinateReferenceSystem(BufferedAuthorityFactory.java:781) at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:799) at org.geotools.referencing.factory.FallbackAuthorityFactory.createCoordinateReferenceSystem(FallbackAuthorityFactory.java:638) at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:799) at org.geotools.referencing.factory.ThreadedAuthorityFactory.createCoordinateReferenceSystem(ThreadedAuthorityFactory.java:729) at org.geotools.referencing.DefaultAuthorityFactory.createCoordinateReferenceSystem(DefaultAuthorityFactory.java:179)
        at org.geotools.referencing.CRS.decode(CRS.java:437)
        at org.geotools.referencing.CRS.decode(CRS.java:365)
        at CRSDecode.main(CRSDecode.java:7)
Caused by: javax.measure.converter.ConversionException: Unit conversion from "DMS" to "°" is non-linear. at org.geotools.referencing.cs.AbstractCS.swapAndScaleAxis(AbstractCS.java:369) at org.geotools.referencing.operation.DefaultMathTransformFactory.createBaseToDerived(DefaultMathTransformFactory.java:387)
        ... 12 more

One way to skin the cat would be to extend the referencing subsystem
to allow such transformations as well... however that would seem to
me like wasted time.... who is actually using DMS as a storage and
computation unit for coordinates? At best it can be a way to represent
data on a screen.
My guess is that anybody using a CRS with DMS unit is actually storing
the data in decimal deegrees, and that providing actual support for
the DMS unit transformation would just result in confused users.

2150 is one of such codes, if I look at spatialreference.org they
are using deegree as well:
http://www.spatialreference.org/ref/epsg/2150/html/

What about:
a) go down and just change the current behavior to just use
   decimal degrees. Rationale: CRS with DMS are not usable anyways,
   so we don't have backwards compatibility issues from that pov
b) alternatively, add a flag to control the DMS/degree behavior.

The patch to do simply a) is attached.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
diff --git a/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/AbstractEpsgFactory.java b/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/AbstractEpsgFactory.java
index b736f25..4bc88cd 100644
--- a/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/AbstractEpsgFactory.java
+++ b/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/AbstractEpsgFactory.java
@@ -2847,10 +2847,10 @@ public abstract class AbstractEpsgFactory extends AbstractCachedAuthorityFactory
             case 9103: return NonSI.MINUTE_ANGLE;
             case 9104: return NonSI.SECOND_ANGLE;
             case 9105: return NonSI.GRADE;
-            case 9107: return Units.DEGREE_MINUTE_SECOND;
-            case 9108: return Units.DEGREE_MINUTE_SECOND;
+            case 9107: return NonSI.DEGREE_ANGLE;
+            case 9108: return NonSI.DEGREE_ANGLE;
             case 9109: return    SI.MICRO(SI.RADIAN);
-            case 9110: return Units.SEXAGESIMAL_DMS;
+            case 9110: return NonSI.DEGREE_ANGLE;
 //TODO      case 9111: return NonSI.SEXAGESIMAL_DM;
             case 9203: // Fall through
             case 9201: return  Unit.ONE;
diff --git a/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/DirectEpsgFactory.java b/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/DirectEpsgFactory.java
index 6ad5a08..2aa0d99 100644
--- a/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/DirectEpsgFactory.java
+++ b/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/DirectEpsgFactory.java
@@ -153,10 +153,10 @@ public abstract class DirectEpsgFactory extends DirectAuthorityFactory
             case 9103: return NonSI.MINUTE_ANGLE;
             case 9104: return NonSI.SECOND_ANGLE;
             case 9105: return NonSI.GRADE;
-            case 9107: return Units.DEGREE_MINUTE_SECOND;
-            case 9108: return Units.DEGREE_MINUTE_SECOND;
+            case 9107: return NonSI.DEGREE_ANGLE;
+            case 9108: return NonSI.DEGREE_ANGLE;
             case 9109: return    SI.MICRO(SI.RADIAN);
-            case 9110: return Units.SEXAGESIMAL_DMS;
+            case 9110: return NonSI.DEGREE_ANGLE;
 //TODO      case 9111: return NonSI.SEXAGESIMAL_DM;
             case 9203: // Fall through
             case 9201: return  Unit.ONE;
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to