]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - src/tim/prune/gui/map/MapPosition.java
Version 20.1, December 2020
[GpsPrune.git] / src / tim / prune / gui / map / MapPosition.java
index 25f05fc1a2a238370d8888ea4b807b7d3f5f8adb..a62d7821c6b1d54db906b73949449b4ef26a39a2 100644 (file)
@@ -17,6 +17,8 @@ public class MapPosition
        private int _zoom = 12;
        /** Factor to zoom by, 2 to the power of zoom */
        private int _zoomFactor = 1 << _zoom;
+       /** Flag to mark if this position has ever been set */
+       private boolean _empty = true;
        /** Maximum zoom level */
        private static final int MAX_ZOOM = 21;
 
@@ -47,10 +49,12 @@ public class MapPosition
                        }
                }
                if (requiredZoom < 2) requiredZoom = 2;
+               else if (requiredZoom > 18) requiredZoom = 18;
                // Set position
                setZoom(requiredZoom);
                _xPosition = transformToPixels((inMinX + inMaxX) / 2.0);
                _yPosition = transformToPixels((inMinY + inMaxY) / 2.0);
+               _empty = false;
        }
 
        /**
@@ -61,6 +65,7 @@ public class MapPosition
        {
                _zoom = inZoom;
                _zoomFactor = 1 << _zoom;
+               _empty = false;
        }
 
        /**
@@ -93,6 +98,7 @@ public class MapPosition
                // Set position
                _xPosition = (_xPosition - inWidth/2 + (inMinX + inMaxX) / 2) * multFactor;
                _yPosition = (_yPosition - inHeight/2 + (inMinY + inMaxY) / 2) * multFactor;
+               _empty = false;
        }
 
        /**
@@ -277,4 +283,12 @@ public class MapPosition
                _xPosition += inDeltaX;
                _yPosition += inDeltaY;
        }
+
+       /**
+        * @return true if this position has never been set
+        */
+       public boolean isEmpty()
+       {
+               return _empty;
+       }
 }