sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1813760 - in /sis/branches/JDK8: core/sis-feature/src/main/java/org/apache/sis/feature/ core/sis-utility/src/main/java/org/apache/sis/setup/ core/sis-utility/src/main/java/org/apache/sis/util/collection/ storage/sis-storage/src/main/java/o...
Date Mon, 30 Oct 2017 13:42:03 GMT
Author: desruisseaux
Date: Mon Oct 30 13:42:02 2017
New Revision: 1813760

URL: http://svn.apache.org/viewvc?rev=1813760&view=rev
Log:
Allow configuration of the way represent moving features.

Added:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FoliationRepresentation.java
  (with props)
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/package-info.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
    sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java

Added: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FoliationRepresentation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FoliationRepresentation.java?rev=1813760&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FoliationRepresentation.java
(added)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FoliationRepresentation.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.feature;
+
+
+/**
+ * Specifies whether trajectories are represented in a single <cite>moving feature</cite>
instance
+ * or fragmented in distinct static feature instances.
+ *
+ * <div class="note"><b>Example:</b>
+ * consider the following trajectories:
+ *
+ * <table>
+ *   <caption>Moving features example</caption>
+ *   <tr><th>Identifier</th> <th>Time</th> <th>Trajectory</th>
  <th>Status</th></tr>
+ *   <tr><td>John Smith</td> <td>8:00</td> <td>(3 4),
(3 5)</td> <td>Walking</td></tr>
+ *   <tr><td>Joe  Blo</td>   <td>8:00</td> <td>(5 5),
(6 6)</td> <td>Walking</td></tr>
+ *   <tr><td>John Smith</td> <td>8:05</td> <td>(3 5),
(3 9)</td> <td>Running</td></tr>
+ * </table>
+ *
+ * In this example, John Smith's trajectory can be represented in two ways:
+ * we can construct a single <cite>moving feature</cite> instance representing
the full trajectory (3 4), (3 5), (3 9)
+ * with some time representation (for example by adding a temporal dimension in each coordinate)
and dynamic "Status"
+ * property. Or alternatively, we can keep John Smith's trajectory fragmented in two {@code
Feature} instance where
+ * each instance can be handled as a static feature.
+ * </div>
+ *
+ * This enumeration can be used with {@link org.apache.sis.storage.DataStore} as a hint about
desired representation
+ * of moving features.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+public enum FoliationRepresentation {
+    /**
+     * Trajectories stored in a single {@code Feature} instance.
+     * Every point on the trajectory may be at a different time.
+     * Properties may be dynamic, i.e. have time-dependent value.
+     */
+    ASSEMBLED,
+
+    /**
+     * Trajectories stored in distinct {@code Feature} instances,
+     * each of them handled as if it was a static feature.
+     */
+    FRAGMENTED
+}

Propchange: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FoliationRepresentation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FoliationRepresentation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java [UTF-8]
Mon Oct 30 13:42:02 2017
@@ -75,16 +75,6 @@ public class OptionKey<T> implements Ser
     private static final long serialVersionUID = -7580514229639750246L;
 
     /**
-     * The library to use for creating geometric objects at reading time.
-     * Some libraries are the Java Topology Suite (JTS), ESRI geometry API and Java2D.
-     * If this option is not specified, then a default library will be selected among
-     * the libraries available in the runtime environment.
-     *
-     * @since 0.8
-     */
-    public static final OptionKey<GeometryLibrary> GEOMETRY_LIBRARY = new OptionKey<>("GEOMETRY_LIBRARY",
GeometryLibrary.class);
-
-    /**
      * The locale to use for locale-sensitive data. This option determines the language to
use for writing
      * {@link org.apache.sis.util.iso.AbstractInternationalString international strings}
when the target
      * storage support only one language. It may also control number and date patterns in
some file formats
@@ -192,6 +182,16 @@ public class OptionKey<T> implements Ser
     public static final OptionKey<ByteBuffer> BYTE_BUFFER = new OptionKey<>("BYTE_BUFFER",
ByteBuffer.class);
 
     /**
+     * The library to use for creating geometric objects at reading time.
+     * Some libraries are the Java Topology Suite (JTS), ESRI geometry API and Java2D.
+     * If this option is not specified, then a default library will be selected among
+     * the libraries available in the runtime environment.
+     *
+     * @since 0.8
+     */
+    public static final OptionKey<GeometryLibrary> GEOMETRY_LIBRARY = new OptionKey<>("GEOMETRY_LIBRARY",
GeometryLibrary.class);
+
+    /**
      * The number of spaces to use for indentation when formatting text files in WKT or XML
formats.
      * A value of {@value org.apache.sis.io.wkt.WKTFormat#SINGLE_LINE} means to format the
whole WKT
      * or XML document on a single line without line feeds or indentation.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -17,9 +17,13 @@
 
 /**
  * Provides information and some controls about SIS configuration.
+ * System-wide informations are provided by the {@link org.apache.sis.setup.About} class.
+ * Some controls, for example on the {@linkplain org.apache.sis.setup.GeometryLibrary geometry
library} to use,
+ * is provided by a set of {@linkplain org.apache.sis.setup.OptionKey options} which can
be used when a data store
+ * is created.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 0.8
  * @since   0.3
  * @module
  */

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -63,7 +63,7 @@ import java.util.function.Supplier;
  *     public MyObject getMyObject(final String key) throws MyCheckedException {
  *         try {
  *             return cache.getOrCreate(key, new Callable<MyObject>() {
- *                 MyObject call() throws FactoryException {
+ *                 public MyObject call() throws MyCheckedException {
  *                     return createMyObject(key);
  *                 }
  *             });

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -32,7 +32,7 @@ import org.apache.sis.util.resources.Res
  * all modules in the Apache SIS project, see {@link org.apache.sis.util.resources} package.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.8
  * @module
  */
@@ -153,6 +153,11 @@ public final class Resources extends Ind
         public static final short FeatureNotFound_2 = 17;
 
         /**
+         * Whether to assemble trajectory fragments (lines in CSV file) in a single feature
instance.
+         */
+        public static final short FoliationRepresentation = 38;
+
+        /**
          * The {0} data store does not accept features of type “{1}”.
          */
         public static final short IllegalFeatureType_2 = 7;

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] Mon Oct 30 13:42:02 2017
@@ -36,6 +36,7 @@ DataStoreTimeZone                 = Time
 DirectoryContent_1                = Content of \u201c{0}\u201d directory.
 FeatureAlreadyPresent_2           = A feature named \u201c{1}\u201d is already present in
the \u201c{0}\u201d data store.
 FeatureNotFound_2                 = Feature \u201c{1}\u201d has not been found in the \u201c{0}\u201d
data store.
+FoliationRepresentation           = Whether to assemble trajectory fragments (lines in CSV
file) in a single feature instance.
 ExcessiveStringSize_3             = Character string in the \u201c{0}\u201d file is too long.
The string has {2} characters while the limit is {1}.
 IllegalFeatureType_2              = The {0} data store does not accept features of type \u201c{1}\u201d.
 IllegalInputTypeForReader_2       = The {0} reader does not accept inputs of type \u2018{1}\u2019.

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] Mon Oct 30 13:42:02 2017
@@ -42,6 +42,7 @@ DirectoryContent_1                = Cont
 ExcessiveStringSize_3             = La cha\u00eene de caract\u00e8res dans le fichier \u00ab\u202f{0}\u202f\u00bb
est trop longue. La cha\u00eene fait {2} caract\u00e8res alors que la limite est {1}.
 FeatureAlreadyPresent_2           = Une entit\u00e9 nomm\u00e9e \u00ab\u202f{1}\u202f\u00bb
est d\u00e9j\u00e0 pr\u00e9sente dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
 FeatureNotFound_2                 = L\u2019entit\u00e9 \u00ab\u202f{1}\u202f\u00bb n\u2019est
pas \u00e9t\u00e9 trouv\u00e9e dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
+FoliationRepresentation           = Indique s\u2019il faut assembler les fragments de trajectoires
(lignes dans un fichier CSV) dans une entit\u00e9 unique.
 IllegalFeatureType_2              = Le format {0} ne stocke pas de donn\u00e9es de type \u00ab\u202f{1}\u202f\u00bb.
 IllegalInputTypeForReader_2       = Le lecteur {0} n\u2019accepte pas des entr\u00e9s de
type \u2018{1}\u2019.
 IllegalOutputTypeForWriter_2      = Le l\u2019encodeur {0} n\u2019accepte pas des sorties
de type \u2018{1}\u2019.

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -17,14 +17,17 @@
 package org.apache.sis.internal.storage;
 
 import java.net.URI;
+import java.nio.charset.Charset;
+import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.parameter.ParameterNotFoundException;
 import org.apache.sis.parameter.ParameterBuilder;
+import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreProvider;
 import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.StorageConnector;
+import org.apache.sis.storage.IllegalOpenParameterException;
 import org.apache.sis.internal.storage.io.IOUtilities;
 
 
@@ -35,7 +38,7 @@ import org.apache.sis.internal.storage.i
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.8
  * @module
  */
@@ -69,12 +72,12 @@ public abstract class URIDataStore exten
 
     /**
      * Creates parameter value group for the current location, if non-null.
-     * This convenience method is used for public {@code DataStore} implementations that
can not extend
-     * {@code URIDataStore} directly, because this class is internal.
+     * This convenience method is used for {@link DataStore#getOpenParameters()} implementations
in public
+     * {@code DataStore} that can not extend {@code URIDataStore} directly, because this
class is internal.
      *
-     * @param provider
-     * @param location
-     * @return
+     * @param  provider  the provider of the data store for which to get open parameters.
+     * @param  location  file opened by the data store.
+     * @return parameters to be returned by {@link DataStore#getOpenParameters()}.
      *
      * @todo Verify if non-exported classes in JDK9 are hidden from Javadoc, like package-private
classes.
      *       If true, we could remove this hack and extend {@code URIDataStore} even in public
classes.
@@ -99,11 +102,19 @@ public abstract class URIDataStore exten
         /**
          * Description of the location parameter.
          */
-        public static final ParameterDescriptor<URI> LOCATION_PARAM = new ParameterBuilder()
-                .setDescription(Resources.formatInternational(Resources.Keys.DataStoreLocation))
-                .addName(LOCATION)
-                .setRequired(true)
-                .create(URI.class, null);
+        public static final ParameterDescriptor<URI> LOCATION_PARAM;
+
+        /**
+         * Description of the optional parameter for character encoding used by the data
store.
+         * This parameter is not included in the descriptor created by {@link #build(ParameterBuilder)}
+         * default implementation. It is subclass responsibility to add it if desired.
+         */
+        public static final ParameterDescriptor<Charset> ENCODING;
+        static {
+            final ParameterBuilder builder = new ParameterBuilder();
+            ENCODING       = builder.addName("encoding").setDescription(Resources.formatInternational(Resources.Keys.DataStoreEncoding)).create(Charset.class,
null);
+            LOCATION_PARAM = builder.addName( LOCATION ).setDescription(Resources.formatInternational(Resources.Keys.DataStoreLocation)).setRequired(true).create(URI.class,
null);
+        }
 
         /**
          * The parameter descriptor to be returned by {@link #getOpenParameters()}.
@@ -161,6 +172,31 @@ public abstract class URIDataStore exten
         public static ParameterDescriptorGroup descriptor(final String name) {
             return new ParameterBuilder().addName(name).createGroup(LOCATION_PARAM);
         }
+
+        /**
+         * Creates a storage connector initialized to the location declared in given parameters.
+         * This convenience method does not set any other parameters.
+         *
+         * @param  provider    the provider for which to create a storage connector (for
error messages).
+         * @param  parameters  the parameters to use for creating a storage connector.
+         * @return the storage connector initialized to the location specified in the parameters.
+         * @throws IllegalOpenParameterException if no {@value #LOCATION} parameter has been
found.
+         */
+        public static StorageConnector connector(final DataStoreProvider provider, final
ParameterValueGroup parameters)
+                throws IllegalOpenParameterException
+        {
+            ParameterNotFoundException cause = null;
+            try {
+                final Object location = parameters.parameter(LOCATION).getValue();
+                if (location != null) {
+                    return new StorageConnector(location);
+                }
+            } catch (ParameterNotFoundException e) {
+                cause = e;
+            }
+            throw new IllegalOpenParameterException(Resources.format(Resources.Keys.UndefinedParameter_2,
+                        provider.getShortName(), LOCATION), cause);
+        }
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -40,6 +40,7 @@ import org.opengis.referencing.crs.Tempo
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.feature.DefaultAttributeType;
 import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.FoliationRepresentation;
 import org.apache.sis.referencing.CRS;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.internal.referencing.GeodeticObjectBuilder;
@@ -55,6 +56,7 @@ import org.apache.sis.geometry.GeneralEn
 import org.apache.sis.geometry.ImmutableEnvelope;
 import org.apache.sis.metadata.iso.DefaultMetadata;
 import org.apache.sis.metadata.sql.MetadataStoreException;
+import org.apache.sis.storage.DataOptionKey;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.storage.DataStoreReferencingException;
@@ -84,7 +86,7 @@ import org.opengis.feature.AttributeType
  * See package javadoc for more information on the syntax.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.7
  * @module
  */
@@ -227,12 +229,9 @@ final class Store extends URIDataStore i
      *
      * @param  provider   the factory that created this {@code DataStore} instance, or {@code
null} if unspecified.
      * @param  connector  information about the storage (URL, stream, <i>etc</i>).
-     * @param  immediate  {@code true} for forcing the creation of a distinct {@code Feature}
instance for each line.
      * @throws DataStoreException if an error occurred while opening the stream.
      */
-    public Store(final StoreProvider provider, final StorageConnector connector, final boolean
immediate)
-            throws DataStoreException
-    {
+    public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException
{
         super(provider, connector);
         final Reader r = connector.getStorageAs(Reader.class);
         connector.closeAllExcept(r);
@@ -242,7 +241,7 @@ final class Store extends URIDataStore i
         }
         source     = (r instanceof BufferedReader) ? (BufferedReader) r : new LineNumberReader(r);
         geometries = Geometries.implementation(connector.getOption(OptionKey.GEOMETRY_LIBRARY));
-        dissociate = immediate;
+        dissociate = FoliationRepresentation.FRAGMENTED.equals(connector.getOption(DataOptionKey.FOLIATION_REPRESENTATION));
         GeneralEnvelope envelope    = null;
         FeatureType     featureType = null;
         Foliation       foliation   = null;

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -16,14 +16,23 @@
  */
 package org.apache.sis.internal.storage.csv;
 
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.ParameterDescriptorGroup;
+import org.apache.sis.parameter.ParameterBuilder;
+import org.apache.sis.parameter.Parameters;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.DataOptionKey;
 import org.apache.sis.storage.ProbeResult;
 import org.apache.sis.storage.StorageConnector;
+import org.apache.sis.feature.FoliationRepresentation;
+import org.apache.sis.internal.storage.Resources;
 import org.apache.sis.internal.storage.Capability;
 import org.apache.sis.internal.storage.Capabilities;
 import org.apache.sis.internal.storage.URIDataStore;
 import org.apache.sis.internal.storage.wkt.FirstKeywordPeek;
+import org.apache.sis.util.ArgumentChecks;
 
 
 /**
@@ -35,7 +44,7 @@ import org.apache.sis.internal.storage.w
  * the part of the caller. However the {@link Store} instances created by this factory are
not thread-safe.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.8
  * @module
  */
@@ -101,6 +110,19 @@ public final class StoreProvider extends
     }
 
     /**
+     * Description of the optional parameter for specifying whether the reader should assemble
distinct CSV lines
+     * into a single {@code Feature} instance forming a foliation. This is ignored if the
CSV file does not seem
+     * to contain moving features.
+     */
+    private static final ParameterDescriptor<FoliationRepresentation> FOLIATION;
+    static {
+        final ParameterBuilder builder = new ParameterBuilder();
+        FOLIATION = builder.addName("foliation")
+                .setDescription(Resources.formatInternational(Resources.Keys.FoliationRepresentation))
+                .create(FoliationRepresentation.class, FoliationRepresentation.ASSEMBLED);
+    }
+
+    /**
      * Creates a new provider.
      */
     public StoreProvider() {
@@ -138,6 +160,32 @@ public final class StoreProvider extends
      */
     @Override
     public DataStore open(final StorageConnector connector) throws DataStoreException {
-        return new Store(this, connector, false);
+        return new Store(this, connector);
+    }
+
+    /**
+     * Returns a CSV {@link Store} implementation from the given parameters.
+     *
+     * @return a data store implementation associated with this provider for the given parameters.
+     * @throws DataStoreException if an error occurred while creating the data store instance.
+     */
+    @Override
+    public DataStore open(final ParameterValueGroup parameters) throws DataStoreException
{
+        ArgumentChecks.ensureNonNull("parameter", parameters);
+        final StorageConnector connector = connector(this, parameters);
+        final Parameters pg = Parameters.castOrWrap(parameters);
+        connector.setOption(DataOptionKey.ENCODING, pg.getValue(ENCODING));
+        connector.setOption(DataOptionKey.FOLIATION_REPRESENTATION, pg.getValue(FOLIATION));
+        return new Store(this, connector);
+    }
+
+    /**
+     * Invoked by {@link #getOpenParameters()} the first time that a parameter descriptor
needs to be created.
+     *
+     * @return the parameters descriptor for CSV files.
+     */
+    @Override
+    protected ParameterDescriptorGroup build(final ParameterBuilder builder) {
+        return builder.createGroup(LOCATION_PARAM, ENCODING, FOLIATION);
     }
 }

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/package-info.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/package-info.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -53,7 +53,7 @@
  * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.7
  * @module
  */

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -27,7 +27,6 @@ import org.opengis.util.InternationalStr
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.parameter.ParameterNotFoundException;
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.parameter.Parameters;
 import org.apache.sis.storage.DataStore;
@@ -35,7 +34,6 @@ import org.apache.sis.storage.DataStoreP
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.ProbeResult;
-import org.apache.sis.storage.IllegalOpenParameterException;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.internal.system.Modules;
@@ -84,11 +82,18 @@ public final class FolderStoreProvider e
         final ParameterDescriptor<Path> location;
         final ParameterBuilder builder = new ParameterBuilder();
         final InternationalString remark = Resources.formatInternational(Resources.Keys.UsedOnlyIfNotEncoded);
+        ENCODING   = annotate(builder, URIDataStore.Provider.ENCODING, remark);
         LOCALE     = builder.addName("locale"  ).setDescription(Resources.formatInternational(Resources.Keys.DataStoreLocale
 )).setRemarks(remark).create(Locale.class,   null);
         TIMEZONE   = builder.addName("timezone").setDescription(Resources.formatInternational(Resources.Keys.DataStoreTimeZone)).setRemarks(remark).create(TimeZone.class,
null);
-        ENCODING   = builder.addName("encoding").setDescription(Resources.formatInternational(Resources.Keys.DataStoreEncoding)).setRemarks(remark).create(Charset.class,
 null);
-        location   = builder.addName( LOCATION ).setDescription(URIDataStore.Provider.LOCATION_PARAM.getDescription())
         .setRequired(true) .create(Path.class,     null);
-        PARAMETERS = builder.addName( NAME     ).createGroup(location, LOCALE, TIMEZONE,
ENCODING);
+        location   = new ParameterBuilder(URIDataStore.Provider.LOCATION_PARAM).create(Path.class,
null);
+        PARAMETERS = builder.addName(NAME).createGroup(location, LOCALE, TIMEZONE, ENCODING);
+    }
+
+    /**
+     * Creates a parameter descriptor equals to the given one except for the remarks which
are set to the given value.
+     */
+    private static <T> ParameterDescriptor<T> annotate(ParameterBuilder builder,
ParameterDescriptor<T> e, InternationalString remark) {
+        return builder.addName(e.getName()).setDescription(e.getDescription()).setRemarks(remark).create(e.getValueClass(),
null);
     }
 
     /**
@@ -173,22 +178,12 @@ public final class FolderStoreProvider e
     @Override
     public DataStore open(final ParameterValueGroup parameters) throws DataStoreException
{
         ArgumentChecks.ensureNonNull("parameter", parameters);
-        ParameterNotFoundException cause = null;
-        try {
-            final Object location = parameters.parameter(LOCATION).getValue();
-            if (location != null) {
-                final Parameters pg = Parameters.castOrWrap(parameters);
-                final StorageConnector connector = new StorageConnector(location);
-                connector.setOption(OptionKey.LOCALE,   pg.getValue(LOCALE));
-                connector.setOption(OptionKey.TIMEZONE, pg.getValue(TIMEZONE));
-                connector.setOption(OptionKey.ENCODING, pg.getValue(ENCODING));
-                return open(connector);
-            }
-        } catch (ParameterNotFoundException e) {
-            cause = e;
-        }
-        throw new IllegalOpenParameterException(Resources.format(Resources.Keys.UndefinedParameter_2,
-                getShortName(), LOCATION), cause);
+        final StorageConnector connector = URIDataStore.Provider.connector(this, parameters);
+        final Parameters pg = Parameters.castOrWrap(parameters);
+        connector.setOption(OptionKey.LOCALE,   pg.getValue(LOCALE));
+        connector.setOption(OptionKey.TIMEZONE, pg.getValue(TIMEZONE));
+        connector.setOption(OptionKey.ENCODING, pg.getValue(ENCODING));
+        return open(connector);
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -24,7 +24,7 @@
  * may change in incompatible ways in any future version without notice.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.3
  * @module
  */

Added: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java?rev=1813760&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage;
+
+import org.apache.sis.setup.OptionKey;
+import org.apache.sis.feature.FoliationRepresentation;
+
+
+/**
+ * Keys in a map of options for configuring the way data are read or written to a storage.
+ * {@code DataOptionKey} extends {@link OptionKey} with options about features, coverages
or other kinds of structure
+ * in data files. Contrarily to {@code OptionKey}, the options defined in this {@code DataOptionKey}
class are usually
+ * not applicable to other kinds of file (e.g. configuration or program files).
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.0
+ *
+ * @param <T>  the type of option values.
+ *
+ * @since 1.0
+ * @module
+ */
+public final class DataOptionKey<T> extends OptionKey<T> {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = 8927757348322016043L;
+
+    /**
+     * Whether to assemble trajectory fragments (distinct CSV lines) into a single {@code
Feature} instance
+     * forming a foliation. This is ignored if the file does not seem to contain moving features.
+     *
+     * @since 1.0
+     */
+    public static final OptionKey<FoliationRepresentation> FOLIATION_REPRESENTATION
=
+            new DataOptionKey<>("FOLIATION_REPRESENTATION", FoliationRepresentation.class);
+
+    /**
+     * Creates a new key of the given name.
+     */
+    private DataOptionKey(final String name, final Class<T> type) {
+        super(name, type);
+    }
+}

Propchange: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -18,10 +18,9 @@ package org.apache.sis.storage;
 
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.metadata.distribution.Format;
 import org.apache.sis.internal.simple.SimpleFormat;
-import org.apache.sis.internal.storage.Resources;
+import org.apache.sis.internal.storage.URIDataStore;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.distribution.DefaultFormat;
 import org.apache.sis.measure.Range;
@@ -287,18 +286,6 @@ public abstract class DataStoreProvider
      */
     public DataStore open(final ParameterValueGroup parameters) throws DataStoreException
{
         ArgumentChecks.ensureNonNull("parameter", parameters);
-        ParameterNotFoundException cause = null;
-        Object location;
-        try {
-            location = parameters.parameter(LOCATION).getValue();
-        } catch (ParameterNotFoundException e) {
-            location = null;
-            cause = e;
-        }
-        if (location == null) {
-            throw new IllegalOpenParameterException(Resources.format(Resources.Keys.UndefinedParameter_2,
-                    getShortName(), LOCATION), cause);
-        }
-        return open(new StorageConnector(location));
+        return open(URIDataStore.Provider.connector(this, parameters));
     }
 }

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -26,7 +26,7 @@
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.3
  * @module
  */

Modified: sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java?rev=1813760&r1=1813759&r2=1813760&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
[UTF-8] Mon Oct 30 13:42:02 2017
@@ -22,8 +22,10 @@ import java.io.StringReader;
 import org.opengis.metadata.Metadata;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.apache.sis.feature.FoliationRepresentation;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.StorageConnector;
+import org.apache.sis.storage.DataOptionKey;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 import com.esri.core.geometry.Point2D;
@@ -46,7 +48,7 @@ import org.opengis.feature.AttributeType
  * Tests {@link Store}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.7
  * @module
  */
@@ -79,6 +81,15 @@ public final strictfp class StoreTest ex
     }
 
     /**
+     * Opens a CSV store on the test data for reading the lines as-is, without assembling
them in a single trajectory.
+     */
+    private static Store open() throws DataStoreException {
+        StorageConnector connector = new StorageConnector(testData());
+        connector.setOption(DataOptionKey.FOLIATION_REPRESENTATION, FoliationRepresentation.FRAGMENTED);
+        return new Store(null, connector);
+    }
+
+    /**
      * Tests {@link Store#getMetadata()}.
      *
      * @throws DataStoreException if an error occurred while parsing the data.
@@ -86,7 +97,7 @@ public final strictfp class StoreTest ex
     @Test
     public void testGetMetadata() throws DataStoreException {
         final Metadata metadata;
-        try (Store store = new Store(null, new StorageConnector(testData()), true)) {
+        try (Store store = open()) {
             metadata = store.getMetadata();
         }
         final Extent extent = getSingleton(getSingleton(metadata.getIdentificationInfo()).getExtents());
@@ -105,7 +116,7 @@ public final strictfp class StoreTest ex
      */
     @Test
     public void testStaticFeatures() throws DataStoreException {
-        try (Store store = new Store(null, new StorageConnector(testData()), true)) {
+        try (Store store = open()) {
             verifyFeatureType(store.featureType, double[].class, 1);
             assertEquals("foliation", Foliation.TIME, store.foliation);
             final Iterator<Feature> it = store.features(false).iterator();
@@ -134,7 +145,7 @@ public final strictfp class StoreTest ex
     @Test
     public void testMovingFeatures() throws DataStoreException {
         isMovingFeature = true;
-        try (Store store = new Store(null, new StorageConnector(testData()), false)) {
+        try (Store store = new Store(null, new StorageConnector(testData()))) {
             verifyFeatureType(store.featureType, Polyline.class, Integer.MAX_VALUE);
             assertEquals("foliation", Foliation.TIME, store.foliation);
             final Iterator<Feature> it = store.features(false).iterator();



Mime
View raw message