本文整理汇总了Java中org.oscim.core.MercatorProjection类的典型用法代码示例。如果您正苦于以下问题:Java MercatorProjection类的具体用法?Java MercatorProjection怎么用?Java MercatorProjection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MercatorProjection类属于org.oscim.core包,在下文中一共展示了MercatorProjection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: populate
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
void populate(int size) {
InternalItem[] tmp = new InternalItem[size];
for (int i = 0; i < size; i++) {
InternalItem it = new InternalItem();
tmp[i] = it;
it.item = mMarkerLayer.createItem(i);
/* pre-project polygonPoints */
MercatorProjection.project(it.item.getPoint(), mMapPoint);
it.px = mMapPoint.x;
it.py = mMapPoint.y;
}
synchronized (this) {
mUpdate = true;
mItems = tmp;
}
}
开发者ID:andreynovikov,项目名称:trekarta,代码行数:20,代码来源:MarkerRenderer.java
示例2: populate
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
protected void populate(int size) {
InternalItem[] tmp = new InternalItem[size];
for (int i = 0; i < size; i++) {
InternalItem it = new InternalItem();
tmp[i] = it;
it.item = mMarkerLayer.createItem(i);
/* pre-project points */
MercatorProjection.project(it.item.getPoint(), mMapPoint);
it.px = mMapPoint.x;
it.py = mMapPoint.y;
}
synchronized (this) {
mUpdate = true;
mItems = tmp;
}
}
开发者ID:opensciencemap,项目名称:vtm,代码行数:20,代码来源:MarkerRenderer.java
示例3: animateTo
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
public synchronized void animateTo(GeoPoint geoPoint) {
double f = Tile.SIZE << ABS_ZOOMLEVEL;
mStartX = mAbsX * f;
mStartY = mAbsY * f;
mEndX = MercatorProjection.longitudeToX(geoPoint.getLongitude()) * f;
mEndY = MercatorProjection.latitudeToY(geoPoint.getLatitude()) * f;
mEndX -= mStartX;
mEndY -= mStartY;
mAnimMove = true;
mAnimScale = false;
mAnimFling = false;
animStart(300);
}
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:18,代码来源:MapViewPosition.java
示例4: constructor
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
@Test
void constructor() {
double latTopLeft = 52.581;
double lonTopLeft = 13.396;
double latBotomRight = 52.579;
double lonBotomright = 13.400;
double latCenter = 52.580;
double lonCenter = 13.398;
GeoPoint leftTop = new GeoPoint(latTopLeft, lonTopLeft);
GeoPoint rightBotom = new GeoPoint(latBotomRight, lonBotomright);
GeoPoint geoPoint = new GeoPoint(latCenter, lonCenter);
GeoBoundingBoxInt gbb = new GeoBoundingBoxInt(leftTop, rightBotom);
assertThat("Point must inside Box", gbb.contains(geoPoint));
Box box = new Box(MercatorProjection.longitudeToX(lonTopLeft)
, MercatorProjection.latitudeToY(latTopLeft)
, MercatorProjection.longitudeToX(lonBotomright)
, MercatorProjection.latitudeToY(latBotomRight));
box.map2mercator();
assertThat("Point must inside Box", box.contains(lonCenter, latCenter));
GeoBoundingBoxInt geoBoundingBox = new GeoBoundingBoxInt(box);
assertThat("Point must inside Box", geoBoundingBox.contains(geoPoint));
}
开发者ID:Longri,项目名称:cachebox3.0,代码行数:32,代码来源:GeoBoundingBoxTest.java
示例5: initialize
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
static TileSource.OpenResult initialize(SQLiteTileSource tileSource, SQLiteDatabase database) {
try {
int minZoom = (int) database.compileStatement(SQL_GET_MIN_ZOOM).simpleQueryForLong();
int maxZoom = (int) database.compileStatement(SQL_GET_MAX_ZOOM).simpleQueryForLong();
tileSource.setMinZoom(minZoom);
tileSource.setMaxZoom(maxZoom);
String[] args = {String.valueOf(17 - maxZoom)};
int minX = getInt(database, SQL_GET_MIN_X, args);
int minY = getInt(database, SQL_GET_MIN_Y, args);
int maxX = getInt(database, SQL_GET_MAX_X, args) + 1;
int maxY = getInt(database, SQL_GET_MAX_Y, args) + 1;
double scale = 1 << maxZoom;
tileSource.mBoundingBox = new BoundingBox(
MercatorProjection.toLatitude(maxY / scale),
MercatorProjection.toLongitude(minX / scale),
MercatorProjection.toLatitude(minY / scale),
MercatorProjection.toLongitude(maxX / scale)
);
//TODO Try to fill zoom table and see what happens
} catch (SQLException e) {
return new TileSource.OpenResult(e.getMessage());
}
return TileSource.OpenResult.SUCCESS;
}
开发者ID:andreynovikov,项目名称:trekarta,代码行数:28,代码来源:RMapsDatabase.java
示例6: contains
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
/**
* Checks if map contains given point
*/
public boolean contains(double x, double y) {
if (polygonPoints == null) {
GeoPoint geoPoint = new GeoPoint(MercatorProjection.toLatitude(y), MercatorProjection.toLongitude(x));
return boundingBox.contains(geoPoint);
}
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
// Note that division by zero is avoided because the division is protected
// by the "if" clause which surrounds it.
int j = polygonPoints.length - 2;
boolean inside = false;
for (int i = 0; i < polygonPoints.length; i += 2) {
double ix = polygonPoints[i];
double iy = polygonPoints[i + 1];
double jx = polygonPoints[j];
double jy = polygonPoints[j + 1];
if (iy < y && jy >= y || jy < y && iy >= y) {
if (ix + (y - iy) * 1. / (jy - iy) * (jx - ix) < x) {
inside = !inside;
}
}
j = i;
}
return inside;
}
开发者ID:andreynovikov,项目名称:trekarta,代码行数:30,代码来源:MapFile.java
示例7: toLatLngBounds
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
public static LatLngBounds toLatLngBounds(Box box) {
double minLon = MercatorProjection.toLongitude(box.xmin);
double maxLon = MercatorProjection.toLongitude(box.xmax);
double minLat = MercatorProjection.toLatitude(box.ymax);
double maxLat = MercatorProjection.toLatitude(box.ymin);
if (Double.isNaN(minLon) || Double.isNaN(maxLon) || Double.isNaN(minLat) || Double.isNaN(maxLat))
minLon = maxLon = minLat = maxLat = 0;
return new LatLngBounds(new LatLng(minLat, minLon), new LatLng(maxLat, maxLon));
}
开发者ID:microg,项目名称:android_packages_apps_GmsCore,代码行数:10,代码来源:GmsMapsTypeHelper.java
示例8: getBBox
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
/**
* Get the minimal axis-aligned BoundingBox that encloses
* the visible part of the map.
*
* @return BoundingBox containing view
*/
public synchronized BoundingBox getBBox(int expand) {
getBBox(mMapBBox, expand);
/* scale map-pixel coordinates at current scale to
* absolute coordinates and apply mercator projection. */
double minLon = MercatorProjection.toLongitude(mMapBBox.xmin);
double maxLon = MercatorProjection.toLongitude(mMapBBox.xmax);
double minLat = MercatorProjection.toLatitude(mMapBBox.ymax);
double maxLat = MercatorProjection.toLatitude(mMapBBox.ymin);
return new BoundingBox(minLat, minLon, maxLat, maxLon);
}
开发者ID:opensciencemap,项目名称:vtm,代码行数:19,代码来源:Viewport.java
示例9: initTile
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
private void initTile(MapTile tile) {
double lat = MercatorProjection.toLatitude(tile.y);
mGroundScale = (float) MercatorProjection
.groundResolution(lat, 1 << mTile.zoomLevel);
mRoofs = new ExtrusionBucket(0, mGroundScale, Color.get(247, 249, 250));
mParts = new ExtrusionBucket(0, mGroundScale, Color.get(255, 254, 252));
//mRoofs = new ExtrusionLayer(0, mGroundScale, Color.get(207, 209, 210));
mRoofs.next = mParts;
BuildingLayer.get(tile).setBuckets(mRoofs);
process(mTilePlane);
}
开发者ID:opensciencemap,项目名称:vtm,代码行数:16,代码来源:S3DBTileLoader.java
示例10: loooop
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
void loooop(final int i) {
final long time = (long) (500 + Math.random() * 1000);
mMapView.postDelayed(new Runnable() {
@Override
public void run() {
MapPosition p = new MapPosition();
if (i == 1) {
mMapView.map().getMapPosition(p);
p.setScale(4);
mMapView.map().animator().animateTo(time, p);
} else {
//mMapView.map().setMapPosition(p);
p.setScale(2 + (1 << (int) (Math.random() * 13)));
// p.setX((p.getX() + (Math.random() * 4 - 2) / p.getScale()));
// p.setY((p.getY() + (Math.random() * 4 - 2) / p.getScale()));
p.setX(MercatorProjection.longitudeToX(Math.random() * 180));
p.setY(MercatorProjection.latitudeToY(Math.random() * 60));
p.setTilt((float) (Math.random() * 60));
p.setBearing((float) (Math.random() * 360));
//mMapView.map().setMapPosition(p);
mMapView.map().animator().animateTo(time, p);
}
loooop((i + 1) % 2);
}
}, time);
}
开发者ID:opensciencemap,项目名称:vtm,代码行数:31,代码来源:BitmapTileMapActivity.java
示例11: loooop
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
void loooop(final int i) {
final long time = (long) (500 + Math.random() * 1000);
mMapView.postDelayed(new Runnable() {
@Override
public void run() {
mMapView.map().setTheme(themes[i]);
MapPosition p = new MapPosition();
if (i == 1) {
mMapView.map().getMapPosition(p);
p.setScale(4);
mMapView.map().animator().animateTo(time, p);
} else {
//mMapView.map().setMapPosition(p);
p.setScale(2 + (1 << (int) (Math.random() * 13)));
// p.setX((p.getX() + (Math.random() * 4 - 2) / p.getScale()));
// p.setY((p.getY() + (Math.random() * 4 - 2) / p.getScale()));
p.setX(MercatorProjection.longitudeToX(Math.random() * 180));
p.setY(MercatorProjection.latitudeToY(Math.random() * 60));
p.setTilt((float) (Math.random() * 60));
p.setBearing((float) (Math.random() * 360));
//mMapView.map().setMapPosition(p);
mMapView.map().animator().animateTo(time, p);
}
loooop((i + 1) % 2);
}
}, time);
}
开发者ID:opensciencemap,项目名称:vtm,代码行数:34,代码来源:SimpleMapActivity.java
示例12: transformPath
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
protected int transformPath(MapPosition pos, GeometryBuffer g, CoordinatePath path) {
double scale = pos.scale * Tile.SIZE / UNSCALE_COORD;
int cnt = 0;
O: while (path.hasNext()) {
Coordinate c = path.next();
float x = (float) ((MercatorProjection.longitudeToX(c.x) - pos.x) * scale);
float y = (float) ((MercatorProjection.latitudeToY(c.y) - pos.y) * scale);
switch (path.getStep()) {
case MOVE_TO:
if (g.isPoly())
g.startPolygon();
else if (g.isLine())
g.startLine();
cnt++;
g.addPoint(x, y);
break;
case LINE_TO:
cnt++;
g.addPoint(x, y);
break;
case CLOSE:
//g.addPoint(x, y);
//if (g.type == GeometryType.POLY)
break;
case STOP:
break O;
}
}
return cnt;
}
开发者ID:opensciencemap,项目名称:vtm,代码行数:34,代码来源:JtsLayer.java
示例13: run
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
@Override
public void run() {
mMap.viewport().getMapPosition(pos);
int lat = (int) (MercatorProjection.toLatitude(pos.y) * 1000);
int lon = (int) (MercatorProjection.toLongitude(pos.x) * 1000);
int rot = (int) (pos.bearing);
rot = (int) (pos.bearing) % 360;
//rot = rot < 0 ? -rot : rot;
if (curZoom != pos.zoomLevel || curLat != lat || curLon != lon
|| curTilt != rot || curRot != (int) (pos.bearing)) {
curLat = lat;
curLon = lon;
curZoom = pos.zoomLevel;
curTilt = (int) pos.tilt;
curRot = rot;
String newURL = Window.Location
.createUrlBuilder()
.setHash(mParams
+ "scale=" + pos.zoomLevel
+ "&rot=" + curRot
+ "&tilt=" + curTilt
+ "&lat=" + (curLat / 1000f)
+ "&lon=" + (curLon / 1000f))
.buildString();
Window.Location.replace(newURL);
}
}
开发者ID:opensciencemap,项目名称:vtm,代码行数:31,代码来源:MapUrl.java
示例14: getViewBox
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
/**
* Get the minimal axis-aligned BoundingBox that encloses
* the visible part of the map.
*
* @return BoundingBox containing view
*/
public synchronized BoundingBox getViewBox() {
getViewBox(mMapBBox);
// scale map-pixel coordinates at current scale to
// absolute coordinates and apply mercator projection.
double minLon = MercatorProjection.toLongitude(mMapBBox.minX);
double maxLon = MercatorProjection.toLongitude(mMapBBox.maxX);
// sic(k)
double minLat = MercatorProjection.toLatitude(mMapBBox.maxY);
double maxLat = MercatorProjection.toLatitude(mMapBBox.minY);
return new BoundingBox(minLat, minLon, maxLat, maxLon);
}
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:20,代码来源:MapViewPosition.java
示例15: populate
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
/**
* Utility method to perform all processing on a new ItemizedOverlay.
* Subclasses provide Items through the createItem(int) method. The subclass
* should call this as soon as it has data, before anything else gets
* called.
*/
protected final void populate() {
synchronized (lock) {
final int size = size();
mSize = size;
// reuse previous items
InternalItem pool = mItems;
mItems = null;
// flip order to draw in backward cycle, so the items
// with the least index are on the front.
for (int a = 0; a < size; a++) {
InternalItem it;
if (pool != null) {
it = pool;
it.visible = false;
it.changes = false;
pool = pool.next;
} else {
it = new InternalItem();
}
it.next = mItems;
mItems = it;
it.item = createItem(a);
// pre-project points
MercatorProjection.project(it.item.mGeoPoint, mMapPoint);
it.px = mMapPoint.x;
it.py = mMapPoint.y;
}
mUpdate = true;
}
}
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:41,代码来源:ItemizedOverlay.java
示例16: setPosition
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
public void setPosition(double latitude, double longitude, double accuracy) {
mLocation.x = MercatorProjection.longitudeToX(longitude);
mLocation.y = MercatorProjection.latitudeToY(latitude);
mRadius = accuracy / MercatorProjection.groundResolution(latitude, 1);
locationAccuracyRenderer.setLocation(mLocation.x, mLocation.y, mRadius);
}
开发者ID:Longri,项目名称:cachebox3.0,代码行数:7,代码来源:LocationAccuracyLayer.java
示例17: onLocationChanged
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
@Override
public void onLocationChanged() {
if (mLocationState == LocationState.SEARCHING) {
mLocationState = mSavedLocationState;
mMap.getEventLayer().setFixOnCenter(true);
updateLocationDrawable();
mLocationOverlay.setEnabled(true);
mMap.updateMap(true);
}
Location location = mLocationService.getLocation();
double lat = location.getLatitude();
double lon = location.getLongitude();
float bearing = location.getBearing();
if (bearing < mAveragedBearing - 180f)
mAveragedBearing -= 360f;
else if (mAveragedBearing < bearing - 180f)
mAveragedBearing += 360f;
mAveragedBearing = (float) movingAverage(bearing, mAveragedBearing);
if (mAveragedBearing < 0f)
mAveragedBearing += 360f;
if (mAveragedBearing >= 360f)
mAveragedBearing -= 360f;
updateGauges();
if (mLocationState == LocationState.NORTH || mLocationState == LocationState.TRACK) {
long time = SystemClock.uptimeMillis();
// Adjust map movement animation to location acquisition period to make movement smoother
long locationDelay = time - mLastLocationMilliseconds;
double duration = Math.min(1500, locationDelay); // 1.5 seconds maximum
mMovementAnimationDuration = (int) movingAverage(duration, mMovementAnimationDuration);
// Update map position
mMap.getMapPosition(mMapPosition);
boolean rotate = mLocationState == LocationState.TRACK && mTrackingDelay < time;
double offset;
if (rotate) {
offset = mTrackingOffset / mTrackingOffsetFactor;
if (mAutoTilt > 0f && !mAutoTiltSet && mAutoTiltShouldSet)
mMapPosition.setTilt(mAutoTilt);
} else {
offset = mMovingOffset;
}
offset = offset / (mMapPosition.scale * Tile.SIZE);
double rad = Math.toRadians(mAveragedBearing);
double dx = offset * Math.sin(rad);
double dy = offset * Math.cos(rad);
if (!mPositionLocked) {
mMapPosition.setX(MercatorProjection.longitudeToX(lon) + dx);
mMapPosition.setY(MercatorProjection.latitudeToY(lat) - dy);
mMapPosition.setBearing(-mAveragedBearing);
//FIXME VTM
mMap.animator().animateTo(mMovementAnimationDuration, mMapPosition, rotate);
}
}
mLocationOverlay.setPosition(lat, lon, bearing);
if (mNavigationLayer != null)
mNavigationLayer.setPosition(lat, lon);
mLastLocationMilliseconds = SystemClock.uptimeMillis();
//if (mNightModeState == NIGHT_MODE_STATE.AUTO)
// checkNightMode(location);
for (WeakReference<LocationChangeListener> weakRef : mLocationChangeListeners) {
LocationChangeListener locationChangeListener = weakRef.get();
if (locationChangeListener != null) {
locationChangeListener.onLocationChanged(location);
}
}
}
开发者ID:andreynovikov,项目名称:trekarta,代码行数:74,代码来源:MainActivity.java
示例18: updateNavigationUI
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
private void updateNavigationUI() {
logger.debug("updateNavigationUI()");
boolean enabled = mLocationService != null && mLocationService.getStatus() == BaseLocationService.GPS_OK &&
mNavigationService != null && mNavigationService.isNavigating();
boolean changed = mGaugePanel.setNavigationMode(enabled);
if (enabled) {
if (mNavigationArrowView.getVisibility() == View.GONE) {
mNavigationArrowView.setAlpha(0f);
mNavigationArrowView.setVisibility(View.VISIBLE);
mNavigationArrowView.animate().alpha(1f).setDuration(MAP_POSITION_ANIMATION_DURATION).setListener(null);
}
GeoPoint destination = mNavigationService.getWaypoint().coordinates;
if (mNavigationLayer == null) {
mNavigationLayer = new NavigationLayer(mMap, 0x66ffff00, 8);
mNavigationLayer.setDestination(destination);
Point point = mLocationOverlay.getPosition();
mNavigationLayer.setPosition(MercatorProjection.toLatitude(point.y), MercatorProjection.toLongitude(point.x));
mMap.layers().add(mNavigationLayer, MAP_POSITIONAL);
} else {
GeoPoint current = mNavigationLayer.getDestination();
if (!destination.equals(current)) {
mNavigationLayer.setDestination(destination);
}
}
} else {
if (mNavigationArrowView.getAlpha() == 1f) {
mNavigationArrowView.animate().alpha(0f).setDuration(MAP_POSITION_ANIMATION_DURATION).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mNavigationArrowView.setVisibility(View.GONE);
}
});
}
if (mNavigationLayer != null) {
mMap.layers().remove(mNavigationLayer);
mNavigationLayer = null;
}
}
if (changed)
updateMapViewArea();
}
开发者ID:andreynovikov,项目名称:trekarta,代码行数:42,代码来源:MainActivity.java
示例19: InternalItem
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
InternalItem(MapObject item) {
this.item = item;
MercatorProjection.project(item.coordinates, mMapPoint);
px = mMapPoint.x;
py = mMapPoint.y;
}
开发者ID:andreynovikov,项目名称:trekarta,代码行数:7,代码来源:MapObjectLayer.java
示例20: process
import org.oscim.core.MercatorProjection; //导入依赖的package包/类
/**
* TileLoaderThemeHook
*/
@Override
public boolean process(MapTile tile, RenderBuckets buckets, MapElement el,
RenderStyle style, int level) {
if (!(style instanceof ExtrusionStyle))
return false;
ExtrusionStyle extrusion = (ExtrusionStyle) style;
ExtendedMapElement element = (ExtendedMapElement) el;
int height = element.buildingHeight > 0 ? element.buildingHeight : 12 * 100; // 12m default
int minHeight = element.buildingMinHeight;
float[] colors = extrusion.colors;
if (element.buildingColor != 0 || element.roofColor != 0) {
// As defined in style
float alpha = 0.9f;
colors = new float[16];
System.arraycopy(extrusion.colors, 0, colors, 0, colors.length);
if (element.roofColor != 0) {
colors[0] = alpha * Color.rToFloat(element.roofColor);
colors[1] = alpha * Color.gToFloat(element.roofColor);
colors[2] = alpha * Color.bToFloat(element.roofColor);
colors[3] = alpha;
}
if (element.buildingColor != 0) {
colors[4] = alpha * Color.rToFloat(element.buildingColor);
colors[5] = alpha * Color.gToFloat(element.buildingColor);
colors[6] = alpha * Color.bToFloat(element.buildingColor);
colors[7] = alpha;
colors[8] = alpha * Color.rToFloat(element.buildingColor);
colors[9] = alpha * Color.gToFloat(element.buildingColor);
colors[10] = alpha * Color.bToFloat(element.buildingColor);
colors[11] = alpha;
}
}
ExtrusionBuckets ebs = get(tile);
for (ExtrusionBucket b = ebs.buckets; b != null; b = b.next()) {
if (b.colors == colors) {
b.add(element, height, minHeight);
return true;
}
}
double lat = MercatorProjection.toLatitude(tile.y);
float groundScale = (float) MercatorProjection.groundResolutionWithScale(lat, 1 << tile.zoomLevel);
ebs.buckets = Inlist.push(ebs.buckets, new ExtrusionBucket(0, groundScale, colors));
ebs.buckets.add(element, height, minHeight);
return true;
}
开发者ID:andreynovikov,项目名称:trekarta,代码行数:60,代码来源:BuildingLayer.java
注:本文中的org.oscim.core.MercatorProjection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论