作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
首先,如果这真的很简单,我深表歉意,但我似乎无法弄明白。我正在使用 RGeo 在 UTM 和纬度/经度之间进行转换,就像这样;
srs_database = RGeo::CoordSys::SRSDatabase::ActiveRecordTable.new
# create the coordinate factory for the relevant UTM zone
utm_factory = RGeo::Cartesian.factory(:srid => srid,
:srs_database => srs_database)
utm_location = utm_factory.point(easting, northing)
# create the standard WGS84 lat/long coordinate factory
wgs84_proj4 = '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
wgs84_factory = RGeo::Geographic.spherical_factory(proj4: wgs84_proj4, :srid => 4326)
# perform the UTM -> lat/long cast
RGeo::Feature.cast(utm_location, :factory => wgs84_factory, :project => true)
如您所见,我正在使用 RGeo::CoordSys::SRSDatabase::ActiveRecordTable
。
我刚刚升级到 RGeo 0.5.2
,我注意到这个类已被弃用。
很公平,但我现在不确定替代方法是什么...我四处搜寻但似乎找不到合适的文档。
此外,我原来的方法对我来说总是有点复杂 - 是否有更简单的方法来完成 UTM -> RGeo 的经纬度转换?
提前致谢!
本
最佳答案
好吧,实际上我很快就解决了这个问题。这对我有用:
if hemisphere == 'S'
srid = 32700 + number.to_i
utm_proj4 = "+proj=utm +zone=#{zone} +south +datum=WGS84 +units=m +no_defs"
else
srid = 32600 + number.to_i
utm_proj4 = "+proj=utm +zone=#{zone} +datum=WGS84 +units=m +no_defs"
end
# create both the UTM and lat / long factories (we will project between them)
utm_factory = RGeo::Cartesian.simple_factory(srid: srid, proj4: utm_proj4)
wgs84_factory = RGeo::Geographic.spherical_factory(srid: 4326, proj4: '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
# create the UTM location
utm_location = utm_factory.point(easting, northing)
# perform the UTM -> lat/long cast
RGeo::Feature.cast(utm_location, :factory => wgs84_factory, :project => true)
我正在根据从 spatial_ref_sys
表中提取的 Proj4 字符串创建自己的工厂。
虽然我不确定这是否“正确”,但可能有更好的方法。
但我希望这对某人有所帮助! :)
关于RGeo 0.5.2 和 RGeo::CoordSys::SRSDatabase::ActiveRecordTable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35098803/
首先,如果这真的很简单,我深表歉意,但我似乎无法弄明白。我正在使用 RGeo 在 UTM 和纬度/经度之间进行转换,就像这样; srs_database = RGeo::CoordSys::SRSD
我是一名优秀的程序员,十分优秀!