public class Projection extends Object implements IProjection
Modifier and Type | Field and Description |
---|---|
double |
mProjectedMapSize
Size of the "projected" map: a virtual map with the largest zoom level
WARNING: `mProjectedMapSize` MUST NOT be a static member,
as it depends on
TileSystem.getTileSize() |
Constructor and Description |
---|
Projection(double pZoomLevel,
int pWidth,
int pHeight,
GeoPoint pCenter,
float pOrientation,
boolean pHorizontalWrapEnabled,
boolean pVerticalWrapEnabled,
int pMapCenterOffsetX,
int pMapCenterOffsetY) |
Projection(double pZoomLevel,
Rect pScreenRect,
GeoPoint pCenter,
long pScrollX,
long pScrollY,
float pOrientation,
boolean pHorizontalWrapEnabled,
boolean pVerticalWrapEnabled,
TileSystem pTileSystem,
int pMapCenterOffsetX,
int pMapCenterOffsetY) |
Projection(MapView mapView) |
Modifier and Type | Method and Description |
---|---|
void |
adjustOffsets(BoundingBox pBoundingBox)
Deprecated.
Use
adjustOffsets(double, double, boolean, int) instead |
(package private) void |
adjustOffsets(double pNorthOrWest,
double pSouthOrEast,
boolean isLatitude,
int pExtraSize)
Adjust offsets so that north and south (if latitude, west and east if longitude)
actually "fit" into the screen, with a tolerance of extraSize pixels.
|
void |
adjustOffsets(IGeoPoint pGeoPoint,
PointF pPixel)
Adjust the offsets so that this geo point projects into that pixel
|
(package private) void |
adjustOffsets(long pDeltaX,
long pDeltaY) |
void |
detach() |
IGeoPoint |
fromPixels(int x,
int y)
Create a new GeoPoint from pixel coordinates relative to the top-left of the MapView that
provided this PixelConverter.
|
IGeoPoint |
fromPixels(int pPixelX,
int pPixelY,
GeoPoint pReuse)
note: if
MapView.setHorizontalMapRepetitionEnabled(boolean) or
MapView.setVerticalMapRepetitionEnabled(boolean) is false, then this
can return values that beyond the max extents of the world. |
IGeoPoint |
fromPixels(int pPixelX,
int pPixelY,
GeoPoint pReuse,
boolean forceWrap)
* note: if
MapView.setHorizontalMapRepetitionEnabled(boolean) or
MapView.setVerticalMapRepetitionEnabled(boolean) is false, then this
can return values that beyond the max extents of the world. |
BoundingBox |
getBoundingBox() |
long |
getCleanMercator(long pMercator,
boolean wrapEnabled) |
GeoPoint |
getCurrentCenter() |
int |
getHeight() |
Rect |
getIntrinsicScreenRect() |
Matrix |
getInvertedScaleRotateCanvasMatrix()
This will provide a Matrix that will revert the current map's scaling and rotation.
|
PointL |
getLongPixelsFromProjected(PointL in,
double powerDifference,
boolean pCloser,
PointL reuse) |
long |
getLongPixelXFromLongitude(double pLongitude) |
long |
getLongPixelXFromLongitude(double pLongitude,
boolean forceWrap) |
long |
getLongPixelYFromLatitude(double pLatitude) |
long |
getLongPixelYFromLatitude(double pLatitude,
boolean forceWrap) |
long |
getMercatorFromTile(int pTile) |
RectL |
getMercatorViewPort(RectL pReuse) |
long |
getMercatorXFromPixel(int pPixelX) |
long |
getMercatorYFromPixel(int pPixelY) |
IGeoPoint |
getNorthEast()
Get the coordinates of the most north-easterly visible point of the map.
|
long |
getOffsetX() |
long |
getOffsetY() |
Projection |
getOffspring(double pZoomLevel,
Rect pScreenRect) |
float |
getOrientation() |
Rect |
getPixelFromTile(int pTileX,
int pTileY,
Rect pReuse) |
Point |
getPixelsFromProjected(PointL in,
double powerDifference,
Point reuse)
Deprecated.
|
double |
getProjectedPowerDifference() |
Matrix |
getScaleRotateCanvasMatrix()
This will provide a Matrix that will revert the current map's scaling and rotation.
|
int |
getScreenCenterX() |
int |
getScreenCenterY() |
Rect |
getScreenRect() |
static long |
getScrollableOffset(long pPixelMin,
long pPixelMax,
double pWorldSize,
int pScreenSize,
int pExtraSize) |
IGeoPoint |
getSouthWest()
Get the coordinates of the most south-westerly visible point of the map.
|
int |
getTileFromMercator(long pMercator) |
int |
getWidth() |
double |
getZoomLevel() |
boolean |
isHorizontalWrapEnabled() |
boolean |
isVerticalWrapEnabled() |
float |
metersToEquatorPixels(float meters)
Converts a distance in meters (along the equator) to one in (horizontal) pixels at the
current zoomlevel.
|
float |
metersToPixels(float meters)
Converts a distance in meters to one in (horizontal) pixels at the current zoomlevel and at
the current latitude at the center of the screen.
|
float |
metersToPixels(float meters,
double latitude,
double zoomLevel) |
void |
restore(Canvas pCanvas,
boolean pForce) |
Point |
rotateAndScalePoint(int x,
int y,
Point reuse)
This will apply the current map's scaling and rotation for a point.
|
void |
save(Canvas pCanvas,
boolean pMapRotation,
boolean pForce) |
(package private) boolean |
setMapScroll(MapView pMapView) |
PointL |
toMercatorPixels(int pPixelX,
int pPixelY,
PointL reuse) |
Point |
toPixels(IGeoPoint in,
Point reuse)
|
Point |
toPixels(IGeoPoint in,
Point reuse,
boolean forceWrap) |
Point |
toPixelsFromMercator(long pMercatorX,
long pMercatorY,
Point reuse)
Deprecated.
|
Point |
toPixelsFromProjected(PointL in,
Point reuse)
Deprecated.
|
PointL |
toProjectedPixels(double latitude,
double longitude,
boolean pWrapEnabled,
PointL reuse) |
PointL |
toProjectedPixels(double latitude,
double longitude,
PointL reuse)
Performs only the first computationally heavy part of the projection.
|
PointL |
toProjectedPixels(GeoPoint geoPoint,
PointL reuse)
A wrapper for
toProjectedPixels(double, double, PointL) |
PointL |
toProjectedPixels(long latituteE6,
long longitudeE6,
PointL reuse)
Deprecated.
Use
toProjectedPixels(double, double, PointL) instead |
Point |
unrotateAndScalePoint(int x,
int y,
Point reuse)
This will revert the current map's scaling and rotation for a point.
|
public final double mProjectedMapSize
TileSystem.getTileSize()
Projection(MapView mapView)
public Projection(double pZoomLevel, Rect pScreenRect, GeoPoint pCenter, long pScrollX, long pScrollY, float pOrientation, boolean pHorizontalWrapEnabled, boolean pVerticalWrapEnabled, TileSystem pTileSystem, int pMapCenterOffsetX, int pMapCenterOffsetY)
public Projection(double pZoomLevel, int pWidth, int pHeight, GeoPoint pCenter, float pOrientation, boolean pHorizontalWrapEnabled, boolean pVerticalWrapEnabled, int pMapCenterOffsetX, int pMapCenterOffsetY)
public Projection getOffspring(double pZoomLevel, Rect pScreenRect)
public double getZoomLevel()
public BoundingBox getBoundingBox()
public Rect getScreenRect()
public Rect getIntrinsicScreenRect()
public IGeoPoint fromPixels(int x, int y)
IProjection
fromPixels
in interface IProjection
public IGeoPoint fromPixels(int pPixelX, int pPixelY, GeoPoint pReuse)
MapView.setHorizontalMapRepetitionEnabled(boolean)
or
MapView.setVerticalMapRepetitionEnabled(boolean)
is false, then this
can return values that beyond the max extents of the world. This may or may not be
desired. https://github.com/osmdroid/osmdroid/pull/722
for more information and the discussion associated with this.pPixelX
- pPixelY
- pReuse
- public IGeoPoint fromPixels(int pPixelX, int pPixelY, GeoPoint pReuse, boolean forceWrap)
MapView.setHorizontalMapRepetitionEnabled(boolean)
or
MapView.setVerticalMapRepetitionEnabled(boolean)
is false, then this
can return values that beyond the max extents of the world. This may or may not be
desired. https://github.com/osmdroid/osmdroid/pull/722
for more information and the discussion associated with this.pPixelX
- pPixelY
- pReuse
- forceWrap
- public Point toPixels(IGeoPoint in, Point reuse)
IProjection
IGeoPoint
to onscreen pixel coordinates, relative to the top-left
of the MapView
that provided this Projection.toPixels
in interface IProjection
in
- The latitude/longitude pair to convert.reuse
- A pre-existing object to use for the output; if null, a new Point will be
allocated and returned.public long getLongPixelXFromLongitude(double pLongitude, boolean forceWrap)
public long getLongPixelXFromLongitude(double pLongitude)
public long getLongPixelYFromLatitude(double pLatitude, boolean forceWrap)
public long getLongPixelYFromLatitude(double pLatitude)
public PointL toProjectedPixels(GeoPoint geoPoint, PointL reuse)
toProjectedPixels(double, double, PointL)
@Deprecated public PointL toProjectedPixels(long latituteE6, long longitudeE6, PointL reuse)
toProjectedPixels(double, double, PointL)
insteadgetLongPixelsFromProjected(PointL, double, boolean, PointL)
to get the final position.latituteE6
- the latitute of the pointlongitudeE6
- the longitude of the pointreuse
- just pass null if you do not have a PointL to be 'recycled'.public PointL toProjectedPixels(double latitude, double longitude, PointL reuse)
getLongPixelsFromProjected(PointL, double, boolean, PointL)
to get the final position.latitude
- the latitute of the pointlongitude
- the longitude of the pointreuse
- just pass null if you do not have a PointL to be 'recycled'.public PointL toProjectedPixels(double latitude, double longitude, boolean pWrapEnabled, PointL reuse)
@Deprecated public Point toPixelsFromProjected(PointL in, Point reuse)
getLongPixelsFromProjected(PointL, double, boolean, PointL)
insteadin
- the PointL calculated by the toProjectedPixels(double, double, PointL)
reuse
- just pass null if you do not have a Point to be 'recycled'.toProjectedPixels(double, double, PointL)
.@Deprecated public Point toPixelsFromMercator(long pMercatorX, long pMercatorY, Point reuse)
getLongPixelsFromProjected(PointL, double, boolean, PointL)
insteadpublic float metersToEquatorPixels(float meters)
IProjection
metersToEquatorPixels
in interface IProjection
meters
- the distance in meterspublic float metersToPixels(float meters)
meters
- the distance in meterspublic float metersToPixels(float meters, double latitude, double zoomLevel)
public IGeoPoint getNorthEast()
IProjection
getNorthEast
in interface IProjection
public IGeoPoint getSouthWest()
IProjection
getSouthWest
in interface IProjection
public Matrix getInvertedScaleRotateCanvasMatrix()
public Point unrotateAndScalePoint(int x, int y, Point reuse)
public Point rotateAndScalePoint(int x, int y, Point reuse)
public void detach()
public long getMercatorFromTile(int pTile)
public Matrix getScaleRotateCanvasMatrix()
public double getProjectedPowerDifference()
@Deprecated public Point getPixelsFromProjected(PointL in, double powerDifference, Point reuse)
getLongPixelsFromProjected(PointL, double, boolean, PointL)
insteadpublic PointL getLongPixelsFromProjected(PointL in, double powerDifference, boolean pCloser, PointL reuse)
in
- Input point: a geo point projected to the map with the largest zoom level (aka "projected" map)powerDifference
- Factor between the large "projected" map and the wanted projection zoom levelpCloser
- "Should we move the resulting point - modulo the map size - so that it's
as close to the screen limits as possible?"public int getTileFromMercator(long pMercator)
public int getScreenCenterX()
public int getScreenCenterY()
public long getMercatorXFromPixel(int pPixelX)
public long getMercatorYFromPixel(int pPixelY)
public long getCleanMercator(long pMercator, boolean wrapEnabled)
public GeoPoint getCurrentCenter()
public long getOffsetX()
public long getOffsetY()
public void save(Canvas pCanvas, boolean pMapRotation, boolean pForce)
public void restore(Canvas pCanvas, boolean pForce)
public void adjustOffsets(IGeoPoint pGeoPoint, PointF pPixel)
@Deprecated public void adjustOffsets(BoundingBox pBoundingBox)
adjustOffsets(double, double, boolean, int)
insteadvoid adjustOffsets(double pNorthOrWest, double pSouthOrEast, boolean isLatitude, int pExtraSize)
void adjustOffsets(long pDeltaX, long pDeltaY)
public static long getScrollableOffset(long pPixelMin, long pPixelMax, double pWorldSize, int pScreenSize, int pExtraSize)
pPixelMin
- Pixel position of the limit (left)pPixelMax
- Pixel position of the limit (right)pWorldSize
- World map size - for modulo adjustmentspScreenSize
- Screen sizepExtraSize
- Extra size to consider at each side of the screenboolean setMapScroll(MapView pMapView)
public boolean isHorizontalWrapEnabled()
public boolean isVerticalWrapEnabled()
public float getOrientation()
public int getWidth()
public int getHeight()