获取 GeoDjango +在 Windows 上运行的 Spatialite

发布于 2024-08-12 09:53:37 字数 1364 浏览 10 评论 0原文

我在 Windows 计算机上设置使用 Spatialite 作为后端的 GeoDjango 安装时仍然遇到问题。

我使用了 GeoDjango 安装程序并从 http://www.gaia-gis 下载了预编译库。 it/spatialite/binaries.html,并将它们转储到我的 geodjango/bin 目录中。

我将 pysqlite2 安装升级到最新版本,以便可以加载扩展,并在设置文件中指定了 SPATIALITE_LIBRARY_PATH

当我运行managesyncdb时,我得到以下输出

C:\stuff>manage.py syncdb
SpatiaLite version ..: 2.3.1    Supported Extensions:
        - 'VirtualShape'        [direct Shapefile access]
        - 'VirtualText'         [direct CSV/TXT access]
        - 'VirtualNetwork       [Dijkstra shortest path]
        - 'RTree'               [Spatial Index - R*Tree]
        - 'MbrCache'            [Spatial Index - MBR cache]
        - 'VirtualFDO'          [FDO-OGR interoperability]
        - 'SpatiaLite'          [Spatial SQL - OGC]
PROJ.4 Rel. 4.6.1, 21 August 2008
GEOS version 3.0.2-CAPI-1.4.2

但是,在设置表的索引时,我收到以下消息:

...
Installing custom SQL for core.LocationHint model
updateTableTriggers: "no such module: rtree"
...

我试图忽略该消息,但是我的模型无法正确保存。

我有点困惑,因为似乎使用了 Spatialite 库并且启用了“RTree”扩展,但我仍然收到错误消息。 网上关于这个错误的信息并不多;我在 sqlite.org/rtree.html 找到了 RTree 文档,但我的印象是它已经包含在 Spatialite 中,因为它列在“支持的扩展”下。

我真的需要编译自己的 sqlite 库吗?有人可以提供一个已经包含 RTree 的 .dll 吗?我做错了什么吗?任何帮助表示赞赏,谢谢!

I continue to have problems setting up a GeoDjango installation that uses Spatialite as a backend on a Windows machine.

I used the GeoDjango installer and downloaded the precompiled libraries from http://www.gaia-gis.it/spatialite/binaries.html, and dumped them into my geodjango/bin directory.

I upgraded my pysqlite2 installation to the newest version, so that extensions can be loaded and I specified SPATIALITE_LIBRARY_PATH in my settings file.

When I run manage syncdb I get the following output

C:\stuff>manage.py syncdb
SpatiaLite version ..: 2.3.1    Supported Extensions:
        - 'VirtualShape'        [direct Shapefile access]
        - 'VirtualText'         [direct CSV/TXT access]
        - 'VirtualNetwork       [Dijkstra shortest path]
        - 'RTree'               [Spatial Index - R*Tree]
        - 'MbrCache'            [Spatial Index - MBR cache]
        - 'VirtualFDO'          [FDO-OGR interoperability]
        - 'SpatiaLite'          [Spatial SQL - OGC]
PROJ.4 Rel. 4.6.1, 21 August 2008
GEOS version 3.0.2-CAPI-1.4.2

However, when setting up the indices for the table I get the following message:

...
Installing custom SQL for core.LocationHint model
updateTableTriggers: "no such module: rtree"
...

I tried to ignore the message, however my models would not save correctly.

I am a little baffled, because the Spatialite library seems to be used and has the "RTree" extension enabled, yet I still get the error message.
There is not much information about this error available online; I found the RTree Documentation at sqlite.org/rtree.html, however I was under the impression that it is already included in spatialite because it is listet under "supported extensions".

Do I really need to compile my own sqlite library? Can somebody provide a .dll that already has RTree included? Am I doing something completely wrong? Any help is appreciated, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感性不性感 2024-08-19 09:53:37

Hans,spatialite 是 SQLITE3 的扩展。

SQLite3 需要使用此选项专门编译,但通常不是。例如,mac 上的默认版本不是使用 RTREE 编译的。不过我认为 sqlite3 应该包含在你的 python 安装中。 pysqlite 可能使用 sqlite3 的原始版本或其他版本。

你可以尝试 sqlite3.version 来查看 python 使用的是哪个版本。

另请注意,您必须使用正确的配置选项重新安装 pysqlite 模块,即在运行 setup.py install 之前,更改 setup.cfg:

[build_ext]
#define=
include_dirs=PATH_TO_INCLUDE
library_dirs=PATH_TO_LIBS
libraries=sqlite3
#define=SQLITE_OMIT_LOAD_EXTENSION

http://www.gaia-gis.it/spatialite/install-windows.html

Hans, spatialite is an extension to SQLITE3.

SQLite3 needs to be specifically compiled with this option, and it is often not. For example the default version on mac does is not compiled with RTREE. However i think sqlite3 should be included though your python installation & pysqlite maybe using the original version of sqlite3 or another version.

you can try, sqlite3.version to see which version is being used by python.

Also note, you have to re-install pysqlite module with the correct config options i.e before running setup.py install, change the setup.cfg:

[build_ext]
#define=
include_dirs=PATH_TO_INCLUDE
library_dirs=PATH_TO_LIBS
libraries=sqlite3
#define=SQLITE_OMIT_LOAD_EXTENSION

http://www.gaia-gis.it/spatialite/install-windows.html

橘亓 2024-08-19 09:53:37

感谢 Issy 为我指明了正确的方向。

问题确实是,pysqlite 创建了一个 sqlite 二进制文件,但没有启用 R*TREE 扩展。

我联系了 pysqlite 的开发人员(请参阅链接文本),他很快回复让我知道,从 2.5.6 版本开始,“未来的 Windows 二进制文件和带有 --build-static 的编译将默认支持 RTree。”

问题解决了。谢谢大家。

Thanks Issy for pointing me in the right direction.

The problem was indeed, that pysqlite created a sqlite binary, that did not have the R*TREE extension enabled.

I contacted the developers of pysqlite (see link text), who responsed very quickly letting me know, that from version 2.5.6 on, "Future Windows binaries and compilations with --build-static will have RTree support by default."

Problem solved. Thanks all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文