Invalid WKT string provided to read() error in converting wkt to geojson using wicket

737 views Asked by At

I want to convert a wkt string received from a textarea in a function called onpaste. But I always got this error :

Invalid WKT string provided to read()

and this is my simple code and I know that my wkt is correct because I have tested it in another place :

var wkt_geom = document.getElementById("inwkt").value;

wkt = new Wkt.Wkt();
wkt.read(wkt_geom);

and this is my wkt :

LINESTRING (30 10, 10 30, 40 40)
1

There are 1 answers

0
Ramesh Ponnusamy On

In my case, wkt_geom variable has double quotes along with values. Replace those quotes and try it.

console.log('wkt_geom value is ',wkt_geom);
wkt_geom =wkt_geom.replace(/\"/g, "")