I am doing a project for a telecom company. I have to render circles on the map(assuming the center of the circle as tower and circle as the area covered by that signal), I am using base layers as Google Maps,Yahoo maps(Spherical Mercator) So I have used CreateGeodesicPolygon() successfully to create circles by reading the values from DB.

Now Since I have to render lot of circles, it made me switch to geoserver. Since the data is being provided by telecom company , they provide Lat,Lon,Gt,Gr,Pt,Pr,lambda(I think their meaning is irrelevant here) values. These values are stored in the database as they are. Now should use a equation(FRIIS transmission equation) and substitute each row(of a tower) values to find the distance covered by the tower.Then I have to create circles with that distance(considered as radius) and lon/lat and render them on map using geoserver.

How do I carry on this task?

My Idea is to use these steps once I get distance from the equation.

CREATE TABLE circles (cid int4,point_circle st_geometry);

INSERT INTO circles 
        ST_BUFFER(ST_GeomFromText('POINT(lon lat)',SRID),radius,'quad-segs=8')

Create a POSTGIS store in geoserver and this circles table as a layer.


3 Answers 3


Using EPSG:4326 you'll buffer in degrees, EPSG:900913 will let you buffer in meters. Google Mercator doesn't lead to correct length measurements but if you just want to get an approximate feel for your data, you should be fine.

This will create a view containing the circles in Google Mercator projection:

   ) AS tower_circle
FROM towers;

Have a look at this blog post http://geo-solutions.blogspot.com/2010/11/fun-stuff-computing-circular-buffers-in.html that discusses using the WPS service in GeoServer to produce circles. It also shows why what you are trying to do will probably not produce the results you expect for largish distances.


You can do it with JavaScript if you'd like and have the client browser take care of it: You can test the code on this website: http://jsfiddle.net/NtuEv/

Basically the function takes a 3 arguments: latitude, longitude and radius. It will return the coordinates that make up the circle.

You can play with the following line of code to output the coordinates however you like either in linestring fashion or whatever:

response += lon_rad.toDeg() + "," + lat_rad.toDeg() + ",0 ";

Javascript Code:

var divElement = $('div#info');

// extend Number object with methods for converting degrees/radians
/** Convert numeric degrees to radians */
if (typeof (String.prototype.toRad) === "undefined") {
    Number.prototype.toRad = function () {
        return this * Math.PI / 180;

/** Convert radians to numeric (signed) degrees */
if (typeof (String.prototype.toDeg) === "undefined") {
    Number.prototype.toDeg = function () {
        return this * 180 / Math.PI;

function fmod (X, Y) {
 return X % Y;

function GetCircleCoordinates (lat, lng, radius) {

        var response = "";
        var rLat = lat.toRad();
        var rLon = lng.toRad();

        var d_rad = radius / 6378137;

        for (i = 0; i <= 360; i++) {

            var radial = i.toRad();
            var lat_rad = Math.asin(Math.sin(rLat) * Math.cos(d_rad) + Math.cos(rLat) * Math.sin(d_rad) * Math.cos(radial));
            var dlon_rad = Math.atan2(Math.sin(radial) * Math.sin(d_rad) * Math.cos(rLat), Math.cos(d_rad) - Math.sin(rLat) * Math.sin(lat_rad));
            var lon_rad = fmod((rLon + dlon_rad + Math.PI), 2 * Math.PI) - Math.PI;
            response += lon_rad.toDeg() + "," + lat_rad.toDeg() + ",0 ";

        return response;

var circlecoords = GetCircleCoordinates(22.26, -73.34, 1100);


EDIT #1: Updated jsfiddle link.... it was wrong, it is: http://jsfiddle.net/NtuEv/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.