sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jso...@apache.org
Subject [sis] branch geoapi-4.0 updated: Filter : add Temporal filter function classes
Date Fri, 16 Aug 2019 10:07:35 GMT
This is an automated email from the ASF dual-hosted git repository.

jsorel pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 1518f6c  Filter : add Temporal filter function classes
1518f6c is described below

commit 1518f6c7357518de8b696e3a2c4d5c2665e367f0
Author: jsorel <johann.sorel@geomatys.com>
AuthorDate: Fri Aug 16 12:07:19 2019 +0200

    Filter : add Temporal filter function classes
---
 .../apache/sis/filter/DefaultFilterFactory.java    |  28 +-
 .../org/apache/sis/filter/TemporalFunction.java    | 373 +++++++++++++++++++++
 .../apache/sis/filter/TemporalFunctionTest.java    | 157 +++++++++
 .../apache/sis/test/suite/FeatureTestSuite.java    |   1 +
 4 files changed, 545 insertions(+), 14 deletions(-)

diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
index e74cef6..5d9ad11 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
@@ -564,7 +564,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public After after(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.After(expression1, expression2);
     }
 
     /**
@@ -572,7 +572,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public AnyInteracts anyInteracts(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.AnyInteracts(expression1, expression2);
     }
 
     /**
@@ -580,7 +580,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public Before before(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.Before(expression1, expression2);
     }
 
     /**
@@ -588,7 +588,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public Begins begins(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.Begins(expression1, expression2);
     }
 
     /**
@@ -596,7 +596,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public BegunBy begunBy(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.BegunBy(expression1, expression2);
     }
 
     /**
@@ -604,7 +604,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public During during(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.During(expression1, expression2);
     }
 
     /**
@@ -612,7 +612,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public Ends ends(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.Ends(expression1, expression2);
     }
 
     /**
@@ -620,7 +620,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public EndedBy endedBy(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.EndedBy(expression1, expression2);
     }
 
     /**
@@ -628,7 +628,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public Meets meets(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.Meets(expression1, expression2);
     }
 
     /**
@@ -636,7 +636,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public MetBy metBy(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.MetBy(expression1, expression2);
     }
 
     /**
@@ -644,7 +644,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public OverlappedBy overlappedBy(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.OverlappedBy(expression1, expression2);
     }
 
     /**
@@ -652,7 +652,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public TContains tcontains(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.TContains(expression1, expression2);
     }
 
     /**
@@ -660,7 +660,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public TEquals tequals(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.TEquals(expression1, expression2);
     }
 
     /**
@@ -668,7 +668,7 @@ public class DefaultFilterFactory implements FilterFactory2 {
      */
     @Override
     public TOverlaps toverlaps(Expression expression1, Expression expression2) {
-        throw new UnsupportedOperationException("Not supported yet.");
+        return new TemporalFunction.TOverlaps(expression1, expression2);
     }
 
     // EXPRESSIONS /////////////////////////////////////////////////////////////
diff --git a/core/sis-feature/src/main/java/org/apache/sis/filter/TemporalFunction.java b/core/sis-feature/src/main/java/org/apache/sis/filter/TemporalFunction.java
new file mode 100644
index 0000000..394f1c8
--- /dev/null
+++ b/core/sis-feature/src/main/java/org/apache/sis/filter/TemporalFunction.java
@@ -0,0 +1,373 @@
+/*
+ * 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.filter;
+
+import org.apache.sis.util.ArgumentChecks;
+import org.opengis.filter.Filter;
+import org.opengis.filter.FilterVisitor;
+import org.opengis.filter.expression.Expression;
+
+
+/**
+ * Temporal operations between two time values.
+ * The nature of the operation depends on the subclass.
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+abstract class TemporalFunction implements Filter {
+
+    /**
+     * The first of the two expressions to be used by this function.
+     *
+     * @see #getExpression1()
+     */
+    protected final Expression expression1;
+
+    /**
+     * The second of the two expressions to be used by this function.
+     *
+     * @see #getExpression2()
+     */
+    protected final Expression expression2;
+
+    /**
+     * Creates a new temporal function.
+     *
+     * @param  expression1  the first of the two expressions to be used by this function.
+     * @param  expression2  the second of the two expressions to be used by this function.
+     */
+    TemporalFunction(final Expression expression1, final Expression expression2) {
+        ArgumentChecks.ensureNonNull("expression1", expression1);
+        ArgumentChecks.ensureNonNull("expression2", expression2);
+        this.expression1 = expression1;
+        this.expression2 = expression2;
+    }
+
+    /**
+     * Returns the first of the two expressions to be used by this function.
+     * This is the value specified at construction time.
+     */
+    public final Expression getExpression1() {
+        return expression1;
+    }
+
+    /**
+     * Returns the second of the two expressions to be used by this function.
+     * This is the value specified at construction time.
+     */
+    public final Expression getExpression2() {
+        return expression2;
+    }
+
+    /**
+     * The "After" filter.
+     */
+    static final class After extends TemporalFunction implements org.opengis.filter.temporal.After
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        After(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "AnyInteracts" filter.
+     */
+    static final class AnyInteracts extends TemporalFunction implements org.opengis.filter.temporal.AnyInteracts
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        AnyInteracts(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "Before" filter.
+     */
+    static final class Before extends TemporalFunction implements org.opengis.filter.temporal.Before
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        Before(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "Begins" filter.
+     */
+    static final class Begins extends TemporalFunction implements org.opengis.filter.temporal.Begins
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        Begins(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "BegunBy" filter.
+     */
+    static final class BegunBy extends TemporalFunction implements org.opengis.filter.temporal.BegunBy
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        BegunBy(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "During" filter.
+     */
+    static final class During extends TemporalFunction implements org.opengis.filter.temporal.During
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        During(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "EndedBy" filter.
+     */
+    static final class EndedBy extends TemporalFunction implements org.opengis.filter.temporal.EndedBy
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        EndedBy(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "Ends" filter.
+     */
+    static final class Ends extends TemporalFunction implements org.opengis.filter.temporal.Ends
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        Ends(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "Meets" filter.
+     */
+    static final class Meets extends TemporalFunction implements org.opengis.filter.temporal.Meets
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        Meets(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "MetBy" filter.
+     */
+    static final class MetBy extends TemporalFunction implements org.opengis.filter.temporal.MetBy
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        MetBy(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "OverlappedBy" filter.
+     */
+    static final class OverlappedBy extends TemporalFunction implements org.opengis.filter.temporal.OverlappedBy
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        OverlappedBy(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "TContains" filter.
+     */
+    static final class TContains extends TemporalFunction implements org.opengis.filter.temporal.TContains
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        TContains(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "TEquals" filter.
+     */
+    static final class TEquals extends TemporalFunction implements org.opengis.filter.temporal.TEquals
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        TEquals(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+
+    /**
+     * The "TOverlaps" filter.
+     */
+    static final class TOverlaps extends TemporalFunction implements org.opengis.filter.temporal.TOverlaps
{
+
+        /** Creates a new expression for the {@value #NAME} operation. */
+        TOverlaps(Expression expression1, Expression expression2) {
+            super(expression1, expression2);
+        }
+
+        @Override
+        public boolean evaluate(Object object) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        /** Implementation of the visitor pattern. */
+        @Override public Object accept(FilterVisitor visitor, Object extraData) {
+            return visitor.visit(this, extraData);
+        }
+    }
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/TemporalFunctionTest.java
b/core/sis-feature/src/test/java/org/apache/sis/filter/TemporalFunctionTest.java
new file mode 100644
index 0000000..78b3bdc
--- /dev/null
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/TemporalFunctionTest.java
@@ -0,0 +1,157 @@
+/*
+ * 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.filter;
+
+import static org.apache.sis.test.Assert.*;
+import org.apache.sis.test.TestCase;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.opengis.filter.Filter;
+import org.opengis.filter.FilterFactory2;
+
+
+/**
+ * Tests {@link TemporalFunction} implementations.
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+public final strictfp class TemporalFunctionTest extends TestCase {
+    /**
+     * The factory to use for creating the objects to test.
+     */
+    private final FilterFactory2 factory = new DefaultFilterFactory();
+
+    /**
+     * Tests "After" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testAfter() {
+    }
+
+    /**
+     * Tests "AnyInteracts" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testAnyInteracts() {
+    }
+
+    /**
+     * Tests "Before" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testBefore() {
+    }
+
+    /**
+     * Tests "Begins" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testBegins() {
+    }
+
+    /**
+     * Tests "BegunBy" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testBegunBy() {
+    }
+
+    /**
+     * Tests "During" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testDuring() {
+    }
+
+    /**
+     * Tests "EndedBy" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testEndedBy() {
+    }
+
+    /**
+     * Tests "Ends" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testEnds() {
+    }
+
+    /**
+     * Tests "Meets" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testMeets() {
+    }
+
+    /**
+     * Tests "MetBy" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testMetBy() {
+    }
+
+    /**
+     * Tests "OverlappedBy" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testOverlappedBy() {
+    }
+
+    /**
+     * Tests "TContains" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testTContains() {
+    }
+
+    /**
+     * Tests "TEquals" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testTEquals() {
+    }
+
+    /**
+     * Tests "TOverlaps" (construction, evaluation, serialization, equality).
+     */
+    @Ignore
+    @Test
+    public void testTOverlaps() {
+    }
+
+    private static void assertFilter(boolean expected, Filter op) {
+        assertEquals(expected, op.evaluate(null));
+        assertSerializedEquals(op);
+    }
+}
diff --git a/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
b/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
index 54b8d66..7c06225 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
@@ -56,6 +56,7 @@ import org.junit.runners.Suite;
     org.apache.sis.filter.FilterByIdentifierTest.class,
     org.apache.sis.filter.ArithmeticFunctionTest.class,
     org.apache.sis.filter.ComparisonFunctionTest.class,
+    org.apache.sis.filter.TemporalFunctionTest.class,
     org.apache.sis.filter.SQLMMTest.class,
     org.apache.sis.internal.feature.AttributeConventionTest.class,
     org.apache.sis.internal.feature.j2d.ShapePropertiesTest.class,


Mime
View raw message