当前位置: 首页>>代码示例>>Java>>正文


Java MercatorProjection类代码示例

本文整理汇总了Java中org.oscim.core.MercatorProjection的典型用法代码示例。如果您正苦于以下问题:Java MercatorProjection类的具体用法?Java MercatorProjection怎么用?Java MercatorProjection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MercatorProjection类属于org.oscim.core包,在下文中一共展示了MercatorProjection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.oscim.core.MercatorProjection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。