[GIS] Using WKT.writeGeometry for ‘Circle’ Geometry in OpenLayers

circlegeometryopenlayerswell-known-text

In my application which I'm building using OpenLayers3, I'm trying to extract the geometry of a feature to WKT using

var format = new ol.format.WKT();
console.log(format.writeGeometry(geometry));
by following this docs.

It works great for Polygon as I have tested, i.e. returning the Geometry String (WKT) but it fails when I try to apply it to Circle Geometry. In particular the log is printed as

Assertion failed: geometryEncoder should be defined

So, is there any solution to this as why this is particularly happening with Circle geometries. And how to resolve it, i.e. where to define this geometryEncoder as suggested in log?

Best Answer

The circle geometry (a center with a radius) is not a supported by the WKT format.

Your best chance is to transofrm your Circle geometry in an approximate Polygon with the circular function