[Marble-devel] How to draw ellipse with GeoPainter at GeoDataCoordinate(center) and specific radius in km not pixel?!

Torsten Rahn tackat at t-online.de
Tue Apr 19 11:35:07 UTC 2016


 
Hi,
 
There is no ready-made method to accomplish this. You can use the 
GeoDataCoordinates::moveByBearing(angle, angleLength) method to create a 
circle: This allows for calculating the coordinates of a polygon that 
approximates a circle. Then use GeoPainter::drawPolygon(GeoDataLinearRing) 
. We are actually doing this inside our measure tool plugin.
 
See src/plugins/render/measure/MeasureToolPlugin.cpp , line 317-327 . We 
are iterating over coordinates there in order to draw a circular pie shape. 
For a full circle you'd just have to iterate over the full 360° instead:
 
 
GeoDataLinearRing ring;
 
[...]

while ( iterBearing < currentBearing ) {
     ring << currentCoordinates.moveByBearing( iterBearing, angleLength );;
     iterBearing += 0.1;
}

[...]
 
painter->drawPolygon( ring );
 
If you have questions don't hesitate to ask.
 
 
 
 
 
-----Original-Nachricht-----
Betreff: [Marble-devel] How to draw ellipse with GeoPainter at 
GeoDataCoordinate(center) and specific radius in km not pixel?!
Datum: 2016-04-19T13:19:05+0200
Von: "Farzad Karamouz" <farzadkaramouz at gmail.com>
An: "marble-devel at kde.org" <marble-devel at kde.org>
 
 
 
Hi,
I want to draw an ellipse in specific point width specific radius (km). For 
example:
 
GeoDataCoordinate center(lat, lon, alt, GeoDataCoordinates::Degree);
qreal width = 100; // Unit is KM not Pixel
qreal height = 100; // Unit is KM not Pixel
painter->drawEllipse(center, width, height, false);
 
how can i do this?! 
or 
how can i convert km to pixel to use in drawEllipse() ?!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/marble-devel/attachments/20160419/1dcf40df/attachment.html>


More information about the Marble-devel mailing list