[
https://issues.apache.org/jira/browse/TINKERPOP-2558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18147689#comment-18147689
]
ASF GitHub Bot commented on TINKERPOP-2558:
-------------------------------------------
GumpacG commented on code in PR #3809:
URL: https://github.com/apache/tinkerpop/pull/3809#discussion_r4631153826
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GeoP.java:
##########
@@ -0,0 +1,227 @@
+/*
+ * 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.tinkerpop.gremlin.process.traversal;
+
+import org.apache.tinkerpop.gremlin.process.traversal.step.GValue;
+import org.apache.tinkerpop.gremlin.structure.geo.Geometry;
+import org.apache.tinkerpop.gremlin.structure.geo.Model;
+
+import java.util.HashMap;
+
+/**
+ * Predefined {@code Predicate} values that filter {@link Geometry} values by
a spatial
+ * relationship, backed by the {@link Geo} predicates.
+ * <p>
+ * An argument may instead come from a child traversal, which is resolved
against each traverser.
+ * An argument may also be a {@link GValue}, whose value is resolved when the
traversal is built.
+ * <p>
+ * <b>Accuracy in the geographic model.</b> Shapes are related in longitude
and latitude, with
+ * edges straight in both, so the predicates hold for edges under about 100 km
that cross neither
+ * the antimeridian nor a pole.
+ *
+ * @since 4.0.0
+ */
+public class GeoP extends P<Geometry> {
+
+ /**
+ * Constructs a {@code GeoP} from the given geometry, which is validated
as a constant. A
+ * geometry resolved at runtime is given as a child traversal instead.
+ *
+ * @since 4.0.0
+ */
+ public GeoP(final PBiPredicate<Object, Object> biPredicate, final Object
value) {
+ super(asGeometryPredicate(biPredicate),
GeoP.<Geometry>validatedValue(biPredicate, value));
+ }
+
+ /**
+ * Constructs a {@code GeoP} with a child traversal whose result is
resolved at runtime against
+ * the current traverser.
+ *
+ * @since 4.0.0
+ */
+ public GeoP(final PBiPredicate<Object, Object> biPredicate, final
Traversal.Admin<?, ?> traversalValue) {
+ super(asGeometryPredicate(biPredicate), traversalValue);
+ }
+
+ /**
+ * Constructs a {@code GeoP} from a variable, whose value is validated
once it is resolved.
+ *
+ * @since 4.0.0
+ */
+ public GeoP(final PBiPredicate<Object, Object> biPredicate, final
GValue<?> value) {
+ super(asGeometryPredicate(biPredicate), asGeometryVariable(value));
+ validateConstants(biPredicate, null == value ? null : value.get());
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ return other instanceof GeoP && super.equals(other);
+ }
+
+ @Override
+ public P<Geometry> negate() {
+ return new NotP<>(this);
+ }
+
+ public GeoP clone() {
+ final GeoP clone = (GeoP) super.clone();
+ clone.variables = new HashMap<>(variables);
+ return clone;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * A new value for one of this predicate's variables is validated as the
same value given to a
+ * constructor would be, before it is kept.
+ */
+ @Override
+ public void updateVariable(final String name, final Object value) {
+ if (!variables.containsKey(name)) return;
+
+ validateConstants(biPredicate, value);
Review Comment:
Updated, thanks!
##########
gremlin-js/gremlin-javascript/lib/language/translator/AnonymizedTranslateVisitor.ts:
##########
@@ -170,3 +174,25 @@ export default class AnonymizedTranslateVisitor extends
TranslateVisitor {
}
}
}
+
+/** The Java simple class name of each geometry kind, keyed by its WKT type
keyword in upper case. */
+const GEOMETRY_KINDS: Record<string, string> = {
+ POINT: 'Point',
+ LINESTRING: 'LineString',
+ POLYGON: 'Polygon',
+ MULTIPOINT: 'MultiPoint',
+ MULTILINESTRING: 'MultiLineString',
+ MULTIPOLYGON: 'MultiPolygon',
+ GEOMETRYCOLLECTION: 'GeometryCollection',
+};
+
+/**
+ * Names the kind of a geometry literal from the type keyword that leads its
WKT, after an optional EWKT
+ * `SRID=n;` prefix, so that a point anonymizes as `point0` the way the Java
translator names it from the parsed
+ * geometry. A keyword that names none of the kinds falls back to `Geometry`.
+ */
+function geometryKind(ctx: any): string {
+ const text =
decodeStringLiteral(ctx.stringLiteral().getText()).trim().replace(/^srid=[^;]*;/i,
'').trim();
Review Comment:
Both anonymizers now name a geometry by its WKT type keyword, so
Geometry("POINT nonsense") is point0 in Java too.
> GEO Spatial APIs
> ----------------
>
> Key: TINKERPOP-2558
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2558
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.5.0
> Reporter: Jitesh
> Priority: Major
>
> Provide support for Geo based APIs (predicates, objects, etc)
>
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)