sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1768401 [1/2] - in /sis/branches/JDK8/storage/sis-xmlstore/src: main/java/org/apache/sis/internal/gpx/ test/java/org/apache/sis/internal/gpx/
Date Sun, 06 Nov 2016 23:04:42 GMT
Author: desruisseaux
Date: Sun Nov  6 23:04:42 2016
New Revision: 1768401

URL: http://svn.apache.org/viewvc?rev=1768401&view=rev
Log:
Partial refactoring of GPX store:
- Reduce code duplication between GroupPolylinesOperation and GroupPointsAsPolylineOperation by using inheritance.
- Replace Envelope by GeographicBoundingBox. It simplifies code and reflects the GPX specification, which restricts the CRS to WGS84.
- Create a Element class as the common parent of Person and Copyright. More code will be added in that parent class for URI parsing.
- Move the FeatureType constants in GPXConstants in a separated class, Types, with non-static fields in order to allow different types.
- Use the names defined in AttributeConvention for the geometry and the identifier in FeatureTypes.
- Opportunistic code formatting.

Added:
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Element.java   (with props)
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Types.java
      - copied, changed from r1768314, sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java
Modified:
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter100.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPointsAsPolylineOperation.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPolylinesOperation.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Person.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/GPXReaderTest.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/GPXWriterTest.java

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java?rev=1768401&r1=1768400&r2=1768401&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Copyright.java [UTF-8] Sun Nov  6 23:04:42 2016
@@ -21,7 +21,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
-import java.util.Set;
 import java.util.Objects;
 import org.apache.sis.metadata.iso.citation.DefaultOnlineResource;
 import org.apache.sis.util.iso.SimpleInternationalString;
@@ -65,7 +64,7 @@ import org.opengis.util.InternationalStr
  * @version 0.8
  * @module
  */
-public final class Copyright implements LegalConstraints, Responsibility, Party, Citation, CitationDate {
+public final class Copyright extends Element implements LegalConstraints, Responsibility, Party, Citation, CitationDate {
     /**
      * The copyright holder.
      * This field is mandatory in principle, but {@code Copyright} implementation is robust to null value.
@@ -474,16 +473,6 @@ public final class Copyright implements
     }
 
     /**
-     * Returns the given object as a singleton if the given condition is {@code true},
-     * or an empty set if the given condition is {@code false}.
-     *
-     * @param  obj  the object (usually {@code this}) to return in a singleton if the condition is true.
-     */
-    private static <T> Set<T> thisOrEmpty(final T obj, final boolean condition) {
-        return condition ? Collections.singleton(obj) : Collections.emptySet();
-    }
-
-    /**
      * Compares this {@code Copyright} with the given object for equality.
      *
      * @param  obj  the object to compare with this {@code Copyright}.

Added: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Element.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Element.java?rev=1768401&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Element.java (added)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Element.java [UTF-8] Sun Nov  6 23:04:42 2016
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2016 desruisseaux.
+ *
+ * Licensed 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.gpx;
+
+import java.util.Collections;
+import java.util.Set;
+
+
+/**
+ * Base class of GPX element.
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+class Element {
+    /**
+     * Creates a new element.
+     */
+    Element() {
+    }
+
+    /**
+     * Returns the given object as a singleton if the given condition is {@code true},
+     * or an empty set if the given condition is {@code false}.
+     *
+     * @param  obj  the object (usually {@code this}) to return in a singleton if the condition is true.
+     */
+    static <T> Set<T> thisOrEmpty(final T obj, final boolean condition) {
+        return condition ? Collections.singleton(obj) : Collections.emptySet();
+    }
+}

Propchange: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Element.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Element.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java?rev=1768401&r1=1768400&r2=1768401&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java [UTF-8] Sun Nov  6 23:04:42 2016
@@ -16,177 +16,154 @@
  */
 package org.apache.sis.internal.gpx;
 
-import java.net.URI;
-import java.time.temporal.Temporal;
-import java.util.Collections;
-import java.util.Map;
-import com.esri.core.geometry.Point;
-import org.opengis.util.LocalName;
-import org.opengis.util.NameFactory;
-import org.opengis.util.FactoryException;
-import org.apache.sis.feature.AbstractIdentifiedType;
-import org.apache.sis.feature.DefaultAttributeType;
-import org.apache.sis.feature.DefaultFeatureType;
-import org.apache.sis.feature.DefaultAssociationRole;
-import org.apache.sis.feature.FeatureOperations;
-import org.apache.sis.feature.builder.FeatureTypeBuilder;
-import org.apache.sis.feature.builder.AttributeRole;
-import org.apache.sis.internal.feature.AttributeConvention;
-import org.apache.sis.internal.system.DefaultFactories;
-import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.util.Static;
-import org.apache.sis.util.iso.Names;
-
-// Branch-dependent imports
-import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
 
 
 /**
  * GPX XML tags and feature types.
  *
- * @author Johann Sorel (Geomatys)
- * @since   0.7
+ * @author  Johann Sorel (Geomatys)
+ * @since   0.8
  * @version 0.8
  * @module
  */
-public final class GPXConstants extends Static {
+final class GPXConstants extends Static {
     /*
-     * Main GPX xml tag.
+     * Main GPX XML tags.
      */
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_GPX = "gpx";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String ATT_GPX_VERSION = "version";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String ATT_GPX_CREATOR = "creator";
 
-    /**
+    /*
      * Attributes used a bit everywhere.
      */
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_NAME = "name";
-    /** used in version : 1.0 */
+    /** Used in version 1.0. */
     public static final String TAG_URL = "url";
-    /** used in version : 1.0 */
+    /** Used in version 1.0. */
     public static final String TAG_URLNAME = "urlname";
-    /** used in version : 1.1 */
+    /** Used in version 1.1. */
     public static final String TAG_LINK = "link";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_DESC = "desc";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_CMT = "cmt";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_SRC = "src";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_TYPE = "type";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_NUMBER = "number";
 
     /*
-     * Metadata tag.
+     * Metadata tags.
      */
-    /** used in version : 1.1 */
+    /** Used in version 1.1. */
     public static final String TAG_METADATA = "metadata";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_METADATA_TIME = "time";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_METADATA_KEYWORDS = "keywords";
 
     /*
-     * Person tag.
+     * Person tags.
      */
-    /** used in version : 1.0(as attribut) and 1.1(as tag) */
+    /** Used in version 1.0 (as attribute) and 1.1 (as tag) */
     public static final String TAG_AUTHOR = "author";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_AUTHOR_EMAIL = "email";
 
     /*
-     * Copyright tag.
+     * Copyright tags.
      */
-    /** used in version : 1.1 */
+    /** Used in version 1.1. */
     public static final String TAG_COPYRIGHT = "copyright";
-    /** used in version : 1.1 */
+    /** Used in version 1.1. */
     public static final String TAG_COPYRIGHT_YEAR = "year";
-    /** used in version : 1.1 */
+    /** Used in version 1.1. */
     public static final String TAG_COPYRIGHT_LICENSE = "license";
-    /** used in version : 1.1 */
+    /** Used in version 1.1. */
     public static final String ATT_COPYRIGHT_AUTHOR = "author";
 
     /*
-     * Bounds tag.
+     * Bounds tags.
      */
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_BOUNDS = "bounds";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String ATT_BOUNDS_MINLAT = "minlat";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String ATT_BOUNDS_MINLON = "minlon";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String ATT_BOUNDS_MAXLAT = "maxlat";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String ATT_BOUNDS_MAXLON = "maxlon";
 
     /*
-     * Link tag.
+     * Link tags.
      */
-    /** used in version : 1.1 */
+    /** Used in version 1.1. */
     public static final String TAG_LINK_TEXT = "text";
-    /** used in version : 1.1 */
+    /** Used in version 1.1. */
     public static final String TAG_LINK_TYPE = "type";
-    /** used in version : 1.1 */
+    /** Used in version 1.1. */
     public static final String ATT_LINK_HREF = "href";
 
     /*
-     * WPT tag.
+     * WPT tags.
      */
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT = "wpt";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String ATT_WPT_LAT = "lat";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String ATT_WPT_LON = "lon";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_ELE = "ele";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_TIME = "time";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_MAGVAR = "magvar";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_GEOIHEIGHT = "geoidheight";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_SYM = "sym";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_FIX = "fix";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_SAT = "sat";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_HDOP = "hdop";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_VDOP = "vdop";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_PDOP = "pdop";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_AGEOFGPSDATA = "ageofdgpsdata";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_WPT_DGPSID = "dgpsid";
 
     /*
-     * RTE tag.
+     * RTE tags.
      */
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_RTE = "rte";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_RTE_RTEPT = "rtept";
 
     /*
-     * TRK tag.
+     * TRK tags.
      */
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_TRK = "trk";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_TRK_SEG = "trkseg";
-    /** used in version : 1.0 and 1.1 */
+    /** Used in versions 1.0 and 1.1. */
     public static final String TAG_TRK_SEG_PT = "trkpt";
 
     /**
@@ -195,199 +172,15 @@ public final class GPXConstants extends
     public static final String GPX_NAMESPACE = "http://www.topografix.com";
 
     /**
-     * GPX 1.1 xml namespace
+     * GPX 1.1 XML namespace.
      */
     public static final String GPX_NAMESPACE_V11 = "http://www.topografix.com/GPX/1/1";
     /**
-     * GPX 1.0 xml namespace
+     * GPX 1.0 XML namespace.
      */
     public static final String GPX_NAMESPACE_V10 = "http://www.topografix.com/GPX/1/0";
 
     /**
-     * Parent feature type of all gpx types.
-     */
-    public static final FeatureType TYPE_GPX_ENTITY;
-
-    /**
-     * Waypoint GPX feature type.
-     */
-    public static final FeatureType TYPE_WAYPOINT;
-
-    /**
-     * Track GPX feature type.
-     */
-    public static final FeatureType TYPE_TRACK;
-
-    /**
-     * Route GPX feature type.
-     */
-    public static final FeatureType TYPE_ROUTE;
-
-    /**
-     * Track segment GPX feature type.
-     */
-    public static final FeatureType TYPE_TRACK_SEGMENT;
-
-    static {
-        final NameFactory   factory  = DefaultFactories.forBuildin(NameFactory.class);
-        final LocalName     geomName = Names.createTypeName(null, null, "geometry");
-        final Map<String,?> geomInfo = Collections.singletonMap(AbstractIdentifiedType.NAME_KEY, geomName);
-
-        //-------------------- GENERIC GPX ENTITY ------------------------------
-        FeatureTypeBuilder builder = new FeatureTypeBuilder(null, factory, null);
-        builder.setDefaultScope(GPX_NAMESPACE).setName("GPXEntity").setAbstract(true);
-        builder.addAttribute(Integer.class).setName("index").addRole(AttributeRole.IDENTIFIER_COMPONENT);
-        TYPE_GPX_ENTITY = builder.build();
-
-        //------------------- WAY POINT TYPE -----------------------------------
-        /*
-         * lat="latitudeType [1] ?"
-         * lon="longitudeType [1] ?">
-         * <ele> xsd:decimal </ele> [0..1] ?
-         * <time> xsd:dateTime </time> [0..1] ?
-         * <magvar> degreesType </magvar> [0..1] ?
-         * <geoidheight> xsd:decimal </geoidheight> [0..1] ?
-         * <name> xsd:string </name> [0..1] ?
-         * <cmt> xsd:string </cmt> [0..1] ?
-         * <desc> xsd:string </desc> [0..1] ?
-         * <src> xsd:string </src> [0..1] ?
-         * <link> linkType </link> [0..*] ?
-         * <sym> xsd:string </sym> [0..1] ?
-         * <type> xsd:string </type> [0..1] ?
-         * <fix> fixType </fix> [0..1] ?
-         * <sat> xsd:nonNegativeInteger </sat> [0..1] ?
-         * <hdop> xsd:decimal </hdop> [0..1] ?
-         * <vdop> xsd:decimal </vdop> [0..1] ?
-         * <pdop> xsd:decimal </pdop> [0..1] ?
-         * <ageofdgpsdata> xsd:decimal </ageofdgpsdata> [0..1] ?
-         * <dgpsid> dgpsStationType </dgpsid> [0..1] ?
-         * <extensions> extensionsType </extensions> [0..1] ?
-         */
-        builder = new FeatureTypeBuilder(null, factory, null);
-        builder.setDefaultScope(GPX_NAMESPACE).setName("WayPoint").setSuperTypes(TYPE_GPX_ENTITY);
-        builder.addAttribute(Point.class).setName(geomName)
-                .setCRS(CommonCRS.defaultGeographic())
-                .addRole(AttributeRole.DEFAULT_GEOMETRY);
-        builder.setDefaultCardinality(0, 1);
-        builder.addAttribute(Double  .class).setName(TAG_WPT_ELE);
-        builder.addAttribute(Temporal.class).setName(TAG_WPT_TIME);
-        builder.addAttribute(Double  .class).setName(TAG_WPT_MAGVAR);
-        builder.addAttribute(Double  .class).setName(TAG_WPT_GEOIHEIGHT);
-        builder.addAttribute(String  .class).setName(TAG_NAME);
-        builder.addAttribute(String  .class).setName(TAG_CMT);
-        builder.addAttribute(String  .class).setName(TAG_DESC);
-        builder.addAttribute(String  .class).setName(TAG_SRC);
-        builder.addAttribute(URI     .class).setName(TAG_LINK).setMaximumOccurs(Integer.MAX_VALUE);
-        builder.addAttribute(String  .class).setName(TAG_WPT_SYM);
-        builder.addAttribute(String  .class).setName(TAG_TYPE);
-        builder.addAttribute(String  .class).setName(TAG_WPT_FIX);
-        builder.addAttribute(Integer .class).setName(TAG_WPT_SAT);
-        builder.addAttribute(Double  .class).setName(TAG_WPT_HDOP);
-        builder.addAttribute(Double  .class).setName(TAG_WPT_VDOP);
-        builder.addAttribute(Double  .class).setName(TAG_WPT_PDOP);
-        builder.addAttribute(Double  .class).setName(TAG_WPT_AGEOFGPSDATA);
-        builder.addAttribute(Integer .class).setName(TAG_WPT_DGPSID);
-        TYPE_WAYPOINT = builder.build();
-
-        //------------------- ROUTE TYPE ---------------------------------------
-        /*
-         * <name> xsd:string </name> [0..1] ?
-         * <cmt> xsd:string </cmt> [0..1] ?
-         * <desc> xsd:string </desc> [0..1] ?
-         * <src> xsd:string </src> [0..1] ?
-         * <link> linkType </link> [0..*] ?
-         * <number> xsd:nonNegativeInteger </number> [0..1] ?
-         * <type> xsd:string </type> [0..1] ?
-         * <extensions> extensionsType </extensions> [0..1] ?
-         * <rtept> wptType </rtept> [0..*] ?
-         */
-        final DefaultAssociationRole attWayPoints = new DefaultAssociationRole(
-                identification(factory, TAG_RTE_RTEPT), TYPE_WAYPOINT, 0, Integer.MAX_VALUE);
-        PropertyType[] properties = {
-                TYPE_WAYPOINT.getProperty(TAG_NAME),
-                TYPE_WAYPOINT.getProperty(TAG_CMT),
-                TYPE_WAYPOINT.getProperty(TAG_DESC),
-                TYPE_WAYPOINT.getProperty(TAG_SRC),
-                TYPE_WAYPOINT.getProperty(TAG_LINK),
-                new DefaultAttributeType<>(identification(factory, TAG_NUMBER), Integer.class, 0, 1, null),
-                TYPE_WAYPOINT.getProperty(TAG_TYPE),
-                attWayPoints,
-                new GroupPointsAsPolylineOperation(geomInfo, attWayPoints.getName(), geomName),
-                null
-        };
-        final Map<String,?> envelopeInfo = Collections.singletonMap(AbstractIdentifiedType.NAME_KEY, AttributeConvention.ENVELOPE_PROPERTY);
-        try {
-            properties[properties.length - 1] = FeatureOperations.envelope(envelopeInfo, null, properties);
-        } catch (FactoryException e) {
-            throw new IllegalStateException(e);
-        }
-        TYPE_ROUTE = new DefaultFeatureType(identification(factory, "Route"), false,
-                new FeatureType[] {TYPE_GPX_ENTITY}, properties);
-
-
-        //------------------- TRACK SEGMENT TYPE -------------------------------
-        /*
-         * <trkpt> wptType </trkpt> [0..*] ?
-         * <extensions> extensionsType </extensions> [0..1] ?
-         */
-        final DefaultAssociationRole attTrackPoints = new DefaultAssociationRole(
-                identification(factory, TAG_TRK_SEG_PT), TYPE_WAYPOINT, 0, Integer.MAX_VALUE);
-        properties = new PropertyType[] {
-                attTrackPoints,
-                new GroupPointsAsPolylineOperation(geomInfo, attTrackPoints.getName(), geomName),
-                null
-        };
-        try {
-            properties[properties.length - 1] = FeatureOperations.envelope(envelopeInfo, null, properties);
-        } catch (FactoryException e) {
-            throw new IllegalStateException(e);
-        }
-        TYPE_TRACK_SEGMENT = new DefaultFeatureType(identification(factory, "TrackSegment"), false,
-                new FeatureType[] {TYPE_GPX_ENTITY}, properties
-        );
-
-        //------------------- TRACK TYPE ---------------------------------------
-        /*
-         * <name> xsd:string </name> [0..1] ?
-         * <cmt> xsd:string </cmt> [0..1] ?
-         * <desc> xsd:string </desc> [0..1] ?
-         * <src> xsd:string </src> [0..1] ?
-         * <link> linkType </link> [0..*] ?
-         * <number> xsd:nonNegativeInteger </number> [0..1] ?
-         * <type> xsd:string </type> [0..1] ?
-         * <extensions> extensionsType </extensions> [0..1] ?
-         * <trkseg> trksegType </trkseg> [0..*] ?
-         */
-        final DefaultAssociationRole attTrackSegments = new DefaultAssociationRole(
-                identification(factory, TAG_TRK_SEG), TYPE_TRACK_SEGMENT, 0, Integer.MAX_VALUE);
-        properties = new PropertyType[] {
-                TYPE_ROUTE.getProperty(TAG_NAME),
-                TYPE_ROUTE.getProperty(TAG_CMT),
-                TYPE_ROUTE.getProperty(TAG_DESC),
-                TYPE_ROUTE.getProperty(TAG_SRC),
-                TYPE_ROUTE.getProperty(TAG_LINK),
-                TYPE_ROUTE.getProperty(TAG_NUMBER),
-                TYPE_ROUTE.getProperty(TAG_TYPE),
-                attTrackSegments,
-                new GroupPolylinesOperation(geomInfo, attTrackSegments.getName(), geomName),
-                null
-        };
-        try {
-            properties[properties.length - 1] = FeatureOperations.envelope(envelopeInfo, null, properties);
-        } catch (FactoryException e) {
-            throw new IllegalStateException(e);
-        }
-        TYPE_TRACK = new DefaultFeatureType(identification(factory, "Track"), false,
-                new FeatureType[] {TYPE_GPX_ENTITY}, properties
-        );
-    }
-
-    private static Map<String,?> identification(final NameFactory factory, final String localPart) {
-        return Collections.singletonMap(AbstractIdentifiedType.NAME_KEY,
-                factory.createGenericName(null, GPX_NAMESPACE, localPart));
-    }
-
-    /**
      * Do not allow instantiation of this class.
      */
     private GPXConstants() {

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java?rev=1768401&r1=1768400&r2=1768401&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java [UTF-8] Sun Nov  6 23:04:42 2016
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.internal.gpx;
 
-import com.esri.core.geometry.Point;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -31,12 +30,10 @@ import java.time.temporal.UnsupportedTem
 import java.util.ArrayList;
 import java.util.List;
 import javax.xml.stream.XMLStreamException;
-import org.opengis.geometry.Envelope;
-import org.opengis.feature.Feature;
-
 import javax.xml.stream.XMLStreamReader;
-import org.apache.sis.geometry.ImmutableEnvelope;
-import org.apache.sis.referencing.CommonCRS;
+import com.esri.core.geometry.Point;
+import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.internal.xml.StaxStreamReader;
@@ -44,6 +41,9 @@ import org.apache.sis.internal.xml.StaxS
 import static javax.xml.stream.XMLStreamReader.*;
 import static org.apache.sis.internal.gpx.GPXConstants.*;
 
+// Branch-dependent imports
+import org.opengis.feature.Feature;
+
 
 /**
  * Stax reader class for GPX 1.0 and 1.1 files.
@@ -65,12 +65,13 @@ import static org.apache.sis.internal.gp
  * </pre>
  *
  * @author Johann Sorel (Geomatys)
- * @since   0.7
+ * @since   0.8
  * @version 0.8
  * @module
  */
 public class GPXReader extends StaxStreamReader {
 
+    private final Types types;
     private Metadata metadata;
     private Feature current;
     private int wayPointInc = 0;
@@ -88,52 +89,51 @@ public class GPXReader extends StaxStrea
      */
     public GPXReader(final Object input, final StorageConnector storage) throws DataStoreException, IOException, XMLStreamException {
         super(input, storage);
+        types = Types.DEFAULT;
         final XMLStreamReader reader = getReader();
 
-        //search for the bound tag to generate the envelope
-        searchLoop :
-        while(reader.hasNext()){
-            final int type = reader.next();
-
-            switch (type) {
-                case START_ELEMENT:
+        // Search for the bound tag to generate the envelope
+searchLoop:
+        while(reader.hasNext()) {
+            switch (reader.next()) {
+                case START_ELEMENT: {
                     final String typeName = reader.getLocalName();
-                    if(TAG_GPX.equalsIgnoreCase(typeName)){
+                    if (TAG_GPX.equalsIgnoreCase(typeName)) {
 
-                        String str = "1.1"; //consider 1.1 by default
-                        for(int i=0,n=reader.getAttributeCount(); i<n;i++){
-                            if(ATT_GPX_VERSION.equalsIgnoreCase(reader.getAttributeLocalName(i))){
+                        String str = "1.1";     // Consider 1.1 by default
+                        for (int i=0,n=reader.getAttributeCount(); i<n;i++) {
+                            if (ATT_GPX_VERSION.equalsIgnoreCase(reader.getAttributeLocalName(i))) {
                                 str = reader.getAttributeValue(i);
                             }
                         }
 
-                        try{
+                        try {
                             this.version = GPXVersion.toVersion(str);
-                        }catch(NumberFormatException ex){
+                        } catch (NumberFormatException ex) {
                             throw new XMLStreamException(ex);
                         }
 
-                        if(version == GPXVersion.v1_0_0){
+                        if (version == GPXVersion.v1_0_0) {
                             baseNamespace = GPX_NAMESPACE_V10;
                             //we wont found a metadata tag, must read the tags here.
                             metadata = parseMetadata100();
                             break searchLoop;
-                        }else{
+                        } else{
                             baseNamespace = GPX_NAMESPACE_V11;
                         }
 
-                    }else if(TAG_METADATA.equalsIgnoreCase(typeName)){
+                    } else if (TAG_METADATA.equalsIgnoreCase(typeName)) {
                         metadata = parseMetadata110();
                         break searchLoop;
-                    }else if(  TAG_WPT.equalsIgnoreCase(typeName)
+                    } else if (  TAG_WPT.equalsIgnoreCase(typeName)
                             || TAG_TRK.equalsIgnoreCase(typeName)
-                            || TAG_RTE.equalsIgnoreCase(typeName)){
+                            || TAG_RTE.equalsIgnoreCase(typeName)) {
                         //there is no metadata tag
                         break searchLoop;
                     }
+                }
             }
         }
-
     }
 
     /**
@@ -173,8 +173,8 @@ public class GPXReader extends StaxStrea
      * Returns true if there is a next feature in the stream.
      *
      * @return true if there is next feature
-     * @throws javax.xml.stream.XMLStreamException if xml parser encounter an invalid
-     *                          element or underlying stream caused an exception
+     * @throws XMLStreamException if xml parser encounter an invalid element
+     *         or underlying stream caused an exception
      */
     public boolean hasNext() throws IOException, XMLStreamException {
         findNext();
@@ -185,8 +185,8 @@ public class GPXReader extends StaxStrea
      * Get next feature in the stream.
      *
      * @return GPX WayPoint, Route or track
-     * @throws javax.xml.stream.XMLStreamException if xml parser encounter an invalid
-     *                          element or underlying stream caused an exception
+     * @throws XMLStreamException if xml parser encounter an invalid element
+     *         or underlying stream caused an exception
      */
     public Feature next() throws IOException, XMLStreamException {
         findNext();
@@ -201,141 +201,131 @@ public class GPXReader extends StaxStrea
      */
     private void findNext() throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
-        if(current != null) return;
+        if (current != null) return;
 
         boolean first = true;
         while ( first || (current == null && reader.hasNext()) ) {
             final int type;
-            if(first){
+            if (first) {
                 type = reader.getEventType();
                 first = false;
-            }else{
+            } else {
                 type = reader.next();
             }
-
-            if(type == START_ELEMENT) {
+            if (type == START_ELEMENT) {
                 final String localName = reader.getLocalName();
-                if(TAG_WPT.equalsIgnoreCase(localName)){
+                if (TAG_WPT.equalsIgnoreCase(localName)) {
                     current = parseWayPoint(wayPointInc++);
                     break;
-                }else if(TAG_RTE.equalsIgnoreCase(localName)){
+                } else if (TAG_RTE.equalsIgnoreCase(localName)) {
                     current = parseRoute(routeInc++);
                     break;
-                }else if(TAG_TRK.equalsIgnoreCase(localName)){
+                } else if (TAG_TRK.equalsIgnoreCase(localName)) {
                     current = parseTrack(trackInc++);
                     break;
                 }
             }
         }
-
     }
 
     /**
      * Parse current metadata element.
      * The stax reader must be placed to the start element of the metadata.
-     *
-     * @return Metadata
      */
     private Metadata parseMetadata100() throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
-
         final Metadata metadata = new Metadata();
 
-        searchLoop:
+searchLoop:
         while (reader.hasNext()) {
             final int type = reader.next();
 
             switch (type) {
-                case START_ELEMENT:
+                case START_ELEMENT: {
                     final String localName = reader.getLocalName();
-                    if(TAG_NAME.equalsIgnoreCase(localName)){
+                    if (TAG_NAME.equalsIgnoreCase(localName)) {
                         metadata.name = reader.getElementText();
-                    }else if(TAG_DESC.equalsIgnoreCase(localName)) {
+                    } else if (TAG_DESC.equalsIgnoreCase(localName)) {
                         metadata.description = reader.getElementText();
-                    }else if(TAG_AUTHOR.equalsIgnoreCase(localName)) {
-                        if(metadata.author == null) metadata.author = new Person();
+                    } else if (TAG_AUTHOR.equalsIgnoreCase(localName)) {
+                        if (metadata.author == null) metadata.author = new Person();
                         metadata.author.name = reader.getElementText();
-                    }else if(TAG_AUTHOR_EMAIL.equalsIgnoreCase(localName)) {
-                        if(metadata.author == null) metadata.author = new Person();
+                    } else if (TAG_AUTHOR_EMAIL.equalsIgnoreCase(localName)) {
+                        if (metadata.author == null) metadata.author = new Person();
                         metadata.author.email = reader.getElementText();
-                    }else if(TAG_URL.equalsIgnoreCase(localName)){
+                    } else if (TAG_URL.equalsIgnoreCase(localName)) {
                         try {
                             metadata.links.add(new URI(reader.getElementText()));
                         } catch (URISyntaxException ex) {
                             throw new XMLStreamException(ex);
                         }
-                    }else if(TAG_URLNAME.equalsIgnoreCase(localName)){
+                    } else if (TAG_URLNAME.equalsIgnoreCase(localName)) {
                         //reader.getElementText();
-                    }else if(TAG_METADATA_TIME.equalsIgnoreCase(localName)){
+                    } else if (TAG_METADATA_TIME.equalsIgnoreCase(localName)) {
                         metadata.time = parseTime(reader.getElementText());
-                    }else if(TAG_METADATA_KEYWORDS.equalsIgnoreCase(localName)){
+                    } else if (TAG_METADATA_KEYWORDS.equalsIgnoreCase(localName)) {
                         metadata.keywords = reader.getElementText();
-                    }else if(TAG_BOUNDS.equalsIgnoreCase(localName)){
+                    } else if (TAG_BOUNDS.equalsIgnoreCase(localName)) {
                         metadata.bounds = parseBound();
-                    }else if(  TAG_WPT.equalsIgnoreCase(localName)
+                    } else if (  TAG_WPT.equalsIgnoreCase(localName)
                             || TAG_TRK.equalsIgnoreCase(localName)
-                            || TAG_RTE.equalsIgnoreCase(localName)){
+                            || TAG_RTE.equalsIgnoreCase(localName)) {
                         //there is no more metadata tags
                         break searchLoop;
                     }
                     break;
+                }
             }
         }
-
         return metadata;
     }
 
     /**
      * Parse current metadata element.
      * The stax reader must be placed to the start element of the metadata.
-     *
-     * @return Metadata
      */
     private Metadata parseMetadata110() throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
         final Metadata metadata = new Metadata();
 
         while (reader.hasNext()) {
-            final int type = reader.next();
-
-            switch (type) {
-                case START_ELEMENT:
+            switch (reader.next()) {
+                case START_ELEMENT: {
                     final String localName = reader.getLocalName();
-                    if(TAG_NAME.equalsIgnoreCase(localName)){
+                    if (TAG_NAME.equalsIgnoreCase(localName)) {
                         metadata.name = reader.getElementText();
-                    }else if(TAG_DESC.equalsIgnoreCase(localName)){
+                    } else if (TAG_DESC.equalsIgnoreCase(localName)) {
                         metadata.description = reader.getElementText();
-                    }else if(TAG_AUTHOR.equalsIgnoreCase(localName)){
+                    } else if (TAG_AUTHOR.equalsIgnoreCase(localName)) {
                         metadata.author = parsePerson();
-                    }else if(TAG_COPYRIGHT.equalsIgnoreCase(localName)){
+                    } else if (TAG_COPYRIGHT.equalsIgnoreCase(localName)) {
                         metadata.copyright = parseCopyright();
-                    }else if(TAG_LINK.equalsIgnoreCase(localName)){
+                    } else if (TAG_LINK.equalsIgnoreCase(localName)) {
                         metadata.links.add(parseLink());
-                    }else if(TAG_METADATA_TIME.equalsIgnoreCase(localName)){
+                    } else if (TAG_METADATA_TIME.equalsIgnoreCase(localName)) {
                         metadata.time = parseTime(reader.getElementText());
-                    }else if(TAG_METADATA_KEYWORDS.equalsIgnoreCase(localName)){
+                    } else if (TAG_METADATA_KEYWORDS.equalsIgnoreCase(localName)) {
                         metadata.keywords = reader.getElementText();
-                    }else if(TAG_BOUNDS.equalsIgnoreCase(localName)){
+                    } else if (TAG_BOUNDS.equalsIgnoreCase(localName)) {
                         metadata.bounds = parseBound();
                     }
                     break;
-                case END_ELEMENT:
-                    if(TAG_METADATA.equalsIgnoreCase(reader.getLocalName())){
-                        //end of the metadata element
+                }
+                case END_ELEMENT: {
+                    if (TAG_METADATA.equalsIgnoreCase(reader.getLocalName())) {
+                        // End of the metadata element
                         return metadata;
                     }
                     break;
+                }
             }
         }
-
         throw new XMLStreamException("Error in xml file, relation tag without end.");
     }
 
     /**
      * Parse current copyright element.
      * The stax reader must be placed to the start element of the copyright.
-     *
-     * @return Copyright
      */
     private Copyright parseCopyright() throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
@@ -343,14 +333,12 @@ public class GPXReader extends StaxStrea
         copyright.author = reader.getAttributeValue(null, ATT_COPYRIGHT_AUTHOR);
 
         while (reader.hasNext()) {
-            final int type = reader.next();
-
-            switch (type) {
-                case START_ELEMENT:
+            switch (reader.next()) {
+                case START_ELEMENT: {
                     final String localName = reader.getLocalName();
-                    if(TAG_COPYRIGHT_YEAR.equalsIgnoreCase(localName)){
+                    if (TAG_COPYRIGHT_YEAR.equalsIgnoreCase(localName)) {
                         copyright.year = Integer.valueOf(reader.getElementText());
-                    }else if(TAG_COPYRIGHT_LICENSE.equalsIgnoreCase(localName)){
+                    } else if (TAG_COPYRIGHT_LICENSE.equalsIgnoreCase(localName)) {
                         try {
                             copyright.license = new URI(reader.getElementText());
                         } catch (URISyntaxException ex) {
@@ -358,22 +346,21 @@ public class GPXReader extends StaxStrea
                         }
                     }
                     break;
-                case END_ELEMENT:
-                    if(TAG_COPYRIGHT.equalsIgnoreCase(reader.getLocalName())){
+                }
+                case END_ELEMENT: {
+                    if (TAG_COPYRIGHT.equalsIgnoreCase(reader.getLocalName())) {
                         return copyright;
                     }
                     break;
+                }
             }
         }
-
         throw new XMLStreamException("Error in xml file, copyright tag without end.");
     }
 
     /**
      * Parse current URI element.
      * The stax reader must be placed to the start element.
-     *
-     * @return URI
      */
     private URI parseLink() throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
@@ -381,103 +368,97 @@ public class GPXReader extends StaxStrea
         String mime = null;
 
         while (reader.hasNext()) {
-            final int type = reader.next();
-
-            switch (type) {
-                case START_ELEMENT:
+            switch (reader.next()) {
+                case START_ELEMENT: {
                     final String localName = reader.getLocalName();
-                    if(TAG_LINK_TEXT.equalsIgnoreCase(localName) && text==null){
+                    if (TAG_LINK_TEXT.equalsIgnoreCase(localName) && text==null) {
                         text = reader.getElementText();
-                    }else if(TAG_LINK_TYPE.equalsIgnoreCase(localName)){
+                    } else if (TAG_LINK_TYPE.equalsIgnoreCase(localName)) {
                         mime = reader.getElementText();
                     }
                     break;
-                case END_ELEMENT:
-                    if(TAG_LINK.equalsIgnoreCase(reader.getLocalName())){
+                }
+                case END_ELEMENT: {
+                    if (TAG_LINK.equalsIgnoreCase(reader.getLocalName())) {
                         try {
-                            //end of the link element
+                            // End of the link element
                             return new URI(text);
                         } catch (URISyntaxException ex) {
                             throw new XMLStreamException(ex);
                         }
                     }
                     break;
+                }
             }
         }
-
         throw new XMLStreamException("Error in xml file, link tag without end.");
     }
 
     /**
      * Parse current Person element.
      * The stax reader must be placed to the start element.
-     *
-     * @return Person
      */
     private Person parsePerson() throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
         final Person person = new Person();
 
         while (reader.hasNext()) {
-            final int type = reader.next();
-
-            switch (type) {
-                case START_ELEMENT:
+            switch (reader.next()) {
+                case START_ELEMENT: {
                     final String localName = reader.getLocalName();
-                    if(TAG_NAME.equalsIgnoreCase(localName)){
+                    if (TAG_NAME.equalsIgnoreCase(localName)) {
                         person.name = reader.getElementText();
-                    }else if(TAG_AUTHOR_EMAIL.equalsIgnoreCase(localName)){
+                    } else if (TAG_AUTHOR_EMAIL.equalsIgnoreCase(localName)) {
                         person.email = reader.getElementText();
-                    }else if(TAG_LINK.equalsIgnoreCase(localName)){
+                    } else if (TAG_LINK.equalsIgnoreCase(localName)) {
                         person.link = parseLink();
                     }
                     break;
-                case END_ELEMENT:
-                    if(TAG_AUTHOR.equalsIgnoreCase(reader.getLocalName())){
-                        //end of the author element
+                }
+                case END_ELEMENT: {
+                    if (TAG_AUTHOR.equalsIgnoreCase(reader.getLocalName())) {
+                        // End of the author element
                         return person;
                     }
                     break;
+                }
             }
         }
-
         throw new XMLStreamException("Error in xml file, person tag without end.");
     }
 
     /**
      * Parse current Envelope element.
      * The stax reader must be placed to the start element.
-     *
-     * @return Envelope
      */
-    private Envelope parseBound() throws IOException, XMLStreamException {
+    private GeographicBoundingBox parseBound() throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
         final String xmin = reader.getAttributeValue(null, ATT_BOUNDS_MINLON);
         final String xmax = reader.getAttributeValue(null, ATT_BOUNDS_MAXLON);
         final String ymin = reader.getAttributeValue(null, ATT_BOUNDS_MINLAT);
         final String ymax = reader.getAttributeValue(null, ATT_BOUNDS_MAXLAT);
 
-        if(xmin == null || xmax == null || ymin == null || ymax == null){
+        if (xmin == null || xmax == null || ymin == null || ymax == null) {
             throw new XMLStreamException("Error in xml file, metadata bounds not defined correctly");
         }
 
         skipUntilEnd(TAG_BOUNDS);
 
-        return new ImmutableEnvelope(new double[] {Double.parseDouble(xmin), Double.parseDouble(ymin)},
-                                     new double[] {Double.parseDouble(xmax), Double.parseDouble(ymax)},
-                                     CommonCRS.WGS84.normalizedGeographic());
+        return new DefaultGeographicBoundingBox(
+                Double.parseDouble(xmin),
+                Double.parseDouble(xmax),
+                Double.parseDouble(ymin),
+                Double.parseDouble(ymax));
     }
 
     /**
      * Parse way point type feature element.
      * The stax reader must be placed to the start element.
-     *
-     * @return Feature
      */
     private Feature parseWayPoint(final int index) throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
-        final Feature feature = TYPE_WAYPOINT.newInstance();
-        feature.setPropertyValue("index", index);
+        final Feature feature = types.wayPoint.newInstance();
+        feature.setPropertyValue("@identifier", index);
 
         //way points might be located in different tag names : wpt, rtept and trkpt
         //we kind the current tag name to know when we reach the end.
@@ -488,58 +469,56 @@ public class GPXReader extends StaxStrea
         final String lat = reader.getAttributeValue(null, ATT_WPT_LAT);
         final String lon = reader.getAttributeValue(null, ATT_WPT_LON);
 
-        if(lat == null || lon == null){
+        if (lat == null || lon == null) {
             throw new XMLStreamException("Error in xml file, way point lat/lon not defined correctly");
-        }else{
+        } else{
             feature.setPropertyValue("@geometry", new Point(Double.parseDouble(lon), Double.parseDouble(lat)));
         }
 
         while (reader.hasNext()) {
-            final int eventType = reader.next();
-
-            switch (eventType) {
-                case START_ELEMENT:
+            switch (reader.next()) {
+                case START_ELEMENT: {
                     final String localName = reader.getLocalName();
-                    if(TAG_WPT_ELE.equalsIgnoreCase(localName)){
+                    if (TAG_WPT_ELE.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_ELE, Double.valueOf(reader.getElementText()));
-                    }else if(TAG_WPT_TIME.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_TIME.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_TIME, parseTime(reader.getElementText()));
-                    }else if(TAG_WPT_MAGVAR.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_MAGVAR.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_MAGVAR, Double.valueOf(reader.getElementText()));
-                    }else if(TAG_WPT_GEOIHEIGHT.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_GEOIHEIGHT.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_GEOIHEIGHT, Double.valueOf(reader.getElementText()));
-                    }else if(TAG_NAME.equalsIgnoreCase(localName)){
+                    } else if (TAG_NAME.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_NAME, reader.getElementText());
-                    }else if(TAG_CMT.equalsIgnoreCase(localName)){
+                    } else if (TAG_CMT.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_CMT,reader.getElementText());
-                    }else if(TAG_DESC.equalsIgnoreCase(localName)){
+                    } else if (TAG_DESC.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_DESC, reader.getElementText());
-                    }else if(TAG_SRC.equalsIgnoreCase(localName)){
+                    } else if (TAG_SRC.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_SRC, reader.getElementText());
-                    }else if(TAG_LINK.equalsIgnoreCase(localName)){
-                        if(links == null) links = new ArrayList<>();
+                    } else if (TAG_LINK.equalsIgnoreCase(localName)) {
+                        if (links == null) links = new ArrayList<>();
                         links.add(parseLink());
-                    }else if(TAG_WPT_SYM.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_SYM.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_SYM, reader.getElementText());
-                    }else if(TAG_TYPE.equalsIgnoreCase(localName)){
+                    } else if (TAG_TYPE.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_TYPE, reader.getElementText());
-                    }else if(TAG_WPT_FIX.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_FIX.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_FIX, reader.getElementText());
-                    }else if(TAG_WPT_SAT.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_SAT.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_SAT, Integer.valueOf(reader.getElementText()));
-                    }else if(TAG_WPT_HDOP.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_HDOP.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_HDOP, Double.valueOf(reader.getElementText()));
-                    }else if(TAG_WPT_PDOP.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_PDOP.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_PDOP, Double.valueOf(reader.getElementText()));
-                    }else if(TAG_WPT_VDOP.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_VDOP.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_VDOP, Double.valueOf(reader.getElementText()));
-                    }else if(TAG_WPT_AGEOFGPSDATA.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_AGEOFGPSDATA.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_AGEOFGPSDATA, Double.valueOf(reader.getElementText()));
-                    }else if(TAG_WPT_DGPSID.equalsIgnoreCase(localName)){
+                    } else if (TAG_WPT_DGPSID.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_WPT_DGPSID, Integer.valueOf(reader.getElementText()));
-                    }else if(version == GPXVersion.v1_0_0 && TAG_URL.equalsIgnoreCase(localName)){
-                        //GPX 1.0 only
-                        if(links == null) links = new ArrayList<>();
+                    } else if (version == GPXVersion.v1_0_0 && TAG_URL.equalsIgnoreCase(localName)) {
+                        // GPX 1.0 only
+                        if (links == null) links = new ArrayList<>();
                         try {
                             links.add(new URI(reader.getElementText()));
                         } catch (URISyntaxException ex) {
@@ -547,61 +526,58 @@ public class GPXReader extends StaxStrea
                         }
                     }
                     break;
-                case END_ELEMENT:
-                    if(tagName.equalsIgnoreCase(reader.getLocalName())){
-                        //end of the way point element
-                        if(links!=null) feature.setPropertyValue(TAG_LINK, links);
+                }
+                case END_ELEMENT: {
+                    if (tagName.equalsIgnoreCase(reader.getLocalName())) {
+                        // End of the way point element
+                        if (links!=null) feature.setPropertyValue(TAG_LINK, links);
                         return feature;
                     }
                     break;
+                }
             }
         }
-
         throw new XMLStreamException("Error in xml file, "+tagName+" tag without end.");
     }
 
     /**
      * Parse route type feature element.
      * The stax reader must be placed to the start element.
-     *
-     * @return Feature
      */
     private Feature parseRoute(final int index) throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
-        final Feature feature = TYPE_ROUTE.newInstance();
-        feature.setPropertyValue("index", index);
+        final Feature feature = types.route.newInstance();
+        feature.setPropertyValue("@identifier", index);
 
         int ptInc = 0;
         List<URI> links = null;
         List<Feature> wayPoints = null;
 
         while (reader.hasNext()) {
-            final int eventType = reader.next();
-
-            switch (eventType) {
-                case START_ELEMENT:
+            switch (reader.next()) {
+                case START_ELEMENT: {
                     final String localName = reader.getLocalName();
-                    if(TAG_RTE_RTEPT.equalsIgnoreCase(localName)){
-                        if(wayPoints == null) wayPoints = new ArrayList<>();
+                    if (TAG_RTE_RTEPT.equalsIgnoreCase(localName)) {
+                        if (wayPoints == null) wayPoints = new ArrayList<>();
                         wayPoints.add(parseWayPoint(ptInc++));
-                    }else if(TAG_NAME.equalsIgnoreCase(localName)){
+                    } else if (TAG_NAME.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_NAME, reader.getElementText());
-                    }else if(TAG_CMT.equalsIgnoreCase(localName)){
+                    } else if (TAG_CMT.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_CMT, reader.getElementText());
-                    }else if(TAG_DESC.equalsIgnoreCase(localName)){
+                    } else if (TAG_DESC.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_DESC, reader.getElementText());
-                    }else if(TAG_SRC.equalsIgnoreCase(localName)){
+                    } else if (TAG_SRC.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_SRC, reader.getElementText());
-                    }else if(TAG_LINK.equalsIgnoreCase(localName)){
-                        if(links == null) links = new ArrayList<>();
+                    } else if (TAG_LINK.equalsIgnoreCase(localName)) {
+                        if (links == null) links = new ArrayList<>();
                         links.add(parseLink());
-                    }else if(TAG_NUMBER.equalsIgnoreCase(localName)){
+                    } else if (TAG_NUMBER.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_NUMBER, Integer.valueOf(reader.getElementText()));
-                    }else if(TAG_TYPE.equalsIgnoreCase(localName)){
+                    } else if (TAG_TYPE.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_TYPE, reader.getElementText());
-                    }else if(version == GPXVersion.v1_0_0 && TAG_URL.equalsIgnoreCase(localName)){
+                    } else if (version == GPXVersion.v1_0_0 && TAG_URL.equalsIgnoreCase(localName)) {
                         //GPX 1.0 only
-                        if(links == null) links = new ArrayList<>();
+                        if (links == null) links = new ArrayList<>();
                         try {
                             links.add(new URI(reader.getElementText()));
                         } catch (URISyntaxException ex) {
@@ -609,98 +585,92 @@ public class GPXReader extends StaxStrea
                         }
                     }
                     break;
-                case END_ELEMENT:
-                    if(TAG_RTE.equalsIgnoreCase(reader.getLocalName())){
-                        //end of the route element
-                        if(links!=null) feature.setPropertyValue(TAG_LINK, links);
-                        if(wayPoints!=null) feature.setPropertyValue(TAG_RTE_RTEPT, wayPoints);
+                }
+                case END_ELEMENT: {
+                    if (TAG_RTE.equalsIgnoreCase(reader.getLocalName())) {
+                        // End of the route element
+                        if (links!=null) feature.setPropertyValue(TAG_LINK, links);
+                        if (wayPoints!=null) feature.setPropertyValue(TAG_RTE_RTEPT, wayPoints);
                         return feature;
                     }
                     break;
+                }
             }
         }
-
         throw new XMLStreamException("Error in xml file, "+TAG_RTE+" tag without end.");
     }
 
     /**
      * Parse track segment type feature element.
      * The stax reader must be placed to the start element.
-     *
-     * @return Feature
      */
     private Feature parseTrackSegment(final int index) throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
-        final Feature feature = TYPE_TRACK_SEGMENT.newInstance();
-        feature.setPropertyValue("index", index);
+        final Feature feature = types.trackSegment.newInstance();
+        feature.setPropertyValue("@identifier", index);
         int ptInc = 0;
         List<Feature> wayPoints = null;
 
         while (reader.hasNext()) {
-            final int eventType = reader.next();
-
-            switch (eventType) {
-                case START_ELEMENT:
+            switch (reader.next()) {
+                case START_ELEMENT: {
                     final String localName = reader.getLocalName();
-                    if(TAG_TRK_SEG_PT.equalsIgnoreCase(localName)){
-                        if(wayPoints == null) wayPoints = new ArrayList<>();
+                    if (TAG_TRK_SEG_PT.equalsIgnoreCase(localName)) {
+                        if (wayPoints == null) wayPoints = new ArrayList<>();
                         wayPoints.add(parseWayPoint(ptInc++));
                     }
                     break;
-                case END_ELEMENT:
-                    if(TAG_TRK_SEG.equalsIgnoreCase(reader.getLocalName())){
-                        //end of the track segment element
-                        if(wayPoints!=null) feature.setPropertyValue(TAG_TRK_SEG_PT, wayPoints);
+                }
+                case END_ELEMENT: {
+                    if (TAG_TRK_SEG.equalsIgnoreCase(reader.getLocalName())) {
+                        // End of the track segment element
+                        if (wayPoints!=null) feature.setPropertyValue(TAG_TRK_SEG_PT, wayPoints);
                         return feature;
                     }
                     break;
+                }
             }
         }
-
         throw new XMLStreamException("Error in xml file, "+TAG_TRK_SEG+" tag without end.");
     }
 
     /**
      * Parse track type feature element.
      * The stax reader must be placed to the start element.
-     *
-     * @return Feature
      */
     private Feature parseTrack(final int index) throws IOException, XMLStreamException {
         final XMLStreamReader reader = getReader();
-        final Feature feature = TYPE_TRACK.newInstance();
-        feature.setPropertyValue("index", index);
+        final Feature feature = types.track.newInstance();
+        feature.setPropertyValue("@identifier", index);
         int segInc = 0;
         List<URI> links = null;
         List<Feature> segments = null;
 
         while (reader.hasNext()) {
-            final int eventType = reader.next();
-
-            switch (eventType) {
-                case START_ELEMENT:
+            switch (reader.next()) {
+                case START_ELEMENT: {
                     final String localName = reader.getLocalName();
-                    if(TAG_TRK_SEG.equalsIgnoreCase(localName)){
-                        if(segments == null) segments = new ArrayList<>();
+                    if (TAG_TRK_SEG.equalsIgnoreCase(localName)) {
+                        if (segments == null) segments = new ArrayList<>();
                         segments.add(parseTrackSegment(segInc++));
-                    }else if(TAG_NAME.equalsIgnoreCase(localName)){
+                    } else if (TAG_NAME.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_NAME, reader.getElementText());
-                    }else if(TAG_CMT.equalsIgnoreCase(localName)){
+                    } else if (TAG_CMT.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_CMT, reader.getElementText());
-                    }else if(TAG_DESC.equalsIgnoreCase(localName)){
+                    } else if (TAG_DESC.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_DESC, reader.getElementText());
-                    }else if(TAG_SRC.equalsIgnoreCase(localName)){
+                    } else if (TAG_SRC.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_SRC, reader.getElementText());
-                    }else if(TAG_LINK.equalsIgnoreCase(localName)){
-                        if(links == null) links = new ArrayList<>();
+                    } else if (TAG_LINK.equalsIgnoreCase(localName)) {
+                        if (links == null) links = new ArrayList<>();
                         links.add(parseLink());
-                    }else if(TAG_NUMBER.equalsIgnoreCase(localName)){
+                    } else if (TAG_NUMBER.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_NUMBER, Integer.valueOf(reader.getElementText()));
-                    }else if(TAG_TYPE.equalsIgnoreCase(localName)){
+                    } else if (TAG_TYPE.equalsIgnoreCase(localName)) {
                         feature.setPropertyValue(TAG_TYPE, reader.getElementText());
-                    }else if(version == GPXVersion.v1_0_0 && TAG_URL.equalsIgnoreCase(localName)){
-                        //GPX 1.0 only
-                        if(links == null) links = new ArrayList<>();
+                    } else if (version == GPXVersion.v1_0_0 && TAG_URL.equalsIgnoreCase(localName)) {
+                        // GPX 1.0 only
+                        if (links == null) links = new ArrayList<>();
                         try {
                             links.add(new URI(reader.getElementText()));
                         } catch (URISyntaxException ex) {
@@ -708,17 +678,18 @@ public class GPXReader extends StaxStrea
                         }
                     }
                     break;
-                case END_ELEMENT:
-                    if(TAG_TRK.equalsIgnoreCase(reader.getLocalName())){
-                        //end of the track element
-                        if(links!=null) feature.setPropertyValue(TAG_LINK, links);
-                        if(segments!=null) feature.setPropertyValue(TAG_TRK_SEG, segments);
+                }
+                case END_ELEMENT: {
+                    if (TAG_TRK.equalsIgnoreCase(reader.getLocalName())) {
+                        // End of the track element
+                        if (links!=null) feature.setPropertyValue(TAG_LINK, links);
+                        if (segments!=null) feature.setPropertyValue(TAG_TRK_SEG, segments);
                         return feature;
                     }
                     break;
+                }
             }
         }
-
         throw new XMLStreamException("Error in xml file, "+TAG_TRK+" tag without end.");
     }
 
@@ -727,24 +698,22 @@ public class GPXReader extends StaxStrea
      * The method support only ISO 8601 Date and DateTime formats.
      *
      * @param dateStr date in ISO date or data time format
-     * @return Temporal
      */
     private static Temporal parseTime(String dateStr) {
-        try{
+        try {
             final DateTimeFormatter format = DateTimeFormatter.ISO_INSTANT;
             final TemporalAccessor accessor = format.parse(dateStr);
             return Instant.from(accessor);
-        }catch(UnsupportedTemporalTypeException | DateTimeParseException ex){
-            try{
+        } catch (UnsupportedTemporalTypeException | DateTimeParseException ex) {
+            try {
                 final DateTimeFormatter format = DateTimeFormatter.ISO_DATE;
                 final TemporalAccessor accessor = format.parse(dateStr);
                 return LocalDate.from(accessor);
-            }catch(UnsupportedTemporalTypeException | DateTimeParseException e){
+            } catch (UnsupportedTemporalTypeException | DateTimeParseException e) {
                 final DateTimeFormatter format = DateTimeFormatter.ISO_DATE_TIME;
                 final TemporalAccessor accessor = format.parse(dateStr);
                 return LocalDateTime.from(accessor);
             }
         }
     }
-
 }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter100.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter100.java?rev=1768401&r1=1768400&r2=1768401&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter100.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter100.java [UTF-8] Sun Nov  6 23:04:42 2016
@@ -32,12 +32,12 @@ import javax.xml.stream.XMLStreamExcepti
 import static org.apache.sis.internal.gpx.GPXConstants.*;
 import org.apache.sis.internal.xml.StaxStreamWriter;
 
-import org.opengis.geometry.Envelope;
 
 import static org.apache.sis.util.ArgumentChecks.*;
 import org.apache.sis.util.collection.BackingStoreException;
 import org.opengis.feature.Feature;
 import org.opengis.feature.Property;
+import org.opengis.metadata.extent.GeographicBoundingBox;
 
 
 /**
@@ -364,15 +364,15 @@ public class GPXWriter100 extends StaxSt
      * @param env if null nothing will be written
      * @throws XMLStreamException if underlying xml stax writer encounter an error
      */
-    protected void writeBounds(final Envelope env) throws XMLStreamException {
+    protected void writeBounds(final GeographicBoundingBox env) throws XMLStreamException {
         if (env == null) return;
 
         writer.writeStartElement(namespace, TAG_BOUNDS);
 
-        writer.writeAttribute(ATT_BOUNDS_MINLAT, Double.toString(env.getMinimum(1)));
-        writer.writeAttribute(ATT_BOUNDS_MINLON, Double.toString(env.getMinimum(0)));
-        writer.writeAttribute(ATT_BOUNDS_MAXLAT, Double.toString(env.getMaximum(1)));
-        writer.writeAttribute(ATT_BOUNDS_MAXLON, Double.toString(env.getMaximum(0)));
+        writer.writeAttribute(ATT_BOUNDS_MINLAT, Double.toString(env.getSouthBoundLatitude()));
+        writer.writeAttribute(ATT_BOUNDS_MINLON, Double.toString(env.getWestBoundLongitude()));
+        writer.writeAttribute(ATT_BOUNDS_MAXLAT, Double.toString(env.getNorthBoundLatitude()));
+        writer.writeAttribute(ATT_BOUNDS_MAXLON, Double.toString(env.getEastBoundLongitude()));
 
         writer.writeEndElement();
     }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPointsAsPolylineOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPointsAsPolylineOperation.java?rev=1768401&r1=1768400&r2=1768401&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPointsAsPolylineOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPointsAsPolylineOperation.java [UTF-8] Sun Nov  6 23:04:42 2016
@@ -16,23 +16,14 @@
  */
 package org.apache.sis.internal.gpx;
 
+import java.util.Map;
+import java.util.Collections;
 import com.esri.core.geometry.Point;
 import com.esri.core.geometry.Polyline;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import org.apache.sis.feature.AbstractAttribute;
-import org.apache.sis.feature.AbstractOperation;
 import org.apache.sis.feature.DefaultAttributeType;
-import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
+
+// Branch-dependent imports
 import org.opengis.feature.AttributeType;
-import org.opengis.feature.Feature;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.MultiValuedPropertyException;
-import org.opengis.feature.Property;
-import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.util.GenericName;
 
 
 /**
@@ -45,121 +36,42 @@ import org.opengis.util.GenericName;
  * Any change applied to the positions will be visible on the line.
  *
  * @author  Johann Sorel (Geomatys)
- * @since   0.7
- * @version 0.7
+ * @since   0.8
+ * @version 0.8
  * @module
  */
-final class GroupPointsAsPolylineOperation extends AbstractOperation {
+final class GroupPointsAsPolylineOperation extends GroupPolylinesOperation {
     /**
      * For cross-version compatibility.
      */
     private static final long serialVersionUID = -5169104838093353092L;
 
     private static final AttributeType<Polyline> TYPE = new DefaultAttributeType<>(
-            Collections.singletonMap(NAME_KEY, "Polyline"),Polyline.class,1,1,null);
-
-    /**
-     * An empty parameter value group for this operation.
-     */
-    private static final ParameterDescriptorGroup EMPTY_PARAMS =
-            new DefaultParameterDescriptorGroup(Collections.singletonMap("name", "noargs"), 0, 1);
-
-    private final GenericName[] path;
+            Collections.singletonMap(NAME_KEY, "Polyline"), Polyline.class, 1, 1, null);
 
     /**
      *
      * @param identification operation identification parameters
      * @param attributePath names of the properties to group
      */
-    GroupPointsAsPolylineOperation(Map<String,?> identification, GenericName... attributePath) {
-        super(identification);
-        this.path = attributePath;
-    }
-
-    /**
-     * Returns an empty parameter descriptor group.
-     * @return Empty parameter descriptor
-     */
-    @Override
-    public ParameterDescriptorGroup getParameters() {
-        return EMPTY_PARAMS;
+    GroupPointsAsPolylineOperation(Map<String,?> identification, String... attributePath) {
+        super(identification, attributePath);
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public IdentifiedType getResult() {
+    public AttributeType<Polyline> getResult() {
         return TYPE;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
-    public Property apply(Feature feature, ParameterValueGroup parameters) {
-        return new GeomAtt(feature);
-    }
-
-    private boolean explore(final Feature att, final int depth, Polyline geom, boolean first) {
-        if (depth == path.length - 1) {
-            // We are on the field that hold the geometry points
-            for (final Object propVal : asCollection(att, path[depth])) {
-                if (first) {
-                    geom.startPath(((Point) propVal));
-                    first = false;
-                } else {
-                    geom.lineTo(((Point) propVal));
-                }
-            }
+    void addGeometry(Polyline geom, final Object propVal, final boolean first) {
+        if (first) {
+            geom.startPath(((Point) propVal));
         } else {
-            // Explore children
-            int d = depth + 1;
-            for (final Object prop : asCollection(att, path[depth])) {
-                final Feature child = (Feature) prop;
-                first = explore(child, d, geom, first);
-            }
-        }
-        return first;
-    }
-
-    private static Collection<?> asCollection(Feature att, GenericName property) {
-        final Object value = att.getPropertyValue(property.toString());
-        if (value == null) {
-            return Collections.emptyList();
-        }
-        if (value instanceof Collection<?>) {
-            return (Collection<?>) value;
-        }
-        return Collections.singletonList(value);
-    }
-
-
-    /**
-     * Operation attribute.
-     * Value is calculated each time it is accessed.
-     */
-    private final class GeomAtt extends AbstractAttribute<Polyline> {
-
-        private static final long serialVersionUID = -8872834506769732436L;
-
-        private final Feature feature;
-
-        GeomAtt(final Feature feature) {
-            super(TYPE);
-            this.feature = feature;
-        }
-
-        @Override
-        public Polyline getValue() throws MultiValuedPropertyException {
-            final Polyline geom = new Polyline();
-            explore(feature, 0, geom, true);
-            return geom;
-        }
-
-        @Override
-        public void setValue(Polyline value) {
-            throw new UnsupportedOperationException("Operation attribute can not be set.");
+            geom.lineTo(((Point) propVal));
         }
     }
 }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPolylinesOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPolylinesOperation.java?rev=1768401&r1=1768400&r2=1768401&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPolylinesOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPolylinesOperation.java [UTF-8] Sun Nov  6 23:04:42 2016
@@ -16,22 +16,23 @@
  */
 package org.apache.sis.internal.gpx;
 
-import com.esri.core.geometry.Polyline;
+import java.util.Map;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
+import com.esri.core.geometry.Polyline;
+import org.opengis.parameter.ParameterDescriptorGroup;
+import org.opengis.parameter.ParameterValueGroup;
 import org.apache.sis.feature.AbstractAttribute;
 import org.apache.sis.feature.AbstractOperation;
 import org.apache.sis.feature.DefaultAttributeType;
 import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
-import org.opengis.feature.AttributeType;
+
+// Branch-dependent imports
 import org.opengis.feature.Feature;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.MultiValuedPropertyException;
 import org.opengis.feature.Property;
-import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.util.GenericName;
+import org.opengis.feature.AttributeType;
+import org.opengis.feature.MultiValuedPropertyException;
+
 
 /**
  * A calculated attribute that define a MultiLineString geometry calculated
@@ -42,19 +43,19 @@ import org.opengis.util.GenericName;
  * This class while extract each track and create a Polyline as a new attribute.
  * Any change applied to the tracks will be visible on the Polyline.
  *
- * @author Johann Sorel (Geomatys)
- * @since   0.7
- * @version 0.7
+ * @author  Johann Sorel (Geomatys)
+ * @since   0.8
+ * @version 0.8
  * @module
  */
-public final class GroupPolylinesOperation extends AbstractOperation {
+class GroupPolylinesOperation extends AbstractOperation {
     /**
      * For cross-version compatibility.
      */
     private static final long serialVersionUID = 7898989085371304159L;
 
     private static final AttributeType<Polyline> TYPE = new DefaultAttributeType<>(
-            Collections.singletonMap(NAME_KEY, "MultiLineString"),Polyline.class,1,1,null);
+            Collections.singletonMap(NAME_KEY, "MultiLineString"), Polyline.class, 1, 1, null);
 
     /**
      * An empty parameter value group for this operation.
@@ -62,23 +63,14 @@ public final class GroupPolylinesOperati
     private static final ParameterDescriptorGroup EMPTY_PARAMS =
             new DefaultParameterDescriptorGroup(Collections.singletonMap("name", "noargs"), 0, 1);
 
-    private final GenericName[] path;
-
-    /**
-     * 
-     * @param name operation name
-     * @param attributePath names of the properties to group
-     */
-    public GroupPolylinesOperation(GenericName name, GenericName ... attributePath) {
-        this(Collections.singletonMap(DefaultAttributeType.NAME_KEY, name),attributePath);
-    }
+    private final String[] path;
 
     /**
      *
      * @param identification operation identification parameters
      * @param attributePath names of the properties to group
      */
-    public GroupPolylinesOperation(Map<String, ?> identification, GenericName ... attributePath) {
+    GroupPolylinesOperation(Map<String,?> identification, String... attributePath) {
         super(identification);
         this.path = attributePath;
     }
@@ -95,60 +87,71 @@ public final class GroupPolylinesOperati
      * {@inheritDoc }
      */
     @Override
-    public IdentifiedType getResult() {
+    public AttributeType<Polyline> getResult() {
         return TYPE;
     }
 
     /**
-     * {@inheritDoc }
+     * {@inheritDoc}
      */
     @Override
     public Property apply(Feature feature, ParameterValueGroup parameters) {
         return new GeomAtt(feature);
     }
 
-    private void explore(final Feature att, final int depth, final Polyline geom) {
-        if(depth == path.length-1){
-            //we are on the field that hold the geometry
+    void addGeometry(Polyline geom, final Object propVal, final boolean first) {
+        geom.add((Polyline) propVal, false);
+    }
+
+    final boolean explore(final Feature att, final int depth, Polyline geom, boolean first) {
+        if (depth == path.length - 1) {
+            // We are on the field that hold the geometry points
             for (final Object propVal : asCollection(att, path[depth])) {
-                geom.add((Polyline)propVal, false);
+                addGeometry(geom, propVal, first);
+                first = false;
             }
-        }else{
-            //explore childs
-            int d = depth+1;
-            for (final Object prop : asCollection(att,path[depth])) {
+        } else {
+            // Explore children
+            int d = depth + 1;
+            for (final Object prop : asCollection(att, path[depth])) {
                 final Feature child = (Feature) prop;
-                explore(child, d, geom);
+                first = explore(child, d, geom, first);
             }
         }
+        return first;
     }
 
-    private static Collection asCollection(Feature att, GenericName property) {
-        final Object value = att.getPropertyValue(property.toString());
-        if(value == null) return Collections.EMPTY_LIST;
-        if(value instanceof Collection) return (Collection) value;
+    private static Collection<?> asCollection(Feature att, String property) {
+        final Object value = att.getPropertyValue(property);
+        if (value == null) {
+            return Collections.emptyList();
+        }
+        if (value instanceof Collection<?>) {
+            return (Collection<?>) value;
+        }
         return Collections.singletonList(value);
     }
 
+
     /**
      * Operation attribute.
      * Value is calculated each time it is accessed.
      */
     private final class GeomAtt extends AbstractAttribute<Polyline> {
 
-        private static final long serialVersionUID = 2246647654324667404L;
+        private static final long serialVersionUID = -8872834506769732436L;
 
         private final Feature feature;
 
-        public GeomAtt(final Feature feature) {
-            super(TYPE);
+        GeomAtt(final Feature feature) {
+            super(getResult());
             this.feature = feature;
         }
 
         @Override
         public Polyline getValue() throws MultiValuedPropertyException {
             final Polyline geom = new Polyline();
-            explore(feature,0,geom);
+            explore(feature, 0, geom, true);
             return geom;
         }
 
@@ -156,7 +159,5 @@ public final class GroupPolylinesOperati
         public void setValue(Polyline value) {
             throw new UnsupportedOperationException("Operation attribute can not be set.");
         }
-
     }
-
 }



Mime
View raw message