Converter

The Converter class provides static utility methods for translating geographical data between common formats, including **GeoJSON**, **WKT (Well-Known Text)**, **Encoded Polyline**, and **Flexible Polyline**.

This class is designed to be used statically. You do not need to instantiate it.

Static Methods

Flexible Polyline Conversion ⚡

flexiblepolylineFromGeoJSON()
static flexiblepolylineFromGeoJSON(GeoJSON: string): string

Encodes a GeoJSON LineString or MultiLineString into a **Flexible Polyline** string (a proprietary, highly precise encoding format).

Parameters:

Parameter Type Description
GeoJSON string The input GeoJSON string (must represent a line geometry).
Returns: string (The Flexible Polyline string)

Example:

var geojson = { "type": "LineString", "coordinates": [ [72.823, 19.045], [72.824, 19.046], [72.825, 19.047] ] };
var flexiblepolyline=gtswebsdkgl.conveter.flexiblepolylineFromGeoJSON(geojson);
console.log(flexiblepolyline);
flexiblepolylineFromWKT()
static flexiblepolylineFromWKT(wkt: string): string

Encodes a WKT LINESTRING or MULTILINESTRING into a **Flexible Polyline** string.

Parameters:

Parameter Type Description
wkt string The input WKT string (must represent a line geometry).
Returns: string (The Flexible Polyline string)
var wkt = "LINESTRING (72.823 19.045, 72.824 19.046, 72.825 19.047)";
var flexiblepolyline=gtswebsdkgl.conveter.flexiblepolylineFromWKT(wkt);
console.log(flexiblepolyline);
flexiblepolylineToGeoJSON()
static flexiblepolylineToGeoJSON(flexiblepolyline: string): string

Decodes a **Flexible Polyline** string back into a GeoJSON LineString string.

Parameters:

Parameter Type Description
flexiblepolyline string The Flexible Polyline string to decode.
Returns: string (The GeoJSON LineString string)
var geojson=gtswebsdkgl.conveter.flexiblepolylineToGeoJSON('BFo3n0D4nv8NoGoGoGoG');
console.log(geojson);
flexiblepolylineToWKT()
static flexiblepolylineToWKT(flexiblepolyline: string): string

Decodes a **Flexible Polyline** string back into a WKT LINESTRING string.

Parameters:

Parameter Type Description
flexiblepolyline string The Flexible Polyline string to decode.
Returns: string (The WKT LINESTRING string)
var wkt=gtswebsdkgl.conveter.flexiblepolylineToWKT('BFo3n0D4nv8NoGoGoGoG');
console.log(wkt);

GeoJSON and WKT Conversion 🌐

geoJSONToWkt()
static geoJSONToWkt(GeoJSON: string): string

Converts a GeoJSON string (any geometry type) into its equivalent **WKT** representation.

Parameters:

Parameter Type Description
GeoJSON string The input GeoJSON string.
Returns: string (The WKT string)
gtswebsdkgl.conveter.geoJSONToWkt({
 "type": "Feature",
 "geometry": {
 "type": "LineString",
 "coordinates": [
     [ 72.823, 19.045 ], [ 72.824, 19.046], [ 72.825, 19.047]
     ]
   },
 "properties": {}
});
wktToGeoJSON()
static wktToGeoJSON(wkt: string): string

Converts a WKT string (any geometry type) into its equivalent **GeoJSON** representation.

Parameters:

Parameter Type Description
wkt string The input WKT string.
Returns: string (The GeoJSON string)
gtswebsdkgl.conveter.wktToGeoJSON("LINESTRING (72.823 19.045, 72.824 19.046, 72.825 19.047)");

Encoded Polyline Conversion 📐

polylineFromGeoJson()
static polylineFromGeoJson(GeoJSON: string): string

Encodes a GeoJSON LineString or MultiLineString into a standard **Encoded Polyline** string (with 5-decimal precision).

Parameters:

Parameter Type Description
GeoJSON string The input GeoJSON string (must represent a line geometry).
Returns: string (The Encoded Polyline string)
gtswebsdkgl.conveter.polylineFromGeoJson({ "type": "Feature", "geometry": { "type": "LineString", "coordinates": [ [ 72.823, 19.045 ], [ 72.824, 19.046 ], [ 72.825, 19.047 ] ] }, "properties": {} });
polylineFromWkt()
static polylineFromWkt(wkt: string): string

Encodes a WKT LINESTRING or MULTILINESTRING into a standard **Encoded Polyline** string.

Parameters:

Parameter Type Description
wkt string The input WKT string (must represent a line geometry).
Returns: string (The Encoded Polyline string)
gtswebsdkgl.conveter.polylineFromWkt("LINESTRING (72.823 19.045, 72.824 19.046, 72.825 19.047)");
polylineToGeoJSON()
static polylineToGeoJSON(polyline: string): string

Decodes a standard **Encoded Polyline** string back into a GeoJSON LineString string.

Parameters:

Parameter Type Description
polyline string The Encoded Polyline string to decode.
Returns: string (The GeoJSON LineString string)
gtswebsdkgl.conveter.polylineToGeoJSON('gvfsBwfn{LgEgEgEgE');
polylineToWkt()
static polylineToWkt(polyline: string): string

Decodes a standard **Encoded Polyline** string back into a WKT LINESTRING string.

Parameters:

Parameter Type Description
polyline string The Encoded Polyline string to decode.
Returns: string (The WKT LINESTRING string)
gtswebsdkgl.conveter.polylineToWkt('gvfsBwfn{LgEgEgEgE');