Ruby:KML库? [英] Ruby: KML Library?

查看:56
本文介绍了Ruby:KML库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在搜索一个ruby库,以将位置数据导出到KML文件中.要导出的数据主要包含经度和纬度的简单点,但是我也希望能够导出更复杂的多边形.

I am searching for a ruby library to export location data into KML files. The data to be exported contains mainly simple points with latitude and longitude, but I'd also like to be able to export more complex polygons.

我尝试了 kamelopard ,但没有发现令人满意的结果因为它缺少教程.对我来说,从哪里开始使用该库并不明显.还有另一个候选人叫 kamel .不幸的是,由于缺少我无法解决的依赖关系,我无法安装该应用程序.

I tried kamelopard, but didn't find it satisfactory as it is missing a tutorial. It wasn't obvious to me where to start using the library. There is another candidate which is called kamel. Unfortunately I couldn't install that one, due to a missing dependency which I couldn't resolve.

那么,您使用哪个库在Ruby中以编程方式创建KML文件?还是您使用构建器gem 并自己​​创建XML?

So, which library are you using to create a KML file programmatically in Ruby? Or do you use the builder gem and create the XML yourself?

推荐答案

我通过使用 schleyfox-ruby_kml 解决了我的问题是的叉子 kmlr .这样,很容易为一组地标生成kml.请参见自述文件中的以下示例:

I solved my problem by using schleyfox-ruby_kml, which is a fork of kmlr. With this, it is easy to generate a kml for a set of placemarks. See the following example from the README:

require 'kml'

kml = KMLFile.new
folder = KML::Folder.new(:name => 'Melbourne Stations')
[
  ["Flinders St",    -37.818078, 144.966811],
  ["Southern Cross", -37.818358, 144.952417],
].each do |name, lat, lng|
  folder.features << KML::Placemark.new(
    :name => name, 
    :geometry => KML::Point.new(:coordinates => {:lat => lat, :lng => lng})
  )
end
kml.objects << folder
puts kml.render

gem还提供了生成多边形等的类.

The gem also provides classes to generate polygons and so forth.

这篇关于Ruby:KML库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆