mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 17:36:40 +00:00
Fix for calculation of zoom factor for boat images with different sizes
This commit is contained in:
1 parent
a2290a770f
commit
28fd53a318
1 file changed
+8
-4
+8
-4
@@ -187,13 +187,14 @@ public class RaceMapResources {
|
||||
// the possible zoom level range is 0 to 21 (zoom level 0 would show the whole world)
|
||||
int zoomLevel = map == null ? 1 : map.getZoomLevel();
|
||||
double minScaleFactor = 0.33;
|
||||
double maxScaleFactor = 2.0;
|
||||
double realBoatSizeScaleFactor = minScaleFactor;
|
||||
// here it would be better to get the boat length from the boat class -> for now we assume a length of 5m
|
||||
double boatLengthInMeter = 5.0;
|
||||
double boatLengthInMeter = 5.0;
|
||||
// to scale the boats to a realistic size we need the length of the boat in pixel,
|
||||
// but it does not work to just take the image size, because the images for the different boat states can be different
|
||||
int boatLengthInPixel = 40;
|
||||
if (zoomLevel > 5) {
|
||||
int boatLengthInPixel = imageSize.getHeight();
|
||||
if(imageSize.getWidth() > boatLengthInPixel)
|
||||
boatLengthInPixel = imageSize.getWidth();
|
||||
LatLngBounds bounds = map.getBounds();
|
||||
if (bounds != null) {
|
||||
LatLng upperRight = bounds.getNorthEast();
|
||||
@@ -206,6 +207,9 @@ public class RaceMapResources {
|
||||
if (realBoatSizeScaleFactor < minScaleFactor) {
|
||||
realBoatSizeScaleFactor = minScaleFactor;
|
||||
}
|
||||
if (realBoatSizeScaleFactor > maxScaleFactor) {
|
||||
realBoatSizeScaleFactor = maxScaleFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
return realBoatSizeScaleFactor;
|
||||
|
||||
Reference in new issue
Block a user