1

I'm developing a webGIS website where I draw circles from two sources:

  • a mapserver mapfile that "draws" them from PostGIS (red circles in image). The circles are created with ST_Buffer, eg

    ST_Buffer(ST_GeomFromText('POINT(A B)', 4326), 0.072414686825054, 'quad_segs=32')

My mapfile serves in 4326 and 3857.

  • Via Openlayers (blue concentric circles in image), either via

    var wgs84Sphere = new ol.Sphere(6378137);
    new ol.Feature(ol.geom.Polygon.circular(wgs84Sphere, GPS_pos_4326, i * 5 * 1852, 64).transform('EPSG:4326', 'EPSG:3857'));

or via turf, then creating an OL polygon, by using turf's destination function.

I understand that projecting a circle in "Google Mercator" should produce ellipses when not on the equator, so the behavior is expected.

But how could I do the same thing via OL?

PostGIS/MapServer circles vs. Openlayers circles

3
  • 1
    On the other hand, maybe circles should be drawn as real circles on web mercator...
    – bluecap
    Jun 20, 2018 at 18:47
  • 1
    +1 for the other hand
    – geozelot
    Jun 20, 2018 at 20:06
  • You were right. In web mercator circles must appear as circles (their only peculiarity being that they appear larger when moving to the poles).
    – bluecap
    Jun 21, 2018 at 9:09

1 Answer 1

1

It seems that in web mercator circles must appear as circles (their only peculiarity being that they appear larger when moving to the poles). This is explained here: Tissot's indicatrix and for OL here: OL Tissot's indicatrix example

The way I overcame the problem was to insert all my geometries into PostGIS in web mercator and have the mapfile read them as such.

For this I used ST_Translate, eg

ST_Buffer(ST_Transform(ST_GeomFromText('POINT($lon $lat)', 4326), 3785), $rad, 'quad_segs=32');

Your Answer

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

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