You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2015/06/30 18:50:24 UTC
svn commit: r1688482 [2/2] - in /sis/branches/JDK7: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-metadata/src/main/java/org/apache/sis/io/wkt/
core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/
core/sis-m...
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/TransliteratorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/TransliteratorTest.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/TransliteratorTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/TransliteratorTest.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -49,6 +49,8 @@ public final strictfp class Transliterat
assertEquals("Geodetic longitude", t.toLongAxisName("ellipsoidal", AxisDirection.EAST, "longitude"));
assertEquals("Spherical latitude", t.toLongAxisName("spherical", AxisDirection.NORTH, "lat"));
assertEquals("Spherical longitude", t.toLongAxisName("spherical", AxisDirection.EAST, "long"));
+ assertEquals("Ellipsoidal height", t.toLongAxisName("ellipsoidal", AxisDirection.UP, "ellipsoidal_height"));
+ assertEquals("Unknown name", t.toLongAxisName("ellipsoidal", AxisDirection.UP, "Unknown name"));
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -30,6 +30,7 @@ import org.junit.BeforeClass;
* @module
*/
@Suite.SuiteClasses({
+ org.apache.sis.internal.metadata.AxisNamesTest.class,
org.apache.sis.internal.metadata.WKTKeywordsTest.class,
org.apache.sis.internal.metadata.NameMeaningTest.class,
org.apache.sis.internal.metadata.MetadataUtilitiesTest.class,
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -590,6 +590,19 @@ public final class ServicesForMetadata e
}
/**
+ * Returns the properties of the given object.
+ *
+ * @param object The object from which to get the properties.
+ * @return The properties of the given object.
+ *
+ * @since 0.6
+ */
+ @Override
+ public Map<String,?> getProperties(final IdentifiedObject object) {
+ return IdentifiedObjects.getProperties(object);
+ }
+
+ /**
* Returns {@code true} if the {@linkplain AbstractIdentifiedObject#getName() primary name} or an aliases
* of the given object matches the given name.
*
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/MatrixParametersAlphaNum.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -109,7 +109,7 @@ final class MatrixParametersAlphaNum ext
*/
if (isEPSG(indices)) {
name = EPSGName.create(name.tip().toString()); // Put the name in EPSG namespace.
- final int code = (indices[0] == 0 ? Constants.A0 : Constants.B0) + indices[1];
+ final int code = (indices[0] == 0 ? Constants.EPSG_A0 : Constants.EPSG_B0) + indices[1];
properties.put(ParameterDescriptor.IDENTIFIERS_KEY, EPSGName.identifier(code));
}
properties.put(ParameterDescriptor.NAME_KEY, name);
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -234,7 +234,8 @@ public class DefaultVerticalDatum extend
private VerticalDatumType type() {
VerticalDatumType t = type;
if (t == null) {
- type = t = VerticalDatumTypes.guess(this);
+ final Identifier name = super.getName();
+ type = t = VerticalDatumTypes.guess(name != null ? name.getCode() : null, super.getAlias(), null);
}
return t;
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -150,31 +150,31 @@ public final strictfp class GeodeticObje
assertEquals("unit", SI.METRE, axis.getUnit());
axis = parse(CoordinateSystemAxis.class, "AXIS[“latitude”,north,ORDER[1],ANGLEUNIT[“degree”,0.0174532925199433]]");
- assertEquals("name", "latitude", axis.getName().getCode());
+ assertEquals("name", "Latitude", axis.getName().getCode());
assertEquals("abbreviation", "φ", axis.getAbbreviation());
assertEquals("direction", AxisDirection.NORTH, axis.getDirection());
assertEquals("unit", NonSI.DEGREE_ANGLE, axis.getUnit());
axis = parse(CoordinateSystemAxis.class, "AXIS[“longitude”,EAST,order[2],UNIT[“degree”,0.0174532925199433]]");
- assertEquals("name", "longitude", axis.getName().getCode());
+ assertEquals("name", "Longitude", axis.getName().getCode());
assertEquals("abbreviation", "λ", axis.getAbbreviation());
assertEquals("direction", AxisDirection.EAST, axis.getDirection());
assertEquals("unit", NonSI.DEGREE_ANGLE, axis.getUnit());
axis = parse(CoordinateSystemAxis.class, "AXIS[“ellipsoidal height (h)”,up,ORDER[3],LengthUnit[“kilometre”,1000]]");
- assertEquals("name", "ellipsoidal height", axis.getName().getCode());
+ assertEquals("name", "Ellipsoidal height", axis.getName().getCode());
assertEquals("abbreviation", "h", axis.getAbbreviation());
assertEquals("direction", AxisDirection.UP, axis.getDirection());
assertEquals("unit", SI.KILOMETRE, axis.getUnit());
axis = parse(CoordinateSystemAxis.class, "AXIS[“time (t)”,future,TimeUnit[“hour”,3600]]");
- assertEquals("name", "time", axis.getName().getCode());
+ assertEquals("name", "Time", axis.getName().getCode());
assertEquals("abbreviation", "t", axis.getAbbreviation());
assertEquals("direction", AxisDirection.FUTURE, axis.getDirection());
assertEquals("unit", NonSI.HOUR, axis.getUnit());
axis = parse(CoordinateSystemAxis.class, "AXIS[“easting (X)”,south,MERIDIAN[90,UNIT[“degree”,0.0174532925199433]]]");
- assertEquals("name", "easting", axis.getName().getCode());
+ assertEquals("name", "Easting", axis.getName().getCode());
assertEquals("abbreviation", "X", axis.getAbbreviation());
assertEquals("direction", CoordinateSystems.directionAlongMeridian(AxisDirection.SOUTH, 90), axis.getDirection());
assertEquals("unit", SI.METRE, axis.getUnit());
@@ -298,6 +298,27 @@ public final strictfp class GeodeticObje
}
/**
+ * Tests the parsing of a geographic CRS from a WKT string with axes in wrong order according the
+ * {@code ORDER} elements. The {@code ORDER} elements are defined in WKT 2 (they did not existed in WKT 1),
+ * but the rest of the string is WKT 1. The SIS parser should sort the axes in the order declared
+ * in the {@code ORDER} elements.
+ *
+ * @throws ParseException if the parsing failed.
+ */
+ @Test
+ @DependsOnMethod("testWithAxisSwapping")
+ public void testAxisSorting() throws ParseException {
+ verifyGeographicCRS(1, parse(GeographicCRS.class,
+ " GEOGCS[“WGS 84”,\n" +
+ " DATUM[“World Geodetic System 1984”,\n" +
+ " SPHEROID[“WGS84”, 6378137.0, 298.257223563]],\n" +
+ " PRIMEM[“Greenwich”, 0.0],\n" +
+ " UNIT[“degree”, 0.017453292519943295],\n" +
+ " AXIS[“Longitude”, EAST, order[2]],\n" +
+ " AXIS[“Latitude”, NORTH, order[1]]]"));
+ }
+
+ /**
* Implementation of {@link #testGeographicCRS()} and {@link #testWithAxisSwapping()}.
* This test expects no {@code AUTHORITY} element on any component.
*
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTParserTest.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTParserTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTParserTest.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -16,12 +16,21 @@
*/
package org.apache.sis.io.wkt;
-import org.opengis.referencing.crs.*;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.crs.CRSFactory;
+import org.opengis.referencing.crs.VerticalCRS;
+import org.opengis.referencing.datum.VerticalDatumType;
+import org.opengis.util.FactoryException;
import org.opengis.test.wkt.CRSParserTest;
+import org.apache.sis.internal.metadata.AxisNames;
import org.apache.sis.test.DependsOn;
+import org.junit.Test;
+import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+import static org.junit.Assert.*;
+
/**
* Tests Well-Known Text parser using the tests defined in GeoAPI. Those tests use the
@@ -41,4 +50,138 @@ public class WKTParserTest extends CRSPa
public WKTParserTest() {
super(org.apache.sis.internal.system.DefaultFactories.forClass(CRSFactory.class));
}
+
+ /**
+ * Verifies the axis names of a geographic CRS. This method is invoked when the parsed object is
+ * expected to have <cite>"Geodetic latitude"</cite> and <cite>"Geodetic longitude"</cite> names.
+ */
+ @SuppressWarnings("fallthrough")
+ private void verifyEllipsoidalCS() {
+ final CoordinateSystem cs = object.getCoordinateSystem();
+ switch (cs.getDimension()) {
+ default: assertEquals("name", AxisNames.ELLIPSOIDAL_HEIGHT, cs.getAxis(2).getName().getCode());
+ case 2: assertEquals("name", AxisNames.GEODETIC_LONGITUDE, cs.getAxis(1).getName().getCode());
+ case 1: assertEquals("name", AxisNames.GEODETIC_LATITUDE, cs.getAxis(0).getName().getCode());
+ case 0: break;
+ }
+ switch (cs.getDimension()) {
+ default: assertEquals("abbreviation", "h", cs.getAxis(2).getAbbreviation());
+ case 2: assertEquals("abbreviation", "λ", cs.getAxis(1).getAbbreviation());
+ case 1: assertEquals("abbreviation", "φ", cs.getAxis(0).getAbbreviation());
+ case 0: break;
+ }
+ }
+
+ /**
+ * Completes the GeoAPI tests with a check of axis names.
+ *
+ * @throws FactoryException if an error occurred during the WKT parsing.
+ */
+ @Test
+ @Override
+ public void testGeographic() throws FactoryException {
+ super.testGeographic();
+ verifyEllipsoidalCS();
+ }
+
+ /**
+ * Completes the GeoAPI tests with a check of axis names.
+ *
+ * @throws FactoryException if an error occurred during the WKT parsing.
+ */
+ @Test
+ @Override
+ public void testGeographicWithRemark() throws FactoryException {
+ super.testGeographicWithRemark();
+ verifyEllipsoidalCS();
+ }
+
+ /**
+ * Completes the GeoAPI tests with a check of axis names.
+ *
+ * @throws FactoryException if an error occurred during the WKT parsing.
+ */
+ @Test
+ @Override
+ public void testGeographicWithId() throws FactoryException {
+ super.testGeographicWithId();
+ verifyEllipsoidalCS();
+ }
+
+ /**
+ * Completes the GeoAPI tests with a check of axis names.
+ *
+ * @throws FactoryException if an error occurred during the WKT parsing.
+ */
+ @Test
+ @Override
+ public void testGeographicWithGradUnits() throws FactoryException {
+ super.testGeographicWithGradUnits();
+ verifyEllipsoidalCS();
+ }
+
+ /**
+ * Completes the GeoAPI tests with a check of axis names.
+ *
+ * @throws FactoryException if an error occurred during the WKT parsing.
+ */
+ @Test
+ @Override
+ public void testGeocentric() throws FactoryException {
+ super.testGeocentric();
+ final CoordinateSystem cs = object.getCoordinateSystem();
+ assertEquals("name", AxisNames.GEOCENTRIC_X, cs.getAxis(0).getName().getCode());
+ assertEquals("name", AxisNames.GEOCENTRIC_Y, cs.getAxis(1).getName().getCode());
+ assertEquals("name", AxisNames.GEOCENTRIC_Z, cs.getAxis(2).getName().getCode());
+ }
+
+ /**
+ * Ignored for now, because the Lambert Azimuthal Equal Area projection method is not yet implemented.
+ *
+ * @throws FactoryException if an error occurred during the WKT parsing.
+ */
+ @Test
+ @Override
+ @Ignore("Lambert Azimuthal Equal Area projection method not yet implemented.")
+ public void testProjected() throws FactoryException {
+ }
+
+ /**
+ * Completes the GeoAPI tests with a check of axis names.
+ *
+ * @throws FactoryException if an error occurred during the WKT parsing.
+ */
+ @Test
+ @Override
+ public void testProjectedWithFootUnits() throws FactoryException {
+ super.testProjectedWithFootUnits();
+ final CoordinateSystem cs = object.getCoordinateSystem();
+ assertEquals("name", AxisNames.EASTING, cs.getAxis(0).getName().getCode());
+ assertEquals("name", AxisNames.NORTHING, cs.getAxis(1).getName().getCode());
+ }
+
+ /**
+ * Ignored for now, because the Transverse Mercator projection method is not yet implemented.
+ *
+ * @throws FactoryException if an error occurred during the WKT parsing.
+ */
+ @Test
+ @Override
+ @Ignore("Transverse Mercator projection method not yet implemented.")
+ public void testProjectedWithImplicitParameterUnits() throws FactoryException {
+ }
+
+ /**
+ * Completes the GeoAPI tests with a check of axis name and vertical datum type.
+ *
+ * @throws FactoryException if an error occurred during the WKT parsing.
+ */
+ @Test
+ @Override
+ public void testVertical() throws FactoryException {
+ super.testVertical();
+ final CoordinateSystem cs = object.getCoordinateSystem();
+ assertEquals("name", AxisNames.GRAVITY_RELATED_HEIGHT, cs.getAxis(0).getName().getCode());
+ assertEquals("datumType", VerticalDatumType.GEOIDAL, ((VerticalCRS) object).getDatum().getVerticalDatumType());
+ }
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -202,7 +202,7 @@ public final strictfp class DefaultParam
* Test below is identical to DefaultParameterDescriptorTest.testIdentifiedParameterWKT(),
* but is reproduced here for easier comparison with the test following it.
*/
- final DefaultParameterDescriptor<Double> descriptor = DefaultParameterDescriptorTest.createEPSG("A0", Constants.A0);
+ final DefaultParameterDescriptor<Double> descriptor = DefaultParameterDescriptorTest.createEPSG("A0", Constants.EPSG_A0);
assertWktEquals("Parameter[“A0”, Id[“EPSG”, 8623, URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor);
/*
* When the parameter is part of a larger element, we expect a simplification.
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -322,7 +322,7 @@ public final strictfp class DefaultParam
@Test
@DependsOnMethod("testWKT")
public void testIdentifiedParameterWKT() {
- final DefaultParameterDescriptor<Double> descriptor = createEPSG("A0", Constants.A0);
+ final DefaultParameterDescriptor<Double> descriptor = createEPSG("A0", Constants.EPSG_A0);
assertWktEquals("Parameter[“A0”, Id[“EPSG”, 8623, URI[“urn:ogc:def:parameter:EPSG::8623”]]]", descriptor);
}
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -603,7 +603,7 @@ public final strictfp class DefaultParam
@Test
@DependsOnMethod("testWKT")
public void testIdentifiedParameterWKT() {
- final Watcher<Double> parameter = new Watcher<>(DefaultParameterDescriptorTest.createEPSG("A0", Constants.A0));
+ final Watcher<Double> parameter = new Watcher<>(DefaultParameterDescriptorTest.createEPSG("A0", Constants.EPSG_A0));
assertWktEquals("Parameter[“A0”, null, Id[“EPSG”, 8623]]", parameter);
}
}
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -142,13 +142,30 @@ public final class Constants extends Sta
* EPSG code of the {@code A0} coefficient used in affine (general parametric) and polynomial transformations.
* Codes for parameters {@code A1} to {@code A8} inclusive follow, but the affine coefficients stop at {@code A2}.
*/
- public static final short A0 = 8623;
+ public static final short EPSG_A0 = 8623;
/**
* EPSG code of the {@code B0} coefficient used in affine (general parametric) and polynomial transformations.
* Codes for parameters {@code B1} to {@code B3} inclusive follow, but the affine coefficients stop at {@code B2}.
*/
- public static final short B0 = 8639;
+ public static final short EPSG_B0 = 8639;
+
+ /**
+ * The EPSG code of the "degree minute second hemisphere" pseudo-unit.
+ * Different symbol sets (º ' ") may be in use as field separators.
+ * Ends with hemisphere abbreviation (single character N S E or W).
+ */
+ public static final short EPSG_DMSH = 9108;
+
+ /**
+ * The EPSG code of the "sexagesimal DMS" pseudo-unit.
+ */
+ public static final short EPSG_DMS = 9110;
+
+ /**
+ * The EPSG code of the "sexagesimal DM" pseudo-unit.
+ */
+ public static final short EPSG_DM = 9111;
/**
* Do not allow instantiation of this class.
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -21,8 +21,11 @@ import java.util.HashMap;
import java.text.Format;
import java.text.FieldPosition;
import java.text.ParsePosition;
+import javax.measure.unit.NonSI;
+import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
+import org.apache.sis.measure.Units;
import org.apache.sis.util.Workaround;
@@ -78,6 +81,12 @@ public final class PatchedUnitFormat ext
private final UnitFormat format;
/**
+ * {@code true} for formatting the unit names using US spelling.
+ * Example: "meter" instead of "metre".
+ */
+ public boolean isLocaleUS;
+
+ /**
* Creates a new {@code PatchedUnitFormat} instance wrapping the given format.
*
* @param format the format to wrap.
@@ -135,6 +144,20 @@ public final class PatchedUnitFormat ext
return toAppendTo.append(symbol);
}
}
+ /*
+ * Following are specific to the WKT format, which is currently the only user of this method.
+ * If we invoke this method for other purposes, then we would need to provide more control on
+ * what kind of formatting is desired.
+ */
+ if (Unit.ONE.equals(unit)) {
+ return toAppendTo.append("unity");
+ } else if (NonSI.DEGREE_ANGLE.equals(unit)) {
+ return toAppendTo.append("degree");
+ } else if (SI.METRE.equals(unit)) {
+ return toAppendTo.append(isLocaleUS ? "meter" : "metre");
+ } else if (Units.PPM.equals(unit)) {
+ return toAppendTo.append("parts per million");
+ }
return format.format(unit, toAppendTo, pos);
}
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -49,9 +49,9 @@ public final class StandardDateFormat ex
public static final String PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SX";
/**
- * Short version of {@link #DATE_PATTERN}, to be used when formatting temporal extents
+ * Short version of {@link #PATTERN}, to be used when formatting temporal extents
* if the duration is greater than some threshold (typically one day). This pattern must
- * be a prefix of {@link #DATE_PATTERN}, since we will use that condition for deciding
+ * be a prefix of {@link #PATTERN}, since we will use that condition for deciding
* if this pattern is really shorter (the user could have created his own date format
* with a different pattern).
*/
@@ -86,27 +86,27 @@ public final class StandardDateFormat ex
*/
@Override
public Date parse(final String text, final ParsePosition position) {
- Date time = super.parse(text, position);
- if (time == null) {
+ Date date = super.parse(text, position);
+ if (date == null) {
/*
* The "yyyy-MM-dd'T'HH:mm:ss.SX" pattern may fail if the user did not specified the time part.
* So if we fail to parse using the full pattern, try again with only the "yyyy-MM-dd" pattern.
*/
final String pattern = toPattern();
- if (PATTERN.startsWith(pattern)) {
+ if (pattern.startsWith(SHORT_PATTERN)) {
final int errorIndex = position.getErrorIndex();
position.setErrorIndex(-1);
applyPattern(SHORT_PATTERN);
try {
- time = parse(text, position);
+ date = parse(text, position);
} finally {
applyPattern(pattern);
}
- if (time == null) {
+ if (date == null) {
position.setErrorIndex(errorIndex); // Reset original error index.
}
}
}
- return time;
+ return date;
}
}
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Tue Jun 30 16:50:23 2015
@@ -257,6 +257,13 @@ public final class Units extends Static
if (abs(factor - (PI / 200)) <= (EPS * PI/200)) {
return (Unit<A>) NonSI.GRADE;
}
+ } else if (SI.METRE.equals(unit)) {
+ if (abs(factor - 0.3048) <= (EPS * 0.3048)) {
+ return (Unit<A>) NonSI.FOOT;
+ }
+ if (abs(factor - (1200.0/3937)) <= (EPS * (1200.0/3937))) {
+ return (Unit<A>) NonSI.FOOT_SURVEY_US;
+ }
}
if (abs(factor - 1) > EPS) {
final long fl = (long) factor;
@@ -550,11 +557,11 @@ public final class Units extends Static
case 9103: return NonSI.MINUTE_ANGLE;
case 9104: return NonSI.SECOND_ANGLE;
case 9105: return NonSI.GRADE;
- case 9107: // Fall through
- case 9108: return SexagesimalConverter.DMS_SCALED;
case 9109: return SI.MetricPrefix.MICRO(SI.RADIAN);
- case 9111: return SexagesimalConverter.DM;
- case 9110: return SexagesimalConverter.DMS;
+ case 9107: // Fall through
+ case Constants.EPSG_DMSH: return SexagesimalConverter.DMS_SCALED;
+ case Constants.EPSG_DM: return SexagesimalConverter.DM;
+ case Constants.EPSG_DMS: return SexagesimalConverter.DMS;
case 9203: // Fall through
case 9201: return Unit .ONE;
case 9202: return Units.PPM;
Modified: sis/branches/JDK7/src/main/javadoc/stylesheet.css
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/src/main/javadoc/stylesheet.css?rev=1688482&r1=1688481&r2=1688482&view=diff
==============================================================================
--- sis/branches/JDK7/src/main/javadoc/stylesheet.css (original)
+++ sis/branches/JDK7/src/main/javadoc/stylesheet.css Tue Jun 30 16:50:23 2015
@@ -218,7 +218,7 @@ span.deprecated {
text-decoration: line-through;
}
-div.block {
+div.details div.block {
text-align: justify;
}