mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 07:50:04 +00:00
Placefile polygon rendering
This commit is contained in:
parent
d9a53ea8d7
commit
cdef5a9938
8 changed files with 547 additions and 5 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/common/geographic.hpp>
|
||||
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
|
@ -157,6 +159,7 @@ public:
|
|||
};
|
||||
|
||||
std::vector<std::vector<Element>> contours_ {};
|
||||
scwx::common::Coordinate center_ {};
|
||||
};
|
||||
|
||||
bool IsValid() const;
|
||||
|
|
|
|||
|
|
@ -729,17 +729,30 @@ void Placefile::Impl::ProcessElementEnd()
|
|||
{
|
||||
if (currentStatement_ == DrawingStatement::Polygon)
|
||||
{
|
||||
auto di = std::static_pointer_cast<PolygonDrawItem>(currentDrawItem_);
|
||||
|
||||
// Complete the current contour when ending the Polygon statement
|
||||
if (!currentPolygonContour_.empty())
|
||||
{
|
||||
auto& contours =
|
||||
std::static_pointer_cast<PolygonDrawItem>(currentDrawItem_)
|
||||
->contours_;
|
||||
auto& contours = di->contours_;
|
||||
|
||||
auto& newContour =
|
||||
contours.emplace_back(std::vector<PolygonDrawItem::Element> {});
|
||||
newContour.swap(currentPolygonContour_);
|
||||
}
|
||||
|
||||
if (!di->contours_.empty())
|
||||
{
|
||||
std::vector<common::Coordinate> coordinates {};
|
||||
std::transform(di->contours_[0].cbegin(),
|
||||
di->contours_[0].cend(),
|
||||
std::back_inserter(coordinates),
|
||||
[](auto& element) {
|
||||
return common::Coordinate {element.latitude_,
|
||||
element.longitude_};
|
||||
});
|
||||
di->center_ = GetCentroid(coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue