ViewController: moveTo respects Viewport limits, fixes #12

This commit is contained in:
Emux 2016-06-17 15:14:07 +03:00
parent 7a952cdaf9
commit e85ec48468

View File

@ -1,3 +1,19 @@
/*
* Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.map;
import static org.oscim.utils.FastMath.clamp;
@ -89,6 +105,17 @@ public class ViewController extends Viewport {
mPos.x -= 1;
while (mPos.x < 0)
mPos.x += 1;
/* limit longitude */
if (mPos.x > mMaxX)
mPos.x = mMaxX;
else if (mPos.x < mMinX)
mPos.x = mMinX;
/* limit latitude */
if (mPos.y > mMaxY)
mPos.y = mMaxY;
else if (mPos.y < mMinY)
mPos.y = mMinY;
}
private Point applyRotation(double mx, double my) {