Skip to content

Commit

Permalink
fix bounding box of rotated projection
Browse files Browse the repository at this point in the history
  • Loading branch information
Karry committed May 21, 2023
1 parent 62facb7 commit 2da9716
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions libosmscout/src/osmscout/projection/MercatorProjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,27 @@ namespace osmscout {

PixelToGeo(0.0,0.0,topLeft);

GeoCoord topRight;

PixelToGeo((double)width,0.0,topRight);

GeoCoord bottomLeft;

PixelToGeo(0.0,(double)height,bottomLeft);

GeoCoord bottomRight;

PixelToGeo((double)width,(double)height,bottomRight);

// evaluate bounding box, crop bounding box to valid Mercator area

boundingBox=GeoBox(topLeft,bottomRight);

if (angle!=0.0) {
// be aware that top-left, bottom-right bounding box may not include top-right and bottom-left coordinates when projection is rotated
GeoCoord topRight;

PixelToGeo((double)width,0.0,topRight);

GeoCoord bottomLeft;

PixelToGeo(0.0,(double)height,bottomLeft);

boundingBox.Include(GeoBox(topRight, bottomLeft));
}

boundingBox.CropTo(GeoBox(GeoCoord(MinLat,MinLon),
GeoCoord(MaxLat,MaxLon)));

Expand Down

0 comments on commit 2da9716

Please sign in to comment.