sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1773750 - /sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/
Date Mon, 12 Dec 2016 08:08:56 GMT
Author: desruisseaux
Date: Mon Dec 12 08:08:55 2016
New Revision: 1773750

URL: http://svn.apache.org/viewvc?rev=1773750&view=rev
Log:
Use FeatureTypeBuilder for creating the FeatureType constants.
Rename GPXConstant as Constant since it is in the gpx package.
Cleanup.

Added:
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Constants.java
      - copied, changed from r1773749, 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/GroupAsPolylineOperation.java
      - copied, changed from r1773749, sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPolylinesOperation.java
Removed:
    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/GroupPolylinesOperation.java
Modified:
    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/GPXWriter110.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/Metadata.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Types.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java

Copied: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Constants.java
(from r1773749, 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/Constants.java?p2=sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Constants.java&p1=sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXConstants.java&r1=1773749&r2=1773750&rev=1773750&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/Constants.java
[UTF-8] Mon Dec 12 08:08:55 2016
@@ -20,14 +20,14 @@ import org.apache.sis.util.Static;
 
 
 /**
- * GPX XML tags and feature types.
+ * GPX XML tag and attribute names.
  *
  * @author  Johann Sorel (Geomatys)
  * @since   0.8
  * @version 0.8
  * @module
  */
-final class GPXConstants extends Static {
+final class Constants extends Static {
     /*
      * Main GPX XML tags.
      */
@@ -169,20 +169,20 @@ final class GPXConstants extends Static
     /**
      * GPX scope name used for feature type names.
      */
-    public static final String GPX_NAMESPACE = "http://www.topografix.com";
+    public static final String NAMESPACE = "http://www.topografix.com";
 
     /**
      * GPX 1.1 XML namespace.
      */
-    public static final String GPX_NAMESPACE_V11 = "http://www.topografix.com/GPX/1/1";
+    public static final String NAMESPACE_V11 = "http://www.topografix.com/GPX/1/1";
     /**
      * GPX 1.0 XML namespace.
      */
-    public static final String GPX_NAMESPACE_V10 = "http://www.topografix.com/GPX/1/0";
+    public static final String NAMESPACE_V10 = "http://www.topografix.com/GPX/1/0";
 
     /**
      * Do not allow instantiation of this class.
      */
-    private GPXConstants() {
+    private Constants() {
     }
 }

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=1773750&r1=1773749&r2=1773750&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] Mon Dec 12 08:08:55 2016
@@ -39,7 +39,7 @@ import org.apache.sis.storage.StorageCon
 import org.apache.sis.internal.xml.StaxStreamReader;
 
 import static javax.xml.stream.XMLStreamReader.*;
-import static org.apache.sis.internal.gpx.GPXConstants.*;
+import static org.apache.sis.internal.gpx.Constants.*;
 
 // Branch-dependent imports
 import org.opengis.feature.Feature;
@@ -78,7 +78,7 @@ public class GPXReader extends StaxStrea
     private int routeInc = 0;
     private int trackInc = 0;
     private GPXVersion version = null;
-    private String baseNamespace = GPX_NAMESPACE_V11;
+    private String baseNamespace = NAMESPACE_V11;
 
     /**
      * {@inheritDoc }
@@ -114,12 +114,12 @@ searchLoop:
                         }
 
                         if (version == GPXVersion.v1_0_0) {
-                            baseNamespace = GPX_NAMESPACE_V10;
+                            baseNamespace = NAMESPACE_V10;
                             //we wont found a metadata tag, must read the tags here.
                             metadata = parseMetadata100();
                             break searchLoop;
                         } else{
-                            baseNamespace = GPX_NAMESPACE_V11;
+                            baseNamespace = NAMESPACE_V11;
                         }
 
                     } else if (TAG_METADATA.equalsIgnoreCase(typeName)) {

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=1773750&r1=1773749&r2=1773750&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] Mon Dec 12 08:08:55 2016
@@ -29,15 +29,16 @@ import java.time.temporal.Temporal;
 import java.util.Collection;
 import java.util.Iterator;
 import javax.xml.stream.XMLStreamException;
-import static org.apache.sis.internal.gpx.GPXConstants.*;
+import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.apache.sis.internal.xml.StaxStreamWriter;
-
+import org.apache.sis.util.collection.BackingStoreException;
 
 import static org.apache.sis.util.ArgumentChecks.*;
-import org.apache.sis.util.collection.BackingStoreException;
+import static org.apache.sis.internal.gpx.Constants.*;
+
+// Branch-dependent imports
 import org.opengis.feature.Feature;
 import org.opengis.feature.Property;
-import org.opengis.metadata.extent.GeographicBoundingBox;
 
 
 /**
@@ -61,7 +62,7 @@ public class GPXWriter100 extends StaxSt
      * @param creator file creator
      */
     public GPXWriter100(final String creator, final Object output) throws IOException, XMLStreamException
{
-        this(GPX_NAMESPACE_V10, creator, output);
+        this(NAMESPACE_V10, creator, output);
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter110.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter110.java?rev=1773750&r1=1773749&r2=1773750&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter110.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter110.java
[UTF-8] Mon Dec 12 08:08:55 2016
@@ -21,7 +21,8 @@ import java.time.temporal.Temporal;
 import java.util.Collection;
 import java.io.IOException;
 import javax.xml.stream.XMLStreamException;
-import static org.apache.sis.internal.gpx.GPXConstants.*;
+
+import static org.apache.sis.internal.gpx.Constants.*;
 
 
 /**
@@ -32,14 +33,13 @@ import static org.apache.sis.internal.gp
  * @version 0.8
  * @module
  */
-public class GPXWriter110 extends GPXWriter100{
-
+public class GPXWriter110 extends GPXWriter100 {
     /**
      *
      * @param creator gpx file creator
      */
     public GPXWriter110(final String creator, final Object output) throws IOException, XMLStreamException
{
-        super(GPX_NAMESPACE_V11, creator, output);
+        super(NAMESPACE_V11, creator, output);
     }
 
     /**

Copied: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupAsPolylineOperation.java
(from r1773749, 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/GroupAsPolylineOperation.java?p2=sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupAsPolylineOperation.java&p1=sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GroupPolylinesOperation.java&r1=1773749&r2=1773750&rev=1773750&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/GroupAsPolylineOperation.java
[UTF-8] Mon Dec 12 08:08:55 2016
@@ -25,7 +25,8 @@ import org.opengis.parameter.ParameterVa
 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.apache.sis.internal.feature.AttributeConvention;
+import org.apache.sis.internal.feature.FeatureUtilities;
 
 // Branch-dependent imports
 import org.opengis.feature.Feature;
@@ -35,33 +36,39 @@ import org.opengis.feature.MultiValuedPr
 
 
 /**
- * A calculated attribute that define a MultiLineString geometry calculated
- * from other attributes of the feature.
+ * 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.
+ * The single (Multi){@code Polyline} instance is re-computed every time this property is
requested.
  *
- * For example : a boat that record tracks every hour.
- * each record is available in a 0-N complex attribute.
- * 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.
+ * <div class="note"><b>Example:</b>
+ * 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.
+ * </div>
  *
  * @author  Johann Sorel (Geomatys)
  * @since   0.8
  * @version 0.8
  * @module
  */
-class GroupPolylinesOperation extends AbstractOperation {
+class GroupAsPolylineOperation 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);
+    /**
+     * The parameter descriptor for the "Group polylines" operation, which does not take
any parameter.
+     */
+    private static final ParameterDescriptorGroup EMPTY_PARAMS = FeatureUtilities.parameters("GroupPolylines");
 
     /**
-     * An empty parameter value group for this operation.
+     * 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.
      */
-    private static final ParameterDescriptorGroup EMPTY_PARAMS =
-            new DefaultParameterDescriptorGroup(Collections.singletonMap("name", "noargs"),
0, 1);
+    private static final AttributeType<Polyline> RESULT_TYPE = new DefaultAttributeType<>(
+            Collections.singletonMap(NAME_KEY, AttributeConvention.ENVELOPE_PROPERTY), Polyline.class,
1, 1, null);
 
     private final String[] path;
 
@@ -70,7 +77,7 @@ class GroupPolylinesOperation extends Ab
      * @param identification operation identification parameters
      * @param attributePath names of the properties to group
      */
-    GroupPolylinesOperation(Map<String,?> identification, String... attributePath)
{
+    GroupAsPolylineOperation(Map<String,?> identification, String... attributePath)
{
         super(identification);
         this.path = attributePath;
     }
@@ -88,7 +95,7 @@ class GroupPolylinesOperation extends Ab
      */
     @Override
     public AttributeType<Polyline> getResult() {
-        return TYPE;
+        return RESULT_TYPE;
     }
 
     /**

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=1773750&r1=1773749&r2=1773750&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] Mon Dec 12 08:08:55 2016
@@ -20,34 +20,49 @@ import java.util.Map;
 import java.util.Collections;
 import com.esri.core.geometry.Point;
 import com.esri.core.geometry.Polyline;
+import org.opengis.parameter.ParameterDescriptorGroup;
 import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.internal.feature.AttributeConvention;
+import org.apache.sis.internal.feature.FeatureUtilities;
 
 // Branch-dependent imports
 import org.opengis.feature.AttributeType;
 
 
 /**
- * A calculated attribute that define a Polyline geometry calculated
- * from other attributes of the feature.
+ * Creates a single (Multi){@code Polyline} instance from a sequence of points stored in
another property.
+ * This class expects a sequence of {@link Point} as input.
+ * The single (Multi){@code Polyline} instance is re-computed every time this property is
requested.
  *
- * For example : a boat that record it's position every hour.
- * each record is available in a 0-N associate attribute.
- * This class while extract each position and create a line as a new attribute.
+ * <div class="note"><b>Example:</b>
+ * 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.
+ * </div>
  *
  * @author  Johann Sorel (Geomatys)
  * @since   0.8
  * @version 0.8
  * @module
  */
-final class GroupPointsAsPolylineOperation extends GroupPolylinesOperation {
+final class GroupPointsAsPolylineOperation extends GroupAsPolylineOperation {
     /**
      * 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);
+    /**
+     * The parameter descriptor for the "Group points" operation, which does not take any
parameter.
+     */
+    private static final ParameterDescriptorGroup EMPTY_PARAMS = FeatureUtilities.parameters("GroupPoints");
+
+    /**
+     * 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.
+     */
+    private static final AttributeType<Polyline> RESULT_TYPE = new DefaultAttributeType<>(
+            Collections.singletonMap(NAME_KEY, AttributeConvention.ENVELOPE_PROPERTY), Polyline.class,
1, 1, null);
 
     /**
      *
@@ -59,11 +74,19 @@ final class GroupPointsAsPolylineOperati
     }
 
     /**
+     * Returns an empty parameter descriptor group.
+     */
+    @Override
+    public ParameterDescriptorGroup getParameters() {
+        return EMPTY_PARAMS;
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
     public AttributeType<Polyline> getResult() {
-        return TYPE;
+        return RESULT_TYPE;
     }
 
     @Override

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java?rev=1773750&r1=1773749&r2=1773750&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Metadata.java
[UTF-8] Mon Dec 12 08:08:55 2016
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
+import java.io.IOException;
 import javax.xml.bind.annotation.XmlElement;
 
 import org.opengis.metadata.citation.CitationDate;
@@ -52,7 +53,7 @@ import org.apache.sis.util.iso.SimpleInt
  * At most one such element may appear in the document.
  * The XML content is like below:
  *
- * {@preformat java
+ * {@preformat xml
  *   <metadata>
  *     <name> String </name>
  *     <desc> String </desc>
@@ -78,31 +79,31 @@ public final class Metadata extends Simp
     /**
      * The name of the GPX file.
      */
-    @XmlElement
+    @XmlElement(name = Constants.TAG_NAME)
     public String name;
 
     /**
      * A description of the contents of the GPX file.
      */
-    @XmlElement(name = "desc")
+    @XmlElement(name = Constants.TAG_DESC)
     public String description;
 
     /**
      * The person or organization who created the GPX file.
      */
-    @XmlElement
+    @XmlElement(name = Constants.TAG_AUTHOR)
     public Person author;
 
     /**
      * Copyright and license information governing use of the file.
      */
-    @XmlElement
+    @XmlElement(name = Constants.TAG_COPYRIGHT)
     public Copyright copyright;
 
     /**
      * URLs associated with the location described in the file.
      */
-    @XmlElement(name = "link")
+    @XmlElement(name = Constants.TAG_LINK)
     public final List<URI> links = new ArrayList<>();
 
     /**
@@ -277,16 +278,16 @@ public final class Metadata extends Simp
      */
     @Override
     public String toString() {
-        final TableAppender table = new TableAppender();
+        final StringBuilder buffer = new StringBuilder();
+        buffer.append("GPX metadata");
+        final TableAppender table = new TableAppender(buffer);
         table.setMultiLinesCells(true);
         table.appendHorizontalSeparator();
-        table.append("GPX metadata").nextLine();
-        table.appendHorizontalSeparator();
         append(table, "Name",        name);
         append(table, "Description", description);
         append(table, "Author",      author);
         append(table, "Copyright",   copyright);
-        String label = "link";
+        String label = "Link(s)";
         for (final URI uri : links) {
             append(table, label, uri);
             label = null;
@@ -294,9 +295,13 @@ public final class Metadata extends Simp
         append(table, "Time",     time);
         append(table, "Keywords", keywords);
         append(table, "Bounds",   bounds);
-        table.append("Links\t");
         table.appendHorizontalSeparator();
-        return table.toString();
+        try {
+            table.flush();
+        } catch (IOException e) {
+            throw new AssertionError(e);        // Should never happen since we are writing
to a StringBuilder.
+        }
+        return buffer.toString();
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Types.java?rev=1773750&r1=1773749&r2=1773750&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Types.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/Types.java
[UTF-8] Mon Dec 12 08:08:55 2016
@@ -27,9 +27,6 @@ import org.opengis.util.NameFactory;
 import org.opengis.util.FactoryException;
 import org.apache.sis.referencing.CommonCRS;
 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;
@@ -38,11 +35,10 @@ import org.apache.sis.internal.system.De
 import org.apache.sis.util.iso.DefaultNameFactory;
 import org.apache.sis.util.Static;
 
-import static org.apache.sis.internal.gpx.GPXConstants.*;
+import static org.apache.sis.internal.gpx.Constants.*;
 
 // Branch-dependent imports
 import org.opengis.feature.FeatureType;
-import org.opengis.feature.PropertyType;
 
 
 /**
@@ -113,7 +109,7 @@ final class Types extends Static {
          * └─────────────┴─────────┴─────────────┘
          */
         FeatureTypeBuilder builder = new FeatureTypeBuilder(null, factory, locale);
-        builder.setDefaultScope(GPX_NAMESPACE).setName("GPXEntity").setAbstract(true);
+        builder.setDefaultScope(NAMESPACE).setName("GPXEntity").setAbstract(true);
         builder.addAttribute(Integer.class).setName(AttributeConvention.IDENTIFIER_PROPERTY);
         final FeatureType parent = builder.build();
         /*
@@ -144,8 +140,8 @@ final class Types extends Static {
          * │ dgpsid        │ Integer  │ gpx:dgpsStationType    │   [0 … 1]   │
          * └───────────────┴──────────┴────────────────────────┴─────────────┘
          */
-        builder = new FeatureTypeBuilder(null, factory, locale);
-        builder.setDefaultScope(GPX_NAMESPACE).setName("WayPoint").setSuperTypes(parent);
+        builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
+        builder.setDefaultScope(NAMESPACE).setName("WayPoint");
         builder.addAttribute(Point.class).setName(geomName)
                 .setCRS(CommonCRS.WGS84.normalizedGeographic())
                 .addRole(AttributeRole.DEFAULT_GEOMETRY);
@@ -187,23 +183,21 @@ final class Types extends Static {
          * │ rtept       │ WayPoint │ gpx:wptType            │   [0 … ∞]   │
          * └─────────────┴──────────┴────────────────────────┴─────────────┘
          */
-        final DefaultAssociationRole attWayPoints = new DefaultAssociationRole(
-                identification(factory, TAG_RTE_RTEPT), wayPoint, 0, Integer.MAX_VALUE);
-        PropertyType[] properties = {
-                wayPoint.getProperty(TAG_NAME),
-                wayPoint.getProperty(TAG_CMT),
-                wayPoint.getProperty(TAG_DESC),
-                wayPoint.getProperty(TAG_SRC),
-                wayPoint.getProperty(TAG_LINK),
-                new DefaultAttributeType<>(identification(factory, TAG_NUMBER), Integer.class,
0, 1, null),
-                wayPoint.getProperty(TAG_TYPE),
-                attWayPoints,
-                new GroupPointsAsPolylineOperation(geomInfo, TAG_RTE_RTEPT, geomName.toString()),
-                null
-        };
-        properties[properties.length - 1] = FeatureOperations.envelope(envpInfo, null, properties);
-        route = new DefaultFeatureType(identification(factory, "Route"), false,
-                new FeatureType[] {parent}, properties);
+        GroupAsPolylineOperation groupOp = new GroupPointsAsPolylineOperation(geomInfo, TAG_RTE_RTEPT,
geomName.toString());
+        builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
+        builder.setDefaultScope(NAMESPACE).setName("Route");
+        builder.addProperty(groupOp);
+        builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
+        builder.setDefaultCardinality(0, 1);
+        builder.addProperty(wayPoint.getProperty(TAG_NAME));
+        builder.addProperty(wayPoint.getProperty(TAG_CMT));
+        builder.addProperty(wayPoint.getProperty(TAG_DESC));
+        builder.addProperty(wayPoint.getProperty(TAG_SRC));
+        builder.addProperty(wayPoint.getProperty(TAG_LINK));
+        builder.addAttribute(Integer.class).setName(TAG_NUMBER);
+        builder.addProperty(wayPoint.getProperty(TAG_TYPE));
+        builder.addAssociation(wayPoint).setName(TAG_RTE_RTEPT).setMaximumOccurs(Integer.MAX_VALUE);
+        route = builder.build();
         /*
          * http://www.topografix.com:TrackSegment ⇾ GPXEntity
          * ┌─────────────┬──────────┬─────────────┬─────────────┐
@@ -215,16 +209,14 @@ final class Types extends Static {
          * │ trkpt       │ WayPoint │ gpx:wptType │   [0 … ∞]   │
          * └─────────────┴──────────┴─────────────┴─────────────┘
          */
-        final DefaultAssociationRole attTrackPoints = new DefaultAssociationRole(
-                identification(factory, TAG_TRK_SEG_PT), wayPoint, 0, Integer.MAX_VALUE);
-        properties = new PropertyType[] {
-                attTrackPoints,
-                new GroupPointsAsPolylineOperation(geomInfo, TAG_TRK_SEG_PT, geomName.toString()),
-                null
-        };
-        properties[properties.length - 1] = FeatureOperations.envelope(envpInfo, null, properties);
-        trackSegment = new DefaultFeatureType(identification(factory, "TrackSegment"), false,
-                new FeatureType[] {parent}, properties);
+        groupOp = new GroupPointsAsPolylineOperation(geomInfo, TAG_TRK_SEG_PT, geomName.toString());
+        builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
+        builder.setDefaultScope(NAMESPACE).setName("TrackSegment");
+        builder.addProperty(groupOp);
+        builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
+        builder.setDefaultCardinality(0, 1);
+        builder.addAssociation(wayPoint).setName(TAG_TRK_SEG_PT).setMaximumOccurs(Integer.MAX_VALUE);
+        trackSegment = builder.build();
         /*
          * http://www.topografix.com:Track ⇾ GPXEntity
          * ┌─────────────┬──────────────┬────────────────────────┬─────────────┐
@@ -243,27 +235,20 @@ final class Types extends Static {
          * │ trkseg      │ TrackSegment │ gpx:trksegType         │   [0 … ∞]
  │
          * └─────────────┴──────────────┴────────────────────────┴─────────────┘
          */
-        final DefaultAssociationRole attTrackSegments = new DefaultAssociationRole(
-                identification(factory, TAG_TRK_SEG), trackSegment, 0, Integer.MAX_VALUE);
-        properties = new PropertyType[] {
-                route.getProperty(TAG_NAME),
-                route.getProperty(TAG_CMT),
-                route.getProperty(TAG_DESC),
-                route.getProperty(TAG_SRC),
-                route.getProperty(TAG_LINK),
-                route.getProperty(TAG_NUMBER),
-                route.getProperty(TAG_TYPE),
-                attTrackSegments,
-                new GroupPolylinesOperation(geomInfo, TAG_TRK_SEG, geomName.toString()),
-                null
-        };
-        properties[properties.length - 1] = FeatureOperations.envelope(envpInfo, null, properties);
-        track = new DefaultFeatureType(identification(factory, "Track"), false,
-                new FeatureType[] {parent}, properties);
-    }
-
-    private static Map<String,?> identification(final NameFactory factory, final String
localPart) {
-        return Collections.singletonMap(AbstractIdentifiedType.NAME_KEY,
-                factory.createGenericName(null, GPX_NAMESPACE, localPart));
+        groupOp = new GroupAsPolylineOperation(geomInfo, TAG_TRK_SEG, geomName.toString());
+        builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
+        builder.setDefaultScope(NAMESPACE).setName("Track");
+        builder.addProperty(groupOp);
+        builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
+        builder.setDefaultCardinality(0, 1);
+        builder.addProperty(route.getProperty(TAG_NAME));
+        builder.addProperty(route.getProperty(TAG_CMT));
+        builder.addProperty(route.getProperty(TAG_DESC));
+        builder.addProperty(route.getProperty(TAG_SRC));
+        builder.addProperty(route.getProperty(TAG_LINK));
+        builder.addProperty(route.getProperty(TAG_NUMBER));
+        builder.addProperty(route.getProperty(TAG_TYPE));
+        builder.addAssociation(trackSegment).setName(TAG_TRK_SEG).setMaximumOccurs(Integer.MAX_VALUE);
+        track = builder.build();
     }
 }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java?rev=1773750&r1=1773749&r2=1773750&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/package-info.java
[UTF-8] Mon Dec 12 08:08:55 2016
@@ -63,8 +63,8 @@
  * @version 0.8
  * @module
  */
-@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = GPXConstants.GPX_NAMESPACE_V11,
xmlns = {
-    @XmlNs(prefix = "gpx", namespaceURI = GPXConstants.GPX_NAMESPACE_V11)
+@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Constants.NAMESPACE_V11,
xmlns = {
+    @XmlNs(prefix = "gpx", namespaceURI = Constants.NAMESPACE_V11)
 })
 package org.apache.sis.internal.gpx;
 



Mime
View raw message