Java Code Examples for mil.nga.sf.proj.ProjectionConstants#WGS84_HALF_WORLD_LAT_HEIGHT

The following examples show how to use mil.nga.sf.proj.ProjectionConstants#WGS84_HALF_WORLD_LAT_HEIGHT . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Get the WGS84 tile bounding box from the tile grid and zoom level
 *
 * @param tileGrid
 *            tile grid
 * @param zoom
 *            zoom
 *
 * @return wgs84 bounding box
 * @since 1.2.0
 */
public static BoundingBox getWGS84BoundingBox(TileGrid tileGrid, int zoom) {

	int tilesPerLat = tilesPerWGS84LatSide(zoom);
	int tilesPerLon = tilesPerWGS84LonSide(zoom);

	double tileSizeLat = tileSizeLatPerWGS84Side(tilesPerLat);
	double tileSizeLon = tileSizeLonPerWGS84Side(tilesPerLon);

	double minLon = (-1 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH)
			+ (tileGrid.getMinX() * tileSizeLon);
	double maxLon = (-1 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH)
			+ ((tileGrid.getMaxX() + 1) * tileSizeLon);
	double minLat = ProjectionConstants.WGS84_HALF_WORLD_LAT_HEIGHT
			- ((tileGrid.getMaxY() + 1) * tileSizeLat);
	double maxLat = ProjectionConstants.WGS84_HALF_WORLD_LAT_HEIGHT
			- (tileGrid.getMinY() * tileSizeLat);

	BoundingBox box = new BoundingBox(minLon, minLat, maxLon, maxLat);

	return box;
}
 
Example 2
Source Project: geopackage-core-java   File: BoundingBox.java    License: MIT License 5 votes vote down vote up
/**
 * Constructor
 */
public BoundingBox() {
	this(-ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH,
			-ProjectionConstants.WGS84_HALF_WORLD_LAT_HEIGHT,
			ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH,
			ProjectionConstants.WGS84_HALF_WORLD_LAT_HEIGHT);
}
 
Example 3
/**
 * Get the tile grid that includes the entire tile bounding box
 *
 * @param boundingBox
 *            wgs84 bounding box
 * @param zoom
 *            zoom level
 *
 * @return tile grid
 * @since 1.2.0
 */
public static TileGrid getTileGridWGS84(BoundingBox boundingBox, int zoom) {

	int tilesPerLat = tilesPerWGS84LatSide(zoom);
	int tilesPerLon = tilesPerWGS84LonSide(zoom);

	double tileSizeLat = tileSizeLatPerWGS84Side(tilesPerLat);
	double tileSizeLon = tileSizeLonPerWGS84Side(tilesPerLon);

	int minX = (int) ((boundingBox.getMinLongitude()
			+ ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH)
			/ tileSizeLon);
	double tempMaxX = (boundingBox.getMaxLongitude()
			+ ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH) / tileSizeLon;
	int maxX = (int) tempMaxX;
	if (tempMaxX % 1 == 0) {
		maxX--;
	}
	maxX = Math.min(maxX, tilesPerLon - 1);

	int minY = (int) (((boundingBox.getMaxLatitude()
			- ProjectionConstants.WGS84_HALF_WORLD_LAT_HEIGHT) * -1)
			/ tileSizeLat);
	double tempMaxY = ((boundingBox.getMinLatitude()
			- ProjectionConstants.WGS84_HALF_WORLD_LAT_HEIGHT) * -1)
			/ tileSizeLat;
	int maxY = (int) tempMaxY;
	if (tempMaxY % 1 == 0) {
		maxY--;
	}
	maxY = Math.min(maxY, tilesPerLat - 1);

	TileGrid grid = new TileGrid(minX, minY, maxX, maxY);

	return grid;
}
 
Example 4
/**
 * Get the tile height in degrees latitude
 *
 * @param tilesPerLat
 *            tiles per latitude side
 *
 * @return degrees
 * @since 1.2.0
 */
public static double tileSizeLatPerWGS84Side(int tilesPerLat) {
	return (2 * ProjectionConstants.WGS84_HALF_WORLD_LAT_HEIGHT)
			/ tilesPerLat;
}