Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix coastlines rendering #339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/Map/MapPrimitiviser_P.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ std::shared_ptr<OsmAnd::MapPrimitiviser_P::PrimitivisedObjects> OsmAnd::MapPrimi

if (detailedmapCoastlinesPresent)
{
isDeterminedSurfaceType = determineSurfaceType(center, detailedmapCoastlineObjects, surfaceType);
isDeterminedSurfaceType = determineSurfaceType(center, area31, detailedmapCoastlineObjects, surfaceType);
}

if (!isDeterminedSurfaceType && basemapCoastlinesPresent)
{
determineSurfaceType(center, basemapCoastlineObjects, surfaceType);
determineSurfaceType(center, area31, basemapCoastlineObjects, surfaceType);
}
}

Expand Down Expand Up @@ -425,7 +425,7 @@ std::shared_ptr<OsmAnd::MapPrimitiviser_P::PrimitivisedObjects> OsmAnd::MapPrimi
return primitivisedObjects;
}

bool OsmAnd::MapPrimitiviser_P::determineSurfaceType(PointI center, QList<std::shared_ptr<const MapObject> > & coastlineObjects, OsmAnd::MapSurfaceType & surfaceType)
bool OsmAnd::MapPrimitiviser_P::determineSurfaceType(PointI center, const AreaI area31, QList<std::shared_ptr<const MapObject> > & coastlineObjects, OsmAnd::MapSurfaceType & surfaceType)
{
std::shared_ptr<const MapObject> neareastCoastlineMapObject;
PointI nearestCoastlineSegment0;
Expand Down Expand Up @@ -491,9 +491,24 @@ bool OsmAnd::MapPrimitiviser_P::determineSurfaceType(PointI center, QList<std::s
// Rule: Water is always on the right along the direction of coastline segment.
if (neareastCoastlineMapObject)
{
const auto sign = crossProductSign(nearestCoastlineSegment0, nearestCoastlineSegment1, mCenter);
surfaceType = (sign >= 0) ? MapSurfaceType::FullLand : MapSurfaceType::FullWater;
return true;
// Filter too short nearest coastline for detailed maps.
// Rule: to correct calulation coastline should be greater then 1/10 of tilesize.
// Size of any detailed map tile is equal tile of ZoomLevel14.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it the same code in core-legacy? if not the bug should be reproducible in core-legacy

const auto detailTileSideDistance31 = Utilities::roundBoundingBox31(area31, ZoomLevel14).width();
const auto minDistanceLimit31 = detailTileSideDistance31 / 10;
PointI coastlineDiff = nearestCoastlineSegment0 - nearestCoastlineSegment1;
const auto nearestCoastlineSegmentDistance31 = std::sqrt(std::pow(coastlineDiff.x, 2) + std::pow(coastlineDiff.y, 2));

if (nearestCoastlineSegmentDistance31 > minDistanceLimit31)
{
const auto sign = crossProductSign(nearestCoastlineSegment0, nearestCoastlineSegment1, mCenter);
surfaceType = (sign >= 0) ? MapSurfaceType::FullLand : MapSurfaceType::FullWater;
return true;
}
else
{
return false;
}
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Map/MapPrimitiviser_P.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace OsmAnd
const std::shared_ptr<const MapObject>& object,
const QString& genTagVal);

static bool determineSurfaceType(PointI center, QList< std::shared_ptr<const MapObject> > & coastlineObjects, OsmAnd::MapSurfaceType & surfaceType);
static bool determineSurfaceType(PointI center, const AreaI area31, QList< std::shared_ptr<const MapObject> > & coastlineObjects, OsmAnd::MapSurfaceType & surfaceType);

public:
~MapPrimitiviser_P();
Expand Down