java 变换投影 EPSG:900913 到 EPSG:4326
在开放层中 我们可以简单地将 EPSG:900913 转换为 EPSG:4326
我正在寻找一个可以做到这一点的 Java 库。
在这里我发现了这个, http://www.jhlabs.com/java/maps/proj/index.html html
但文档是用 c++ 编写的
我不知道如何使用它。
如果有人知道的话,
请发布一个简单的代码
in the openlayers
we can simple transform EPSG:900913 to EPSG:4326
I'm look for a java lib can do that.
here I found this,
http://www.jhlabs.com/java/maps/proj/index.html
but the document is in c++
I don't know how to use it.
If anyone konw that,
please post a simple code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我知道这是近 8 年前的事了,但也许这可以帮助另一个勇敢的旅行者。
我们不得不放弃 GeoTools,因为它是 LGPL,这是我们的法律人员不允许的。
我刚刚将代码移至使用 proj4j (https://trac.osgeo.org/proj4j/) 。它看起来不像是在积极开发,但它可以满足我们的简单需求。此外,许可证是 Apache 2.0,更加宽松。
它可以通过 Maven 获得,因此变得很容易: http:// /search.maven.org/#artifactdetails%7Corg.osgeo%7Cproj4j%7C0.1.0%7Cjar。
它不直接支持 EPSG:900913,因为它并不是真正的官方标准。它确实支持 EPSG:3857,这是同样的事情。
这是执行您正在寻找的操作的片段:
I understand that this is from almost 8 years ago, but maybe this can help another intrepid traveller.
We had to move away from GeoTools because it's LGPL, which is not allowed by our legal folk.
I just moved our code to use proj4j (https://trac.osgeo.org/proj4j/). It doesn't look like it's being actively developed, but it works for our simple needs. Also, the license is Apache 2.0, which is much more permissive.
It's available via Maven, so that makes it easy: http://search.maven.org/#artifactdetails%7Corg.osgeo%7Cproj4j%7C0.1.0%7Cjar.
It doesn't directly support EPSG:900913, since it's not really the official standard. It does support EPSG:3857, which is the same thing.
Here's a snippet doing what you're looking for:
Jerry Huxtable 在您引用的页面确实是用Java编写的,如下载中所示。 com.jhlabs.map.proj.ProjectionFactory 类包含一个名为
fromPROJ4Specification()
的方法,该方法返回一个com.jhlabs.map.proj.Projection
代码>.您可以使用 OpenLayers 站点上指定的 EPSG:900913 参数来创建所需的投影。您还应该查看 OpenMap。
Jerry Huxtable's delightful Globe Applet on the page you cited is indeed written in Java, as seen in the download. The class
com.jhlabs.map.proj.ProjectionFactory
contains a method namedfromPROJ4Specification()
, which returns acom.jhlabs.map.proj.Projection
. You can use the EPSG:900913 parameters specified on the OpenLayers site to create the desired projection.You should also look at OpenMap.
另一种选择是使用开源 GIS Java 库 GeoTools:
http://geotools.org/
有关投影类的详细信息这里:
http://geotools.org/javadocs/org/ geotools/referencing/operation/projection/MapProjection.html
所有投影的多种不同格式的投影定义可以从以下位置下载:
http://www.spatialreference.org/
例如 http:// www.spatialreference.org/ref/epsg/4326/
Another option is to use the OpenSource GIS Java library GeoTools:
http://geotools.org/
Details on the projection classes here:
http://geotools.org/javadocs/org/geotools/referencing/operation/projection/MapProjection.html
Projection definitions in many different formats for all projections can be downloaded from:
http://www.spatialreference.org/
E.g. http://www.spatialreference.org/ref/epsg/4326/
Geotools 可能是最好的库。看看他们的 CRS 教程,从一个转变看起来很简单坐标系到另一个使用:
可以使用以下方式检索 CRS 引用:
根据 javadoc。
Geotools is probably the best library to use for this. Taking a look at their CRS tutorial, it looks trivial to transform from one coordinate system to another using:
Your CRS references can be retrieved using:
Per the javadoc.
同样有趣的是: Proj4j
Proj4J 是一个 Java 库,用于将点坐标从一个地理坐标系转换为另一个,包括数据转换。
该库的核心是PROJ.4 C库的移植。
Also interesting: Proj4j
Proj4J is a Java library to transform point coordinates from one geographic coordinate system to another, including datum transformations.
The core of this library is a port of the PROJ.4 C library.
似乎有一个新的 Apache 项目,它可能是上述开源项目的更新替代方案:
http ://sis.apache.org/
它作为 proj4 的替代品:
https://sis.apache.org/book/en/developer-guide.html
There seems to be a new Apache project, which may be a more up to date alternative for the open source projects mentioned above:
http://sis.apache.org/
It presents itself as an alternative for proj4:
https://sis.apache.org/book/en/developer-guide.html