osgEarth::CircleNode Radius and SRS Relation

40 views Asked by At

I want to show a CircleNode in the map. But the radius that I see is not right when I actually measure it.

  osg::ref_ptr<CircleNode> circle = new CircleNode();
  circle->setPosition(center); // center has the same srs as the map
  circle->setRadius(Distance(2000, Units::METERS));
  ...

When I create a line it shows correct distance

auto centerPoint = m_Center.transform(m_Center.getSRS()->getGeographicSRS());
    double outLon;
    double outLat;
    GeoMath::destination(osgEarth::deg2rad(centerPoint.y()),
      osgEarth::deg2rad(centerPoint.x()), osgEarth::deg2rad(angle),
      radius.as(Units::METERS), outLat, outLon); // move 2km

    centerPoint.x() = osgEarth::rad2deg(outLon);
    centerPoint.y() = osgEarth::rad2deg(outLat);
    const auto endPoint = wgsCenterPoint.transform(m_Center.getSRS());
  ...

In the picture below, the red circle's radius is 2km.

Line vs CircleNode

The map profile is

+proj=webmerc +a=6378137 +b=6378137 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +towgs84=0,0,0,0,0,0,0 +no_defs

The map source is http://[abc].tile.openstreetmap.org/{z}/{x}/{y}.png (spherical-mercator)

What am I missing?
Thanks

Edit

It seems CircleNode doesn't pass SRS to the GeometryFactory.

https://github.com/gwaldron/osgearth/blob/fd58fbbaa658ed731e6e823af0c2c2148bf58a2d/src/osgEarth/CircleNode.cpp#L149C5-L149C21

0

There are 0 answers