Package org.oscim.map

Class Viewport

java.lang.Object
org.oscim.map.Viewport
Direct Known Subclasses:
GLViewport, ViewController

public class Viewport extends Object
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 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_TILT
      Limited 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

      protected final MapPosition mPos
    • mProjMatrix

      protected final GLMatrix mProjMatrix
    • mProjMatrixUnscaled

      protected final GLMatrix mProjMatrixUnscaled
    • mProjMatrixInverse

      protected final GLMatrix mProjMatrixInverse
    • mRotationMatrix

      protected final GLMatrix mRotationMatrix
    • mViewMatrix

      protected final GLMatrix mViewMatrix
    • mViewProjMatrix

      protected final GLMatrix mViewProjMatrix
    • mUnprojMatrix

      protected final GLMatrix mUnprojMatrix
    • mTmpMatrix

      protected final GLMatrix mTmpMatrix
    • mMovePoint

      protected final Point mMovePoint
    • mv

      protected final float[] mv
    • mu

      protected final float[] mu
    • mViewCoords

      protected final float[] mViewCoords
    • mHeight

      protected float mHeight
      Height and width in pixels
    • mWidth

      protected float mWidth
      Height 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_SCALE
      scale 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

      public boolean limitPosition(MapPosition pos)
    • getMapPosition

      public boolean getMapPosition(MapPosition pos)
      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

      public Box getBBox(Box box, int expand)
      Get the minimal axis-aligned BoundingBox that encloses the visible part of the map. Sets box to map coordinates: xmin,ymin,xmax,ymax
    • fromScreenPoint

      public GeoPoint fromScreenPoint(float x, float y)
      Get the GeoPoint for x,y from screen coordinates.
      Parameters:
      x - screen coordinate
      y - screen coordinate
      Returns:
      the corresponding GeoPoint
    • unprojectScreen

      protected void unprojectScreen(double x, double y, float[] out)
    • fromScreenPoint

      public void fromScreenPoint(double x, double y, Point out)
      Get the map position x,y from screen coordinates.
      Parameters:
      x - screen coordinate
      y - screen coordinate
      out - map position as Point x and y
    • toScreenPoint

      public void toScreenPoint(GeoPoint geoPoint, Point out)
      Get the screen pixel for a GeoPoint (relative to center)
      Parameters:
      geoPoint - the GeoPoint
      out - Point projected to screen pixel relative to center
    • toScreenPoint

      public void toScreenPoint(GeoPoint geoPoint, boolean relativeToCenter, Point out)
      Get the screen pixel for a GeoPoint
      Parameters:
      geoPoint - the GeoPoint
      out - Point projected to screen pixel
    • toScreenPoint

      public void toScreenPoint(double x, double y, Point out)
      Get the screen pixel for map coordinates (relative to center)
      Parameters:
      out - Point projected to screen coordinate relative to center
    • toScreenPoint

      public void toScreenPoint(double x, double y, boolean relativeToCenter, Point out)
      Get the screen pixel for map coordinates
      Parameters:
      out - Point projected to screen coordinate
    • copy

      protected boolean copy(Viewport viewport)
    • 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

      public BoundingBox getMapLimit()
    • setMapLimit

      public void setMapLimit(BoundingBox mapLimit)