Java源码示例:mil.nga.sf.proj.ProjectionFactory

示例1
/**
 * Get the coverage data value at the coordinate
 *
 * @param geoPackage GeoPackage
 * @param algorithm  algorithm
 * @param latitude   latitude
 * @param longitude  longitude
 * @param epsg       epsg
 * @return coverage data value
 * @throws Exception
 */
public static Double getValue(GeoPackage geoPackage,
                              CoverageDataAlgorithm algorithm, double latitude,
                              double longitude, long epsg) throws Exception {

    Double value = null;

    List<String> coverageDataTables = CoverageData.getTables(geoPackage);
    TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao();

    for (String coverageTable : coverageDataTables) {

        TileMatrixSet tileMatrixSet = dao.queryForId(coverageTable);
        TileDao tileDao = geoPackage.getTileDao(tileMatrixSet);

        Projection requestProjection = ProjectionFactory
                .getProjection(epsg);

        // Test getting the coverage data value of a single coordinate
        CoverageData<?> coverageData = CoverageData.getCoverageData(geoPackage, tileDao, requestProjection);
        coverageData.setAlgorithm(algorithm);
        value = coverageData.getValue(latitude, longitude);
    }

    return value;
}
 
示例2
/**
 * Create a tile table in the given GeoPackage
 * @return
 */
public boolean createTileTable(String gpName, BoundingBox boundingBox, long epsg, String tableName, TileScaling scaling){
    GeoPackage geoPackage = manager.open(gpName);
    try {
        // Create the srs if needed
        SpatialReferenceSystemDao srsDao = geoPackage.getSpatialReferenceSystemDao();
        SpatialReferenceSystem srs = srsDao.getOrCreateFromEpsg(epsg);
        // Create the tile table
        mil.nga.sf.proj.Projection projection = ProjectionFactory.getProjection(epsg);
        BoundingBox bbox = LoadTilesTask.transform(boundingBox, projection);
        geoPackage.createTileTableWithMetadata(
                tableName, bbox, srs.getSrsId(),
                bbox, srs.getSrsId());

        TileTableScaling tileTableScaling = new TileTableScaling(geoPackage, tableName);
        tileTableScaling.createOrUpdate(scaling);
    } catch (Exception e) {
        Log.i("Exception", e.toString());
        return false;
    } finally {
        geoPackage.close();
    }
    return true;
}
 
示例3
/**
 * Query for features in the bounding box
 *
 * @param columns     columns
 * @param boundingBox query bounding box
 * @param projection  bounding box projection
 * @return feature index results, must be closed
 * @since 3.5.0
 */
public FeatureIndexResults queryFeatures(String[] columns, BoundingBox boundingBox, Projection projection) {

    if (projection == null) {
        projection = ProjectionFactory.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
    }

    // Query for features
    FeatureIndexManager indexManager = featureTiles.getIndexManager();
    if (indexManager == null) {
        throw new GeoPackageException("Index Manager is not set on the Feature Tiles and is required to query indexed features");
    }
    FeatureIndexResults results = indexManager.query(columns, boundingBox, projection);
    return results;
}
 
示例4
/**
 * Get the bounding box as the provided projection
 *
 * @param projection projection
 */
public BoundingBox getBoundingBox(Projection projection) {
    ProjectionTransform webMercatorToProjection = ProjectionFactory
            .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR)
            .getTransformation(projection);
    return webMercatorBoundingBox
            .transform(webMercatorToProjection);
}
 
示例5
/**
 * 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);
}
 
示例6
/**
 * Draw a preview image
 *
 * @return preview image
 */
public Bitmap draw() {

    Bitmap image = null;

    FeatureDao featureDao = featureTiles.getFeatureDao();
    String table = featureDao.getTableName();

    Projection webMercator = ProjectionFactory
            .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);

    BoundingBox boundingBox = geoPackage.getFeatureBoundingBox(webMercator,
            table, false);
    if (boundingBox == null) {
        boundingBox = geoPackage.getContentsBoundingBox(webMercator, table);
    }
    if (boundingBox == null && manual) {
        boundingBox = geoPackage.getFeatureBoundingBox(webMercator, table,
                manual);
    }
    if (boundingBox != null) {
        boundingBox = TileBoundingBoxUtils
                .boundWebMercatorBoundingBox(boundingBox);
        BoundingBox expandedBoundingBox = boundingBox
                .squareExpand(bufferPercentage);
        expandedBoundingBox = TileBoundingBoxUtils
                .boundWebMercatorBoundingBox(expandedBoundingBox);
        int zoom = TileBoundingBoxUtils.getZoomLevel(expandedBoundingBox);

        FeatureCursor results = featureDao.query(
                columns.toArray(new String[]{}), where, whereArgs, null,
                null, null, limit != null ? limit.toString() : null);
        image = featureTiles.drawTile(zoom, expandedBoundingBox, results);
    }

    return image;
}
 
示例7
/**
 * Get the coverage data for the bounding box
 *
 * @param geoPackage  GeoPackage
 * @param algorithm   algorithm
 * @param boundingBox bounding box
 * @param width       results width
 * @param height      results height
 * @param epsg        epsg code
 * @return coverage data results
 * @throws Exception
 */
public static CoverageDataResults getValues(GeoPackage geoPackage,
                                            CoverageDataAlgorithm algorithm, BoundingBox boundingBox,
                                            int width, int height, long epsg) throws Exception {

    CoverageDataResults values = null;

    List<String> coverageDataTables = CoverageData.getTables(geoPackage);
    TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao();

    for (String coverageTable : coverageDataTables) {

        TileMatrixSet tileMatrixSet = dao.queryForId(coverageTable);
        TileDao tileDao = geoPackage.getTileDao(tileMatrixSet);

        Projection requestProjection = ProjectionFactory
                .getProjection(epsg);

        // Test getting the coverage data value of a single coordinate
        CoverageData<?> coverageData = CoverageData.getCoverageData(geoPackage, tileDao, requestProjection);
        coverageData.setAlgorithm(algorithm);
        coverageData.setWidth(width);
        coverageData.setHeight(height);
        values = coverageData.getValues(boundingBox);
    }

    return values;
}
 
示例8
private static void createFeatureTileLinkExtension(Context context, GeoPackage geoPackage)
        throws SQLException, IOException {

    List<String> featureTables = geoPackage.getFeatureTables();
    for (String featureTable : featureTables) {

        FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
        FeatureTiles featureTiles = new DefaultFeatureTiles(context, geoPackage, featureDao,
                context.getResources().getDisplayMetrics().density);

        BoundingBox boundingBox = featureDao.getBoundingBox();
        Projection projection = featureDao.getProjection();

        Projection requestProjection = ProjectionFactory
                .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);
        ProjectionTransform transform = projection
                .getTransformation(requestProjection);
        BoundingBox requestBoundingBox = boundingBox.transform(transform);

        int zoomLevel = TileBoundingBoxUtils
                .getZoomLevel(requestBoundingBox);
        zoomLevel = Math.max(zoomLevel, 8);
        zoomLevel = Math.min(zoomLevel, 19);

        int minZoom = zoomLevel - 8;
        int maxZoom = zoomLevel + 2;

        TileGenerator tileGenerator = new FeatureTileGenerator(context, geoPackage,
                featureTable + "_tiles", featureTiles, minZoom, maxZoom,
                requestBoundingBox, requestProjection);

        tileGenerator.generateTiles();
        featureTiles.close();
    }
}
 
示例9
/**
 * Create a projection
 * 
 * @param authority
 *            authority
 * @param code
 *            code
 * @return projection
 */
protected Projection createProjection(String authority, String code) {

	Projection projection = null;

	try {
		projection = ProjectionFactory.getProjection(authority, code);
	} catch (Exception e) {
		LOGGER.log(Level.WARNING, "Unable to create projection. Authority: "
				+ authority + ", Code: " + code);
	}

	return projection;
}
 
示例10
/**
 * Get the projection for the Spatial Reference System
 * 
 * @return projection
 * @since 3.0.0
 */
public Projection getProjection() {

	String authority = getOrganization();
	long code = getOrganizationCoordsysId();
	String definition = getDefinition_12_063();
	if (definition == null) {
		definition = getDefinition();
	}

	Projection projection = ProjectionFactory.getProjection(authority,
			code, null, definition);

	return projection;
}
 
示例11
/**
 * 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);
}
 
示例12
/**
 * Draw a preview image
 * 
 * @return preview image
 */
public BufferedImage draw() {

	BufferedImage image = null;

	FeatureDao featureDao = featureTiles.getFeatureDao();
	String table = featureDao.getTableName();

	Projection webMercator = ProjectionFactory
			.getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);

	BoundingBox boundingBox = geoPackage.getFeatureBoundingBox(webMercator,
			table, false);
	if (boundingBox == null) {
		boundingBox = geoPackage.getContentsBoundingBox(webMercator, table);
	}
	if (boundingBox == null && manual) {
		boundingBox = geoPackage.getFeatureBoundingBox(webMercator, table,
				manual);
	}
	if (boundingBox != null) {
		boundingBox = TileBoundingBoxUtils
				.boundWebMercatorBoundingBox(boundingBox);
		BoundingBox expandedBoundingBox = boundingBox
				.squareExpand(bufferPercentage);
		expandedBoundingBox = TileBoundingBoxUtils
				.boundWebMercatorBoundingBox(expandedBoundingBox);
		int zoom = TileBoundingBoxUtils.getZoomLevel(expandedBoundingBox);

		FeatureResultSet results = featureDao.query(
				columns.toArray(new String[] {}), where, whereArgs, null,
				null, null, limit != null ? limit.toString() : null);
		image = featureTiles.drawTile(zoom, expandedBoundingBox, results);
	}

	return image;
}
 
示例13
/**
 * Get the coverage data value at the coordinate
 * 
 * @param geoPackage
 *            GeoPackage
 * @param algorithm
 *            algorithm
 * @param latitude
 *            latitude
 * @param longitude
 *            longitude
 * @param epsg
 *            epsg
 * @return coverage data value
 * @throws Exception
 */
public static Double getValue(GeoPackage geoPackage,
		CoverageDataAlgorithm algorithm, double latitude, double longitude,
		long epsg) throws Exception {

	Double value = null;

	List<String> coverageDataTables = CoverageData.getTables(geoPackage);
	TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao();

	for (String coverageTable : coverageDataTables) {

		TileMatrixSet tileMatrixSet = dao.queryForId(coverageTable);
		TileDao tileDao = geoPackage.getTileDao(tileMatrixSet);

		Projection requestProjection = ProjectionFactory
				.getProjection(epsg);

		// Test getting the coverage data value of a single coordinate
		CoverageData<?> coverageData = CoverageData.getCoverageData(
				geoPackage, tileDao, requestProjection);
		coverageData.setAlgorithm(algorithm);
		value = coverageData.getValue(latitude, longitude);
	}

	return value;
}
 
示例14
/**
 * Get the coverage data for the bounding box
 * 
 * @param geoPackage
 *            GeoPackage
 * @param algorithm
 *            algorithm
 * @param boundingBox
 *            bounding box
 * @param width
 *            results width
 * @param height
 *            results height
 * @param epsg
 *            epsg
 * @return coverage data results
 * @throws Exception
 */
public static CoverageDataResults getValues(GeoPackage geoPackage,
		CoverageDataAlgorithm algorithm, BoundingBox boundingBox,
		int width, int height, long epsg) throws Exception {

	CoverageDataResults values = null;

	List<String> coverageDataTables = CoverageData.getTables(geoPackage);
	TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao();

	for (String coverageTable : coverageDataTables) {

		TileMatrixSet tileMatrixSet = dao.queryForId(coverageTable);
		TileDao tileDao = geoPackage.getTileDao(tileMatrixSet);

		Projection requestProjection = ProjectionFactory
				.getProjection(epsg);

		// Test getting the coverage data value of a single coordinate
		CoverageData<?> coverageData = CoverageData.getCoverageData(
				geoPackage, tileDao, requestProjection);
		coverageData.setAlgorithm(algorithm);
		coverageData.setWidth(width);
		coverageData.setHeight(height);
		values = coverageData.getValues(boundingBox);
	}

	return values;
}
 
示例15
private static void createFeatureTileLinkExtension(GeoPackage geoPackage)
		throws SQLException, IOException {

	List<String> featureTables = geoPackage.getFeatureTables();
	for (String featureTable : featureTables) {

		FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
		FeatureTiles featureTiles = new DefaultFeatureTiles(geoPackage,
				featureDao);

		BoundingBox boundingBox = featureDao.getBoundingBox();
		Projection projection = featureDao.getProjection();

		Projection requestProjection = ProjectionFactory
				.getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);
		ProjectionTransform transform = projection
				.getTransformation(requestProjection);
		BoundingBox requestBoundingBox = boundingBox.transform(transform);

		int zoomLevel = TileBoundingBoxUtils
				.getZoomLevel(requestBoundingBox);
		zoomLevel = Math.max(zoomLevel, 8);
		zoomLevel = Math.min(zoomLevel, 19);

		int minZoom = zoomLevel - 8;
		int maxZoom = zoomLevel + 2;

		TileGenerator tileGenerator = new FeatureTileGenerator(geoPackage,
				featureTable + "_tiles", featureTiles, minZoom, maxZoom,
				requestBoundingBox, requestProjection);

		tileGenerator.generateTiles();
	}
}
 
示例16
private static BoundingBox getBoundingBox(BoundingBox boundingBox) {
	boundingBox = TileBoundingBoxUtils
			.boundWgs84BoundingBoxWithWebMercatorLimits(boundingBox);
	boundingBox = boundingBox.transform(ProjectionFactory.getProjection(
			ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM)
			.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR));
	return boundingBox;
}
 
示例17
/**
 * Test 10 random locations and optionally print
 *
 * @throws Exception
 */
@Test
public void testRandomLocations() throws Exception {

    BoundingBox projectedBoundingBox = null;

    List<String> coverageDataTables = CoverageDataPng.getTables(geoPackage);
    TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao();

    for (String coverageTable : coverageDataTables) {

        TileMatrixSet tileMatrixSet = dao.queryForId(coverageTable);

        BoundingBox boundingBox = tileMatrixSet.getBoundingBox();
        if (PRINT) {
            System.out.println("Min Latitude: "
                    + boundingBox.getMinLatitude());
            System.out.println("Max Latitude: "
                    + boundingBox.getMaxLatitude());
            System.out.println("Min Longitude: "
                    + boundingBox.getMinLongitude());
            System.out.println("Max Longitude: "
                    + boundingBox.getMaxLongitude());
            System.out.println();
        }
        SpatialReferenceSystemDao srsDao = geoPackage
                .getSpatialReferenceSystemDao();
        long srsId = tileMatrixSet.getSrsId();
        SpatialReferenceSystem srs = srsDao.queryForId(srsId);
        Projection projection = srs.getProjection();
        Projection requestProjection = ProjectionFactory
                .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
        ProjectionTransform coverageToRequest = projection
                .getTransformation(requestProjection);
        projectedBoundingBox = boundingBox.transform(coverageToRequest);

    }
    if (PRINT) {
        System.out.println("Min Latitude: "
                + projectedBoundingBox.getMinLatitude());
        System.out.println("Max Latitude: "
                + projectedBoundingBox.getMaxLatitude());
        System.out.println("Min Longitude: "
                + projectedBoundingBox.getMinLongitude());
        System.out.println("Max Longitude: "
                + projectedBoundingBox.getMaxLongitude());
        System.out.println();
    }

    double latDistance = projectedBoundingBox.getMaxLatitude()
            - projectedBoundingBox.getMinLatitude();
    double lonDistance = projectedBoundingBox.getMaxLongitude()
            - projectedBoundingBox.getMinLongitude();

    for (int i = 0; i < 10; i++) {

        // Get a random coordinate
        double latitude = latDistance * .9 * Math.random()
                + projectedBoundingBox.getMinLatitude()
                + (.05 * latDistance);
        double longitude = lonDistance * .9 * Math.random()
                + projectedBoundingBox.getMinLongitude()
                + (.05 * lonDistance);
        testLocation(latitude, longitude);
        if (PRINT) {
            System.out.println();
        }
    }
}
 
示例18
/**
 * Test 10 random locations and optionally print
 *
 * @throws Exception
 */
@Test
public void testRandomLocations() throws Exception {

    BoundingBox projectedBoundingBox = null;

    List<String> coverageDataTables = CoverageDataTiff.getTables(geoPackage);
    TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao();

    for (String coverageTable : coverageDataTables) {

        TileMatrixSet tileMatrixSet = dao.queryForId(coverageTable);

        BoundingBox boundingBox = tileMatrixSet.getBoundingBox();
        if (PRINT) {
            System.out.println("Min Latitude: "
                    + boundingBox.getMinLatitude());
            System.out.println("Max Latitude: "
                    + boundingBox.getMaxLatitude());
            System.out.println("Min Longitude: "
                    + boundingBox.getMinLongitude());
            System.out.println("Max Longitude: "
                    + boundingBox.getMaxLongitude());
            System.out.println();
        }
        SpatialReferenceSystemDao srsDao = geoPackage
                .getSpatialReferenceSystemDao();
        long srsId = tileMatrixSet.getSrsId();
        SpatialReferenceSystem srs = srsDao.queryForId(srsId);
        Projection projection = srs.getProjection();
        Projection requestProjection = ProjectionFactory
                .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
        ProjectionTransform coverageToRequest = projection
                .getTransformation(requestProjection);
        projectedBoundingBox = boundingBox.transform(coverageToRequest);

    }
    if (PRINT) {
        System.out.println("Min Latitude: "
                + projectedBoundingBox.getMinLatitude());
        System.out.println("Max Latitude: "
                + projectedBoundingBox.getMaxLatitude());
        System.out.println("Min Longitude: "
                + projectedBoundingBox.getMinLongitude());
        System.out.println("Max Longitude: "
                + projectedBoundingBox.getMaxLongitude());
        System.out.println();
    }

    double latDistance = projectedBoundingBox.getMaxLatitude()
            - projectedBoundingBox.getMinLatitude();
    double lonDistance = projectedBoundingBox.getMaxLongitude()
            - projectedBoundingBox.getMinLongitude();

    for (int i = 0; i < 10; i++) {

        // Get a random coordinate
        double latitude = latDistance * .9 * Math.random()
                + projectedBoundingBox.getMinLatitude()
                + (.05 * latDistance);
        double longitude = lonDistance * .9 * Math.random()
                + projectedBoundingBox.getMinLongitude()
                + (.05 * lonDistance);
        testLocation(latitude, longitude);
        if (PRINT) {
            System.out.println();
        }
    }
}
 
示例19
/**
 * Load tiles from a URL
 *
 * @param activity
 * @param callback
 * @param active
 * @param database
 * @param tableName
 * @param tileUrl
 * @param minZoom
 * @param maxZoom
 * @param compressFormat
 * @param compressQuality
 * @param googleTiles
 * @param boundingBox
 * @param scaling
 * @param authority
 * @param code
 */
public static void loadTiles(Activity activity, ILoadTilesTask callback,
                             GeoPackageDatabases active, String database, String tableName,
                             String tileUrl, int minZoom, int maxZoom,
                             CompressFormat compressFormat, Integer compressQuality,
                             boolean googleTiles, BoundingBox boundingBox, TileScaling scaling, String authority, String code) {

    GeoPackageManager manager = GeoPackageFactory.getManager(activity);
    GeoPackage geoPackage = manager.open(database);

    Projection projection = ProjectionFactory.getProjection(authority, code);
    BoundingBox bbox = transform(boundingBox, projection);

    TileGenerator tileGenerator = new UrlTileGenerator(activity, geoPackage,
            tableName, tileUrl, minZoom, maxZoom, bbox, projection);
    setTileGenerator(activity, tileGenerator, minZoom, maxZoom, compressFormat, compressQuality, googleTiles, boundingBox, scaling);

    loadTiles(activity, callback, active, geoPackage, tableName, tileGenerator);
}
 
示例20
/**
 * Load tiles from features
 *
 * @param activity
 * @param callback
 * @param active
 * @param geoPackage
 * @param tableName
 * @param featureTiles
 * @param minZoom
 * @param maxZoom
 * @param compressFormat
 * @param compressQuality
 * @param googleTiles
 * @param boundingBox
 * @param scaling
 * @param authority
 * @param code
 */
public static void loadTiles(Activity activity, ILoadTilesTask callback,
                             GeoPackageDatabases active, GeoPackage geoPackage, String tableName,
                             FeatureTiles featureTiles, int minZoom, int maxZoom,
                             CompressFormat compressFormat, Integer compressQuality,
                             boolean googleTiles, BoundingBox boundingBox, TileScaling scaling, String authority, String code) {

    GeoPackageUtils.prepareFeatureTiles(featureTiles);

    Projection projection = ProjectionFactory.getProjection(authority, code);
    BoundingBox bbox = transform(boundingBox, projection);

    TileGenerator tileGenerator = new FeatureTileGenerator(activity, geoPackage,
            tableName, featureTiles, minZoom, maxZoom, bbox, projection);
    setTileGenerator(activity, tileGenerator, minZoom, maxZoom, compressFormat, compressQuality, googleTiles, boundingBox, scaling);

    loadTiles(activity, callback, active, geoPackage, tableName, tileGenerator);
}
 
示例21
/**
 * Test 10 random locations and optionally print
 * 
 * @throws Exception
 */
@Test
public void testRandomLocations() throws Exception {

	BoundingBox projectedBoundingBox = null;

	List<String> coverageDataTables = CoverageDataPng.getTables(geoPackage);
	TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao();

	for (String coverageTable : coverageDataTables) {

		TileMatrixSet tileMatrixSet = dao.queryForId(coverageTable);

		BoundingBox boundingBox = tileMatrixSet.getBoundingBox();
		if (PRINT) {
			System.out.println("Min Latitude: "
					+ boundingBox.getMinLatitude());
			System.out.println("Max Latitude: "
					+ boundingBox.getMaxLatitude());
			System.out.println("Min Longitude: "
					+ boundingBox.getMinLongitude());
			System.out.println("Max Longitude: "
					+ boundingBox.getMaxLongitude());
			System.out.println();
		}
		SpatialReferenceSystemDao srsDao = geoPackage
				.getSpatialReferenceSystemDao();
		long srsId = tileMatrixSet.getSrsId();
		SpatialReferenceSystem srs = srsDao.queryForId(srsId);
		Projection projection = srs.getProjection();
		Projection requestProjection = ProjectionFactory
				.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
		ProjectionTransform coverageToRequest = projection
				.getTransformation(requestProjection);
		projectedBoundingBox = boundingBox.transform(coverageToRequest);

	}
	if (PRINT) {
		System.out.println("Min Latitude: "
				+ projectedBoundingBox.getMinLatitude());
		System.out.println("Max Latitude: "
				+ projectedBoundingBox.getMaxLatitude());
		System.out.println("Min Longitude: "
				+ projectedBoundingBox.getMinLongitude());
		System.out.println("Max Longitude: "
				+ projectedBoundingBox.getMaxLongitude());
		System.out.println();
	}

	double latDistance = projectedBoundingBox.getMaxLatitude()
			- projectedBoundingBox.getMinLatitude();
	double lonDistance = projectedBoundingBox.getMaxLongitude()
			- projectedBoundingBox.getMinLongitude();

	for (int i = 0; i < 10; i++) {

		// Get a random coordinate
		double latitude = latDistance * .9 * Math.random()
				+ projectedBoundingBox.getMinLatitude()
				+ (.05 * latDistance);
		double longitude = lonDistance * .9 * Math.random()
				+ projectedBoundingBox.getMinLongitude()
				+ (.05 * lonDistance);
		testLocation(latitude, longitude);
		if (PRINT) {
			System.out.println();
		}
	}
}
 
示例22
/**
 * Test 10 random locations and optionally print
 * 
 * @throws Exception
 */
@Test
public void testRandomLocations() throws Exception {

	BoundingBox projectedBoundingBox = null;

	List<String> coverageDataTables = CoverageDataTiff
			.getTables(geoPackage);
	TileMatrixSetDao dao = geoPackage.getTileMatrixSetDao();

	for (String coverageTable : coverageDataTables) {

		TileMatrixSet tileMatrixSet = dao.queryForId(coverageTable);

		BoundingBox boundingBox = tileMatrixSet.getBoundingBox();
		if (PRINT) {
			System.out.println("Min Latitude: "
					+ boundingBox.getMinLatitude());
			System.out.println("Max Latitude: "
					+ boundingBox.getMaxLatitude());
			System.out.println("Min Longitude: "
					+ boundingBox.getMinLongitude());
			System.out.println("Max Longitude: "
					+ boundingBox.getMaxLongitude());
			System.out.println();
		}
		SpatialReferenceSystemDao srsDao = geoPackage
				.getSpatialReferenceSystemDao();
		long srsId = tileMatrixSet.getSrsId();
		SpatialReferenceSystem srs = srsDao.queryForId(srsId);
		Projection projection = srs.getProjection();
		Projection requestProjection = ProjectionFactory
				.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
		ProjectionTransform coverageToRequest = projection
				.getTransformation(requestProjection);
		projectedBoundingBox = boundingBox.transform(coverageToRequest);

	}
	if (PRINT) {
		System.out.println("Min Latitude: "
				+ projectedBoundingBox.getMinLatitude());
		System.out.println("Max Latitude: "
				+ projectedBoundingBox.getMaxLatitude());
		System.out.println("Min Longitude: "
				+ projectedBoundingBox.getMinLongitude());
		System.out.println("Max Longitude: "
				+ projectedBoundingBox.getMaxLongitude());
		System.out.println();
	}

	double latDistance = projectedBoundingBox.getMaxLatitude()
			- projectedBoundingBox.getMinLatitude();
	double lonDistance = projectedBoundingBox.getMaxLongitude()
			- projectedBoundingBox.getMinLongitude();

	for (int i = 0; i < 10; i++) {

		// Get a random coordinate
		double latitude = latDistance * .9 * Math.random()
				+ projectedBoundingBox.getMinLatitude()
				+ (.05 * latDistance);
		double longitude = lonDistance * .9 * Math.random()
				+ projectedBoundingBox.getMinLongitude()
				+ (.05 * lonDistance);
		testLocation(latitude, longitude);
		if (PRINT) {
			System.out.println();
		}
	}
}
 
示例23
private static Projection getProjection() {
	return ProjectionFactory
			.getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);
}
 
示例24
/**
 * Constructor with specified tile size
 *
 * @param tileDao tile dao
 * @param width   width
 * @param height  height
 */
public GeoPackageTileRetriever(TileDao tileDao, Integer width, Integer height) {

    tileDao.adjustTileMatrixLengths();

    Projection webMercator = ProjectionFactory
            .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);

    tileCreator = new TileCreator(tileDao, width, height, webMercator);
}
 
示例25
/**
 * Constructor with specified tile size
 *
 * @param tileDao
 *            tile dao
 * @param width
 *            width
 * @param height
 *            height
 * @param imageFormat
 *            image format
 */
public GeoPackageTileRetriever(TileDao tileDao, Integer width,
		Integer height, String imageFormat) {

	tileDao.adjustTileMatrixLengths();

	Projection webMercator = ProjectionFactory
			.getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);

	tileCreator = new TileCreator(tileDao, width, height, webMercator,
			imageFormat);
}
 
示例26
/**
 * Get the tile grid for the location specified as WGS84
 * 
 * @param point
 *            point
 * @param zoom
 *            zoom level
 * @return tile grid
 * @since 1.1.0
 */
public static TileGrid getTileGridFromWGS84(Point point, int zoom) {
	Projection projection = ProjectionFactory
			.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
	return getTileGrid(point, zoom, projection);
}