Proj.4 Java - 将坐标从WGS84转换为EPSG4141?

时间:2016-08-11 21:26:11

标签: java proj4

我使用的Proj.4 java库可以是found here 我非常不确定如何在Proj.4JS中实现这样的代码:

// include the library
<script src="lib/proj4js-combined.js"></script>  //adjust the path for your server
                                                 //or else use the compressed version
// creating source and destination Proj4js objects
// once initialized, these may be re-used as often as needed
var source = new Proj4js.Proj('EPSG:4326');    //source coordinates will be in Longitude/Latitude, WGS84
var dest = new Proj4js.Proj('EPSG:4141');     //destination coordinates in meters, global spherical mercators projection, see http://spatialreference.org/ref/epsg/3785/


// transforming point coordinates
var p = new Proj4js.Point(-76.0,45.0);   //any object will do as long as it has 'x' and 'y' properties
Proj4js.transform(source, dest, p);      //do the transformation.  x and y are modified in place

//p.x and p.y are now EPSG:3785 in meters

我是整个投影科目的新手,我真的很想知道我在做什么。我需要将我的坐标系从WGS84转换为EPSG:4141但是Proj.4 Java库根本没有记录,我无法真正了解如何使用它。

有人熟悉这个吗?

1 个答案:

答案 0 :(得分:2)

不幸的是,对于那些仍在寻找解决方案的人来说,图书馆仍然没有得到很好的记录:

CRSFactory factory = new CRSFactory();
CoordinateReferenceSystem srcCrs = factory.createFromName("EPSG:4326");
CoordinateReferenceSystem dstCrs = factory.createFromName("EPSG:4141");

BasicCoordinateTransform transform = new BasicCoordinateTransform(srcCrs, dstCrs);

// Note these are x, y so lng, lat
ProjCoordinate srcCoord = new ProjCoordinate(-76.0, 45.0);
ProjCoordinate dstCoord = new ProjCoordinate();

// Writes result into dstCoord
transform.transform(srcCoord, dstCoord);

https://github.com/Proj4J/proj4j的源代码,如果您需要解决其他问题。