/** * 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); }
/** * 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); }
/** * 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); }
/** * Adjust the tile matrix set and web mercator bounds for Google tile format */ private void adjustGoogleBounds() { // 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); }
/** * Adjust the tile matrix set and web mercator bounds for Google tile format */ private void adjustGoogleBounds() { // 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); }
/** * 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; }
bboxProjection = ProjectionFactory.getProjection(epsg); } else { boundingBox = new BoundingBox(); bboxProjection = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Projection urlProjection = ProjectionFactory.getProjection(urlEpsg); ProjectionTransform transform = bboxProjection .getTransformation(urlProjection);
/** * Convert the bounding box coordinates to a new web mercator bounding box * * @param boundingBox * bounding box * @return bounding box */ public static BoundingBox toWebMercator(BoundingBox boundingBox) { double minLatitude = Math.max(boundingBox.getMinLatitude(), ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE); double maxLatitude = Math.min(boundingBox.getMaxLatitude(), ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE); Point lowerLeftPoint = new Point(false, false, boundingBox.getMinLongitude(), minLatitude); Point upperRightPoint = new Point(false, false, boundingBox.getMaxLongitude(), maxLatitude); ProjectionTransform toWebMercator = ProjectionFactory.getProjection( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); lowerLeftPoint = toWebMercator.transform(lowerLeftPoint); upperRightPoint = toWebMercator.transform(upperRightPoint); BoundingBox mercatorBox = new BoundingBox(lowerLeftPoint.getX(), lowerLeftPoint.getY(), upperRightPoint.getX(), upperRightPoint.getY()); return mercatorBox; }
.getProjection(ProjectionConstants.EPSG_WEB_MERCATOR); Projection wgs84 = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
maxLongitude, maxLatitude); Projection projection = ProjectionFactory.getProjection(requestEpsg); Projection printProjection = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); ProjectionTransform wgs84Transform = projection .getTransformation(printProjection);
.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
maxLongitude, maxLatitude); Projection projection = ProjectionFactory.getProjection(requestEpsg); Projection printProjection = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); ProjectionTransform wgs84Transform = projection .getTransformation(printProjection);
/** * 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; }
if (projection.equals(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR)) { queryProjection = ProjectionFactory.getProjection( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); } else { queryProjection = ProjectionFactory.getProjection( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR);
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, featureDao); FeatureIndexManager indexer = new FeatureIndexManager(context, geoPackage, featureDao); featureTiles.setIndexManager(indexer); 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.min(zoomLevel, 19); int minZoom = zoomLevel - 2; int maxZoom = zoomLevel + 2; TileGenerator tileGenerator = new FeatureTileGenerator(context, geoPackage, featureTable + "_tiles", featureTiles, minZoom, maxZoom, requestBoundingBox, requestProjection); tileGenerator.generateTiles(); featureTiles.close(); } }
BoundingBox webMercatorBoundingBox = boundingBox .transform(ProjectionFactory .getProjection( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) .getTransformation( webMercatorBoundingBox = boundingBox .transform(ProjectionFactory .getProjection( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) .getTransformation(
Projection projection = srs.getProjection(); Projection requestProjection = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); ProjectionTransform coverageToRequest = projection .getTransformation(requestProjection);
Projection projection = srs.getProjection(); Projection requestProjection = ProjectionFactory .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); ProjectionTransform coverageToRequest = projection .getTransformation(requestProjection);
boundingBox = boundingBox .transform(ProjectionFactory .getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR)); TileGenerator tileGenerator = new FeatureTileGenerator(activity, geoPackage, boundingBox, ProjectionFactory .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR)); tileGenerator.setGoogleTiles(false);