From 6d05c1ae25a451ca4b0cc42170283848ce08f554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E9=9B=A8?= Date: Thu, 28 Jul 2022 17:10:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E6=89=80=E5=B1=9E?= =?UTF-8?q?=E5=8C=85=E6=8C=89mapbox=E6=96=87=E6=A1=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{decision => lookup}/Has.java | 2 +- .../mbexpression/{decision => lookup}/In.java | 2 +- .../{decision => lookup}/IndexOf.java | 2 +- .../{decision => lookup}/Length.java | 2 +- .../{decision => lookup}/Slice.java | 2 +- .../vector/mbexpression/ExpressionTest.java | 107 +++++++++--------- 6 files changed, 59 insertions(+), 58 deletions(-) rename giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/{decision => lookup}/Has.java (97%) rename giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/{decision => lookup}/In.java (97%) rename giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/{decision => lookup}/IndexOf.java (98%) rename giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/{decision => lookup}/Length.java (97%) rename giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/{decision => lookup}/Slice.java (98%) diff --git a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/Has.java b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/Has.java similarity index 97% rename from giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/Has.java rename to giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/Has.java index 5a23547..ec380ee 100644 --- a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/Has.java +++ b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/Has.java @@ -17,7 +17,7 @@ * specific language governing permissions and limitations * under the License. ****************************************************************/ -package org.wowtools.giscat.vector.mbexpression.decision; +package org.wowtools.giscat.vector.mbexpression.lookup; import org.wowtools.giscat.vector.mbexpression.Expression; import org.wowtools.giscat.vector.mbexpression.ExpressionName; diff --git a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/In.java b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/In.java similarity index 97% rename from giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/In.java rename to giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/In.java index 455fe98..d23447e 100644 --- a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/In.java +++ b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/In.java @@ -17,7 +17,7 @@ * specific language governing permissions and limitations * under the License. ****************************************************************/ -package org.wowtools.giscat.vector.mbexpression.decision; +package org.wowtools.giscat.vector.mbexpression.lookup; import org.wowtools.giscat.vector.mbexpression.Expression; import org.wowtools.giscat.vector.mbexpression.ExpressionName; diff --git a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/IndexOf.java b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/IndexOf.java similarity index 98% rename from giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/IndexOf.java rename to giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/IndexOf.java index 2d1ad57..8839f76 100644 --- a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/IndexOf.java +++ b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/IndexOf.java @@ -17,7 +17,7 @@ * specific language governing permissions and limitations * under the License. ****************************************************************/ -package org.wowtools.giscat.vector.mbexpression.decision; +package org.wowtools.giscat.vector.mbexpression.lookup; import org.wowtools.giscat.vector.mbexpression.Expression; import org.wowtools.giscat.vector.mbexpression.ExpressionName; diff --git a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/Length.java b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/Length.java similarity index 97% rename from giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/Length.java rename to giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/Length.java index 3752b0b..5fbde8b 100644 --- a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/Length.java +++ b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/Length.java @@ -17,7 +17,7 @@ * specific language governing permissions and limitations * under the License. ****************************************************************/ -package org.wowtools.giscat.vector.mbexpression.decision; +package org.wowtools.giscat.vector.mbexpression.lookup; import org.wowtools.giscat.vector.mbexpression.Expression; import org.wowtools.giscat.vector.mbexpression.ExpressionName; diff --git a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/Slice.java b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/Slice.java similarity index 98% rename from giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/Slice.java rename to giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/Slice.java index 20a971e..afcf07a 100644 --- a/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/decision/Slice.java +++ b/giscat-vector/giscat-vector-mbexpression/src/main/java/org/wowtools/giscat/vector/mbexpression/lookup/Slice.java @@ -17,7 +17,7 @@ * specific language governing permissions and limitations * under the License. ****************************************************************/ -package org.wowtools.giscat.vector.mbexpression.decision; +package org.wowtools.giscat.vector.mbexpression.lookup; import org.wowtools.giscat.vector.mbexpression.Expression; import org.wowtools.giscat.vector.mbexpression.ExpressionName; diff --git a/giscat-vector/giscat-vector-mbexpression/src/test/java/org/wowtools/giscat/vector/mbexpression/ExpressionTest.java b/giscat-vector/giscat-vector-mbexpression/src/test/java/org/wowtools/giscat/vector/mbexpression/ExpressionTest.java index 228e078..7589356 100644 --- a/giscat-vector/giscat-vector-mbexpression/src/test/java/org/wowtools/giscat/vector/mbexpression/ExpressionTest.java +++ b/giscat-vector/giscat-vector-mbexpression/src/test/java/org/wowtools/giscat/vector/mbexpression/ExpressionTest.java @@ -108,46 +108,7 @@ public void decision() { Assert.assertEquals(false, getValue(feature, "[\">\", 1.0,1.0]") ); - //has - Assert.assertEquals(true, - getValue(feature, "[\"has\", \"int1\"]") - ); - Assert.assertEquals(false, - getValue(feature, "[\"has\", \"int3\"]") - ); - //in - Assert.assertEquals(true, - getValue(feature, "[\"in\", 1,[0,1]]") - ); - Assert.assertEquals(false, - getValue(feature, "[\"in\", 1,[0,2]]") - ); - Assert.assertEquals(true, - getValue(feature, "[\"in\", \"a\",\"abc\"]") - ); - Assert.assertEquals(false, - getValue(feature, "[\"in\", \"a\",\"bbc\"]") - ); - //index-of - Assert.assertEquals(2, - getValue(feature, "[\"index-of\", \"a\",\"ihas\"]") - ); - Assert.assertEquals(-1, - getValue(feature, "[\"index-of\", \"a\",\"ihs\"]") - ); - Assert.assertEquals(1, - getValue(feature, "[\"index-of\", \"a\",[\"i\",\"a\",\"a\"]]") - ); - Assert.assertEquals(2, - getValue(feature, "[\"index-of\", \"a\",[\"i\",\"a\",\"a\"],2]") - ); - //length - Assert.assertEquals(4, - getValue(feature, "[\"length\", \"ihas\"]") - ); - Assert.assertEquals(3, - getValue(feature, "[\"length\", [\"i\",\"a\",\"a\"]]") - ); + //<= Assert.assertEquals(true, getValue(feature, "[\"<=\", 1,2]") @@ -192,19 +153,6 @@ public void decision() { Assert.assertEquals(true, getValue(feature, "[\"!=\",1.0,1.2]") ); - //slice - Assert.assertArrayEquals(new Object[]{2, 3, 4}, - ((ArrayList) getValue(feature, "[\"slice\",[1,2,3,4],1]")).toArray() - ); - Assert.assertArrayEquals(new Object[]{2, 3}, - ((ArrayList) getValue(feature, "[\"slice\",[1,2,3,4],1,3]")).toArray() - ); - Assert.assertEquals("bcd", - getValue(feature, "[\"slice\",\"abcd\",1]") - ); - Assert.assertEquals("bc", - getValue(feature, "[\"slice\",\"abcd\",1,3]") - ); //组合测试 Assert.assertEquals(true, getValue(feature, "[\"all\", [\"==\", [\"get\", \"int1\"], [\"get\", \"int1\"]]]") @@ -228,6 +176,59 @@ public void lookup() { Assert.assertEquals("1", getValue(feature, "[\"get\",\"str1\"]") ); + //has + Assert.assertEquals(true, + getValue(feature, "[\"has\", \"int1\"]") + ); + Assert.assertEquals(false, + getValue(feature, "[\"has\", \"int3\"]") + ); + //in + Assert.assertEquals(true, + getValue(feature, "[\"in\", 1,[0,1]]") + ); + Assert.assertEquals(false, + getValue(feature, "[\"in\", 1,[0,2]]") + ); + Assert.assertEquals(true, + getValue(feature, "[\"in\", \"a\",\"abc\"]") + ); + Assert.assertEquals(false, + getValue(feature, "[\"in\", \"a\",\"bbc\"]") + ); + //index-of + Assert.assertEquals(2, + getValue(feature, "[\"index-of\", \"a\",\"ihas\"]") + ); + Assert.assertEquals(-1, + getValue(feature, "[\"index-of\", \"a\",\"ihs\"]") + ); + Assert.assertEquals(1, + getValue(feature, "[\"index-of\", \"a\",[\"i\",\"a\",\"a\"]]") + ); + Assert.assertEquals(2, + getValue(feature, "[\"index-of\", \"a\",[\"i\",\"a\",\"a\"],2]") + ); + //length + Assert.assertEquals(4, + getValue(feature, "[\"length\", \"ihas\"]") + ); + Assert.assertEquals(3, + getValue(feature, "[\"length\", [\"i\",\"a\",\"a\"]]") + ); + //slice + Assert.assertArrayEquals(new Object[]{2, 3, 4}, + ((ArrayList) getValue(feature, "[\"slice\",[1,2,3,4],1]")).toArray() + ); + Assert.assertArrayEquals(new Object[]{2, 3}, + ((ArrayList) getValue(feature, "[\"slice\",[1,2,3,4],1,3]")).toArray() + ); + Assert.assertEquals("bcd", + getValue(feature, "[\"slice\",\"abcd\",1]") + ); + Assert.assertEquals("bc", + getValue(feature, "[\"slice\",\"abcd\",1,3]") + ); } @org.junit.Test