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/07/01 13:22:09 UTC
svn commit: r1688624 - in /sis/branches/JDK8/core:
sis-metadata/src/main/java/org/apache/sis/internal/metadata/
sis-metadata/src/main/java/org/apache/sis/io/wkt/
sis-utility/src/test/java/org/apache/sis/util/iso/
Author: desruisseaux
Date: Wed Jul 1 11:22:08 2015
New Revision: 1688624
URL: http://svn.apache.org/r1688624
Log:
WKT 2: parse ImageCRS.
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java?rev=1688624&r1=1688623&r2=1688624&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java [UTF-8] Wed Jul 1 11:22:08 2015
@@ -134,6 +134,7 @@ public final class WKTKeywords extends S
public static final String
ImageDatum = "ImageDatum",
ImageCRS = "ImageCRS",
+ IDatum = "IDatum",
EngineeringDatum = "EngineeringDatum",
EngineeringCRS = "EngineeringCRS",
BaseEngCRS = "BaseEngCRS",
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1688624&r1=1688623&r2=1688624&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] Wed Jul 1 11:22:08 2015
@@ -320,6 +320,7 @@ final class GeodeticObjectParser extends
(object = parseVerticalDatum (FIRST, element, false)) == null &&
(object = parseTimeDatum (FIRST, element )) == null &&
(object = parseEngineeringDatum (FIRST, element, false)) == null &&
+ (object = parseImageDatum (FIRST, element )) == null &&
(object = parseConversion (FIRST, element, false, SI.METRE, NonSI.DEGREE_ANGLE)) == null)
{
throw element.missingOrUnknownComponent(WKTKeywords.GeodeticCRS);
@@ -344,6 +345,7 @@ final class GeodeticObjectParser extends
(crs = parseVerticalCRS (FIRST, element)) == null &&
(crs = parseTimeCRS (FIRST, element)) == null &&
(crs = parseEngineeringCRS (FIRST, element)) == null &&
+ (crs = parseImageCRS (FIRST, element)) == null &&
(crs = parseCompoundCRS (FIRST, element)) == null &&
(crs = parseFittedCS (FIRST, element)) == null)
{
@@ -1315,7 +1317,7 @@ final class GeodeticObjectParser extends
final Date epoch = origin .pullDate("origin");
origin.close(ignoredElements);
try {
- return datumFactory.createTemporalDatum(parseMetadataAndClose(element, name), epoch);
+ return datumFactory.createTemporalDatum(parseAnchorAndClose(element, name), epoch);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1352,7 +1354,31 @@ final class GeodeticObjectParser extends
element.pullInteger("datum"); // Ignored for now.
}
try {
- return datumFactory.createEngineeringDatum(parseMetadataAndClose(element, name));
+ return datumFactory.createEngineeringDatum(parseAnchorAndClose(element, name));
+ } catch (FactoryException exception) {
+ throw element.parseFailed(exception);
+ }
+ }
+
+ /**
+ * Parses an {@code "ImageDatum"} (WKT 2) element. The syntax is given by
+ * <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#81">WKT 2 specification §12.2</a>.
+ *
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent The parent element.
+ * @return The {@code "ImageDatum"} element as an {@link ImageDatum} object.
+ * @throws ParseException if the {@code "ImageDatum"} element can not be parsed.
+ */
+ private ImageDatum parseImageDatum(final int mode, final Element parent) throws ParseException {
+ final Element element = parent.pullElement(mode, WKTKeywords.ImageDatum, WKTKeywords.IDatum);
+ if (element == null) {
+ return null;
+ }
+ final String name = element.pullString("name");
+ final PixelInCell pixelInCell = Types.forCodeName(PixelInCell.class,
+ element.pullVoidElement("pixelInCell").keyword, true);
+ try {
+ return datumFactory.createImageDatum(parseAnchorAndClose(element, name), pixelInCell);
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
@@ -1392,6 +1418,31 @@ final class GeodeticObjectParser extends
} catch (FactoryException exception) {
throw element.parseFailed(exception);
}
+ }
+
+ /**
+ * Parses an {@code "ImageCRS"} (WKT 2) element. The syntax is given by
+ * <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#79">WKT 2 specification §12</a>.
+ *
+ * @param mode {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
+ * @param parent The parent element.
+ * @return The {@code "ImageCRS"} element as an {@link ImageCRS} object.
+ * @throws ParseException if the {@code "ImageCRS"} element can not be parsed.
+ */
+ private ImageCRS parseImageCRS(final int mode, final Element parent) throws ParseException {
+ final Element element = parent.pullElement(mode, WKTKeywords.ImageCRS);
+ if (element == null) {
+ return null;
+ }
+ final String name = element.pullString("name");
+ final ImageDatum datum = parseImageDatum(MANDATORY, element);
+ final Unit<?> unit = parseUnit(element);
+ try {
+ final CoordinateSystem cs = parseCoordinateSystem(element, WKTKeywords.Cartesian, 2, false, unit, datum);
+ return crsFactory.createImageCRS(parseMetadataAndClose(element, name), datum, (CartesianCS) cs);
+ } catch (FactoryException exception) {
+ throw element.parseFailed(exception);
+ }
}
/**
Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java?rev=1688624&r1=1688623&r2=1688624&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/TypesTest.java [UTF-8] Wed Jul 1 11:22:08 2015
@@ -28,6 +28,7 @@ import org.opengis.metadata.citation.Cit
import org.opengis.metadata.citation.OnLineFunction;
import org.opengis.metadata.content.ImagingCondition;
import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.parameter.ParameterDirection;
import org.apache.sis.test.TestCase;
@@ -41,7 +42,7 @@ import static org.opengis.test.Assert.*;
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*/
public final strictfp class TypesTest extends TestCase {
@@ -145,6 +146,13 @@ public final strictfp class TypesTest ex
assertSame(ImagingCondition.SEMI_DARKNESS, Types.forCodeName(ImagingCondition.class, "semi darkness", false));
assertSame(ImagingCondition.SEMI_DARKNESS, Types.forCodeName(ImagingCondition.class, "semi-darkness", false));
assertNull(Types.forCodeName(ImagingCondition.class, "darkness", false));
+
+ assertSame(PixelInCell.CELL_CORNER, Types.forCodeName(PixelInCell.class, "cell corner", false));
+ assertSame(PixelInCell.CELL_CORNER, Types.forCodeName(PixelInCell.class, "cellCorner", false));
+ assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cell center", false));
+ assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cellCenter", false));
+ assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cell centre", false));
+ assertSame(PixelInCell.CELL_CENTER, Types.forCodeName(PixelInCell.class, "cellCentre", false));
}
/**