[
https://issues.apache.org/jira/browse/TINKERPOP-2558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146992#comment-18146992
]
ASF GitHub Bot commented on TINKERPOP-2558:
-------------------------------------------
GumpacG commented on code in PR #3809:
URL: https://github.com/apache/tinkerpop/pull/3809#discussion_r4622641147
##########
gremlin-js/gremlin-javascript/lib/language/translator/TranslateVisitor.ts:
##########
@@ -268,6 +278,55 @@ export default class TranslateVisitor {
this.appendExplicitNaming(ctx.getText(), 'GType');
}
+ /**
+ * Extracts the name of the type from a `GType` which may be written with
or without the `GType`
+ * prefix and in either the camel case or the upper case form, as in
`lineString` and `LINESTRING`.
+ */
+ protected static extractGTypeName(ctx: any): string {
+ const split: string[] = ctx.getText().split('.');
+ return split[split.length - 1];
+ }
+
+ /**
+ * Determines if a `GType` names a geometry type, which the translators
that have no geometry support use
+ * to reject the type.
+ */
+ protected static isGeometryGType(ctx: any): boolean {
+ return
TranslateVisitor.GEOMETRY_GTYPE_NAMES.has(TranslateVisitor.extractGTypeName(ctx).toUpperCase());
+ }
+
+ /**
+ * Appends `Geometry.fromWkt("...")`, the form the JVM languages use since
they have a WKT reader, with
+ * `Model.GEOGRAPHIC` or the SRID as a second argument where the geometry
carries one. The WKT is written
+ * as the Gremlin spells it, since this translator has no WKT reader of
its own to normalize it through.
+ * WKT holds no quote or backslash, so the text needs no escaping.
+ */
+ protected appendGeometryFromWkt(ctx: any): void {
+ this.sb.push('Geometry.fromWkt("');
+
this.sb.push(TranslateVisitor.removeFirstAndLastCharacters(ctx.stringLiteral().getText()));
Review Comment:
Fixed, the string is decoded like GenericLiteralVisitor.visitStringLiteral
and written with JSON.stringify
##########
gremlin-js/gremlin-javascript/lib/language/translator/TranslateVisitor.ts:
##########
@@ -268,6 +278,55 @@ export default class TranslateVisitor {
this.appendExplicitNaming(ctx.getText(), 'GType');
Review Comment:
Fixed, names are upper-cased as in the Java translator.
##########
gremlin-js/gremlin-javascript/lib/language/translator/TranslateVisitor.ts:
##########
@@ -450,3 +536,38 @@ export default class TranslateVisitor {
this.visitChildren(ctx);
}
}
+
+// ─── Helpers
─────────────────────────────────────────────────────────────────
+
+/** The SRID of the CARTESIAN model. */
+const CARTESIAN_SRID = 0;
+
+/** The SRID of the GEOGRAPHIC model, which is WGS84. */
+const GEOGRAPHIC_SRID = 4326;
+
+/**
+ * Reads the SRID of a geometry literal, which the grammar writes in the
decimal, hexadecimal or octal
+ * form, with underscore separators and an optional integer type suffix.
+ */
+function parseSridLiteral(text: string): number {
Review Comment:
Fixed, the SRID is read exactly with BigInt, with suffix ranges and the
32-bit range enforced.
> 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)