MercatorProjection: minor code improvements
This commit is contained in:
parent
d81eb3d706
commit
fa5a72f20d
@ -99,14 +99,14 @@ public final class MercatorProjection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Point getPixelWithScale(GeoPoint geoPoint, double scale) {
|
public static Point getPixelWithScale(GeoPoint geoPoint, double scale) {
|
||||||
double pixelX = MercatorProjection.longitudeToPixelXWithScale(geoPoint.getLongitude(), scale);
|
double pixelX = longitudeToPixelXWithScale(geoPoint.getLongitude(), scale);
|
||||||
double pixelY = MercatorProjection.latitudeToPixelYWithScale(geoPoint.getLatitude(), scale);
|
double pixelY = latitudeToPixelYWithScale(geoPoint.getLatitude(), scale);
|
||||||
return new Point(pixelX, pixelY);
|
return new Point(pixelX, pixelY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Point getPixel(GeoPoint geoPoint, long mapSize) {
|
public static Point getPixel(GeoPoint geoPoint, long mapSize) {
|
||||||
double pixelX = MercatorProjection.longitudeToPixelX(geoPoint.getLongitude(), mapSize);
|
double pixelX = longitudeToPixelX(geoPoint.getLongitude(), mapSize);
|
||||||
double pixelY = MercatorProjection.latitudeToPixelY(geoPoint.getLatitude(), mapSize);
|
double pixelY = latitudeToPixelY(geoPoint.getLatitude(), mapSize);
|
||||||
return new Point(pixelX, pixelY);
|
return new Point(pixelX, pixelY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,8 +130,8 @@ public final class MercatorProjection {
|
|||||||
* @return the relative pixel position to the origin values (e.g. for a tile)
|
* @return the relative pixel position to the origin values (e.g. for a tile)
|
||||||
*/
|
*/
|
||||||
public static Point getPixelRelative(GeoPoint geoPoint, long mapSize, double x, double y) {
|
public static Point getPixelRelative(GeoPoint geoPoint, long mapSize, double x, double y) {
|
||||||
double pixelX = MercatorProjection.longitudeToPixelX(geoPoint.getLongitude(), mapSize) - x;
|
double pixelX = longitudeToPixelX(geoPoint.getLongitude(), mapSize) - x;
|
||||||
double pixelY = MercatorProjection.latitudeToPixelY(geoPoint.getLatitude(), mapSize) - y;
|
double pixelY = latitudeToPixelY(geoPoint.getLatitude(), mapSize) - y;
|
||||||
return new Point(pixelX, pixelY);
|
return new Point(pixelX, pixelY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,11 +172,8 @@ public final class MercatorProjection {
|
|||||||
/ (Tile.SIZE * scale);
|
/ (Tile.SIZE * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float groundResolution(MapPosition pos) {
|
public static double groundResolution(MapPosition pos) {
|
||||||
double lat = MercatorProjection.toLatitude(pos.y);
|
return groundResolutionWithScale(toLatitude(pos.y), pos.scale);
|
||||||
return (float) (Math.cos(lat * (Math.PI / 180))
|
|
||||||
* MercatorProjection.EARTH_CIRCUMFERENCE
|
|
||||||
/ (Tile.SIZE * pos.scale));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -360,7 +357,7 @@ public final class MercatorProjection {
|
|||||||
* @return pixels that represent the meters at the given zoom-level and latitude.
|
* @return pixels that represent the meters at the given zoom-level and latitude.
|
||||||
*/
|
*/
|
||||||
public static double metersToPixelsWithScale(float meters, double latitude, double scale) {
|
public static double metersToPixelsWithScale(float meters, double latitude, double scale) {
|
||||||
return meters / MercatorProjection.groundResolutionWithScale(latitude, scale);
|
return meters / groundResolutionWithScale(latitude, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -372,7 +369,7 @@ public final class MercatorProjection {
|
|||||||
* @return pixels that represent the meters at the given zoom-level and latitude.
|
* @return pixels that represent the meters at the given zoom-level and latitude.
|
||||||
*/
|
*/
|
||||||
public static double metersToPixels(float meters, double latitude, long mapSize) {
|
public static double metersToPixels(float meters, double latitude, long mapSize) {
|
||||||
return meters / MercatorProjection.groundResolution(latitude, mapSize);
|
return meters / groundResolution(latitude, mapSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -638,8 +638,7 @@ public class LineBucket extends RenderBucket {
|
|||||||
if (lb.heightOffset != heightOffset) {
|
if (lb.heightOffset != heightOffset) {
|
||||||
heightOffset = lb.heightOffset;
|
heightOffset = lb.heightOffset;
|
||||||
|
|
||||||
gl.uniform1f(uLineHeight, heightOffset /
|
gl.uniform1f(uLineHeight, (float) (heightOffset / MercatorProjection.groundResolution(v.pos)));
|
||||||
MercatorProjection.groundResolution(v.pos));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.fadeScale < v.pos.zoomLevel) {
|
if (line.fadeScale < v.pos.zoomLevel) {
|
||||||
|
|||||||
@ -191,8 +191,7 @@ public class MeshBucket extends RenderBucket {
|
|||||||
if (ml.heightOffset != heightOffset) {
|
if (ml.heightOffset != heightOffset) {
|
||||||
heightOffset = ml.heightOffset;
|
heightOffset = ml.heightOffset;
|
||||||
|
|
||||||
gl.uniform1f(s.uHeight, heightOffset /
|
gl.uniform1f(s.uHeight, (float) (heightOffset / MercatorProjection.groundResolution(v.pos)));
|
||||||
MercatorProjection.groundResolution(v.pos));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ml.area == null)
|
if (ml.area == null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user