[ 
https://issues.apache.org/jira/browse/TINKERPOP-2558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18147688#comment-18147688
 ] 

ASF GitHub Bot commented on TINKERPOP-2558:
-------------------------------------------

GumpacG commented on code in PR #3809:
URL: https://github.com/apache/tinkerpop/pull/3809#discussion_r4631147159


##########
gremlin-js/gremlin-javascript/lib/language/translator/TranslateVisitor.ts:
##########
@@ -265,7 +276,73 @@ export default class TranslateVisitor {
     }
 
     visitTraversalGType(ctx: any): void {
-        this.appendExplicitNaming(ctx.getText(), 'GType');
+        
this.appendExplicitNaming(TranslateVisitor.extractGTypeName(ctx).toUpperCase(), 
'GType');
+    }
+
+    visitGeoModel(ctx: any): void {
+        this.appendExplicitNaming(ctx.getText(), 'Model');
+    }
+
+    /**
+     * 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 decoded
+     * from the Gremlin string literal and written back escaped for a JVM 
string literal, since this translator
+     * has no WKT reader of its own to normalize the text through. The 
whitespace the JVM WKT reader skips at
+     * either end is dropped, while the whitespace within the text is kept as 
written.
+     */
+    protected appendGeometryFromWkt(ctx: any): void {
+        const text = decodeStringLiteral(ctx.stringLiteral().getText()).trim();
+        // an EWKT SRID= prefix moves into the second argument, and must agree 
with an explicit model or SRID
+        const prefix = /^srid=\s*([+-]?\d+)\s*;/i.exec(text);
+        const ewktSrid = prefix !== null ? BigInt(prefix[1]) : null;

Review Comment:
   Fixed, the prefix now gets the Java translator's ten-digit and signed 32-bit 
checks.





> 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)

Reply via email to