Skip to content

Commit

Permalink
Merge pull request #1137 from Framstag/issue_1045_3
Browse files Browse the repository at this point in the history
Further cleanup of MapPainter and Co.
  • Loading branch information
Framstag authored Oct 14, 2021
2 parents 4049f28 + 8cf50ec commit f498f98
Show file tree
Hide file tree
Showing 11 changed files with 277 additions and 243 deletions.
6 changes: 3 additions & 3 deletions libosmscout-map-agg/src/osmscout/MapPainterAgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,9 @@ namespace osmscout {
for (const auto& data : area.clippings) {
agg::path_storage clipPath;

clipPath.move_to(coordBuffer.buffer[data.transStart].GetX(),
coordBuffer.buffer[data.transStart].GetY());
for (size_t i=data.transStart+1; i<=data.transEnd; i++) {
clipPath.move_to(coordBuffer.buffer[data.GetStart()].GetX(),
coordBuffer.buffer[data.GetStart()].GetY());
for (size_t i=data.GetStart()+1; i<=data.GetEnd(); i++) {
clipPath.line_to(coordBuffer.buffer[i].GetX(),
coordBuffer.buffer[i].GetY());
}
Expand Down
6 changes: 3 additions & 3 deletions libosmscout-map-cairo/src/osmscout/MapPainterCairo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,9 +1347,9 @@ namespace osmscout {
cairo_new_sub_path(draw);
cairo_set_line_width(draw,0.0);
cairo_move_to(draw,
coordBuffer.buffer[data.transStart].GetX(),
coordBuffer.buffer[data.transStart].GetY());
for (size_t i=data.transStart+1; i<=data.transEnd; i++) {
coordBuffer.buffer[data.GetStart()].GetX(),
coordBuffer.buffer[data.GetStart()].GetY());
for (size_t i=data.GetStart()+1; i<=data.GetEnd(); i++) {
cairo_line_to(draw,
coordBuffer.buffer[i].GetX(),
coordBuffer.buffer[i].GetY());
Expand Down
11 changes: 5 additions & 6 deletions libosmscout-map-directx/src/osmscout/MapPainterDirectX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,10 +976,7 @@ namespace osmscout
m_pRenderTarget->DrawGeometry(pPathGeometry, GetColorBrush(borderStyle->GetColor()), borderWidth, GetStrokeStyle(borderStyle->GetDash()));
pPathGeometry->Release();

for (std::list<PolyData>::const_iterator c = area.clippings.begin();
c != area.clippings.end();
c++) {
const PolyData &data = *c;
for (const auto& data : area.clippings) {
ID2D1PathGeometry* pPathGeometry;
HRESULT hr = m_pDirect2dFactory->CreatePathGeometry(&pPathGeometry);
if (SUCCEEDED(hr))
Expand All @@ -988,9 +985,11 @@ namespace osmscout
hr = pPathGeometry->Open(&pSink);
if (SUCCEEDED(hr))
{
pSink->BeginFigure(POINTF(coordBuffer.buffer[data.transStart].GetX(), coordBuffer.buffer[data.transStart].GetY()), D2D1_FIGURE_BEGIN_FILLED);
pSink->BeginFigure(POINTF(coordBuffer.buffer[data.GetStart()].GetX(),
coordBuffer.buffer[data.GetStart()].GetY()),
D2D1_FIGURE_BEGIN_FILLED);

for (size_t i = data.transStart + 1; i <= data.transEnd; i++) {
for (size_t i = data.GetStart() + 1; i <= data.GetEnd(); i++) {
pSink->AddLine(POINTF(coordBuffer.buffer[i].GetX(), coordBuffer.buffer[i].GetY()));
}
pSink->EndFigure(D2D1_FIGURE_END_CLOSED);
Expand Down
7 changes: 2 additions & 5 deletions libosmscout-map-gdi/src/osmscout/MapPainterGDI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,13 +747,10 @@ namespace osmscout {
Gdiplus::Region* region;
};
std::vector<clippingRegion> clippingInfo;
for (std::list<PolyData>::const_iterator c = area.clippings.begin();
c != area.clippings.end();
++c) {
const PolyData &data = *c;
for (const auto& data : area.clippings) {
clippingRegion cr;
cr.points = new PointFBuffer();
for (size_t i = data.transStart; i <= data.transEnd; i++) {
for (size_t i = data.GetStart(); i <= data.GetEnd(); i++) {
cr.points->AddPoint(coordBuffer.buffer[i].GetX(), coordBuffer.buffer[i].GetY());
}
cr.points->Close();
Expand Down
6 changes: 3 additions & 3 deletions libosmscout-map-iosx/src/osmscout/MapPainterIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -914,9 +914,9 @@ static void DrawPattern (void * info,CGContextRef cg){

if (!area.clippings.empty()) {
for (const auto& data : area.clippings) {
CGContextMoveToPoint(cg,coordBuffer.buffer[data.transStart].GetX(),
coordBuffer.buffer[data.transStart].GetY());
for (size_t i=data.transStart+1; i<=data.transEnd; i++) {
CGContextMoveToPoint(cg,coordBuffer.buffer[data.GetStart()].GetX(),
coordBuffer.buffer[data.GetStart()].GetY());
for (size_t i=data.GetStart()+1; i<=data.GetEnd(); i++) {
CGContextAddLineToPoint(cg,coordBuffer.buffer[i].GetX(),
coordBuffer.buffer[i].GetY());
}
Expand Down
6 changes: 3 additions & 3 deletions libosmscout-map-qt/src/osmscout/MapPainterQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,10 @@ namespace osmscout {

if (!area.clippings.empty()) {
for (const auto& data : area.clippings) {
path.moveTo(coordBuffer.buffer[data.transStart].GetX(),
coordBuffer.buffer[data.transStart].GetY());
path.moveTo(coordBuffer.buffer[data.GetStart()].GetX(),
coordBuffer.buffer[data.GetStart()].GetY());

for (size_t i=data.transStart+1; i<=data.transEnd; i++) {
for (size_t i=data.GetStart()+1; i<=data.GetEnd(); i++) {
path.lineTo(coordBuffer.buffer[i].GetX(),
coordBuffer.buffer[i].GetY());
}
Expand Down
10 changes: 3 additions & 7 deletions libosmscout-map-svg/src/osmscout/MapPainterSVG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,13 +1013,9 @@ namespace osmscout {
}
stream << " Z";

for (std::list<PolyData>::const_iterator c=area.clippings.begin();
c!=area.clippings.end();
++c) {
const PolyData &data=*c;

stream << "M " << coordBuffer.buffer[data.transStart].GetX() << " " << coordBuffer.buffer[data.transStart].GetY();
for (size_t i=data.transStart+1; i<=data.transEnd; i++) {
for (const auto& data : area.clippings) {
stream << "M " << coordBuffer.buffer[data.GetStart()].GetX() << " " << coordBuffer.buffer[data.GetStart()].GetY();
for (size_t i=data.GetStart()+1; i<=data.GetEnd(); i++) {
stream << " L " << coordBuffer.buffer[i].GetX() << " " << coordBuffer.buffer[i].GetY();
}
stream << " Z";
Expand Down
33 changes: 18 additions & 15 deletions libosmscout-map/include/osmscoutmap/MapPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,20 @@ namespace osmscout {
double mainSlotWidth; //!< Width of main slot, used for relative positioning
};

struct OSMSCOUT_MAP_API PolyData
{
size_t transStart; //!< Start of coordinates in transformation buffer
size_t transEnd; //!< End of coordinates in transformation buffer (inclusive)
};

/**
* Data structure for holding temporary data about areas
*/
struct OSMSCOUT_MAP_API AreaData
{
ObjectFileRef ref;
TypeInfoRef type;
const FeatureValueBuffer *buffer; //!< Features of the line segment, can be NULL in case of border only areas
FillStyleRef fillStyle; //!< Fill style
BorderStyleRef borderStyle; //!< Border style
GeoBox boundingBox; //!< Bounding box of the area
bool isOuter; //!< flag if this area is outer ring of some relation
CoordBufferRange coordRange; //!< Range of coordinates in transformation buffer
std::list<PolyData> clippings; //!< Clipping polygons to be used during drawing of this area
ObjectFileRef ref;
TypeInfoRef type;
const FeatureValueBuffer *buffer; //!< Features of the line segment, can be NULL in case of border only areas
FillStyleRef fillStyle; //!< Fill style
BorderStyleRef borderStyle; //!< Border style
GeoBox boundingBox; //!< Bounding box of the area
bool isOuter; //!< flag if this area is outer ring of some relation
CoordBufferRange coordRange; //!< Range of coordinates in transformation buffer
std::list<CoordBufferRange> clippings; //!< Clipping polygons to be used during drawing of this area
};

using WayPathDataIt=std::list<WayPathData>::iterator;
Expand Down Expand Up @@ -316,6 +310,15 @@ namespace osmscout {
const MapParameter& parameter,
const MapData& data);

bool PrepareAreaRing(const StyleConfig& styleConfig,
const Projection& projection,
const MapParameter& parameter,
const std::vector<CoordBufferRange>& coordRanges,
const Area& area,
const Area::Ring& ring,
size_t i,
const TypeInfoRef& type);

void PrepareArea(const StyleConfig& styleConfig,
const Projection& projection,
const MapParameter& parameter,
Expand Down
Loading

0 comments on commit f498f98

Please sign in to comment.