Sign in Join
Wiki copytemporary

Spatialite: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Spatialite

OldNewLine
1+## What is spatialite
2+
3+Spatialite is an extension to SQLite that allows you to use spatial data, including OpenStreetMap road networks, that allow e.g. routing between destinations. It's meant for standalone use and can be thought of as a smaller cousin of PostGIS, and allows you to program your own GIS (Geographical Information System).
4+
5+The spatialite developers provide their own GUI, and projects such as QGIS support spatialite as well.
6+
7+## Spatialite in FPC/Lazarus
8+
9+To use spatialite, you can either use an "all in one" package of spatialite and sqlite bundled into one big DLL/.so/library. Alternatively, you can use a regular sqlite DLL/.so/library, and load the sqlite library by calling the SQLite load_extension function. Support for this method has been added in FPC revision 20146, 21 January 2012. It is present in FPC fixes 2.6 and FPC trunk.
10+
11+``` pascal
12+ // Try to load extensions
13+ DBConnection.DatabaseName:='osm.sqlite';
14+ DBConnection.Open;
15+ DBConnection.LoadExtension('libspatialite-4.dll'); //Note: we need an open db before doing this
16+```
17+
18+Once you've loaded the spatialite library, you can use spatial queries just as you would regular queries.
19+
20+## References
21+
22+- <https://bitbucket.org/reiniero/openrormap> Unfinished project that does demonstrate how to load spatialite. It downloads some OpenStreetmap data and is meant to load that into a spatialite database and create a map for the [Rigs of Rods game](http://www.rigsofrods.com/content/)
23+- <https://www.gaia-gis.it/fossil/libspatialite/index> Spatialite homepage
24+- <http://bugs.freepascal.org/view.php?id=20640> Patch that enabled SQLite load_extension
25+
26+## See also
27+
28+- [[Databases|Databases#sqldblaz.lpk]]
29+
30+---
31+*From the Free Pascal wiki, page "Spatialite", as it stood on 2020-02-26 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history