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

The following examples show how to use mil.nga.sf.proj.ProjectionConstants#WEB_MERCATOR_MIN_LAT_RANGE . 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
Source Project: geopackage-android   File: TestUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Create a random point
 *
 * @param hasZ
 * @param hasM
 * @return
 */
public static Point createPoint(boolean hasZ, boolean hasM) {

    double x = Math.random() * 180.0 * (Math.random() < .5 ? 1 : -1);
    double y = Math.random() * ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE * (Math.random() < .5 ? 1 : -1);

    Point point = new Point(hasZ, hasM, x, y);

    if (hasZ) {
        double z = Math.random() * 1000.0;
        point.setZ(z);
    }

    if (hasM) {
        double m = Math.random() * 1000.0;
        point.setM(m);
    }

    return point;
}
 
Example 2
/**
 * Bound the upper and lower bounds of the degrees bounding box with web
 * mercator limits
 * 
 * @param boundingBox
 *            degrees bounding box
 * @return bounding box
 * @since 1.3.1
 */
public static BoundingBox boundDegreesBoundingBoxWithWebMercatorLimits(
		BoundingBox boundingBox) {
	BoundingBox bounded = new BoundingBox(boundingBox);
	if (bounded
			.getMinLatitude() < ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE) {
		bounded.setMinLatitude(
				ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE);
	}
	if (bounded
			.getMaxLatitude() < ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE) {
		bounded.setMaxLatitude(
				ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE);
	}
	if (bounded
			.getMaxLatitude() > ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE) {
		bounded.setMaxLatitude(
				ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE);
	}
	if (bounded
			.getMinLatitude() > ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE) {
		bounded.setMinLatitude(
				ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE);
	}
	return bounded;
}
 
Example 3
Source Project: geopackage-java   File: TestUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Create a random point
 * 
 * @param hasZ
 * @param hasM
 * @return point
 */
public static Point createPoint(boolean hasZ, boolean hasM) {

	double x = Math.random() * 180.0 * (Math.random() < .5 ? 1 : -1);
	double y = Math.random()
			* ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE
			* (Math.random() < .5 ? 1 : -1);

	Point point = new Point(hasZ, hasM, x, y);

	if (hasZ) {
		double z = Math.random() * 1000.0;
		point.setZ(z);
	}

	if (hasM) {
		double m = Math.random() * 1000.0;
		point.setM(m);
	}

	return point;
}
 
Example 4
Source Project: geopackage-android   File: TileGenerator.java    License: MIT License 5 votes vote down vote up
/**
 * Adjust the tile matrix set and web mercator bounds for XYZ tile format
 */
private void adjustXYZBounds() {
    // Set the tile matrix set bounding box to be the world
    BoundingBox standardWgs84Box = new BoundingBox(-ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH,
            ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE,
            ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH,
            ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE);
    ProjectionTransform wgs84ToWebMercatorTransform = ProjectionFactory.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM)
            .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR);
    tileGridBoundingBox = standardWgs84Box.transform(wgs84ToWebMercatorTransform);
}
 
Example 5
Source Project: geopackage-android   File: TileDao.java    License: MIT License 5 votes vote down vote up
/**
 * Determine if the tiles are in the XYZ tile coordinate format
 *
 * @return true if XYZ tile format
 * @since 3.5.0
 */
public boolean isXYZTiles() {

    // Convert the bounding box to wgs84
    BoundingBox boundingBox = tileMatrixSet.getBoundingBox();
    BoundingBox wgs84BoundingBox = boundingBox.transform(
            projection.getTransformation(
                    ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM));

    boolean xyzTiles = false;

    // Verify the bounds are the entire world
    if (wgs84BoundingBox.getMinLatitude() <= ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE
            && wgs84BoundingBox.getMaxLatitude() >= ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE
            && wgs84BoundingBox.getMinLongitude() <= -ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH
            && wgs84BoundingBox.getMaxLongitude() >= ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH) {

        xyzTiles = true;

        // Verify each tile matrix is the correct width and height
        for (TileMatrix tileMatrix : tileMatrices) {
            long zoomLevel = tileMatrix.getZoomLevel();
            long tilesPerSide = TileBoundingBoxUtils
                    .tilesPerSide((int) zoomLevel);
            if (tileMatrix.getMatrixWidth() != tilesPerSide
                    || tileMatrix.getMatrixHeight() != tilesPerSide) {
                xyzTiles = false;
                break;
            }
        }
    }

    return xyzTiles;
}
 
Example 6
Source Project: geopackage-java   File: TileGenerator.java    License: MIT License 5 votes vote down vote up
/**
 * Adjust the tile matrix set and web mercator bounds for XYZ tile format
 */
private void adjustXYZBounds() {
	// Set the tile matrix set bounding box to be the world
	BoundingBox standardWgs84Box = new BoundingBox(
			-ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH,
			ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE,
			ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH,
			ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE);
	ProjectionTransform wgs84ToWebMercatorTransform = ProjectionFactory
			.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM)
			.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR);
	tileGridBoundingBox = standardWgs84Box
			.transform(wgs84ToWebMercatorTransform);
}
 
Example 7
Source Project: geopackage-java   File: TileDao.java    License: MIT License 5 votes vote down vote up
/**
 * Determine if the tiles are in the XYZ tile coordinate format
 * 
 * @return true if XYZ tile format
 * @since 3.5.0
 */
public boolean isXYZTiles() {

	// Convert the bounding box to wgs84
	BoundingBox boundingBox = tileMatrixSet.getBoundingBox();
	BoundingBox wgs84BoundingBox = boundingBox
			.transform(projection.getTransformation(
					ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM));

	boolean xyzTiles = false;

	// Verify the bounds are the entire world
	if (wgs84BoundingBox
			.getMinLatitude() <= ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE
			&& wgs84BoundingBox
					.getMaxLatitude() >= ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE
			&& wgs84BoundingBox
					.getMinLongitude() <= -ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH
			&& wgs84BoundingBox
					.getMaxLongitude() >= ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH) {

		xyzTiles = true;

		// Verify each tile matrix is the correct width and height
		for (TileMatrix tileMatrix : tileMatrices) {
			long zoomLevel = tileMatrix.getZoomLevel();
			long tilesPerSide = TileBoundingBoxUtils
					.tilesPerSide((int) zoomLevel);
			if (tileMatrix.getMatrixWidth() != tilesPerSide
					|| tileMatrix.getMatrixHeight() != tilesPerSide) {
				xyzTiles = false;
				break;
			}
		}
	}

	return xyzTiles;
}