Author: desruisseaux
Date: Mon Oct 16 10:55:02 2017
New Revision: 1812283
URL: http://svn.apache.org/viewvc?rev=1812283&view=rev
Log:
Add support for netCDF "geospatial_bounds" attribute parsing.
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/GeometryWrapper.java
(with props)
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreFormat.java
(with props)
Modified:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultBoundingPolygon.java
sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties
sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
Modified:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/ESRI.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -23,6 +23,8 @@ import com.esri.core.geometry.MultiPath;
import com.esri.core.geometry.Polyline;
import com.esri.core.geometry.Polygon;
import com.esri.core.geometry.Point;
+import com.esri.core.geometry.WktImportFlags;
+import com.esri.core.geometry.OperatorImportFromWkt;
import org.apache.sis.geometry.GeneralEnvelope;
import org.apache.sis.setup.GeometryLibrary;
import org.apache.sis.math.Vector;
@@ -178,4 +180,12 @@ final class ESRI extends Geometries<Geom
}
return path;
}
+
+ /**
+ * Parses the given WKT.
+ */
+ @Override
+ public Object parseWKT(final String wkt) {
+ return
OperatorImportFromWkt.local().execute(WktImportFlags.wktImportDefaults,
Geometry.Type.Unknown, wkt, null);
+ }
}
Modified:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Geometries.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -284,6 +284,14 @@ public abstract class Geometries<G> {
}
/**
+ * Parses the given WKT.
+ *
+ * @param wkt the WKT to parse.
+ * @return the geometry object for the given WKT.
+ */
+ public abstract Object parseWKT(String wkt);
+
+ /**
* Returns an error message for an unsupported geometry object.
*
* @param dimension number of dimensions (2 or 3) requested for the
geometry object.
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/GeometryWrapper.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/GeometryWrapper.java?rev=1812283&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/GeometryWrapper.java
(added)
+++
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/GeometryWrapper.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.feature;
+
+import java.util.Set;
+import java.util.Objects;
+import org.opengis.geometry.Boundary;
+import org.opengis.geometry.DirectPosition;
+import org.opengis.geometry.Envelope;
+import org.opengis.geometry.Geometry;
+import org.opengis.geometry.Precision;
+import org.opengis.geometry.TransfiniteSet;
+import org.opengis.geometry.complex.Complex;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.MathTransform;
+
+
+/**
+ * Wraps a JTS or ESRI geometry behind a {@code Geometry} interface.
+ * This is a temporary class to be refactored later as a more complete
geometry framework.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since 0.8
+ * @module
+ */
+public final class GeometryWrapper implements Geometry {
+ /**
+ * The JTS or ESRI geometric object.
+ */
+ public final Object geometry;
+
+ /**
+ * Geometry bounding box, together with its coordinate reference system.
+ */
+ private final Envelope envelope;
+
+ /**
+ * Creates a new geometry object.
+ *
+ * @param geometry the JTS or ESRI geometric object.
+ * @param envelope geometry bounding box, together with its coordinate
reference system.
+ */
+ public GeometryWrapper(final Object geometry, final Envelope envelope) {
+ this.geometry = geometry;
+ this.envelope = envelope;
+ }
+
+ /**
+ * Returns the geometry CRS, which is taken from the envelope CRS.
+ *
+ * @return the geometry CRS.
+ */
+ @Override
+ public CoordinateReferenceSystem getCoordinateReferenceSystem() {
+ return envelope.getCoordinateReferenceSystem();
+ }
+
+ /**
+ * Returns the envelope specified at construction time.
+ */
+ @Override public Envelope getEnvelope() {
+ return envelope;
+ }
+
+ @Override public Precision getPrecision()
{throw new UnsupportedOperationException();}
+ @Override public Geometry getMbRegion()
{throw new UnsupportedOperationException();}
+ @Override public DirectPosition getRepresentativePoint()
{throw new UnsupportedOperationException();}
+ @Override public Boundary getBoundary()
{throw new UnsupportedOperationException();}
+ @Override public Complex getClosure()
{throw new UnsupportedOperationException();}
+ @Override public boolean isSimple()
{throw new UnsupportedOperationException();}
+ @Override public boolean isCycle()
{throw new UnsupportedOperationException();}
+ @Override public double distance(Geometry geometry)
{throw new UnsupportedOperationException();}
+ @Override public int getDimension(DirectPosition point)
{throw new UnsupportedOperationException();}
+ @Override public int getCoordinateDimension()
{throw new UnsupportedOperationException();}
+ @Override public Set<Complex> getMaximalComplex()
{throw new UnsupportedOperationException();}
+ @Override public DirectPosition getCentroid()
{throw new UnsupportedOperationException();}
+ @Override public Geometry getConvexHull()
{throw new UnsupportedOperationException();}
+ @Override public Geometry getBuffer(double distance)
{throw new UnsupportedOperationException();}
+ @Override public boolean isMutable()
{throw new UnsupportedOperationException();}
+ @Override public Geometry toImmutable()
{throw new UnsupportedOperationException();}
+ @Override public Geometry clone() throws CloneNotSupportedException
{throw new CloneNotSupportedException();}
+ @Override public boolean contains(TransfiniteSet pointSet)
{throw new UnsupportedOperationException();}
+ @Override public boolean contains(DirectPosition point)
{throw new UnsupportedOperationException();}
+ @Override public boolean intersects(TransfiniteSet pointSet)
{throw new UnsupportedOperationException();}
+ @Override public boolean equals(TransfiniteSet pointSet)
{throw new UnsupportedOperationException();}
+ @Override public TransfiniteSet union(TransfiniteSet pointSet)
{throw new UnsupportedOperationException();}
+ @Override public TransfiniteSet intersection(TransfiniteSet pointSet)
{throw new UnsupportedOperationException();}
+ @Override public TransfiniteSet difference(TransfiniteSet pointSet)
{throw new UnsupportedOperationException();}
+ @Override public TransfiniteSet symmetricDifference(TransfiniteSet ps)
{throw new UnsupportedOperationException();}
+ @Override public Geometry transform(CoordinateReferenceSystem crs)
{throw new UnsupportedOperationException();}
+ @Override public Geometry transform(CoordinateReferenceSystem crs,
MathTransform tr) {throw new UnsupportedOperationException();}
+
+ @Override
+ public boolean equals(final Object obj) {
+ return (obj instanceof GeometryWrapper) &&
Objects.equals(((GeometryWrapper) obj).geometry, geometry);
+ }
+
+ @Override
+ public int hashCode() {
+ return ~Objects.hashCode(geometry);
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(geometry);
+ }
+}
Propchange:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/GeometryWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/GeometryWrapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/JTS.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -146,4 +146,12 @@ final class JTS extends Geometries<Objec
final Object tryMergePolylines(final Object first, final Iterator<?>
polylines) {
throw unsupported(2); // TODO - see class javadoc
}
+
+ /**
+ * Parses the given WKT.
+ */
+ @Override
+ public Object parseWKT(final String wkt) {
+ throw unsupported(2);
+ }
}
Modified:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Java2D.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -213,4 +213,12 @@ final class Java2D extends Geometries<Sh
}
return ShapeUtilities.toPrimitive(path);
}
+
+ /**
+ * Parses the given WKT.
+ */
+ @Override
+ public Object parseWKT(final String wkt) {
+ throw unsupported(2);
+ }
}
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultBoundingPolygon.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultBoundingPolygon.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultBoundingPolygon.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultBoundingPolygon.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -47,7 +47,7 @@ import org.opengis.metadata.extent.Bound
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @author Guilhem Legal (Geomatys)
- * @version 0.3
+ * @version 0.8
* @since 0.3
* @module
*/
@@ -77,6 +77,7 @@ public class DefaultBoundingPolygon exte
* @param polygon the sets of points defining the bounding polygon.
*/
public DefaultBoundingPolygon(final Geometry polygon) {
+ super(true);
polygons = singleton(polygon, Geometry.class);
}
Modified: sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
--- sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties
[ISO-8859-1] Mon Oct 16 10:55:02 2017
@@ -3,6 +3,6 @@
build.xml.data.CRC32=58e6b21c
build.xml.script.CRC32=462eaba0
[email protected]
-nbproject/build-impl.xml.data.CRC32=48810fa6
+nbproject/build-impl.xml.data.CRC32=5985fde7
nbproject/build-impl.xml.script.CRC32=9ba3ba27
nbproject/[email protected]
Modified: sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
--- sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml (original)
+++ sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml Mon Oct 16
10:55:02 2017
@@ -84,6 +84,7 @@
<word>deserialized</word>
<word>endianness</word>
<word>geoidal</word>
+ <word>geospatial</word>
<word>grayscale</word>
<word>hectopascals</word>
<word>initially</word>
Modified:
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -44,9 +44,11 @@ import org.opengis.metadata.identificati
import org.opengis.metadata.identification.Keywords;
import org.opengis.metadata.quality.DataQuality;
import org.opengis.metadata.lineage.Lineage;
+import org.opengis.metadata.lineage.Source;
import org.opengis.metadata.extent.Extent;
import org.opengis.metadata.extent.VerticalExtent;
import org.opengis.metadata.extent.TemporalExtent;
+import org.opengis.metadata.extent.BoundingPolygon;
import org.opengis.metadata.extent.GeographicBoundingBox;
import org.opengis.metadata.extent.GeographicDescription;
@@ -109,6 +111,7 @@ import org.opengis.metadata.extent.Geogr
* {@value #PURPOSE}<br>
* {@value #REFERENCES}<br>
* </td><td style="width: 25%">
+ * {@value #SOURCE}<br>
* {@value #STANDARD_NAME}<br>
* {@value #STANDARD_NAME_VOCABULARY}<br>
* {@value #SUMMARY}<br>
@@ -190,7 +193,8 @@ public class AttributeNames {
* {@link Metadata#getIdentificationInfo() identificationInfo} /
* {@link DataIdentification#getCitation() citation} /
* {@link Citation#getIdentifiers() identifier} /
- * {@link Identifier#getAuthority() authority}</li></ul>
+ * {@link Identifier#getAuthority() authority} /
+ * {@link Citation#getTitle() title}</li></ul>
*
* @see #IDENTIFIER
* @see <a
href="http://wiki.esipfed.org/index.php/Attribute_Convention_for_Data_Discovery#naming_authority">ESIP
reference</a>
@@ -296,6 +300,7 @@ public class AttributeNames {
/**
* The {@value} attribute name for providing an audit trail for
modifications to the
* original data (<em>Recommended</em>).
+ * This is a character array with a line for each invocation of a program
that has modified the dataset.
*
* <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
* {@link Metadata#getDataQualityInfo() dataQualityInfo} /
@@ -307,6 +312,21 @@ public class AttributeNames {
public static final String HISTORY = ACDD.history;
/**
+ * The {@value} attribute name for the method of production of the
original data (<em>Recommended</em>).
+ *
+ * <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
+ * {@link Metadata#getDataQualityInfo() dataQualityInfo} /
+ * {@link DataQuality#getLineage() lineage} /
+ * {@link Lineage#getSources() source} /
+ * {@link Source#getDescription() description}</li></ul>
+ *
+ * @see <a
href="http://wiki.esipfed.org/index.php/Attribute_Convention_for_Data_Discovery#source">ESIP
reference</a>
+ *
+ * @since 0.8
+ */
+ public static final String SOURCE = "source";
+
+ /**
* The {@value} attribute name for miscellaneous information about the data
* (<em>Recommended</em>).
*
@@ -664,6 +684,19 @@ public class AttributeNames {
public static final String GEOGRAPHIC_IDENTIFIER = "geographic_identifier";
/**
+ * Data's 2D or 3D geospatial extent in OGC's Well-Known Text (WKT)
geometry format.
+ *
+ * <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
+ * {@link Metadata#getIdentificationInfo() identificationInfo} /
+ * {@link DataIdentification#getExtents() extent} /
+ * {@link Extent#getGeographicElements() geographicElement} /
+ * {@link BoundingPolygon#getPolygons() polygon}</li></ul>
+ *
+ * @since 0.8
+ */
+ public static final String GEOSPATIAL_BOUNDS = "geospatial_bounds";
+
+ /**
* Holds the attribute names describing a simple latitude, longitude, and
vertical bounding box.
* In the following table, the header lists the constants defined in the
{@link AttributeNames}
* class and the other cells give the values assigned in this class fields
for those constants.
@@ -806,7 +839,7 @@ public class AttributeNames {
* @param positive the attribute name for indicating which
direction is positive.
*/
public Dimension(final DimensionNameType type, final String min, final
String max, final String span,
- final String resolution,final String units, final String
positive)
+ final String resolution, final String units, final String
positive)
{
DEFAULT_NAME_TYPE = type;
MINIMUM = min;
Modified:
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -53,6 +53,7 @@ import org.apache.sis.storage.DataStoreE
import org.apache.sis.metadata.iso.DefaultMetadata;
import org.apache.sis.metadata.iso.citation.*;
import org.apache.sis.metadata.iso.identification.*;
+import org.apache.sis.metadata.iso.lineage.DefaultSource;
import org.apache.sis.metadata.iso.lineage.DefaultLineage;
import org.apache.sis.metadata.iso.quality.DefaultDataQuality;
import org.apache.sis.internal.netcdf.Axis;
@@ -61,6 +62,7 @@ import org.apache.sis.internal.netcdf.Va
import org.apache.sis.internal.netcdf.GridGeometry;
import org.apache.sis.internal.storage.io.IOUtilities;
import org.apache.sis.internal.storage.MetadataBuilder;
+import org.apache.sis.internal.storage.wkt.StoreFormat;
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.util.CollectionsExt;
import org.apache.sis.util.resources.Errors;
@@ -623,6 +625,15 @@ split: while ((start = CharSequences.sk
addKeywords(keywords, KeywordType.THEME,
stringValue(VOCABULARY));
addKeywords(project, KeywordType.PROJECT, null);
addKeywords(publisher, KeywordType.DATA_CENTRE, null);
+ /*
+ * Add geospatial bounds as a geometric object. This optional
operation requires
+ * an external library (ESRI or JTS) to be present on the classpath.
+ */
+ final String wkt = stringValue(GEOSPATIAL_BOUNDS);
+ if (wkt != null) {
+ addBoundingPolygon(new StoreFormat(decoder.geomlib,
decoder.listeners).parseGeometry(wkt,
+ stringValue(GEOSPATIAL_BOUNDS + "_crs"),
stringValue(GEOSPATIAL_BOUNDS + "_vertical_crs")));
+ }
}
/**
@@ -658,7 +669,7 @@ split: while ((start = CharSequences.sk
}
/**
- * Adds the extent declared in the given group. For more consistent
results, the caller should restrict
+ * Adds the extent declared in the current group. For more consistent
results, the caller should restrict
* the {@linkplain Decoder#setSearchPath search path} to a single group
before invoking this method.
*
* @return {@code true} if at least one numerical value has been added.
@@ -928,11 +939,19 @@ split: while ((start = CharSequences.sk
final DefaultMetadata metadata = build(false);
for (final String path : searchPath) {
decoder.setSearchPath(path);
- final String history = stringValue(HISTORY);
- if (history != null) {
+ DefaultLineage lineage = null;
+ String value = stringValue(HISTORY);
+ if (value != null) {
+ lineage = new DefaultLineage();
+ lineage.setStatement(new SimpleInternationalString(value));
+ }
+ value = stringValue(SOURCE);
+ if (value != null) {
+ if (lineage == null) lineage = new DefaultLineage();
+ addIfAbsent(lineage.getSources(), new DefaultSource(value));
+ }
+ if (lineage != null) {
final DefaultDataQuality quality = new
DefaultDataQuality(ScopeCode.DATASET);
- final DefaultLineage lineage = new DefaultLineage();
- lineage.setStatement(new SimpleInternationalString(history));
quality.setLineage(lineage);
addIfAbsent(metadata.getDataQualityInfo(), quality);
}
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -29,6 +29,7 @@ import javax.measure.Unit;
import org.opengis.util.MemberName;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
+import org.opengis.geometry.Geometry;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Role;
import org.opengis.metadata.citation.DateType;
@@ -62,6 +63,7 @@ import org.apache.sis.metadata.iso.Defau
import org.apache.sis.metadata.iso.extent.DefaultExtent;
import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
+import org.apache.sis.metadata.iso.extent.DefaultBoundingPolygon;
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
import org.apache.sis.metadata.iso.extent.DefaultGeographicDescription;
import org.apache.sis.metadata.iso.spatial.DefaultGridSpatialRepresentation;
@@ -1637,6 +1639,22 @@ parse: for (int i = 0; i < length;)
}
}
+ /**
+ * Adds the given geometry as a bounding polygon.
+ * Storage locations is:
+ *
+ * <ul>
+ * <li>{@code
metadata/identificationInfo/extent/geographicElement/polygon}</li>
+ * </ul>
+ *
+ * @param bounds the bounding polygon, or {@code null} if none.
+ */
+ public final void addBoundingPolygon(final Geometry bounds) {
+ if (bounds != null) {
+ addIfNotPresent(extent().getGeographicElements(), new
DefaultBoundingPolygon(bounds));
+ }
+ }
+
/**
* Adds a geographic extent described by an identifier. The given
identifier is stored as-is as
* the natural language description, and possibly in a modified form as
the geographic identifier.
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -67,6 +67,11 @@ public final class Resources extends Ind
public static final short AmbiguousName_4 = 15;
/**
+ * Can not read the Coordinate Reference System (CRS) Well Known Text
(WKT) in “{0}”.
+ */
+ public static final short CanNotReadCRS_WKT_1 = 37;
+
+ /**
* Can not read “{0}” directory.
*/
public static final short CanNotReadDirectory_1 = 34;
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] Mon Oct 16 10:55:02 2017
@@ -20,6 +20,7 @@
# For resources shared by all modules in the Apache SIS project, see
"org.apache.sis.util.resources" package.
#
AmbiguousName_4 = Name \u201c{3}\u201d is ambiguous because
it can be understood as either \u201c{1}\u201d or \u201c{2}\u201d in the
context of \u201c{0}\u201d data.
+CanNotReadCRS_WKT_1 = Can not read the Coordinate Reference
System (CRS) Well Known Text (WKT) in \u201c{0}\u201d.
CanNotReadDirectory_1 = Can not read \u201c{0}\u201d directory.
CanNotReadFile_2 = Can not read \u201c{1}\u201d as a file in
the {0} format.
CanNotReadFile_3 = Can not read line {2} of \u201c{1}\u201d
as part of a file in the {0} format.
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] Mon Oct 16 10:55:02 2017
@@ -25,6 +25,7 @@
# U+00A0 NO-BREAK SPACE before :
#
AmbiguousName_4 = Le nom \u00ab\u202f{3}\u202f\u00bb est
ambigu\u00eb car il peut \u00eatre interpr\u00e9t\u00e9 aussi bien comme
\u00ab\u202f{1}\u202f\u00bb ou \u00ab\u202f{2}\u202f\u00bb dans le contexte des
donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
+CanNotReadCRS_WKT_1 = Ne peut pas lire le syst\u00e8me de
r\u00e9f\u00e9rence spatial dans le \u00ab\u202fWell Known Text\u202f\u00bb
(WKT) de \u00ab\u202f{0}\u202f\u00bb.
CanNotReadDirectory_1 = Ne peut pas lire le r\u00e9pertoire
\u00ab\u202f{0}\u202f\u00bb.
CanNotReadFile_2 = Ne peut pas lire
\u00ab\u202f{1}\u202f\u00bb comme un fichier au format {0}.
CanNotReadFile_3 = Ne peut pas lire la ligne {2} de
\u00ab\u202f{1}\u202f\u00bb comme une partie d\u2019un fichier au format {0}.
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1812283&r1=1812282&r2=1812283&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -19,27 +19,22 @@ package org.apache.sis.internal.storage.
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
-import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.io.Reader;
import java.io.IOException;
import java.text.ParsePosition;
import java.text.ParseException;
import org.opengis.metadata.Metadata;
-import org.opengis.util.FactoryException;
import org.opengis.referencing.ReferenceSystem;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.internal.storage.Resources;
import org.apache.sis.internal.system.Loggers;
-import org.apache.sis.io.wkt.WKTFormat;
-import org.apache.sis.io.wkt.Warnings;
import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.DataStoreContentException;
import org.apache.sis.storage.UnsupportedStorageException;
-import org.apache.sis.internal.referencing.DefinitionVerifier;
import org.apache.sis.internal.storage.MetadataBuilder;
import org.apache.sis.internal.storage.URIDataStore;
+import org.apache.sis.setup.GeometryLibrary;
import org.apache.sis.setup.OptionKey;
import org.apache.sis.util.CharSequences;
@@ -66,6 +61,11 @@ final class Store extends URIDataStore {
private Reader source;
/**
+ * The geometry library, or {@code null} for the default.
+ */
+ private final GeometryLibrary library;
+
+ /**
* The parsed objects, filled only when first needed.
* May still be empty if the parsing failed.
*/
@@ -92,6 +92,7 @@ final class Store extends URIDataStore {
throw new UnsupportedStorageException(super.getLocale(),
StoreProvider.NAME,
connector.getStorage(),
connector.getOption(OptionKey.OPEN_OPTIONS));
}
+ library = connector.getOption(OptionKey.GEOMETRY_LIBRARY);
}
/**
@@ -128,30 +129,12 @@ final class Store extends URIDataStore {
* definitions.
*/
final ParsePosition pos = new ParsePosition(0);
- final WKTFormat parser = new WKTFormat(null, null);
+ final StoreFormat parser = new StoreFormat(library, listeners);
do {
final Object obj = parser.parse(wkt, pos);
objects.add(obj);
pos.setIndex(CharSequences.skipLeadingWhitespaces(wkt,
pos.getIndex(), wkt.length()));
- final Warnings warnings = parser.getWarnings();
- if (warnings != null) {
- log(new LogRecord(Level.WARNING, warnings.toString()));
- }
- /*
- * The WKT has been parsed. Below is a verification of whether
the parsed WKT is conform with
- * the authority definition (if an authority code has been
specified). This verification is not
- * really necessary since we will use the WKT definition
anyway even if we find discrepancies.
- * But non-conform WKT definitions happen so often in practice
that we are better to check.
- */
- if (obj instanceof CoordinateReferenceSystem) try {
- final DefinitionVerifier v =
DefinitionVerifier.withAuthority((CoordinateReferenceSystem) obj, null, false);
- if (v != null) {
- final LogRecord warning = v.warning(false);
- if (warning != null) log(warning);
- }
- } catch (FactoryException e) {
- listeners.warning(null, e);
- }
+ parser.validate(obj);
} while (pos.getIndex() < wkt.length());
} catch (ParseException e) {
throw new DataStoreContentException(getLocale(), "WKT",
getDisplayName(), in).initCause(e);
Added:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreFormat.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreFormat.java?rev=1812283&view=auto
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreFormat.java
(added)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreFormat.java
[UTF-8] Mon Oct 16 10:55:02 2017
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.storage.wkt;
+
+import java.text.ParseException;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import org.opengis.geometry.Geometry;
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.io.wkt.WKTFormat;
+import org.apache.sis.io.wkt.Warnings;
+import org.apache.sis.referencing.CRS;
+import org.apache.sis.storage.DataStore;
+import org.apache.sis.geometry.GeneralEnvelope;
+import org.apache.sis.setup.GeometryLibrary;
+import org.apache.sis.internal.feature.Geometries;
+import org.apache.sis.internal.feature.GeometryWrapper;
+import org.apache.sis.internal.referencing.DefinitionVerifier;
+import org.apache.sis.internal.storage.Resources;
+import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.util.logging.WarningListeners;
+import org.apache.sis.util.ArraysExt;
+
+
+/**
+ * Helper class for reading and writing WKT in the metadata of a data store.
+ * This is provided as a separated class for allowing reuse by other data
stores.
+ * For example WKT may also appear in some global attributes of CF-netCDF
files.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since 0.8
+ * @module
+ */
+@SuppressWarnings("serial")
+public final class StoreFormat extends WKTFormat {
+ /**
+ * The geometry library, or {@code null} for the default.
+ */
+ private final GeometryLibrary library;
+
+ /**
+ * Where to send warnings.
+ */
+ private final WarningListeners<DataStore> listeners;
+
+ /**
+ * Creates a new WKT parser and encoder.
+ *
+ * @param library the geometry library, or {@code null} for the
default.
+ * @param listeners where to send warnings.
+ */
+ public StoreFormat(final GeometryLibrary library, final
WarningListeners<DataStore> listeners) {
+ super(null, null);
+ this.library = library;
+ this.listeners = listeners;
+ }
+
+ /**
+ * Parses a geometry together with its coordinate reference system, all in
Well Known Text (WKT).
+ *
+ * @param geometry the geometry to parse, or {@code null} if none.
+ * @param crs the horizontal part of the WKT (2D or 3D), or
{@code null} if none.
+ * @param additionalCRS the vertical or temporal part of the WKT, or
{@code null} if none.
+ * @return the geometry, or {@code null} if none.
+ */
+ public Geometry parseGeometry(final String geometry, final String crs,
final String additionalCRS) {
+ if (geometry != null) {
+ final Object obj =
Geometries.implementation(library).parseWKT(geometry);
+ final GeneralEnvelope envelope = Geometries.getEnvelope(geometry);
+ if (envelope != null) {
+ envelope.setCoordinateReferenceSystem(parseCRS(crs,
additionalCRS));
+ return new GeometryWrapper(obj, envelope);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Parses the given WKTs as a coordinate reference system. The given array
may contain two elements if,
+ * for example, vertical CRS is specified separately from horizontal CRS.
If an exception occurs during
+ * parsing, it will be reported as a data store warning.
+ *
+ * @param wkt the Well Known Texts to parse. Null elements are ignored.
+ * @return the parsed coordinate reference system, or {@code null} if none.
+ */
+ public CoordinateReferenceSystem parseCRS(final String... wkt) {
+ try {
+ final CoordinateReferenceSystem[] components = new
CoordinateReferenceSystem[wkt.length];
+ int n = 0;
+ for (final String ct : wkt) {
+ if (ct != null) {
+ final Object crs = parseObject(ct);
+ validate(crs);
+ components[n++] = (CoordinateReferenceSystem) crs;
+ }
+ }
+ if (n == 0) {
+ return null;
+ }
+ return CRS.compound(ArraysExt.resize(components, n));
+ } catch (ParseException | ClassCastException |
IllegalArgumentException | FactoryException e) {
+ log(e);
+ return null;
+ }
+ }
+
+ /**
+ * Reports pending warnings and verifies if the parsed WKT is conform with
the authority definition
+ * (if an authority code has been specified). This verification is not
really necessary since we will
+ * use the WKT definition anyway even if we find discrepancies. But
non-conform WKT definitions happen
+ * so often in practice that we are better to check and warn users.
+ *
+ * <p>This method does not need to be invoked after {@code
parseGeometry(…)} or {@code parseCRS(…)}
+ * since it is already done.</p>
+ *
+ * @param parsed the object parsed from WKT, or {@code null} if none.
+ */
+ public void validate(final Object parsed) {
+ final Warnings warnings = getWarnings();
+ if (warnings != null) {
+ log(new LogRecord(Level.WARNING, warnings.toString()));
+ }
+ if (parsed instanceof CoordinateReferenceSystem) try {
+ final DefinitionVerifier v =
DefinitionVerifier.withAuthority((CoordinateReferenceSystem) parsed, null,
false);
+ if (v != null) {
+ final LogRecord warning = v.warning(false);
+ if (warning != null) log(warning);
+ }
+ } catch (FactoryException e) {
+ listeners.warning(null, e);
+ }
+ }
+
+ /**
+ * Reports a warning for a WKT that can not be read. This method should be
invoked only when the CRS
+ * can not be created at all; it should not be invoked if the CRS has been
created with some warnings.
+ */
+ final void log(final Exception e) {
+ final DataStore store = listeners.getSource();
+ listeners.warning(Resources.forLocale(store.getLocale())
+ .getString(Resources.Keys.CanNotReadCRS_WKT_1,
store.getDisplayName()), e);
+ }
+
+ /**
+ * Reports a warning in the {@code "org.apache.sis.io.wkt"} logger. This
method pretends that the
+ * warning come from {@code getMetadata()} method, which is the public
facade for the parsing method.
+ *
+ * @param record the warning to report.
+ */
+ private void log(final LogRecord record) {
+ record.setSourceClassName(listeners.getSource().getClass().getName());
+ record.setSourceMethodName("getMetadata");
+ record.setLoggerName(Loggers.WKT);
+ listeners.warning(record);
+ }
+}
Propchange:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreFormat.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8