GSoC/GCI Archive
Google Code-in 2014 KDE

Marble: Add Polygon Area feature

completed by: Ilya Kowalewski

mentors: Dennis Nienhüser, shentey, Sanjiban Bairagya, Torsten Rahn

The settings dialog for the Measure Tool contains an entry for Polygon "Area" measurement already.

Please enhance the Measure tool so that

- The setting for the Polygon Area is reenabled

In case the checkmark for the Area is set:

- the polyline ("lineString") that holds the measure points should be used ("casted" ?) as a linear ring and it should be filled in the same way as the circle area ruler.

- In the center of the area inside the polygon the text should be displayed in the same way as for the circle measure tool

- the value for the polygon area is calculated like this:

In a previous task the bearing change for each node was calculated. We need the bearing change for every single node in the polygon - so we need to calculate the bearing change for the first and last node in addition.

then we need to sum up all bearing changes for all n nodes:

theta1 = bearingChange1 + bearingChange2 + .... + bearingchangen

In addition we need to calculate:

theta2 = n * 2 * pi - theta1

Now we pick the smaller one to make a good guess for the inner angle set:

theta = (theta1 < theta2) ? theta1 : theta2

and we use theta to calculate the area:

S=[theta-(n-2)pi]R^2

Please verify the result value by roughly drawing along a border  of a country (e.g. poland, ukraine, france, germany or romania, etc.) and compare the resulting value with the one displayed when clicking the country label.