Plugin.SpatialiteForms
0.0.3
See the version list below for details.
dotnet add package Plugin.SpatialiteForms --version 0.0.3
NuGet\Install-Package Plugin.SpatialiteForms -Version 0.0.3
<PackageReference Include="Plugin.SpatialiteForms" Version="0.0.3" />
paket add Plugin.SpatialiteForms --version 0.0.3
#r "nuget: Plugin.SpatialiteForms, 0.0.3"
// Install Plugin.SpatialiteForms as a Cake Addin #addin nuget:?package=Plugin.SpatialiteForms&version=0.0.3 // Install Plugin.SpatialiteForms as a Cake Tool #tool nuget:?package=Plugin.SpatialiteForms&version=0.0.3
SpatialiteForms
A nuget package that enables spatialite for Xamarin Forms. As an example this allows to do offline reverse geocoding on mobile devices (this barely scratches the surface of Spatialite, but it's a very common usecase for mobile dev)
It's entirely based on:
- sqlite-net and
- Spatialite and
- SQLitePCL.raw for SQLitePCLRaw.bundle_e_sqlite3 - which gives better iOS supprort for sqlite extensions
If you find this library useful, please support the above two projects.
What this means is that it exposes a SQLiteConnection that supports spatial SQL capabilities.
To enable this functionality native libraries/framework is required (apart from the nuget package itself) :
- Get Android libraries from here and add under libs folder, with build action as "AndroidNativeLibrary". Folder structure under Android project:
.
├── Assets
├── ...
├── libs
│ ├── armeabi-v7a
│ ├── libspatialite.so
│ ├── x86
│ ├── libspatialite.so
└── ...
- Get iOS framework from here and add as Native Reference to iOS project
There's small version mismatches which shouldn't cause problems, but please raise an issue if anything occurs.
Current versioning/capabilities information can be accessed via SpatialiteInfo property, available in the SpatialiteConnection class.
SpatialiteForms also allows to use "pre-packaged" database files using Assets folder in Android and Resources folder for iOS.
Usage
Example using countryData.db on how to prepackage a database with geometry data within the xamarin app and to get a Spatialite-capable SQLiteConnection.
Database countryData was created using Spatialite-GUI (very powerful tool) through which shape data was imported (shape data originated from here)
Add countryData.db under Assets folder on Android (build action - Android asset) and Resources folder on iOS (build action - Bundle resource)
Define a Region class
public class Region {
public string Name { get; set; }
}
- Get the Spatialite capable SQLiteConnection
var dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "countryData.db");
SpatialiteConnection spatialite = CrossSpatialiteForms.Current.GetSpatialiteConnection(dbPath, "countryData.db", true);
var info = spatialite.SpatialiteInfo;
var region = spatialite.SQLiteConnection.Query<Region>("select name from region where within(Makepoint(-100.7594387, 46.77519), geometry);").FirstOrDefault();
the result region should have the name of North Dakota
Again this is only a small thing of what spatialite is capable of, please check official Spatialite documentation for more details.
License
This project is licensed under GPL3
Spatialite libraries have been compiled from original source code and no changes were made to it.
If you believe that I have infringed your copyright in any way please let me know and I will remove any code that is your copyright ASAP.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.1 is compatible. netstandard1.2 was computed. netstandard1.3 was computed. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. monoandroid81 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. xamarinios10 is compatible. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.1
- NETStandard.Library (>= 1.6.1)
- sqlite-net-base (>= 1.5.231)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.11)
-
.NETStandard 2.0
- sqlite-net-base (>= 1.5.231)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.11)
-
MonoAndroid 8.1
- sqlite-net-base (>= 1.5.231)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.11)
-
Xamarin.iOS 1.0
- sqlite-net-base (>= 1.5.231)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 1.1.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Switched from sqlite-net-pcl to sqlite-net-base + bundle_e_sqlite3 (for better iOS compatibility)