Установка SpatiaLite¶
SpatiaLite добавляет пространственную поддержку в SQLite, превращая его в полнофункциональную пространственную базу данных.
Сначала проверьте, можете ли вы установить SpatiaLite из системных пакетов или двоичных файлов.
For example, on Debian-based distributions that package SpatiaLite 4.2+, try to
install the libsqlite3-mod-spatialite package. For older releases install
spatialite-bin.
Для macOS следуйте инструкциям ниже.
Для Windows вы можете найти двоичные файлы на домашней странице Gaia-SINS.
В любом случае у вас всегда должна быть возможность установить из исходного кода.
Установка из исходников¶
GEOS and PROJ.4 should be installed prior to building SpatiaLite.
SQLite¶
Check first if SQLite is compiled with the R*Tree module. Run the sqlite3 command line interface and enter the following query:
sqlite> CREATE VIRTUAL TABLE testrtree USING rtree(id,minX,maxX,minY,maxY);
Если вы получите ошибку, вам придется перекомпилировать SQLite из исходного кода. В противном случае пропустите этот раздел.
To install from sources, download the latest amalgamation source archive from the SQLite download page, and extract:
$ wget https://www.sqlite.org/YYYY/sqlite-amalgamation-XXX0000.zip
$ unzip sqlite-amalgamation-XXX0000.zip
$ cd sqlite-amalgamation-XXX0000
Next, run the configure script – however the CFLAGS environment variable
needs to be customized so that SQLite knows to build the R*Tree module:
$ CFLAGS="-DSQLITE_ENABLE_RTREE=1" ./configure
$ make
$ sudo make install
$ cd ..
Библиотека SpatiaLite (libspatialite)¶
Get the latest SpatiaLite library source bundle from the download page:
$ wget https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-X.Y.Z.tar.gz
$ tar xaf libspatialite-X.Y.Z.tar.gz
$ cd libspatialite-X.Y.Z
$ ./configure
$ make
$ sudo make install
Примечание
For macOS users building from source, the SpatiaLite library and tools
need to have their target configured:
$ ./configure --target=macosx
инструкции для macOS¶
To install the SpatiaLite library and tools, macOS users can choose between KyngChaos packages and Homebrew.
KyngChaos¶
First, follow the instructions in the KyngChaos packages section.
When creating a SpatiaLite database, the spatialite program is required.
However, instead of attempting to compile the SpatiaLite tools from source,
download the SpatiaLite Tools package for macOS, and install spatialite
in a location available in your PATH. For example:
$ curl -O https://www.kyngchaos.com/files/software/frameworks/Spatialite_Tools-4.3.zip
$ unzip Spatialite_Tools-4.3.zip
$ cd Spatialite\ Tools/tools
$ sudo cp spatialite /Library/Frameworks/SQLite3.framework/Programs
Finally, for GeoDjango to be able to find the KyngChaos SpatiaLite library,
add the following to your settings.py:
SPATIALITE_LIBRARY_PATH='/Library/Frameworks/SQLite3.framework/SQLite3'
Домашнее пиво¶
Homebrew handles all the SpatiaLite related packages on your behalf, including SQLite, SpatiaLite, PROJ, and GEOS. Install them like this:
$ brew update
$ brew install spatialite-tools
$ brew install gdal
Finally, for GeoDjango to be able to find the SpatiaLite library, add the
following to your settings.py:
SPATIALITE_LIBRARY_PATH='/usr/local/lib/mod_spatialite.dylib'