Package org.oscim.map
Class Viewport
java.lang.Object
org.oscim.map.Viewport
- Direct Known Subclasses:
GLViewport,ViewController
The Viewport class contains a MapPosition and the projection matrices.
It provides functions to modify the MapPosition and translate between
map and screen coordinates.
Public methods are thread safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatLimited by:static final intprotected floatHeight and width in pixelsstatic final floatstatic final intprotected floatprotected floatprotected doubleprotected floatprotected doubleprotected doubleprotected floatprotected floatprotected doubleprotected floatprotected doubleprotected doubleprotected final Pointprotected final MapPositionprotected final GLMatrixprotected final GLMatrixprotected final GLMatrixprotected final GLMatrixprotected final GLMatrixprotected final float[]protected final GLMatrixprotected final float[]protected final float[]protected final GLMatrixprotected final GLMatrixprotected floatHeight and width in pixelsstatic final floatstatic final floatstatic final floatstatic final floatscale map plane at VIEW_DISTANCE to near plane -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanvoidfromScreenPoint(double x, double y, Point out) Get the map position x,y from screen coordinates.fromScreenPoint(float x, float y) Get the GeoPoint for x,y from screen coordinates.Get the minimal axis-aligned BoundingBox that encloses the visible part of the map.voidgetMapExtents(float[] box, float add) Get the inverse projection of the viewport, i.e.booleanGet the current MapPosition.floatfloatdoublefloatdoublegetMaxX()doublegetMaxY()intfloatfloatdoublefloatdoublegetMinX()doublegetMinY()intbooleanlimitPosition(MapPosition pos) doublelimitScale(double scale) floatlimitTilt(float tilt) voidsetMapLimit(double minX, double minY, double maxX, double maxY) voidsetMapLimit(BoundingBox mapLimit) voidsetMaxBearing(float maxBearing) voidsetMaxRoll(float maxRoll) voidsetMaxScale(double maxScale) voidsetMaxTilt(float maxTilt) voidsetMaxX(double maxX) voidsetMaxY(double maxY) voidsetMaxZoomLevel(int maxZoomLevel) voidsetMinBearing(float minBearing) voidsetMinRoll(float minRoll) voidsetMinScale(double minScale) voidsetMinTilt(float minTilt) voidsetMinX(double minX) voidsetMinY(double minY) voidsetMinZoomLevel(int minZoomLevel) voidtoScreenPoint(double x, double y, boolean relativeToCenter, Point out) Get the screen pixel for map coordinatesvoidtoScreenPoint(double x, double y, Point out) Get the screen pixel for map coordinates (relative to center)voidtoScreenPoint(GeoPoint geoPoint, boolean relativeToCenter, Point out) Get the screen pixel for a GeoPointvoidtoScreenPoint(GeoPoint geoPoint, Point out) Get the screen pixel for a GeoPoint (relative to center)protected voidunproject(float x, float y, float[] coords, int position) protected voidunprojectScreen(double x, double y, float[] out)
-
Field Details
-
MAX_ZOOM_LEVEL
public static final int MAX_ZOOM_LEVEL- See Also:
-
MIN_ZOOM_LEVEL
public static final int MIN_ZOOM_LEVEL- See Also:
-
MIN_TILT
public static final float MIN_TILT- See Also:
-
MAX_TILT
public static final float MAX_TILTLimited by:- numTiles in
TileManager- tilt of map when cutting map on near and far plane.
- See Also:
-
mMaxScale
protected double mMaxScale -
mMinScale
protected double mMinScale -
mMinTilt
protected float mMinTilt -
mMaxTilt
protected float mMaxTilt -
mMinBearing
protected float mMinBearing -
mMaxBearing
protected float mMaxBearing -
mMinRoll
protected float mMinRoll -
mMaxRoll
protected float mMaxRoll -
mMinX
protected double mMinX -
mMaxX
protected double mMaxX -
mMinY
protected double mMinY -
mMaxY
protected double mMaxY -
mPos
-
mProjMatrix
-
mProjMatrixUnscaled
-
mProjMatrixInverse
-
mRotationMatrix
-
mViewMatrix
-
mViewProjMatrix
-
mUnprojMatrix
-
mTmpMatrix
-
mMovePoint
-
mv
protected final float[] mv -
mu
protected final float[] mu -
mViewCoords
protected final float[] mViewCoords -
mHeight
protected float mHeightHeight and width in pixels -
mWidth
protected float mWidthHeight and width in pixels -
VIEW_DISTANCE
public static final float VIEW_DISTANCE- See Also:
-
VIEW_NEAR
public static final float VIEW_NEAR- See Also:
-
VIEW_FAR
public static final float VIEW_FAR- See Also:
-
VIEW_SCALE
public static final float VIEW_SCALEscale map plane at VIEW_DISTANCE to near plane- See Also:
-
-
Constructor Details
-
Viewport
public Viewport()
-
-
Method Details
-
limitScale
public double limitScale(double scale) -
limitTilt
public float limitTilt(float tilt) -
limitPosition
-
getMapPosition
Get the current MapPosition.- Parameters:
pos- MapPosition to be updated.- Returns:
- true iff current position is different from passed position.
-
getMapExtents
public void getMapExtents(float[] box, float add) Get the inverse projection of the viewport, i.e. the coordinates with z==0 that will be projected exactly to screen corners by current view-projection-matrix.Except when screen corners don't hit the map (e.g. on large tilt), then it will return the intersection with near and far plane.
- Parameters:
box- float[8] will be set to 0,1 -> x,y bottom-right, 2,3 -> x,y bottom-left, 4,5 -> x,y top-left, 6,7 -> x,y top-right.add- increase extents of box
-
unproject
protected void unproject(float x, float y, float[] coords, int position) -
getBBox
Get the minimal axis-aligned BoundingBox that encloses the visible part of the map. Sets box to map coordinates: xmin,ymin,xmax,ymax -
fromScreenPoint
Get the GeoPoint for x,y from screen coordinates.- Parameters:
x- screen coordinatey- screen coordinate- Returns:
- the corresponding GeoPoint
-
unprojectScreen
protected void unprojectScreen(double x, double y, float[] out) -
fromScreenPoint
Get the map position x,y from screen coordinates. -
toScreenPoint
Get the screen pixel for a GeoPoint (relative to center)- Parameters:
geoPoint- the GeoPointout- Point projected to screen pixel relative to center
-
toScreenPoint
Get the screen pixel for a GeoPoint- Parameters:
geoPoint- the GeoPointout- Point projected to screen pixel
-
toScreenPoint
Get the screen pixel for map coordinates (relative to center)- Parameters:
out- Point projected to screen coordinate relative to center
-
toScreenPoint
Get the screen pixel for map coordinates- Parameters:
out- Point projected to screen coordinate
-
copy
-
getMaxScale
public double getMaxScale() -
setMaxScale
public void setMaxScale(double maxScale) -
getMinScale
public double getMinScale() -
setMinScale
public void setMinScale(double minScale) -
getMaxZoomLevel
public int getMaxZoomLevel() -
setMaxZoomLevel
public void setMaxZoomLevel(int maxZoomLevel) -
getMinZoomLevel
public int getMinZoomLevel() -
setMinZoomLevel
public void setMinZoomLevel(int minZoomLevel) -
getMaxTilt
public float getMaxTilt() -
setMaxTilt
public void setMaxTilt(float maxTilt) -
getMinTilt
public float getMinTilt() -
setMinTilt
public void setMinTilt(float minTilt) -
getMaxBearing
public float getMaxBearing() -
setMaxBearing
public void setMaxBearing(float maxBearing) -
getMinBearing
public float getMinBearing() -
setMinBearing
public void setMinBearing(float minBearing) -
getMaxRoll
public float getMaxRoll() -
setMaxRoll
public void setMaxRoll(float maxRoll) -
getMinRoll
public float getMinRoll() -
setMinRoll
public void setMinRoll(float minRoll) -
getMaxX
public double getMaxX() -
setMaxX
public void setMaxX(double maxX) -
getMinX
public double getMinX() -
setMinX
public void setMinX(double minX) -
getMaxY
public double getMaxY() -
setMaxY
public void setMaxY(double maxY) -
getMinY
public double getMinY() -
setMinY
public void setMinY(double minY) -
setMapLimit
public void setMapLimit(double minX, double minY, double maxX, double maxY) -
getMapLimit
-
setMapLimit
-