Difference between revisions of "Spatialite"

From Lazarus wiki
Jump to navigationJump to search
m (Fixed syntax highlighting)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{Spatialite}}
 +
 
== What is spatialite ==
 
== What is spatialite ==
 
Spatialite is an extension to SQLite that allows you to use spatial data, including OpenStreetMap road networks, that allow e.g. routing between destinations.
 
Spatialite is an extension to SQLite that allows you to use spatial data, including OpenStreetMap road networks, that allow e.g. routing between destinations.
Line 7: Line 9:
 
== Spatialite in FPC/Lazarus ==
 
== Spatialite in FPC/Lazarus ==
 
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.
 
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.
<delphi>
+
 
 +
<syntaxhighlight lang=pascal>
 
   // Try to load extensions
 
   // Try to load extensions
 
   DBConnection.DatabaseName:='osm.sqlite';
 
   DBConnection.DatabaseName:='osm.sqlite';
 
   DBConnection.Open;
 
   DBConnection.Open;
 
   DBConnection.LoadExtension('libspatialite-4.dll'); //Note: we need an open db before doing this
 
   DBConnection.LoadExtension('libspatialite-4.dll'); //Note: we need an open db before doing this
</delphi>
+
</syntaxhighlight>
  
 
Once you've loaded the spatialite library, you can use spatial queries just as you would regular queries.
 
Once you've loaded the spatialite library, you can use spatial queries just as you would regular queries.
Line 22: Line 25:
  
 
== See also ==
 
== See also ==
[[SQLite]]
+
 
[[Category:Databases]]
+
* [[Databases#sqldblaz.lpk]]
[[Category:SQLite]]
 

Latest revision as of 12:58, 26 February 2020

English (en) français (fr)

What is spatialite

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).

The spatialite developers provide their own GUI, and projects such as QGIS support spatialite as well.

Spatialite in FPC/Lazarus

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.

  // Try to load extensions
  DBConnection.DatabaseName:='osm.sqlite';
  DBConnection.Open;
  DBConnection.LoadExtension('libspatialite-4.dll'); //Note: we need an open db before doing this

Once you've loaded the spatialite library, you can use spatial queries just as you would regular queries.

References

See also