当前位置: 首页>>代码示例>>Java>>正文


Java ProjCoordinate类代码示例

本文整理汇总了Java中org.osgeo.proj4j.ProjCoordinate的典型用法代码示例。如果您正苦于以下问题:Java ProjCoordinate类的具体用法?Java ProjCoordinate怎么用?Java ProjCoordinate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ProjCoordinate类属于org.osgeo.proj4j包,在下文中一共展示了ProjCoordinate类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromHK80toWGS84

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
private static Pair<Double, Double> fromHK80toWGS84(Pair<Double, Double> pair) {
    try {
        // reference: blog.tiger-workshop.com/hk1980-grid-to-wgs84/
        CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
        CRSFactory csFactory = new CRSFactory();
        CoordinateReferenceSystem HK80 = csFactory.createFromParameters("EPSG:2326", "+proj=tmerc +lat_0=22.31213333333334 +lon_0=114.1785555555556 +k=1 +x_0=836694.05 +y_0=819069.8 +ellps=intl +towgs84=-162.619,-276.959,-161.764,0.067753,-2.24365,-1.15883,-1.09425 +units=m +no_defs");
        CoordinateReferenceSystem WGS84 = csFactory.createFromParameters("WGS84", "+proj=longlat +datum=WGS84 +no_defs");
        CoordinateTransform trans = ctFactory.createTransform(HK80, WGS84);
        ProjCoordinate p = new ProjCoordinate();
        ProjCoordinate p2 = new ProjCoordinate();
        p.x = pair.first;
        p.y = pair.second;
        trans.transform(p, p2);
        return new Pair<>(p2.x, p2.y);
    } catch (IllegalStateException e) {
        Timber.e(e);
    }
    return null;
}
 
开发者ID:alvinhkh,项目名称:buseta,代码行数:20,代码来源:BusRouteStopUtil.java

示例2: latlon2twd97

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
public static ProjCoordinate latlon2twd97(LatLng latLng) {

        CoordinateReferenceSystem crs1 = mCsFactory.createFromParameters(EPSG_WGS84, FUNC_WGS84);
        CoordinateReferenceSystem crs2 = mCsFactory.createFromParameters(EPSG_TWD97, FUNC_TWD97);
        CoordinateTransform trans = mCtFactory.createTransform(crs1, crs2);
        ProjCoordinate p1 = new ProjCoordinate();
        ProjCoordinate p2 = new ProjCoordinate();
        p1.x = latLng.longitude;
        p1.y = latLng.latitude;
        trans.transform(p1, p2);

        return p2;
    }
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:14,代码来源:ProjFuncs.java

示例3: latlon2twd67

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
public static ProjCoordinate latlon2twd67(LatLng latLng) {

        CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
        CRSFactory csFactory = new CRSFactory();
        CoordinateReferenceSystem crs1 = csFactory.createFromParameters(EPSG_WGS84, FUNC_WGS84);
        CoordinateReferenceSystem crs2 = csFactory.createFromParameters(EPSG_TWD67, FUNC_TWD67);
        CoordinateTransform trans = ctFactory.createTransform(crs1, crs2);
        ProjCoordinate p1 = new ProjCoordinate();
        ProjCoordinate p2 = new ProjCoordinate();
        p1.x = latLng.longitude;
        p1.y = latLng.latitude;
        trans.transform(p1, p2);

        return p2;
    }
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:16,代码来源:ProjFuncs.java

示例4: twd2String

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
public static String twd2String(ProjCoordinate coor, String prefix) {
    String x = (int) coor.x + "";
    x = x.substring(0, x.length() - 3) + "-" + x.substring(x.length() - 3);

    String y = (int) coor.y + "";
    y = y.substring(0, y.length() - 3) + "-" + y.substring(x.length() - 3);

    return prefix + x + ", " + y;
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:10,代码来源:ProjFuncs.java

示例5: transform

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
/**
 * Transform the bounding box
 * 
 * @param boundingBox
 *            bounding box
 * @return bounding box
 */
public BoundingBox transform(BoundingBox boundingBox) {

	ProjCoordinate lowerLeft = new ProjCoordinate(
			boundingBox.getMinLongitude(), boundingBox.getMinLatitude());
	ProjCoordinate lowerRight = new ProjCoordinate(
			boundingBox.getMaxLongitude(), boundingBox.getMinLatitude());
	ProjCoordinate upperRight = new ProjCoordinate(
			boundingBox.getMaxLongitude(), boundingBox.getMaxLatitude());
	ProjCoordinate upperLeft = new ProjCoordinate(
			boundingBox.getMinLongitude(), boundingBox.getMaxLatitude());

	ProjCoordinate projectedLowerLeft = transform(lowerLeft);
	ProjCoordinate projectedLowerRight = transform(lowerRight);
	ProjCoordinate projectedUpperRight = transform(upperRight);
	ProjCoordinate projectedUpperLeft = transform(upperLeft);

	double minX = Math.min(projectedLowerLeft.x, projectedUpperLeft.x);
	double maxX = Math.max(projectedLowerRight.x, projectedUpperRight.x);
	double minY = Math.min(projectedLowerLeft.y, projectedLowerRight.y);
	double maxY = Math.max(projectedUpperLeft.y, projectedUpperRight.y);

	BoundingBox projectedBoundingBox = new BoundingBox(minX, minY, maxX,
			maxY);

	return projectedBoundingBox;
}
 
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:34,代码来源:ProjectionTransform.java

示例6: convert

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
/**
 * Convert proj4 coordinates to JTS coordinates.
 *
 * @param projCoords
 * @return
 */
protected static Coordinate[] convert(ProjCoordinate[] projCoords) {
    Coordinate[] jtsCoords = new Coordinate[projCoords.length];
    for (int i = 0; i < projCoords.length; ++i) {
        jtsCoords[i] = new Coordinate(projCoords[i].x, projCoords[i].y);
    }
    return jtsCoords;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:14,代码来源:GeometryTransformUtils.java

示例7: transformCoordinates

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
protected static ProjCoordinate[] transformCoordinates(CoordinateTransform ct,
                                                       ProjCoordinate[] in) {
    ProjCoordinate[] out = new ProjCoordinate[in.length];
    for (int i = 0; i < in.length; ++i) {
        out[i] = ct.transform(in[i], new ProjCoordinate());
    }
    return out;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:9,代码来源:GeometryTransformUtils.java

示例8: reprojectTile

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
/**
 * Reproject the tile to the requested projection
 *
 * @param tile                    tile in the tile matrix projection
 * @param requestedTileWidth      requested tile width
 * @param requestedTileHeight     requested tile height
 * @param requestBoundingBox      request bounding box in the request projection
 * @param transformRequestToTiles transformation from request to tiles
 * @param tilesBoundingBox        request bounding box in the tile matrix projection
 * @return projected tile
 */
private Bitmap reprojectTile(Bitmap tile, int requestedTileWidth, int requestedTileHeight, BoundingBox requestBoundingBox, ProjectionTransform transformRequestToTiles, BoundingBox tilesBoundingBox) {

    final double requestedWidthUnitsPerPixel = (requestBoundingBox.getMaxLongitude() - requestBoundingBox.getMinLongitude()) / requestedTileWidth;
    final double requestedHeightUnitsPerPixel = (requestBoundingBox.getMaxLatitude() - requestBoundingBox.getMinLatitude()) / requestedTileHeight;

    final double tilesDistanceWidth = tilesBoundingBox.getMaxLongitude() - tilesBoundingBox.getMinLongitude();
    final double tilesDistanceHeight = tilesBoundingBox.getMaxLatitude() - tilesBoundingBox.getMinLatitude();

    final int width = tile.getWidth();
    final int height = tile.getHeight();

    // Tile pixels of the tile matrix tiles
    int[] pixels = new int[width * height];
    tile.getPixels(pixels, 0, width, 0, 0, width, height);

    // Projected tile pixels to draw the reprojected tile
    int[] projectedPixels = new int[requestedTileWidth * requestedTileHeight];

    // Retrieve each pixel in the new tile from the unprojected tile
    for (int y = 0; y < requestedTileHeight; y++) {
        for (int x = 0; x < requestedTileWidth; x++) {

            double longitude = requestBoundingBox.getMinLongitude() + (x * requestedWidthUnitsPerPixel);
            double latitude = requestBoundingBox.getMaxLatitude() - (y * requestedHeightUnitsPerPixel);
            ProjCoordinate fromCoord = new ProjCoordinate(longitude, latitude);
            ProjCoordinate toCoord = transformRequestToTiles.transform(fromCoord);
            double projectedLongitude = toCoord.x;
            double projectedLatitude = toCoord.y;

            int xPixel = (int) Math.round(((projectedLongitude - tilesBoundingBox.getMinLongitude()) / tilesDistanceWidth) * width);
            int yPixel = (int) Math.round(((tilesBoundingBox.getMaxLatitude() - projectedLatitude) / tilesDistanceHeight) * height);

            xPixel = Math.max(0, xPixel);
            xPixel = Math.min(width - 1, xPixel);

            yPixel = Math.max(0, yPixel);
            yPixel = Math.min(height - 1, yPixel);

            int color = pixels[(yPixel * width) + xPixel];
            projectedPixels[(y * requestedTileWidth) + x] = color;
        }
    }

    // Draw the new tile bitmap
    Bitmap projectedTileBitmap = Bitmap.createBitmap(requestedTileWidth,
            requestedTileHeight, tile.getConfig());
    projectedTileBitmap.setPixels(projectedPixels, 0, requestedTileWidth, 0, 0, requestedTileWidth, requestedTileHeight);

    return projectedTileBitmap;
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:62,代码来源:TileCreator.java

示例9: reprojectElevations

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
/**
 * Reproject the elevations to the requested projection
 *
 * @param elevations
 *            elevations
 * @param requestedElevationsWidth
 *            requested elevations width
 * @param requestedElevationsHeight
 *            requested elevations height
 * @param requestBoundingBox
 *            request bounding box in the request projection
 * @param transformRequestToElevation
 *            transformation from request to elevations
 * @param elevationBoundingBox
 *            elevations bounding box
 * @return projected elevations
 */
protected Double[][] reprojectElevations(Double[][] elevations,
		int requestedElevationsWidth, int requestedElevationsHeight,
		BoundingBox requestBoundingBox,
		ProjectionTransform transformRequestToElevation,
		BoundingBox elevationBoundingBox) {

	final double requestedWidthUnitsPerPixel = (requestBoundingBox
			.getMaxLongitude() - requestBoundingBox.getMinLongitude())
			/ requestedElevationsWidth;
	final double requestedHeightUnitsPerPixel = (requestBoundingBox
			.getMaxLatitude() - requestBoundingBox.getMinLatitude())
			/ requestedElevationsHeight;

	final double tilesDistanceWidth = elevationBoundingBox
			.getMaxLongitude() - elevationBoundingBox.getMinLongitude();
	final double tilesDistanceHeight = elevationBoundingBox
			.getMaxLatitude() - elevationBoundingBox.getMinLatitude();

	final int width = elevations[0].length;
	final int height = elevations.length;

	Double[][] projectedElevations = new Double[requestedElevationsHeight][requestedElevationsWidth];

	// Retrieve each elevation in the unprojected elevations
	for (int y = 0; y < requestedElevationsHeight; y++) {
		for (int x = 0; x < requestedElevationsWidth; x++) {

			double longitude = requestBoundingBox.getMinLongitude()
					+ (x * requestedWidthUnitsPerPixel);
			double latitude = requestBoundingBox.getMaxLatitude()
					- (y * requestedHeightUnitsPerPixel);
			ProjCoordinate fromCoord = new ProjCoordinate(longitude,
					latitude);
			ProjCoordinate toCoord = transformRequestToElevation
					.transform(fromCoord);
			double projectedLongitude = toCoord.x;
			double projectedLatitude = toCoord.y;

			int xPixel = (int) Math
					.round(((projectedLongitude - elevationBoundingBox
							.getMinLongitude()) / tilesDistanceWidth)
							* width);
			int yPixel = (int) Math
					.round(((elevationBoundingBox.getMaxLatitude() - projectedLatitude) / tilesDistanceHeight)
							* height);

			xPixel = Math.max(0, xPixel);
			xPixel = Math.min(width - 1, xPixel);

			yPixel = Math.max(0, yPixel);
			yPixel = Math.min(height - 1, yPixel);

			Double elevation = elevations[yPixel][xPixel];
			projectedElevations[y][x] = elevation;
		}
	}

	return projectedElevations;
}
 
开发者ID:ngageoint,项目名称:geopackage-core-java,代码行数:77,代码来源:ElevationTilesCore.java

示例10: reproject

import org.osgeo.proj4j.ProjCoordinate; //导入依赖的package包/类
/**
 * Reprojects an envelope between two coordinate reference systems.
 * <p>
 * In the event a transformation between the two crs objects can not be found this method throws
 * {@link IllegalArgumentException}.
 * 
 * In the event the two specified coordinate reference systems are equal this method is a 
 * no-op and returns the original envelope. 
 * </p>
 * @param e The envelope to reproject.
 * @param from The source coordinate reference system.
 * @param to The target coordinate reference system.
 * 
 * @return The reprojected envelope.
 * 
 * @throws IllegalArgumentException If no coordinate transform can be found.
 */
public static Envelope reproject(Envelope e, CoordinateReferenceSystem from, CoordinateReferenceSystem to) {

	CoordinateTransform tx = transform(from, to);

	Coordinate c1 = new Coordinate(e.getMinX(), e.getMinY());
	Coordinate c2 = new Coordinate(e.getMaxX(), e.getMaxY());

	ProjCoordinate p1 = new ProjCoordinate(c1.x, c1.y);
	ProjCoordinate p2 = new ProjCoordinate(c2.x, c2.y);

	tx.transform(p1, p1);
	tx.transform(p2, p2);

	c1.x = p1.x;
	c1.y = p1.y;

	c2.x = p2.x;
	c2.y = p2.y;

	return new Envelope(c1.x, c2.x, c1.y, c2.y);
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:39,代码来源:Proj.java


注:本文中的org.osgeo.proj4j.ProjCoordinate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。