sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/01: Merge branch 'geoapi-3.1' The main work is GeodeticCalculator on ellipsoid. The work on filters & expressions is excluded since filter interfaces are not available in GeoAPI 3.0.
Date Tue, 27 Aug 2019 09:30:27 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 309aad84b195a29ffc08f218f27c66118b79289c
Merge: c8bf605 38edbe5
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Aug 27 11:29:17 2019 +0200

    Merge branch 'geoapi-3.1'
    The main work is GeodeticCalculator on ellipsoid.
    The work on filters & expressions is excluded since filter interfaces are not available
in GeoAPI 3.0.

 .../org/apache/sis/services/LocationServlet.java   |  13 +-
 .../apache/sis/coverage/grid/GridDerivation.java   |  92 +-
 .../org/apache/sis/coverage/grid/GridGeometry.java |   4 +
 .../java/org/apache/sis/feature/FeatureFormat.java |  11 +-
 .../main/java/org/apache/sis/feature/Features.java |   6 +
 .../java/org/apache/sis/internal/feature/ESRI.java |  17 +-
 .../sis/internal/feature/FeatureExpression.java    |  46 -
 .../apache/sis/internal/feature/Geometries.java    | 234 ++++-
 .../java/org/apache/sis/internal/feature/JTS.java  | 100 ++-
 .../org/apache/sis/internal/feature/Java2D.java    |  22 +-
 .../org/apache/sis/internal/feature/Resources.java |  15 +
 .../sis/internal/feature/Resources.properties      |   3 +
 .../sis/internal/feature/Resources_fr.properties   |   3 +
 .../org/apache/sis/internal/feature/jts/JTS.java   |  59 +-
 .../sis/coverage/grid/GridDerivationTest.java      |  30 +-
 .../apache/sis/test/suite/FeatureTestSuite.java    |   2 +-
 .../org/apache/sis/distance/LatLonPointRadius.java |  45 +-
 .../sis/internal/referencing/EPSGFactoryProxy.java |   7 +-
 .../apache/sis/internal/referencing/Formulas.java  |   4 +-
 .../apache/sis/internal/referencing/Resources.java |   5 +
 .../sis/internal/referencing/Resources.properties  |   1 +
 .../internal/referencing/Resources_fr.properties   |   1 +
 .../referencing/provider/GeocentricAffine.java     |   2 +-
 .../sis/referencing/GeodesicsOnEllipsoid.java      | 996 +++++++++++++++++++++
 .../apache/sis/referencing/GeodeticCalculator.java | 474 +++++++---
 .../apache/sis/referencing/GeodeticException.java  |  74 ++
 .../sis/referencing/datum/DefaultEllipsoid.java    |   7 +-
 .../org/apache/sis/referencing/datum/Sphere.java   |   1 +
 .../sis/referencing/operation/matrix/Matrices.java |   5 +-
 .../operation/projection/Mollweide.java            |   4 +-
 .../operation/projection/package-info.java         |   6 +-
 .../apache/sis/referencing/ClenshawSummation.java  | 460 ++++++++++
 .../sis/referencing/GeodesicsOnEllipsoidTest.java  | 561 ++++++++++++
 .../sis/referencing/GeodeticCalculatorTest.java    | 371 +++++---
 .../sis/test/suite/ReferencingTestSuite.java       |   1 +
 .../main/java/org/apache/sis/io/TableAppender.java |   5 +-
 .../java/org/apache/sis/math/MathFunctions.java    | 255 +++++-
 .../java/org/apache/sis/util/ArgumentChecks.java   |  25 +
 .../java/org/apache/sis/util/StringBuilders.java   |  31 +-
 .../org/apache/sis/math/MathFunctionsTest.java     |  43 +
 .../test/java/org/apache/sis/test/TestCase.java    |   3 +
 ide-project/NetBeans/nbproject/genfiles.properties |   4 +-
 ide-project/NetBeans/nbproject/project.properties  |   2 +-
 ide-project/NetBeans/nbproject/project.xml         |   2 +
 .../apache/sis/internal/netcdf/RasterResource.java |  10 +-
 .../java/org/apache/sis/index/tree/QuadTree.java   |   5 +-
 .../org/apache/sis/internal/storage/Resources.java |  10 +
 .../sis/internal/storage/Resources.properties      |   2 +
 .../sis/internal/storage/Resources_fr.properties   |   2 +
 .../sis/internal/storage/query/FeatureSubset.java  |  10 +-
 .../sis/internal/storage/query/SimpleQuery.java    |  32 +-
 .../storage/gpx/GroupAsPolylineOperation.java      |   3 +
 52 files changed, 3635 insertions(+), 491 deletions(-)

diff --cc core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
index 5ab8882,7bcc201..441db55
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
@@@ -399,7 -412,15 +400,15 @@@ public class FeatureFormat extends Tabu
                  }
                  value = feature.getPropertyValue(propertyType.getName().toString());
                  if (value == null) {
-                     if (propertyType instanceof FieldType && ((FieldType) propertyType).getMinimumOccurs()
== 0) {
 -                    if (propertyType instanceof AttributeType<?>
 -                            && ((AttributeType<?>) propertyType).getMinimumOccurs()
== 0
 -                            && ((AttributeType<?>) propertyType).characteristics().isEmpty())
++                    if (propertyType instanceof DefaultAttributeType<?>
++                            && ((DefaultAttributeType<?>) propertyType).getMinimumOccurs()
== 0
++                            && ((DefaultAttributeType<?>) propertyType).characteristics().isEmpty())
+                     {
+                         continue;                           // If optional, no value and
no characteristics, skip the full row.
+                     }
 -                    if (propertyType instanceof FeatureAssociationRole
 -                            && ((FeatureAssociationRole) propertyType).getMinimumOccurs()
== 0)
++                    if (propertyType instanceof DefaultAssociationRole
++                            && ((DefaultAssociationRole) propertyType).getMinimumOccurs()
== 0)
+                     {
                          continue;                           // If optional and no value,
skip the full row.
                      }
                      cardinality = 0;
diff --cc core/sis-feature/src/main/java/org/apache/sis/feature/Features.java
index 672e8be,7ff600f..48c694c
--- a/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java
@@@ -124,9 -136,44 +124,15 @@@ public final class Features extends Sta
          return (types != null) ? CommonParentFinder.select(types) : null;
      }
  
 -    /**
 -     * Returns the type of values provided by the given property. For {@linkplain AttributeType
attributes}
 -     * (which is the most common case), the value type is given by {@link AttributeType#getValueClass()}.
 -     * For {@linkplain FeatureAssociationRole feature associations}, the value type is {@link
Feature}.
 -     * For {@linkplain Operation operations}, the value type is determined recursively from
the
 -     * {@linkplain Operation#getResult() operation result}.
 -     * If the value type can not be determined, then this method returns {@code null}.
 -     *
 -     * @param  type  the property for which to get the type of values, or {@code null}.
 -     * @return the type of values provided by the given property, or {@code null} if unknown.
++    /*
++     * Following method is omitted on master because it depends on GeoAPI interfaces not
yet published:
+      *
 -     * @see AttributeType#getValueClass()
 -     *
 -     * @since 1.0
++     *     public static Class<?> getValueClass(PropertyType type)
+      */
 -    public static Class<?> getValueClass(PropertyType type) {
 -        while (type instanceof Operation) {
 -            final IdentifiedType result = ((Operation) type).getResult();
 -            if (result != type && result instanceof PropertyType) {
 -                type = (PropertyType) result;
 -            } else if (result instanceof FeatureType) {
 -                return Feature.class;
 -            } else {
 -                break;
 -            }
 -        }
 -        if (type instanceof AttributeType<?>) {
 -            return ((AttributeType<?>) type).getValueClass();
 -        } else if (type instanceof FeatureAssociationRole) {
 -            return Feature.class;
 -        } else {
 -            return null;
 -        }
 -    }
+ 
      /**
       * Returns the name of the type of values that the given property can take.
 -     * The type of value can be a {@link Class}, a {@link org.opengis.feature.FeatureType}
 +     * The type of value can be a {@link Class}, a {@code FeatureType}
       * or another {@code PropertyType} depending on given argument:
       *
       * <ul>
diff --cc core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java
index b17e984,1aeea6b..0000000
deleted file mode 100644,100644
--- a/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java
+++ /dev/null
@@@ -1,46 -1,97 +1,0 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one or more
-- * contributor license agreements.  See the NOTICE file distributed with
-- * this work for additional information regarding copyright ownership.
-- * The ASF licenses this file to You under the Apache License, Version 2.0
-- * (the "License"); you may not use this file except in compliance with
-- * the License.  You may obtain a copy of the License at
-- *
-- *     http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--package org.apache.sis.internal.feature;
--
- // Branch-dependent imports
- import org.apache.sis.feature.AbstractIdentifiedType;
- import org.apache.sis.feature.DefaultFeatureType;
 -import org.opengis.feature.FeatureType;
 -import org.opengis.feature.PropertyType;
 -import org.opengis.feature.AttributeType;
 -import org.opengis.filter.expression.Expression;
 -import org.apache.sis.internal.util.CollectionsExt;
 -import org.apache.sis.feature.builder.FeatureTypeBuilder;
 -import org.apache.sis.feature.builder.PropertyTypeBuilder;
--
--
--/**
-- * OGC expressions or other functions operating on feature instances.
-  * This interface adds an additional method, {@link #expectedType(DefaultFeatureType)},
 - * This interface adds an additional method, {@link #expectedType(FeatureType, FeatureTypeBuilder)},
-- * for fetching in advance the expected type of expression results.
 - *
 - * <p>This is an experimental interface which may be removed in any future version.</p>
-- *
-- * @author  Johann Sorel (Geomatys)
 - * @author  Martin Desruisseaux (Geomatys)
-- * @version 1.0
-- * @since   1.0
-- * @module
-- */
--public interface FeatureExpression {
--    /**
-      * Returns the expected type of values produced by this expression when a feature of
the given
 -     * Provides the expected type of values produced by this expression when a feature of
the given
--     * type is evaluated. The resulting type shall describe a "static" property, i.e. it
can be an
-      * {@code org.opengis.feature.AttributeType} or a {@code org.opengis.feature.FeatureAssociationRole}
-      * but not an {@code org.opengis.feature.Operation}.
 -     * {@link AttributeType} or a {@link org.opengis.feature.FeatureAssociationRole}
 -     * but not an {@link org.opengis.feature.Operation}.
--     *
-      * @param  type  the type of features on which to apply this expression.
-      * @return expected expression result type.
-      * @throws IllegalArgumentException if this method can not determine the property type
for the given feature type.
 -     * @param  valueType  the type of features to be evaluated by the given expression.
 -     * @param  addTo      where to add the type of properties evaluated by this expression.
 -     * @return builder of the added property, or {@code null} if this method can not add
a property.
 -     * @throws IllegalArgumentException if this method can operate only on some feature
types
 -     *         and the given type is not one of them.
--     */
-     AbstractIdentifiedType expectedType(DefaultFeatureType type);
 -    PropertyTypeBuilder expectedType(FeatureType valueType, FeatureTypeBuilder addTo);
 -
 -    /**
 -     * Provides the type of results computed by the given expression.
 -     * This method executes the first of the following choices that apply:
 -     *
 -     * <ol>
 -     *   <li>If the expression implements {@link FeatureExpression}, delegate to {@link
#expectedType(FeatureType,
 -     *       FeatureTypeBuilder)}. Note that the invoked method may throw an {@link IllegalArgumentException}.</li>
 -     *   <li>Otherwise if {@link Expression#evaluate(Object, Class)} with a {@code
PropertyType.class} argument
 -     *       returns a non-null property, adds that property to the given builder.</li>
 -     *   <li>Otherwise if the given feature type contains exactly one property (including
inherited properties),
 -     *       adds that property to the given builder.</li>
 -     *   <li>Otherwise returns {@code null}.</li>
 -     * </ol>
 -     *
 -     * It is caller's responsibility to verify if this method returns {@code null} and to
throw an exception in such case.
 -     * We leave that responsibility to the caller because (s)he may be able to provide better
error messages.
 -     *
 -     * @param  expression  the expression for which to get the result type, or {@code null}.
 -     * @param  valueType   the type of features to be evaluated by the given expression.
 -     * @param  addTo       where to add the type of properties evaluated by the given expression.
 -     * @return builder of the added property, or {@code null} if this method can not add
a property.
 -     * @throws IllegalArgumentException if this method can operate only on some feature
types
 -     *         and the given type is not one of them.
 -     */
 -    public static PropertyTypeBuilder expectedType(final Expression expression, final FeatureType
valueType, final FeatureTypeBuilder addTo) {
 -        if (expression instanceof FeatureExpression) {
 -            return ((FeatureExpression) expression).expectedType(valueType, addTo);
 -        }
 -        PropertyType pt = null;
 -        if (expression != null) {
 -            // TODO: remove this hack if we can get more type-safe Expression.
 -            pt = expression.evaluate(valueType, PropertyType.class);
 -        }
 -        if (pt == null) {
 -            pt = CollectionsExt.singletonOrNull(valueType.getProperties(true));
 -            if (pt == null) {
 -                return null;
 -            }
 -        }
 -        return addTo.addProperty(pt);
 -    }
--}
diff --cc core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticCalculatorTest.java
index 637b98e,2d9ae74..2223ac7
--- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticCalculatorTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticCalculatorTest.java
@@@ -26,7 -26,7 +26,6 @@@ import java.util.Random
  import java.io.IOException;
  import java.io.LineNumberReader;
  import org.opengis.geometry.DirectPosition;
- import org.opengis.referencing.operation.TransformException;
 -import org.opengis.referencing.cs.AxisDirection;
  import org.apache.sis.internal.referencing.j2d.ShapeUtilitiesExt;
  import org.apache.sis.internal.referencing.Formulas;
  import org.apache.sis.referencing.crs.HardCodedCRS;
@@@ -197,10 -220,10 +219,8 @@@ public strictfp class GeodeticCalculato
       */
      @Test
      @DependsOnMethod("testGeodesicDistanceAndAzimuths")
-     public void testUsingTransform() throws TransformException {
+     public void testUsingTransform() {
          final GeodeticCalculator c = create(true);
 -        assertAxisDirectionsEqual("GeographicCRS", c.getGeographicCRS().getCoordinateSystem(),
AxisDirection.NORTH, AxisDirection.EAST);
 -        assertAxisDirectionsEqual("PositionCRS",     c.getPositionCRS().getCoordinateSystem(),
AxisDirection.EAST, AxisDirection.NORTH);
          final double φ = -33.0;
          final double λ = -71.6;
          c.setStartPoint(new DirectPosition2D(λ, φ));
diff --cc ide-project/NetBeans/nbproject/genfiles.properties
index da6ac3c,56a977b..5d88045
--- a/ide-project/NetBeans/nbproject/genfiles.properties
+++ b/ide-project/NetBeans/nbproject/genfiles.properties
@@@ -3,6 -3,6 +3,6 @@@
  build.xml.data.CRC32=58e6b21c
  build.xml.script.CRC32=462eaba0
  build.xml.stylesheet.CRC32=28e38971@1.53.1.46
- nbproject/build-impl.xml.data.CRC32=fb5ce999
 -nbproject/build-impl.xml.data.CRC32=5a726ec7
 -nbproject/build-impl.xml.script.CRC32=f4ace637
++nbproject/build-impl.xml.data.CRC32=1e9c8996
 +nbproject/build-impl.xml.script.CRC32=1aba96b2
- nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.91.1.48
+ nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.92.0.48
diff --cc storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureSubset.java
index 3afeaf2,828feb5..33b87d0
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureSubset.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/FeatureSubset.java
@@@ -19,7 -19,12 +19,9 @@@ package org.apache.sis.internal.storage
  import java.util.Optional;
  import java.util.stream.Stream;
  import org.opengis.util.GenericName;
 -import org.apache.sis.internal.feature.FeatureUtilities;
  import org.apache.sis.internal.storage.AbstractFeatureSet;
+ import org.apache.sis.internal.storage.Resources;
 -import org.apache.sis.filter.InvalidExpressionException;
+ import org.apache.sis.storage.DataStoreContentException;
  import org.apache.sis.storage.DataStoreException;
  import org.apache.sis.storage.FeatureSet;
  
@@@ -78,9 -86,15 +80,15 @@@ final class FeatureSubset extends Abstr
       * Returns a description of properties that are common to all features in this dataset.
       */
      @Override
 -    public synchronized FeatureType getType() throws DataStoreException {
 +    public synchronized DefaultFeatureType getType() throws DataStoreException {
          if (resultType == null) {
-             resultType = query.expectedType(source.getType());
 -            final FeatureType type = source.getType();
++            final DefaultFeatureType type = source.getType();
+             try {
+                 resultType = query.expectedType(type);
 -            } catch (IllegalArgumentException | InvalidExpressionException e) {
++            } catch (IllegalArgumentException e) {
+                 throw new DataStoreContentException(Resources.forLocale(getLocale())
+                         .getString(Resources.Keys.CanNotDeriveTypeFromFeature_1, type.getName()),
e);
+             }
          }
          return resultType;
      }
diff --cc storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SimpleQuery.java
index 38f897b,8752f73..a907391
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SimpleQuery.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SimpleQuery.java
@@@ -135,10 -395,24 +135,15 @@@ public class SimpleQuery extends Query 
      }
  
      /**
-      * Returns the expected property type for this query executed on features of the given
type.
+      * Returns the type or values evaluated by this query when executed on features of the
given type.
+      *
+      * @param  valueType  the type of features to be evaluated by the expressions in this
query.
+      * @return type resulting from expressions evaluation (never null).
+      * @throws IllegalArgumentException if this method can operate only on some feature
types
+      *         and the given type is not one of them.
 -     * @throws InvalidExpressionException if this method can not determine the result type
of an expression
 -     *         in this query. It may be because that expression is backed by an unsupported
implementation.
       */
-     final DefaultFeatureType expectedType(final DefaultFeatureType source) {
-         return source;          // More developped code in JDK8 branch.
 -    final FeatureType expectedType(final FeatureType valueType) {
 -        if (columns == null) {
 -            return valueType;           // All columns included: result is of the same type.
 -        }
 -        final FeatureTypeBuilder ftb = new FeatureTypeBuilder().setName(valueType.getName());
 -        for (int i=0; i<columns.length; i++) {
 -            columns[i].expectedType(i, valueType, ftb);
 -        }
 -        return ftb.build();
++    final DefaultFeatureType expectedType(final DefaultFeatureType valueType) {
++        return valueType;       // More elaborated code in geoapi-4.0 branch.
      }
  
      /**
@@@ -165,8 -440,47 +170,27 @@@
          if (obj != null && getClass() == obj.getClass()) {
              final SimpleQuery other = (SimpleQuery) obj;
              return skip  == other.skip &&
 -                   limit == other.limit &&
 -                   filter.equals(other.filter) &&
 -                   Arrays.equals(columns, other.columns) &&
 -                   Arrays.equals(sortBy,  other.sortBy);
 +                   limit == other.limit;
          }
-         return true;
+         return false;
+     }
+ 
+     /**
+      * Returns a textual representation looking like an SQL Select query.
+      *
+      * @return textual representation of this query.
+      */
+     @Override
+     public String toString() {
+         final StringBuilder sb = new StringBuilder(80);
+         sb.append("SELECT ");
 -        if (columns != null) {
 -            for (int i=0; i<columns.length; i++) {
 -                if (i != 0) sb.append(", ");
 -                columns[i].appendTo(sb);
 -            }
 -        } else {
 -            sb.append('*');
 -        }
 -        if (filter != Filter.INCLUDE) {
 -            sb.append(" WHERE ").append(filter);
 -        }
 -        if (sortBy != SortBy.UNSORTED) {
 -            sb.append(" ORDER BY ");
 -            for (int i=0; i<sortBy.length; i++) {
 -                if (i != 0) sb.append(", ");
 -                sb.append(sortBy[i]);
 -            }
 -        }
++        sb.append('*');
+         if (limit != UNLIMITED) {
+             sb.append(" LIMIT ").append(limit);
+         }
+         if (skip != 0) {
+             sb.append(" OFFSET ").append(skip);
+         }
+         return sb.toString();
      }
  }


Mime
View raw message