本文整理汇总了Java中mil.nga.geopackage.projection.ProjectionTransform类的典型用法代码示例。如果您正苦于以下问题:Java ProjectionTransform类的具体用法?Java ProjectionTransform怎么用?Java ProjectionTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectionTransform类属于mil.nga.geopackage.projection包,在下文中一共展示了ProjectionTransform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBoundingBox
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public BoundingBox getBoundingBox() {
Contents contents = geometryColumns.getContents();
BoundingBox boundingBox = contents.getBoundingBox();
if (boundingBox != null) {
Projection contentsProjection = ProjectionFactory
.getProjection(contents.getSrs());
if (!projection.equals(contentsProjection)) {
ProjectionTransform transform = contentsProjection
.getTransformation(projection);
boundingBox = transform.transform(boundingBox);
}
}
return boundingBox;
}
示例2: drawTile
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Bitmap drawTile(int zoom, BoundingBox webMercatorBoundingBox, FeatureIndexResults results) {
// Create bitmap and canvas
Bitmap bitmap = createNewBitmap();
Canvas canvas = new Canvas(bitmap);
ProjectionTransform transform = getProjectionToWebMercatorTransform(featureDao.getProjection());
for (FeatureRow featureRow : results) {
drawFeature(zoom, webMercatorBoundingBox, transform, canvas, featureRow);
}
return bitmap;
}
示例3: addLineString
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* Add the linestring to the path
*
* @param simplifyTolerance simplify tolerance in meters
* @param boundingBox
* @param transform
* @param path
* @param lineString
*/
private void addLineString(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, Path path, LineString lineString) {
List<Point> points = lineString.getPoints();
if (points.size() >= 2) {
// Try to simplify the number of points in the LineString
points = simplifyPoints(simplifyTolerance, points);
for (int i = 0; i < points.size(); i++) {
Point point = points.get(i);
Point webMercatorPoint = getPoint(transform, point);
float x = TileBoundingBoxUtils.getXPixel(tileWidth, boundingBox,
webMercatorPoint.getX());
float y = TileBoundingBoxUtils.getYPixel(tileHeight, boundingBox,
webMercatorPoint.getY());
if (i == 0) {
path.moveTo(x, y);
} else {
path.lineTo(x, y);
}
}
}
}
示例4: addPolygon
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* Add the polygon on the canvas
*
* @param simplifyTolerance simplify tolerance in meters
* @param boundingBox
* @param transform
* @param path
* @param polygon
*/
private void addPolygon(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, Path path, Polygon polygon) {
List<LineString> rings = polygon.getRings();
if (!rings.isEmpty()) {
// Add the polygon points
LineString polygonLineString = rings.get(0);
List<Point> polygonPoints = polygonLineString.getPoints();
if (polygonPoints.size() >= 2) {
addRing(simplifyTolerance, boundingBox, transform, path, polygonPoints);
// Add the holes
for (int i = 1; i < rings.size(); i++) {
LineString holeLineString = rings.get(i);
List<Point> holePoints = holeLineString.getPoints();
if (holePoints.size() >= 2) {
addRing(simplifyTolerance, boundingBox, transform, path, holePoints);
}
}
}
}
}
示例5: addRing
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* Add a ring
*
* @param simplifyTolerance simplify tolerance in meters
* @param boundingBox
* @param transform
* @param path
* @param points
*/
private void addRing(double simplifyTolerance, BoundingBox boundingBox, ProjectionTransform transform, Path path, List<Point> points) {
// Try to simplify the number of points in the LineString
points = simplifyPoints(simplifyTolerance, points);
for (int i = 0; i < points.size(); i++) {
Point point = points.get(i);
Point webMercatorPoint = getPoint(transform, point);
float x = TileBoundingBoxUtils.getXPixel(tileWidth, boundingBox,
webMercatorPoint.getX());
float y = TileBoundingBoxUtils.getYPixel(tileHeight, boundingBox,
webMercatorPoint.getY());
if (i == 0) {
path.moveTo(x, y);
} else {
path.lineTo(x, y);
}
}
path.close();
}
示例6: drawPoint
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* Draw the point on the canvas
*
* @param boundingBox
* @param transform
* @param canvas
* @param paint
* @param point
*/
private void drawPoint(BoundingBox boundingBox, ProjectionTransform transform, Canvas canvas, Paint paint, Point point) {
Point webMercatorPoint = getPoint(transform, point);
float x = TileBoundingBoxUtils.getXPixel(tileWidth, boundingBox,
webMercatorPoint.getX());
float y = TileBoundingBoxUtils.getYPixel(tileHeight, boundingBox,
webMercatorPoint.getY());
if (pointIcon != null) {
if (x >= 0 - pointIcon.getWidth() && x <= tileWidth + pointIcon.getWidth() && y >= 0 - pointIcon.getHeight() && y <= tileHeight + pointIcon.getHeight()) {
canvas.drawBitmap(pointIcon.getIcon(), x - pointIcon.getXOffset(), y - pointIcon.getYOffset(), paint);
}
} else {
if (x >= 0 - pointRadius && x <= tileWidth + pointRadius && y >= 0 - pointRadius && y <= tileHeight + pointRadius) {
canvas.drawCircle(x, y, pointRadius, paint);
}
}
}
示例7: getZoomLevel
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* 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.getUnit() instanceof DegreeUnit) {
boundingBox = TileBoundingBoxUtils
.boundDegreesBoundingBoxWithWebMercatorLimits(boundingBox);
}
ProjectionTransform webMercatorTransform = projection
.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR);
BoundingBox webMercatorBoundingBox = webMercatorTransform
.transform(boundingBox);
zoomLevel = TileBoundingBoxUtils
.getZoomLevel(webMercatorBoundingBox);
}
return zoomLevel;
}
示例8: getBoundingBox
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public BoundingBox getBoundingBox() {
Contents contents = geometryColumns.getContents();
Projection contentsProjection = ProjectionFactory
.getProjection(contents.getSrs());
BoundingBox boundingBox = contents.getBoundingBox();
if (!projection.equals(contentsProjection)) {
ProjectionTransform transform = contentsProjection
.getTransformation(projection);
boundingBox = transform.transform(boundingBox);
}
return boundingBox;
}
示例9: drawTile
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public BufferedImage drawTile(int zoom, BoundingBox webMercatorBoundingBox,
CloseableIterator<GeometryIndex> results) {
// Create image and graphics
BufferedImage image = createNewImage();
Graphics2D graphics = getGraphics(image);
// WGS84 to web mercator projection and google shape converter
ProjectionTransform webMercatorTransform = getWebMercatorTransform();
while (results.hasNext()) {
GeometryIndex geometryIndex = results.next();
FeatureRow featureRow = getFeatureIndex().getFeatureRow(
geometryIndex);
drawFeature(zoom, webMercatorBoundingBox, webMercatorTransform,
graphics, featureRow);
}
return image;
}
示例10: drawFeature
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* Draw the feature
*
* @param zoom
* zoom level
* @param boundingBox
* @param transform
* @param graphics
* @param row
*/
private void drawFeature(int zoom, BoundingBox boundingBox,
ProjectionTransform transform, Graphics2D graphics, FeatureRow row) {
try {
GeoPackageGeometryData geomData = row.getGeometry();
if (geomData != null) {
Geometry geometry = geomData.getGeometry();
double simplifyTolerance = TileBoundingBoxUtils
.toleranceDistance(zoom, tileWidth, tileHeight);
drawGeometry(simplifyTolerance, boundingBox, transform,
graphics, geometry);
}
} catch (Exception e) {
log.log(Level.SEVERE, "Failed to draw feature in tile. Table: "
+ featureDao.getTableName(), e);
}
}
示例11: getArea
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* Get the area of the polygon
*
* @param simplifyTolerance
* simplify tolerance in meters
* @param boundingBox
* @param transform
* @param lineString
*/
private Area getArea(double simplifyTolerance, BoundingBox boundingBox,
ProjectionTransform transform, Polygon polygon) {
Area area = null;
for (LineString ring : polygon.getRings()) {
Path2D path = getPath(simplifyTolerance, boundingBox, transform,
ring);
Area ringArea = new Area(path);
if (area == null) {
area = ringArea;
} else {
area.subtract(ringArea);
}
}
return area;
}
示例12: getTileSources
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* returns ALL available raster tile sources for all "imported" geopackage databases
*
* @return
*/
public List<GeopackageRasterTileSource> getTileSources() {
List<GeopackageRasterTileSource> srcs = new ArrayList<>();
List<String> databases = manager.databases();
for (int i = 0; i < databases.size(); i++) {
GeoPackage open = manager.open(databases.get(i));
List<String> tileTables = open.getTileTables();
for (int k = 0; k < tileTables.size(); k++) {
TileDao tileDao = open.getTileDao(tileTables.get(k));
mil.nga.geopackage.BoundingBox boundingBox = tileDao.getBoundingBox();
ProjectionTransform transformation = tileDao.getProjection().getTransformation(tileDao.getProjection());
boundingBox = transformation.transform(boundingBox);
BoundingBox bounds = new BoundingBox(boundingBox.getMaxLatitude(), boundingBox.getMaxLongitude(), boundingBox.getMinLatitude(), boundingBox.getMinLongitude());
srcs.add(new GeopackageRasterTileSource(databases.get(i), tileTables.get(k), (int)tileDao.getMinZoom(), (int)tileDao.getMaxZoom(), bounds));
}
open.close();
}
return srcs;
}
示例13: getTileSource
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
public GeopackageRasterTileSource getTileSource(String database, String table) {
Iterator<GeoPackage> iterator = geopackage.tileSources.iterator();
while (iterator.hasNext()){
GeoPackage next = iterator.next();
if (next.getName().equalsIgnoreCase(database)) {
//found the database
if (next.getTileTables().contains(table)) {
//find the tile table
TileDao tileDao = next.getTileDao(table);
mil.nga.geopackage.BoundingBox boundingBox = tileDao.getBoundingBox();
ProjectionTransform transformation = tileDao.getProjection().getTransformation(tileDao.getProjection());
boundingBox=transformation.transform(boundingBox);
BoundingBox bounds =new BoundingBox(boundingBox.getMaxLatitude(),boundingBox.getMaxLongitude(),boundingBox.getMinLatitude(),boundingBox.getMinLongitude());
return new GeopackageRasterTileSource(database,table, (int)tileDao.getMinZoom(),(int)tileDao.getMaxZoom(), bounds);
}
}
}
return null;
}
示例14: projectGeometry
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* Project the geometry into the provided projection
*
* @param geometryData geometry data
* @param projection projection
*/
public void projectGeometry(GeoPackageGeometryData geometryData, Projection projection) {
if (geometryData.getGeometry() != null) {
try {
SpatialReferenceSystemDao srsDao = DaoManager.createDao(featureDao.getDb().getConnectionSource(), SpatialReferenceSystem.class);
int srsId = geometryData.getSrsId();
SpatialReferenceSystem srs = srsDao.queryForId((long) srsId);
if (!projection.equals(srs.getOrganization(), srs.getOrganizationCoordsysId())) {
Projection geomProjection = ProjectionFactory.getProjection(srs);
ProjectionTransform transform = geomProjection.getTransformation(projection);
Geometry projectedGeometry = transform.transform(geometryData.getGeometry());
geometryData.setGeometry(projectedGeometry);
SpatialReferenceSystem projectionSrs = srsDao.getOrCreateCode(projection.getAuthority(), Long.parseLong(projection.getCode()));
geometryData.setSrsId((int) projectionSrs.getSrsId());
}
} catch (SQLException e) {
throw new GeoPackageException("Failed to project geometry to projection with Authority: "
+ projection.getAuthority() + ", Code: " + projection.getCode(), e);
}
}
}
示例15: setBoundingBox
import mil.nga.geopackage.projection.ProjectionTransform; //导入依赖的package包/类
/**
* Set the bounding box, provided as the indicated projection
*
* @param boundingBox
* @param projection
*/
public void setBoundingBox(BoundingBox boundingBox, Projection projection) {
ProjectionTransform projectionToWebMercator = projection
.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR);
webMercatorBoundingBox = projectionToWebMercator
.transform(boundingBox);
}