mil.nga.sf.proj.ProjectionConstants Java Examples
The following examples show how to use
mil.nga.sf.proj.ProjectionConstants.
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 File: GoogleMapShapeConverter.java From geopackage-android-map with MIT License | 6 votes |
/** * Constructor with specified projection, see * {@link FeatureDao#getProjection} * * @param projection projection */ public GoogleMapShapeConverter(Projection projection) { this.projection = projection; if (projection != null) { toWgs84 = projection .getTransformation(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Projection wgs84 = toWgs84.getToProjection(); fromWgs84 = wgs84.getTransformation(projection); toWebMercator = projection.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); Projection webMercator = toWebMercator.getToProjection(); fromWebMercator = webMercator.getTransformation(projection); } else { toWgs84 = null; fromWgs84 = null; toWebMercator = null; fromWebMercator = null; } }
Example #2
Source File: GeoPackageTestUtils.java From geopackage-java with MIT License | 6 votes |
/** * Test create feature table with metadata and id column * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataIdColumn( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata2", "geom2")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao() .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); String idColumn = "my_id"; geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, idColumn, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, idColumn, null); }
Example #3
Source File: FeatureTiles.java From geopackage-android with MIT License | 6 votes |
/** * Create an expanded bounding box to handle features outside the tile that * overlap * * @param boundingBox bounding box * @param projection bounding box projection * @return bounding box * @since 3.2.0 */ public BoundingBox expandBoundingBox(BoundingBox boundingBox, Projection projection) { BoundingBox expandedBoundingBox = boundingBox; ProjectionTransform toWebMercator = projection .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); if (!toWebMercator.isSameProjection()) { expandedBoundingBox = expandedBoundingBox.transform(toWebMercator); } expandedBoundingBox = expandBoundingBox(expandedBoundingBox); if (!toWebMercator.isSameProjection()) { ProjectionTransform fromWebMercator = toWebMercator .getInverseTransformation(); expandedBoundingBox = expandedBoundingBox .transform(fromWebMercator); } return expandedBoundingBox; }
Example #4
Source File: FeatureTileGenerator.java From geopackage-android with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public BoundingBox getBoundingBox(int zoom) { ProjectionTransform projectionToWebMercator = projection .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); BoundingBox webMercatorBoundingBox = boundingBox .transform(projectionToWebMercator); TileGrid tileGrid = TileBoundingBoxUtils.getTileGrid(webMercatorBoundingBox, zoom); BoundingBox tileBoundingBox = TileBoundingBoxUtils.getWebMercatorBoundingBox( tileGrid.getMinX(), tileGrid.getMinY(), zoom); BoundingBox expandedBoundingBox = featureTiles.expandBoundingBox(webMercatorBoundingBox, tileBoundingBox); BoundingBox zoomBoundingBox = expandedBoundingBox.transform(projectionToWebMercator.getInverseTransformation()); return zoomBoundingBox; }
Example #5
Source File: CoverageDataTiffImportTest.java From geopackage-android with MIT License | 6 votes |
/** * Test a single location * * @param latitude * @param longitude * @throws Exception */ private void testLocation(double latitude, double longitude) throws Exception { if (PRINT) { System.out.println("Latitude: " + latitude); System.out.println("Longitude: " + longitude); } for (CoverageDataAlgorithm algorithm : CoverageDataAlgorithm .values()) { Double value = CoverageDataTestUtils.getValue( geoPackage, algorithm, latitude, longitude, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); if (PRINT) { System.out.println(algorithm.name() + ": " + value); } } }
Example #6
Source File: FeatureTileUtils.java From geopackage-java with MIT License | 6 votes |
/** * Create feature dao * * @return feature dao */ public static FeatureDao createFeatureDao(GeoPackage geoPackage) { BoundingBox boundingBox = new BoundingBox(); GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey(TABLE_NAME, "geom")); geometryColumns.setGeometryType(GeometryType.GEOMETRY); geometryColumns.setZ((byte) 0); geometryColumns.setM((byte) 0); geoPackage.createFeatureTableWithMetadata(geometryColumns, boundingBox, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns); return featureDao; }
Example #7
Source File: GeoPackageTestUtils.java From geopackage-java with MIT License | 6 votes |
/** * Test create feature table with metadata * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadata(GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata", "geom")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao() .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, null, null); }
Example #8
Source File: FeatureTileUtils.java From geopackage-android with MIT License | 6 votes |
public static long insertPolygon(FeatureDao featureDao, double[][]... points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Polygon polygon = new Polygon(false, false); for (double[][] ring : points) { LineString lineString = getLineString(ring); polygon.addRing(lineString); } geomData.setGeometry(polygon); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example #9
Source File: GeoPackageTestUtils.java From geopackage-android with MIT License | 6 votes |
/** * Test create feature table with metadata * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadata(GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata", "geom")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao().getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, null, null); }
Example #10
Source File: GeoPackageTestUtils.java From geopackage-android with MIT License | 6 votes |
/** * Test create feature table with metadata and id column * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataIdColumn( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata2", "geom2")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao().getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); String idColumn = "my_id"; geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, idColumn, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, idColumn, null); }
Example #11
Source File: GeoPackageTestUtils.java From geopackage-android with MIT License | 6 votes |
/** * Test create feature table with metadata and additional columns * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataAdditionalColumns( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata3", "geom3")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); List<FeatureColumn> additionalColumns = getFeatureColumns(); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao().getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, additionalColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, null, additionalColumns); }
Example #12
Source File: GeoPackageTestUtils.java From geopackage-android with MIT License | 6 votes |
/** * Test create feature table with metadata, id column, and additional * columns * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataIdColumnAdditionalColumns( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata4", "geom4")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); List<FeatureColumn> additionalColumns = getFeatureColumns(); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao().getOrCreateCode( ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); String idColumn = "my_other_id"; geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, idColumn, additionalColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, idColumn, additionalColumns); }
Example #13
Source File: UserCoreDao.java From geopackage-core-java with MIT License | 6 votes |
/** * Get the approximate zoom level of where the bounding box of the user data * fits into the world * * @return zoom level * @since 1.1.0 */ public int getZoomLevel() { Projection projection = getProjection(); if (projection == null) { throw new GeoPackageException( "No projection was set which is required to determine the zoom level"); } int zoomLevel = 0; BoundingBox boundingBox = getBoundingBox(); if (boundingBox != null) { if (projection.isUnit(Units.DEGREES)) { boundingBox = TileBoundingBoxUtils .boundDegreesBoundingBoxWithWebMercatorLimits( boundingBox); } ProjectionTransform webMercatorTransform = projection .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); BoundingBox webMercatorBoundingBox = boundingBox .transform(webMercatorTransform); zoomLevel = TileBoundingBoxUtils .getZoomLevel(webMercatorBoundingBox); } return zoomLevel; }
Example #14
Source File: TileBoundingBoxUtils.java From geopackage-core-java with MIT License | 6 votes |
/** * Get the Web Mercator tile bounding box from the XYZ tile coordinates and * zoom level * * @param x * x coordinate * @param y * y coordinate * @param zoom * zoom level * @return bounding box */ public static BoundingBox getWebMercatorBoundingBox(long x, long y, int zoom) { double tileSize = tileSizeWithZoom(zoom); double minLon = (-1 * ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH) + (x * tileSize); double maxLon = (-1 * ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH) + ((x + 1) * tileSize); double minLat = ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH - ((y + 1) * tileSize); double maxLat = ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH - (y * tileSize); BoundingBox box = new BoundingBox(minLon, minLat, maxLon, maxLat); return box; }
Example #15
Source File: TileBoundingBoxUtils.java From geopackage-core-java with MIT License | 6 votes |
/** * Get the Web Mercator tile bounding box from the XYZ tile grid and zoom * level * * @param tileGrid * tile grid * @param zoom * zoom level * @return bounding box */ public static BoundingBox getWebMercatorBoundingBox(TileGrid tileGrid, int zoom) { double tileSize = tileSizeWithZoom(zoom); double minLon = (-1 * ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH) + (tileGrid.getMinX() * tileSize); double maxLon = (-1 * ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH) + ((tileGrid.getMaxX() + 1) * tileSize); double minLat = ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH - ((tileGrid.getMaxY() + 1) * tileSize); double maxLat = ProjectionConstants.WEB_MERCATOR_HALF_WORLD_WIDTH - (tileGrid.getMinY() * tileSize); BoundingBox box = new BoundingBox(minLon, minLat, maxLon, maxLat); return box; }
Example #16
Source File: TileBoundingBoxUtils.java From geopackage-core-java with MIT License | 6 votes |
/** * 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 #17
Source File: TileBoundingBoxUtils.java From geopackage-core-java with MIT License | 6 votes |
/** * 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 #18
Source File: GeoPackageRepository.java From geopackage-mapcache-android with MIT License | 6 votes |
/** * Create feature table in the given geopackage */ public boolean createFeatureTable(String gpName, BoundingBox boundingBox, GeometryType geometryType, String tableName){ GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey(tableName, "geom")); geometryColumns.setGeometryType(geometryType); geometryColumns.setZ((byte) 0); geometryColumns.setM((byte) 0); GeoPackage geoPackage = manager.open(gpName); try { GeometryColumns created = geoPackage.createFeatureTableWithMetadata( geometryColumns, boundingBox, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); if(created != null) { return true; } } finally { geoPackage.close(); } return false; }
Example #19
Source File: FeatureTileGenerator.java From geopackage-java with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public BoundingBox getBoundingBox(int zoom) { ProjectionTransform projectionToWebMercator = projection .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); BoundingBox webMercatorBoundingBox = boundingBox .transform(projectionToWebMercator); TileGrid tileGrid = TileBoundingBoxUtils.getTileGrid( webMercatorBoundingBox, zoom); BoundingBox tileBoundingBox = TileBoundingBoxUtils .getWebMercatorBoundingBox(tileGrid.getMinX(), tileGrid.getMinY(), zoom); BoundingBox expandedBoundingBox = featureTiles.expandBoundingBox( webMercatorBoundingBox, tileBoundingBox); BoundingBox zoomBoundingBox = expandedBoundingBox .transform(projectionToWebMercator.getInverseTransformation()); return zoomBoundingBox; }
Example #20
Source File: TestUtils.java From geopackage-java with MIT License | 6 votes |
/** * 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 #21
Source File: GeoPackageTestUtils.java From geopackage-java with MIT License | 6 votes |
/** * Test create feature table with metadata, id column, and additional * columns * * @param geoPackage * @throws SQLException */ public static void testCreateFeatureTableWithMetadataIdColumnAdditionalColumns( GeoPackage geoPackage) throws SQLException { GeometryColumns geometryColumns = new GeometryColumns(); geometryColumns.setId(new TableColumnKey("feature_metadata", "geom")); geometryColumns.setGeometryType(GeometryType.POINT); geometryColumns.setZ((byte) 1); geometryColumns.setM((byte) 0); BoundingBox boundingBox = new BoundingBox(-90, -45, 90, 45); List<FeatureColumn> additionalColumns = getFeatureColumns(); SpatialReferenceSystem srs = geoPackage.getSpatialReferenceSystemDao() .getOrCreateCode(ProjectionConstants.AUTHORITY_EPSG, ProjectionConstants.EPSG_WEB_MERCATOR); String idColumn = "my_other_id"; geometryColumns = geoPackage.createFeatureTableWithMetadata( geometryColumns, idColumn, additionalColumns, boundingBox, srs.getId()); validateFeatureTableWithMetadata(geoPackage, geometryColumns, idColumn, additionalColumns); }
Example #22
Source File: CoverageDataTiffImportTest.java From geopackage-java with MIT License | 6 votes |
/** * Test a single location * * @param latitude * @param longitude * @throws Exception */ private void testLocation(double latitude, double longitude) throws Exception { if (PRINT) { System.out.println("Latitude: " + latitude); System.out.println("Longitude: " + longitude); } for (CoverageDataAlgorithm algorithm : CoverageDataAlgorithm.values()) { Double value = CoverageDataTestUtils.getValue(geoPackage, algorithm, latitude, longitude, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); if (PRINT) { System.out.println(algorithm.name() + ": " + value); } } }
Example #23
Source File: GeoPackageExample.java From geopackage-java with MIT License | 5 votes |
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(); } }
Example #24
Source File: GoogleMapShape.java From geopackage-android-map with MIT License | 5 votes |
/** * Expand the bounding box by the LatLng * * @param boundingBox bounding box * @param latLng lat lng */ private void expandBoundingBox(BoundingBox boundingBox, LatLng latLng) { double latitude = latLng.latitude; double longitude = latLng.longitude; if (boundingBox.getMinLongitude() <= 3 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH && boundingBox.getMaxLongitude() >= 3 * -ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH) { if (longitude < boundingBox.getMinLongitude()) { if (boundingBox.getMinLongitude() - longitude > (longitude + (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH)) - boundingBox.getMaxLongitude()) { longitude += (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH); } } else if (longitude > boundingBox.getMaxLongitude()) { if (longitude - boundingBox.getMaxLongitude() > boundingBox.getMinLongitude() - (longitude - (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH))) { longitude -= (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH); } } } if (latitude < boundingBox.getMinLatitude()) { boundingBox.setMinLatitude(latitude); } if (latitude > boundingBox.getMaxLatitude()) { boundingBox.setMaxLatitude(latitude); } if (longitude < boundingBox.getMinLongitude()) { boundingBox.setMinLongitude(longitude); } if (longitude > boundingBox.getMaxLongitude()) { boundingBox.setMaxLongitude(longitude); } }
Example #25
Source File: BoundedOverlay.java From geopackage-android-map with MIT License | 5 votes |
/** * Set the bounding box, provided as the indicated projection * * @param boundingBox bounding box * @param projection projection */ public void setBoundingBox(BoundingBox boundingBox, Projection projection) { ProjectionTransform projectionToWebMercator = projection .getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); webMercatorBoundingBox = boundingBox .transform(projectionToWebMercator); }
Example #26
Source File: BoundedOverlay.java From geopackage-android-map with MIT License | 5 votes |
/** * 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); }
Example #27
Source File: TileGenerator.java From geopackage-android with MIT License | 5 votes |
/** * Get the tile count of tiles to be generated * * @return tile count */ public int getTileCount() { if (tileCount == null) { long count = 0; boolean degrees = projection.isUnit(Units.DEGREES); ProjectionTransform transformToWebMercator = null; if (!degrees) { transformToWebMercator = projection.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR); } for (int zoom = minZoom; zoom <= maxZoom; zoom++) { BoundingBox expandedBoundingBox = getBoundingBox(zoom); // Get the tile grid that includes the entire bounding box TileGrid tileGrid = null; if (degrees) { tileGrid = TileBoundingBoxUtils.getTileGridWGS84(expandedBoundingBox, zoom); } else { tileGrid = TileBoundingBoxUtils.getTileGrid(expandedBoundingBox.transform(transformToWebMercator), zoom); } count += tileGrid.count(); tileGrids.put(zoom, tileGrid); tileBounds.put(zoom, expandedBoundingBox); } tileCount = (int) Math.min(count, Integer.MAX_VALUE); } return tileCount; }
Example #28
Source File: TileGenerator.java From geopackage-android with MIT License | 5 votes |
/** * 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 #29
Source File: FeatureTileUtils.java From geopackage-java with MIT License | 5 votes |
public static long insertPolygon(FeatureDao featureDao, double[][]... points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Polygon polygon = new Polygon(false, false); for (double[][] ring : points) { LineString lineString = getLineString(ring); polygon.addRing(lineString); } geomData.setGeometry(polygon); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example #30
Source File: FeaturePreview.java From geopackage-android with MIT License | 5 votes |
/** * 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; }