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


Java MercatorProjection.toLatitude方法代码示例

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


在下文中一共展示了MercatorProjection.toLatitude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: addLabels

import org.oscim.core.MercatorProjection; //导入方法依赖的package包/类
private void addLabels(final int x, final int y, final int z, final MapPosition mapPosition) {

		final int s = Tile.SIZE;

		final int tileZ = 1 << z;
		final float lineHeight = _textStyle.fontSize + 1;

		final TextBucket textBucket = mTextBucket;
		textBucket.clear();

		for (int yy = -2; yy < 2; yy++) {
			for (int xx = -2; xx < 2; xx++) {

				final int tileX = x + xx;
				final int tileY = y + yy;

				final double latitude = MercatorProjection.toLatitude((double) tileY / tileZ);
				final double longitude = MercatorProjection.toLongitude((double) tileX / tileZ);

				final String labelTile = String.format("%d / %d / %d", z, tileX, tileY); //$NON-NLS-1$

				final String labelLat = String.format("lat %.4f", latitude); //$NON-NLS-1$
				final String labelLon = String.format("lon %.4f", longitude); //$NON-NLS-1$

				final int textX = s * xx + s / 2;
				final int textY = s * yy + s / 2;

				TextItem textItem = TextItem.pool.get();
				textItem.set(textX, textY, labelTile, _textStyle);
				textBucket.addText(textItem);

				/*
				 * Lat/Lon
				 */
				textItem = TextItem.pool.get();
				textItem.set(textX, textY + lineHeight, labelLat, _textStyle);
				textBucket.addText(textItem);

				textItem = TextItem.pool.get();
				textItem.set(textX, textY + lineHeight * 2, labelLon, _textStyle);
				textBucket.addText(textItem);
			}
		}
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:45,代码来源:GridRendererMT.java

示例10: onMapEvent

import org.oscim.core.MercatorProjection; //导入方法依赖的package包/类
@Override
   public void onMapEvent(Event e, MapPosition mapPosition) {
	if (e == Map.UPDATE_EVENT)
		return;

	double latitude = MercatorProjection.toLatitude(mapPosition.y);

	if (!mRedrawNeeded) {
		double scaleDiff = mPrevScale / mapPosition.scale;
		if (scaleDiff < 1.1 && scaleDiff > 0.9) {
			double latitudeDiff = Math.abs(mPrevLatitude - latitude);
			if (latitudeDiff < LATITUDE_REDRAW_THRESHOLD)
				return;
		}
	}
	mPrevLatitude = latitude;

	double groundResolution = MercatorProjection
	    .groundResolution(latitude, mapPosition.scale);

	int[] scaleBarValues;
	if (mImperialUnits) {
		groundResolution = groundResolution / METER_FOOT_RATIO;
		scaleBarValues = SCALE_BAR_VALUES_IMPERIAL;
	} else {
		scaleBarValues = SCALE_BAR_VALUES_METRIC;
	}

	float scaleBarLength = 0;
	int mapScaleValue = 0;

	for (int i = 0; i < scaleBarValues.length; ++i) {
		mapScaleValue = scaleBarValues[i];
		scaleBarLength = mapScaleValue / (float) groundResolution;
		if (scaleBarLength < (BITMAP_WIDTH - 10)) {
			break;
		}
	}
	synchronized (mLayerBitmap) {
		redrawMapScaleBitmap(scaleBarLength, mapScaleValue);
	}

	mBitmapLayer.updateBitmap();

	mRedrawNeeded = false;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:47,代码来源:MapScaleBar.java

示例11: render

import org.oscim.core.MercatorProjection; //导入方法依赖的package包/类
/** TileLoaderThemeHook */
@Override
public boolean render(MapTile tile, RenderBuckets buckets, MapElement element,
        RenderStyle style, int level) {

	if (!(style instanceof ExtrusionStyle))
		return false;

	ExtrusionStyle extrusion = (ExtrusionStyle) style;

	int height = 0;
	int minHeight = 0;

	String v = element.tags.getValue(Tag.KEY_HEIGHT);
	if (v != null)
		height = Integer.parseInt(v);

	v = element.tags.getValue(Tag.KEY_MIN_HEIGHT);
	if (v != null)
		minHeight = Integer.parseInt(v);

	/* 12m default */
	if (height == 0)
		height = 12 * 100;

	ExtrusionBuckets ebs = get(tile);

	for (ExtrusionBucket b = ebs.buckets; b != null; b = b.next()) {
		if (b.colors == extrusion.colors) {
			b.add(element, height, minHeight);
			return true;
		}
	}

	double lat = MercatorProjection.toLatitude(tile.y);
	float groundScale = (float) MercatorProjection
	    .groundResolution(lat, 1 << tile.zoomLevel);

	ebs.buckets = Inlist.push(ebs.buckets,
	                          new ExtrusionBucket(0, groundScale,
	                                              extrusion.colors));

	ebs.buckets.add(element, height, minHeight);

	return true;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:47,代码来源:BuildingLayer.java

示例12: getMapCenter

import org.oscim.core.MercatorProjection; //导入方法依赖的package包/类
/** @return the current center point of the MapView. */
public synchronized GeoPoint getMapCenter() {
	return new GeoPoint(MercatorProjection.toLatitude(mAbsY),
			MercatorProjection.toLongitude(mAbsX));
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:6,代码来源:MapViewPosition.java

示例13: executeJob

import org.oscim.core.MercatorProjection; //导入方法依赖的package包/类
@Override
public boolean executeJob(MapTile mapTile) {

	if (mTileDataSource == null)
		return false;

	mTile = mapTile;

	if (mTile.layers != null) {
		// should be fixed now.
		Log.d(TAG, "BUG tile already loaded " + mTile + " " + mTile.state);
		mTile = null;
		return false;
	}

	setScaleStrokeWidth(mTile.zoomLevel);

	// account for area changes with latitude
	double latitude = MercatorProjection.toLatitude(mTile.y);

	mLatScaleFactor = 0.4f + 0.6f * ((float) Math.sin(Math.abs(latitude) * (Math.PI / 180)));

	mGroundResolution = (float) (Math.cos(latitude * (Math.PI / 180))
			* MercatorProjection.EARTH_CIRCUMFERENCE
			/ ((long) Tile.SIZE << mTile.zoomLevel));

	mTile.layers = new Layers();

	// query database, which calls renderWay and renderPOI
	// callbacks while processing map tile data.
	if (mTileDataSource.executeQuery(mTile, this) != QueryResult.SUCCESS) {

		//Log.d(TAG, "Failed loading: " + tile);
		mTile.layers.clear();
		mTile.layers = null;
		TextItem.pool.releaseAll(mTile.labels);
		mTile.labels = null;
		// FIXME add STATE_FAILED?
		// in passTile everything but STATE_LOADING is considered failed.
		mTile.state = STATE_NONE;
		mTile = null;
		return false;
	}

	//		if (debug.drawTileFrames) {
	//			// draw tile coordinate
	//			mTagName = new Tag("name", mTile.toString(), false);
	//			mElement = mDebugPoint;
	//			RenderInstruction[] ri;
	//			ri = renderTheme.matchNode(debugTagWay, (byte) 0);
	//			renderNode(ri);
	//
	//			// draw tile box
	//			mElement = mDebugWay;
	//			mDrawingLayer = 100 * renderLevels;
	//			ri = renderTheme.matchWay(mDebugWay.tags, (byte) 0, false);
	//			renderWay(ri);
	//		}

	mTile = null;
	return true;
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:63,代码来源:MapTileLoader.java

示例14: onUpdate

import org.oscim.core.MercatorProjection; //导入方法依赖的package包/类
@Override
public void onUpdate(MapPosition mapPosition, boolean changed, boolean clear) {
	double latitude = MercatorProjection.toLatitude(mapPosition.y);

	if (!mRedrawNeeded) {
		double scaleDiff = mPrevScale / mapPosition.scale;
		if (scaleDiff < 1.1 && scaleDiff > 0.9) {
			double latitudeDiff = Math.abs(mPrevLatitude - latitude);
			if (latitudeDiff < LATITUDE_REDRAW_THRESHOLD)
				return;
		}
	}
	mPrevLatitude = latitude;

	double groundResolution = MercatorProjection.calculateGroundResolution(
			latitude, mapPosition.scale);

	int[] scaleBarValues;
	if (mImperialUnits) {
		groundResolution = groundResolution / METER_FOOT_RATIO;
		scaleBarValues = SCALE_BAR_VALUES_IMPERIAL;
	} else {
		scaleBarValues = SCALE_BAR_VALUES_METRIC;
	}

	float scaleBarLength = 0;
	int mapScaleValue = 0;

	for (int i = 0; i < scaleBarValues.length; ++i) {
		mapScaleValue = scaleBarValues[i];
		scaleBarLength = mapScaleValue / (float) groundResolution;
		if (scaleBarLength < (BITMAP_WIDTH - 10)) {
			break;
		}
	}
	synchronized (mMapScaleBitmap) {
		redrawMapScaleBitmap(scaleBarLength, mapScaleValue);
	}

	mBitmapLayer.updateBitmap();

	mRedrawNeeded = false;
}
 
开发者ID:opensciencemap,项目名称:vtm-android,代码行数:44,代码来源:MapScaleBar.java

示例15: fromScreenPoint

import org.oscim.core.MercatorProjection; //导入方法依赖的package包/类
/**
 * Get the GeoPoint for x,y in screen coordinates.
 * 
 * @param x screen coordinate
 * @param y screen coordinate
 * @return the corresponding GeoPoint
 */
public synchronized GeoPoint fromScreenPoint(float x, float y) {
	fromScreenPoint(x, y, mMovePoint);
	return new GeoPoint(
	                    MercatorProjection.toLatitude(mMovePoint.y),
	                    MercatorProjection.toLongitude(mMovePoint.x));
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:14,代码来源:Viewport.java


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