sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1799891 [2/2] - in /sis/branches/JDK7: ./ application/sis-console/src/main/java/org/apache/sis/console/ core/sis-feature/ core/sis-feature/src/main/java/org/apache/sis/feature/ core/sis-feature/src/main/java/org/apache/sis/feature/builder/...
Date Mon, 26 Jun 2017 12:25:47 GMT
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java?rev=1799891&r1=1799890&r2=1799891&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
[UTF-8] Mon Jun 26 12:25:46 2017
@@ -34,7 +34,6 @@ import org.opengis.metadata.citation.Rol
 import org.opengis.metadata.citation.DateType;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.citation.CitationDate;
-import org.opengis.metadata.citation.Responsibility;
 import org.opengis.metadata.spatial.Dimension;
 import org.opengis.metadata.spatial.DimensionNameType;
 import org.opengis.metadata.spatial.CellGeometry;
@@ -107,6 +106,7 @@ import static org.apache.sis.internal.ut
 import org.apache.sis.internal.jdk8.LocalDate;
 import org.apache.sis.internal.jdk8.JDK8;
 import org.opengis.feature.FeatureType;
+import org.opengis.metadata.citation.Responsibility;
 
 
 /**
@@ -1230,7 +1230,7 @@ public class MetadataBuilder {
     }
 
     /**
-     * Adds s role, name, contact and position information for an individual or organization
that is responsible
+     * Adds role, name, contact and position information for an individual or organization
that is responsible
      * for the resource. This method can be used as an alternative to {@link #addAuthor(CharSequence)}
when the
      * caller needs to create the responsibly party itself.
      *

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/TimeEncoding.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/TimeEncoding.java?rev=1799891&r1=1799890&r2=1799891&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/TimeEncoding.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/TimeEncoding.java
[UTF-8] Mon Jun 26 12:25:46 2017
@@ -20,6 +20,7 @@ import javax.measure.Unit;
 import javax.measure.quantity.Time;
 import org.opengis.referencing.datum.TemporalDatum;
 import org.apache.sis.internal.converter.SurjectiveConverter;
+import org.apache.sis.internal.util.StandardDateFormat;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.measure.Units;
 
@@ -96,7 +97,12 @@ class TimeEncoding extends SurjectiveCon
     public Instant apply(final String time) {
         final double value = Double.parseDouble(time) * interval;
         final long millis = Math.round(value);
-        return Instant.ofEpochMilli(millis + origin).plusNanos(Math.round((value - millis)*1E6));
+        return Instant.ofEpochMilli(millis + origin)
+                      .plusNanos(Math.round((value - millis) * StandardDateFormat.NANOS_PER_MILLISECOND));
+        /*
+         * Performance note: the call to .plusNano(…) will usually return the same 'Instant'
instance
+         * (without creating new object) since the time granularity is rarely finer than
milliseconds.
+         */
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-xmlstore/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/pom.xml?rev=1799891&r1=1799890&r2=1799891&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-xmlstore/pom.xml (original)
+++ sis/branches/JDK7/storage/sis-xmlstore/pom.xml Mon Jun 26 12:25:46 2017
@@ -112,6 +112,11 @@ Read and write files in the GPX format.
       <artifactId>sis-storage</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>com.esri.geometry</groupId>
+      <artifactId>esri-geometry-api</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>

Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/GroupAsPolylineOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/GroupAsPolylineOperation.java?rev=1799891&r1=1799890&r2=1799891&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/GroupAsPolylineOperation.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/GroupAsPolylineOperation.java
[UTF-8] Mon Jun 26 12:25:46 2017
@@ -17,9 +17,9 @@
 package org.apache.sis.internal.storage.gpx;
 
 import java.util.Map;
+import java.util.Iterator;
 import java.util.Collection;
 import java.util.Collections;
-import com.esri.core.geometry.Polyline;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.ParameterValueGroup;
 import org.apache.sis.feature.AbstractAttribute;
@@ -27,6 +27,7 @@ import org.apache.sis.feature.AbstractOp
 import org.apache.sis.feature.DefaultAttributeType;
 import org.apache.sis.internal.feature.AttributeConvention;
 import org.apache.sis.internal.feature.FeatureUtilities;
+import org.apache.sis.internal.feature.Geometries;
 import org.apache.sis.util.resources.Errors;
 
 // Branch-dependent imports
@@ -38,22 +39,30 @@ import org.opengis.feature.AttributeType
 
 /**
  * Creates a single (Multi){@code Polyline} instance from a sequence of points or polylines
stored in another property.
- * This base class expects a sequence of {@link Polyline} as input, but subclass will expect
other kind of geometries.
+ * This base class expects a sequence of {@code Point} or {@code Polyline} instances as input.
  * The single (Multi){@code Polyline} instance is re-computed every time this property is
requested.
  *
- * <div class="note"><b>Example:</b>
+ * <div class="note"><b>Examples:</b>
+ * <p><i>Polylines created from points:</i>
+ * a boat that record it's position every hour.
+ * The list of all positions is stored in an attribute with [0 … ∞] cardinality.
+ * This class will extract each position and create a line as a new attribute.
+ * Any change applied to the positions will be visible on the line.</p>
+ *
+ * <p><i>Polylines created from other polylines:</i>
  * a boat that record track every hour.
  * The list of all tracks is stored in an attribute with [0 … ∞] cardinality.
  * This class will extract each track and create a polyline as a new attribute.
- * Any change applied to the tracks will be visible on the polyline.
+ * Any change applied to the tracks will be visible on the polyline.</p>
  * </div>
  *
  * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @version 0.8
  * @since   0.8
  * @module
  */
-class GroupAsPolylineOperation extends AbstractOperation {
+final class GroupAsPolylineOperation extends AbstractOperation {
     /**
      * For cross-version compatibility.
      */
@@ -65,27 +74,38 @@ class GroupAsPolylineOperation extends A
     private static final ParameterDescriptorGroup EMPTY_PARAMS = FeatureUtilities.parameters("GroupPolylines");
 
     /**
-     * The type of the values computed by this operation. The name of this type presumes
-     * that the result will be assigned to the "geometry" attribute of the feature type.
+     * Name of the property to follow in order to get the geometries to add to a polyline.
+     * This property shall be a feature association, usually with [0 … ∞] cardinality.
      */
-    static final AttributeType<Polyline> RESULT_TYPE = new DefaultAttributeType<>(
-            Collections.singletonMap(NAME_KEY, AttributeConvention.ENVELOPE_PROPERTY), Polyline.class,
1, 1, null);
+    private final String association;
 
     /**
-     * Name of the property to follow in order to get the geometries to add to a polyline.
-     * This property shall be a feature association, usually with [0 … ∞] cardinality.
+     * The expected result type to be returned by {@link #getResult()}.
      */
-    final String association;
+    private final AttributeType<?> result;
 
     /**
      * Creates a new operation which will look for geometries in the given feature association.
      *
      * @param  identification  name and other information to be given to this operation.
      * @param  association     name of the property to follow in order to get the geometries
to add to a polyline.
+     * @param  result          the expected result type to be returned by {@link #getResult()}.
      */
-    GroupAsPolylineOperation(final Map<String,?> identification, final String association)
{
+    GroupAsPolylineOperation(final Map<String,?> identification, final String association,
final AttributeType<?> result) {
         super(identification);
         this.association = association;
+        this.result = result;
+    }
+
+    /**
+     * Creates the {@code result} argument for the constructor. This creation is provided
in a separated method
+     * because the same instance will be shared by many {@code GroupAsPolylineOperation}
instances.
+     *
+     * @param  geometries  accessor to the geometry implementation in use (Java2D, ESRI or
JTS).
+     */
+    static AttributeType<?> getResult(final Geometries geometries) {
+        return new DefaultAttributeType<>(Collections.singletonMap(NAME_KEY, AttributeConvention.ENVELOPE_PROPERTY),
+                geometries.polylineClass, 1, 1, null);
     }
 
     /**
@@ -100,8 +120,8 @@ class GroupAsPolylineOperation extends A
      * Returns the expected result type.
      */
     @Override
-    public final AttributeType<Polyline> getResult() {
-        return RESULT_TYPE;
+    public final AttributeType<?> getResult() {
+        return result;
     }
 
     /**
@@ -110,19 +130,9 @@ class GroupAsPolylineOperation extends A
      * the result will be recomputed.
      */
     @Override
+    @SuppressWarnings({"rawtypes", "unchecked"})
     public final Property apply(Feature feature, ParameterValueGroup parameters) {
-        return new Result(feature);
-    }
-
-    /**
-     * Invoked for every geometric objects to put in a single polyline.
-     *
-     * @param addTo     where to add the geometry object.
-     * @param geometry  the point or polyline to add to {@code addTo}.
-     * @param isFirst   whether {@code geometry} is the first object added to the given polyline.
-     */
-    void addGeometry(final Polyline addTo, final Object geometry, final boolean isFirst)
{
-        addTo.add((Polyline) geometry, false);
+        return new Result(feature, association, result);
     }
 
 
@@ -132,8 +142,10 @@ class GroupAsPolylineOperation extends A
      * Note that the cache is not used when {@link #apply(Feature, ParameterValueGroup)}
is invoked,
      * causing a new value to be computed again. The intend is to behave as if the operation
has been
      * executed at {@code apply(…)} invocation time, even if we deferred the actual execution.
+     *
+     * @param  <G>  the root geometry class (implementation-dependent).
      */
-    private final class Result extends AbstractAttribute<Polyline> {
+    private static final class Result<G> extends AbstractAttribute<G> {
         /**
          * For cross-version compatibility.
          */
@@ -145,31 +157,47 @@ class GroupAsPolylineOperation extends A
         private final Feature feature;
 
         /**
+         * Name of the property to follow in order to get the geometries to add to a polyline.
+         * This property shall be a feature association, usually with [0 … ∞] cardinality.
+         */
+        private final String association;
+
+        /**
          * The result, computed when first needed.
          */
-        private transient Polyline geometry;
+        private transient G geometry;
 
         /**
          * Creates a new result for an execution on the given feature.
          * The actual computation is deferred to the first call of {@link #getValue()}.
          */
-        Result(final Feature feature) {
-            super(RESULT_TYPE);
+        Result(final Feature feature, final String association, final AttributeType<G>
result) {
+            super(result);
             this.feature = feature;
+            this.association = association;
         }
 
         /**
-         * Computes the geometry from all points of polylines found in the associated feature.
+         * Computes the geometry from all points or polylines found in the associated feature.
          */
         @Override
-        public Polyline getValue() {
+        public G getValue() {
             if (geometry == null) {
-                boolean isFirst = true;
-                geometry = new Polyline();
-                for (final Object child : (Collection<?>) feature.getPropertyValue(association))
{
-                    addGeometry(geometry, ((Feature) child).getPropertyValue("sis:geometry"),
isFirst);
-                    isFirst = false;
-                }
+                final Iterator<?> it = ((Collection<?>) feature.getPropertyValue(association)).iterator();
+                final Object geom = Geometries.mergePolylines(new Iterator<Object>()
{
+                    @Override public boolean hasNext() {
+                        return it.hasNext();
+                    }
+
+                    @Override public Object next() {
+                        return ((Feature) it.next()).getPropertyValue("sis:geometry");
+                    }
+
+                    @Override public void remove() {
+                        throw new UnsupportedOperationException();
+                    }
+                });
+                geometry = getType().getValueClass().cast(geom);
             }
             return geometry;
         }
@@ -178,7 +206,7 @@ class GroupAsPolylineOperation extends A
          * Does not allow modification of this attribute.
          */
         @Override
-        public void setValue(Polyline value) {
+        public void setValue(G value) {
             throw new UnsupportedOperationException(Errors.format(Errors.Keys.UnmodifiableObject_1,
Attribute.class));
         }
     }

Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java?rev=1799891&r1=1799890&r2=1799891&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java
[UTF-8] Mon Jun 26 12:25:46 2017
@@ -25,7 +25,6 @@ import java.net.URISyntaxException;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.bind.JAXBException;
-import com.esri.core.geometry.Point;
 import org.apache.sis.storage.gps.Fix;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
@@ -413,9 +412,10 @@ parse:  while (reader.hasNext()) {
             throw new DataStoreContentException(errors().getString(Errors.Keys.MandatoryAttribute_2,
                     (lat == null) ? Attributes.LATITUDE : Attributes.LONGITUDE, tagName));
         }
-        final Feature feature = ((Store) owner).types.wayPoint.newInstance();
+        final Types types = ((Store) owner).types;
+        final Feature feature = types.wayPoint.newInstance();
         feature.setPropertyValue("sis:identifier", index);
-        feature.setPropertyValue("sis:geometry", new Point(parseDouble(lon), parseDouble(lat)));
+        feature.setPropertyValue("sis:geometry", types.geometries.createPoint(parseDouble(lon),
parseDouble(lat)));
         List<Link> links = null;
         while (true) {
             /*

Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java?rev=1799891&r1=1799890&r2=1799891&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
[UTF-8] Mon Jun 26 12:25:46 2017
@@ -17,6 +17,8 @@
 package org.apache.sis.internal.storage.gpx;
 
 import java.net.URISyntaxException;
+import org.opengis.util.NameFactory;
+import org.opengis.util.FactoryException;
 import org.opengis.metadata.Metadata;
 import org.opengis.metadata.distribution.Format;
 import org.apache.sis.storage.StorageConnector;
@@ -24,10 +26,14 @@ import org.apache.sis.storage.DataStoreE
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.storage.ConcurrentReadException;
 import org.apache.sis.storage.IllegalNameException;
+import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.storage.xml.stream.StaxDataStore;
 import org.apache.sis.util.collection.BackingStoreException;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Version;
+import org.apache.sis.setup.OptionKey;
+import org.apache.sis.setup.GeometryLibrary;
+import org.apache.sis.util.iso.DefaultNameFactory;
 import org.apache.sis.util.iso.SimpleInternationalString;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.distribution.DefaultFormat;
@@ -84,7 +90,14 @@ public final class Store extends StaxDat
      */
     public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException
{
         super(provider, connector);
-        types = Types.DEFAULT;
+        final GeometryLibrary library = connector.getOption(OptionKey.GEOMETRY_LIBRARY);
+        if (library == null || Types.DEFAULT.geometries.library == library) {
+            types = Types.DEFAULT;
+        } else try {
+            types = new Types(DefaultFactories.forBuildin(NameFactory.class, DefaultNameFactory.class),
null, library);
+        } catch (FactoryException e) {
+            throw new DataStoreException(e);
+        }
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java?rev=1799891&r1=1799890&r2=1799891&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
[UTF-8] Mon Jun 26 12:25:46 2017
@@ -21,14 +21,15 @@ import java.util.Collections;
 import java.util.Locale;
 import java.util.Map;
 import java.util.HashMap;
-import com.esri.core.geometry.Point;
 import org.opengis.util.ScopedName;
 import org.opengis.util.GenericName;
 import org.opengis.util.NameFactory;
 import org.opengis.util.FactoryException;
 import org.opengis.util.InternationalString;
+import org.apache.sis.setup.GeometryLibrary;
 import org.opengis.metadata.citation.OnlineResource;
 import org.opengis.metadata.content.ContentInformation;
+import org.opengis.metadata.acquisition.GeometryType;
 import org.apache.sis.storage.gps.Fix;
 import org.apache.sis.storage.FeatureNaming;
 import org.apache.sis.storage.IllegalNameException;
@@ -39,14 +40,15 @@ import org.apache.sis.feature.builder.Fe
 import org.apache.sis.feature.builder.PropertyTypeBuilder;
 import org.apache.sis.feature.builder.AttributeRole;
 import org.apache.sis.internal.feature.AttributeConvention;
+import org.apache.sis.internal.feature.Geometries;
 import org.apache.sis.internal.storage.FeatureCatalogBuilder;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.util.iso.ResourceInternationalString;
 import org.apache.sis.util.iso.DefaultNameFactory;
-import org.apache.sis.util.Static;
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk8.Temporal;
+import org.opengis.feature.AttributeType;
 import org.opengis.feature.FeatureType;
 
 
@@ -60,7 +62,7 @@ import org.opengis.feature.FeatureType;
  * @since   0.8
  * @module
  */
-final class Types extends Static {
+final class Types {
     /**
      * Way point GPX feature type.
      */
@@ -93,13 +95,18 @@ final class Types extends Static {
     final FeatureNaming<FeatureType> names;
 
     /**
+     * Accessor to the geometry implementation in use (Java2D, ESRI or JTS).
+     */
+    final Geometries geometries;
+
+    /**
      * A system-wide instance for {@code FeatureType} instances created using the {@link
DefaultNameFactory}.
      * This is normally the only instance used in an application.
      */
     static final Types DEFAULT;
     static {
         try {
-            DEFAULT = new Types(DefaultFactories.forBuildin(NameFactory.class, DefaultNameFactory.class),
null);
+            DEFAULT = new Types(DefaultFactories.forBuildin(NameFactory.class, DefaultNameFactory.class),
null, null);
         } catch (FactoryException | IllegalNameException e) {
             throw new AssertionError(e);        // Should never happen with DefaultNameFactory
implementation.
         }
@@ -110,9 +117,13 @@ final class Types extends Static {
      *
      * @param  factory   the factory to use for creating names, or {@code null} for the default
factory.
      * @param  locale    the locale to use for formatting error messages, or {@code null}
for the default locale.
+     * @param  library   the required geometry library, or {@code null} for the default.
      * @throws FactoryException if an error occurred while creating an "envelope bounds"
operation.
      */
-    Types(final NameFactory factory, final Locale locale) throws FactoryException, IllegalNameException
{
+    Types(final NameFactory factory, final Locale locale, final GeometryLibrary library)
+            throws FactoryException, IllegalNameException
+    {
+        geometries = Geometries.implementation(library);
         final Map<String,InternationalString[]> resources = new HashMap<>();
         final ScopedName    geomName = AttributeConvention.GEOMETRY_PROPERTY;
         final Map<String,?> geomInfo = Collections.singletonMap(AbstractIdentifiedType.NAME_KEY,
geomName);
@@ -129,7 +140,7 @@ final class Types extends Static {
          * │ sis:identifier │ Integer │   [1 … 1]   │      SIS-specific property
          * └────────────────┴─────────┴─────────────┘
          */
-        FeatureTypeBuilder builder = new FeatureTypeBuilder(null, factory, locale);
+        final FeatureTypeBuilder builder = new FeatureTypeBuilder(factory, library, locale);
         builder.setNameSpace(Tags.PREFIX).setName("GPXEntity").setAbstract(true);
         builder.addAttribute(Integer.class).setName(AttributeConvention.IDENTIFIER_PROPERTY);
         final FeatureType parent = builder.build();
@@ -161,9 +172,8 @@ final class Types extends Static {
          * │ dgpsid           │ Integer        │ gpx:dgpsStationType    │   [0 …
1]   │
          * └──────────────────┴────────────────┴────────────────────────┴─────────────┘
          */
-        builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
-        builder.setNameSpace(Tags.PREFIX).setName("WayPoint");
-        builder.addAttribute(Point.class).setName(geomName)
+        builder.clear().setSuperTypes(parent).setNameSpace(Tags.PREFIX).setName("WayPoint");
+        builder.addAttribute(GeometryType.POINT).setName(geomName)
                 .setCRS(CommonCRS.WGS84.normalizedGeographic())
                 .addRole(AttributeRole.DEFAULT_GEOMETRY);
         builder.setDefaultCardinality(0, 1);
@@ -204,9 +214,9 @@ final class Types extends Static {
          * │ rtept          │ WayPoint       │ gpx:wptType            │   [0 …
∞]   │
          * └────────────────┴────────────────┴────────────────────────┴─────────────┘
          */
-        GroupAsPolylineOperation groupOp = new GroupPointsAsPolylineOperation(geomInfo, Tags.ROUTE_POINTS);
-        builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
-        builder.setNameSpace(Tags.PREFIX).setName("Route");
+        final AttributeType<?> groupResult = GroupAsPolylineOperation.getResult(geometries);
+        GroupAsPolylineOperation groupOp = new GroupAsPolylineOperation(geomInfo, Tags.ROUTE_POINTS,
groupResult);
+        builder.clear().setSuperTypes(parent).setNameSpace(Tags.PREFIX).setName("Route");
         builder.addProperty(groupOp);
         builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
         builder.setDefaultCardinality(0, 1);
@@ -230,9 +240,8 @@ final class Types extends Static {
          * │ trkpt          │ WayPoint │ gpx:wptType │   [0 … ∞]   │
          * └────────────────┴──────────┴─────────────┴─────────────┘
          */
-        groupOp = new GroupPointsAsPolylineOperation(geomInfo, Tags.TRACK_POINTS);
-        builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
-        builder.setNameSpace(Tags.PREFIX).setName("TrackSegment");
+        groupOp = new GroupAsPolylineOperation(geomInfo, Tags.TRACK_POINTS, groupResult);
+        builder.clear().setSuperTypes(parent).setNameSpace(Tags.PREFIX).setName("TrackSegment");
         builder.addProperty(groupOp);
         builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
         builder.setDefaultCardinality(0, 1);
@@ -256,9 +265,8 @@ final class Types extends Static {
          * │ trkseg         │ TrackSegment   │ gpx:trksegType         │   [0 …
∞]   │
          * └────────────────┴────────────────┴────────────────────────┴─────────────┘
          */
-        groupOp = new GroupAsPolylineOperation(geomInfo, Tags.TRACK_SEGMENTS);
-        builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
-        builder.setNameSpace(Tags.PREFIX).setName("Track");
+        groupOp = new GroupAsPolylineOperation(geomInfo, Tags.TRACK_SEGMENTS, groupResult);
+        builder.clear().setSuperTypes(parent).setNameSpace(Tags.PREFIX).setName("Track");
         builder.addProperty(groupOp);
         builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
         builder.setDefaultCardinality(0, 1);

Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Writer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Writer.java?rev=1799891&r1=1799890&r2=1799891&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Writer.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Writer.java
[UTF-8] Mon Jun 26 12:25:46 2017
@@ -20,11 +20,11 @@ import java.io.IOException;
 import java.util.Collection;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.bind.JAXBException;
-import com.esri.core.geometry.Point;
 import org.apache.sis.storage.gps.Fix;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.IllegalFeatureTypeException;
 import org.apache.sis.internal.storage.xml.stream.StaxStreamWriter;
+import org.apache.sis.internal.feature.Geometries;
 import org.apache.sis.util.Version;
 
 // Branch-dependent imports
@@ -191,31 +191,33 @@ final class Writer extends StaxStreamWri
      */
     private void writeWayPoint(final Feature feature, final String tagName) throws XMLStreamException,
JAXBException {
         if (feature != null) {
-            final Point pt = (Point) feature.getPropertyValue("sis:geometry");
-            writer.writeStartElement(tagName);
-            writer.writeAttribute(Attributes.LATITUDE, Double.toString(pt.getY()));
-            writer.writeAttribute(Attributes.LONGITUDE, Double.toString(pt.getX()));
-
-            writeSingleValue(Tags.ELEVATION,       feature.getPropertyValue(Tags.ELEVATION));
-            writeSingleValue(Tags.TIME,            feature.getPropertyValue(Tags.TIME));
-            writeSingleValue(Tags.MAGNETIC_VAR,    feature.getPropertyValue(Tags.MAGNETIC_VAR));
-            writeSingleValue(Tags.GEOID_HEIGHT,    feature.getPropertyValue(Tags.GEOID_HEIGHT));
-            writeSingleValue(Tags.NAME,            feature.getPropertyValue(Tags.NAME));
-            writeSingleValue(Tags.COMMENT,         feature.getPropertyValue(Tags.COMMENT));
-            writeSingleValue(Tags.DESCRIPTION,     feature.getPropertyValue(Tags.DESCRIPTION));
-            writeSingleValue(Tags.SOURCE,          feature.getPropertyValue(Tags.SOURCE));
-            writeLinks((Collection<?>)             feature.getPropertyValue(Tags.LINK));
-            writeSingleValue(Tags.SYMBOL,          feature.getPropertyValue(Tags.SYMBOL));
-            writeSingleValue(Tags.TYPE,            feature.getPropertyValue(Tags.TYPE));
-            writeSingle((Fix)                      feature.getPropertyValue(Tags.FIX));
-            writeSingleValue(Tags.SATELITTES,      feature.getPropertyValue(Tags.SATELITTES));
-            writeSingleValue(Tags.HDOP,            feature.getPropertyValue(Tags.HDOP));
-            writeSingleValue(Tags.VDOP,            feature.getPropertyValue(Tags.VDOP));
-            writeSingleValue(Tags.PDOP,            feature.getPropertyValue(Tags.PDOP));
-            writeSingleValue(Tags.AGE_OF_GPS_DATA, feature.getPropertyValue(Tags.AGE_OF_GPS_DATA));
-            writeSingleValue(Tags.DGPS_ID,         feature.getPropertyValue(Tags.DGPS_ID));
+            final double[] pt = Geometries.getCoordinate(feature.getPropertyValue("sis:geometry"));
+            if (pt != null && pt.length >= 2) {
+                writer.writeStartElement(tagName);
+                writer.writeAttribute(Attributes.LATITUDE,  Double.toString(pt[1]));
+                writer.writeAttribute(Attributes.LONGITUDE, Double.toString(pt[0]));
+
+                writeSingleValue(Tags.ELEVATION,       feature.getPropertyValue(Tags.ELEVATION));
+                writeSingleValue(Tags.TIME,            feature.getPropertyValue(Tags.TIME));
+                writeSingleValue(Tags.MAGNETIC_VAR,    feature.getPropertyValue(Tags.MAGNETIC_VAR));
+                writeSingleValue(Tags.GEOID_HEIGHT,    feature.getPropertyValue(Tags.GEOID_HEIGHT));
+                writeSingleValue(Tags.NAME,            feature.getPropertyValue(Tags.NAME));
+                writeSingleValue(Tags.COMMENT,         feature.getPropertyValue(Tags.COMMENT));
+                writeSingleValue(Tags.DESCRIPTION,     feature.getPropertyValue(Tags.DESCRIPTION));
+                writeSingleValue(Tags.SOURCE,          feature.getPropertyValue(Tags.SOURCE));
+                writeLinks((Collection<?>)             feature.getPropertyValue(Tags.LINK));
+                writeSingleValue(Tags.SYMBOL,          feature.getPropertyValue(Tags.SYMBOL));
+                writeSingleValue(Tags.TYPE,            feature.getPropertyValue(Tags.TYPE));
+                writeSingle((Fix)                      feature.getPropertyValue(Tags.FIX));
+                writeSingleValue(Tags.SATELITTES,      feature.getPropertyValue(Tags.SATELITTES));
+                writeSingleValue(Tags.HDOP,            feature.getPropertyValue(Tags.HDOP));
+                writeSingleValue(Tags.VDOP,            feature.getPropertyValue(Tags.VDOP));
+                writeSingleValue(Tags.PDOP,            feature.getPropertyValue(Tags.PDOP));
+                writeSingleValue(Tags.AGE_OF_GPS_DATA, feature.getPropertyValue(Tags.AGE_OF_GPS_DATA));
+                writeSingleValue(Tags.DGPS_ID,         feature.getPropertyValue(Tags.DGPS_ID));
 
-            writer.writeEndElement();
+                writer.writeEndElement();
+            }
         }
     }
 



Mime
View raw message