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 ⚡
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). |
string (The Flexible Polyline string)Example:
var flexiblepolyline=gtswebsdkgl.conveter.flexiblepolylineFromGeoJSON(geojson);
console.log(flexiblepolyline);
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). |
string (The Flexible Polyline string)var flexiblepolyline=gtswebsdkgl.conveter.flexiblepolylineFromWKT(wkt);
console.log(flexiblepolyline);
Decodes a **Flexible Polyline** string back into a GeoJSON
LineString string.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| flexiblepolyline | string | The Flexible Polyline string to decode. |
string (The GeoJSON LineString string)console.log(geojson);
Decodes a **Flexible Polyline** string back into a WKT
LINESTRING string.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| flexiblepolyline | string | The Flexible Polyline string to decode. |
string (The WKT LINESTRING string)console.log(wkt);
GeoJSON and WKT Conversion 🌐
Converts a GeoJSON string (any geometry type) into its equivalent **WKT** representation.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| GeoJSON | string | The input GeoJSON string. |
string (The WKT string)"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[ 72.823, 19.045 ], [ 72.824, 19.046], [ 72.825, 19.047]
]
},
"properties": {}
});
Converts a WKT string (any geometry type) into its equivalent **GeoJSON** representation.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| wkt | string | The input WKT string. |
string (The GeoJSON string)Encoded Polyline Conversion 📐
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). |
string (The Encoded Polyline 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). |
string (The Encoded Polyline 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. |
string (The GeoJSON LineString 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. |
string (The WKT LINESTRING string)