[GIS] Get Radius in epsg 4326 with Openlayers 3

coordinate systemgeodesicmap-drawingMeasurementsopenlayers

What is the best method for getting the radius of a circle in Openlayers 3 in epsg 4326 (geodesic)? I'm using this example for a base and trying to draw a circle while getting the radius, but using proj 4326 is proving difficult.
Here's my code:

var pointerMoveHandler = function(evt) {
   if (evt.dragging) {
     return;
  }
var tooltipCoord = evt.coordinate;

  if (sketch) {
    var output;
    var geom = (sketch.getGeometry());
    if (geom instanceof ol.geom.Cirlce) {
      output = formatCircle(/** @type {ol.geom.Circle} */ (geom));
      tooltipCoord = geom.getCenter().getRadius();

    measureTooltipElement.innerHTML = output;
    measureTooltip.setPosition(tooltipCoord);
  }
};

var sourceProj = map.getView().getProjection();
    var geom = /** @type {ol.geom.Circle} */(Circle.clone().transform(
        sourceProj, 'EPSG:4326'));
    var center= geom.getRadius;
    radius = Math.abs(wgs84Sphere.geodesicArea(center));
var output;
  if (area > 10000) {
    output = (Math.round(area / 1000000 * 100) / 100) +
        ' ' + 'km<sup>2</sup>';
  } else {
    output = (Math.round(area * 100) / 100) +
        ' ' + 'm<sup>2</sup>';
  }
  return output;
};

radius = Math.abs(wgs84Sphere.geodesicArea(center)); isn't right, but I'm not sure what to put there….

Best Answer

Found it..

var formatRadius = function(Circle) { 
    var radius; 
        if (geodesicCheckbox.checked) { 
            var center = Circle.getCenter();
                var pointOnPerimeter = [center[0], center[1] + Circle.getRadius()]
            var sourceProj = map.getView().getProjection(); 
                var c1 = ol.proj.transform(center, sourceProj, 'EPSG:4326'); 
                var c2 = ol.proj.transform(pointOnPerimeter, sourceProj,                    'EPSG:4326'); 
                radius = wgs84Sphere.haversineDistance(c1, c2); 
        } else { 
             radius = Math.round(Circle.getRadius() * 100) / 100; 
        } 
        var output; 
         if (radius > 100) { 
            output = (Math.round(radius / 1000 * 100) / 100) + ' ' + 'km'; 
        } else { 
                output = (Math.round(radius * 100) / 100) + ' ' + 'm'; 
        } 
    return output; 
};