Windows下在Ruby上的RGeo:如何启用GEOS支持?

编程入门 行业动态 更新时间:2024-10-28 12:16:02
本文介绍了Windows下在Ruby上的RGeo:如何启用GEOS支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用RGeo gem在Ruby中进行一些空间操作.不幸的是,很多操作都需要GEOS库,而且我找不到任何文档说明如何在Windows中集成它(我使用的是Windows 7 64bit).

I'm trying to do some spatial operations in Ruby with the RGeo gem. Unfortunately, a lot of operations require the GEOS library and I can't find any documentation showing how to integrate this in Windows (I am using Windows 7 64bit).

我尝试从 trac.osgeo/下载并安装GEOS的Windows二进制文件. osgeo4w/并通过gem install rgeo -- --with-geos-dir="C:\OSGeo4W64\bin重新安装RGeo gem(<<在此目录中有一个文件geos_c.dll).

I tried downloading and installing the Windows binaries of GEOS from trac.osgeo/osgeo4w/ and reinstalling the RGeo gem via gem install rgeo -- --with-geos-dir="C:\OSGeo4W64\bin (<< in this directory there is a file geos_c.dll).

仍然使用RGeo::Geos.supported?返回false.

有人知道如何解决这个问题吗?

Does anybody know how to solve this?

推荐答案

对于其他想要这样做的人-这里有一些有关如何使其工作的提示.

For anyone else looking to do this - here are some tips as to how I got it working.

    通过点击 trac.osgeo/geos/安装GEOS Windows二进制文件a>(我有Ruby 32位版本,所以我选择了32位版本)
  • 您现在应该可以在C:\OSGeo4W\bin
  • 中找到文件geos_c.dll.
  • 将Windows环境变量ENV['GEOS_LIBRARY_PATH']设置为C:\OSGeo4W\bin
  • 此时检查以确保ENV变量存在-也许重新启动PC!
  • 在您的Gem文件中,添加gem 'ffi-geos'和gem 'rgeo'并捆绑安装
  • 在您的Ruby文件中,请记住依次按require 'ffi-geos'和require 'rgeo'
  • 使用factory = RGeo::Geos.factory(:native_interface => :ffi)-不 RGeo::Cartesian.factory
  • 按照Dirk的说法检查RGeo::Geos.supported?
  • install GEOS Windows binaries by following the link from trac.osgeo/geos/ (I have Ruby 32 bit version, so I went for the 32 bit version)
  • you should now be able to find a file geos_c.dll in C:\OSGeo4W\bin
  • set a Windows environment variable ENV['GEOS_LIBRARY_PATH'] to be C:\OSGeo4W\bin
  • check at this point to make sure that ENV variable is there - maybe restart your PC!
  • in your Gemfile, add gem 'ffi-geos' and gem 'rgeo' and bundle install
  • in your Ruby file, remember to require 'ffi-geos' and require 'rgeo' (in that order)
  • use factory = RGeo::Geos.factory(:native_interface => :ffi) - not RGeo::Cartesian.factory
  • check RGeo::Geos.supported? as Dirk said

更多推荐

Windows下在Ruby上的RGeo:如何启用GEOS支持?

本文发布于:2023-10-13 09:24:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1487565.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Ruby   Windows   GEOS   RGeo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!