Porting SpatiaLite To More Platforms

287 views
Skip to first unread message

Plamen Ivanov

unread,
Sep 5, 2018, 9:00:22 AM9/5/18
to SpatiaLite Users
Hi SpatiaLite Community,

I'm a .NET/C# & Xamarin GIS developer and my day-to-day job is to develop full-stack GIS applications which works on different platforms - desktop, web and mobile. Depending on requirements applications can use different spatially-enabled databases on the server - mainly PostgreSQL/PostGIS and SQL Server. On the client (especially on mobile clients) almost always work in online/offline mode is required. This means SQLite + SpatiaLite becomes first choice in these cases given wide support for SQLite on all possible platforms.

I know SpatiaLite because it is used in many popular desktop applications (QGIS is first to come in mind). After more than 2 years without new versions when I saw new uploaded sources (5.0.0-beta0) I was ecstatic that the project is still alive & kicking :-)

The good news is that .NET evolves towards .NET Core/.NET Standard - open-source cross-platform implementation which supports almost any server/desktop (Windows, several Linux distros, macOS) and device (Android, iOS, UWP and recently - Tizen). The bad news - currently there are no official SpatiaLite ports for some of these platforms (except old Android ports).

As .NET Core finally gears at full speed to support spatial data thanks to community (me included; see https://github.com/aspnet/EntityFrameworkCore/issues/1100 and https://github.com/bricelam/EFCore/commit/0a9dc2829e39e174c31721ae57d269ed2be2017a) it becomes obviously that these ports are a MUST in very near future. If available they will guarantee widespread of SpatiaLite technology on all platforms.


You can see from the last link that main obstacle is porting of the C code to these platforms and availability of compiled dll/so/dylib libraries the same way they currently are awailable for x86/x64. After that .NET community can self-organize to add cross-platform support for SpatiaLite on top of .NET Core.

I ask SpatiaLite community for this because in my opinion this task is low-level/C development-oriented and requires support from GIS developers of highest competency.

Best Regards,
Plamen Ivanov
plamen-i

Brice Lambson

unread,
Sep 5, 2018, 3:42:21 PM9/5/18
to SpatiaLite Users

Collin Tewalt

unread,
Oct 23, 2018, 10:51:45 AM10/23/18
to SpatiaLite Users
I think there are definitely a lot of software developers in the GIS world that would love this, myself included.

I would also think Microsoft could have a lot to gain by investing some developers into this effort.
They would have a free and open source .NET cross platform SDK for people to have the most powerful mobile spatial database out there.

Even a .NET port of Spatialite with a fraction of the functionality to start with would be immensely powerful/useful to a lot of developers.

I know you can compile Spatialite in iOS into a static library (.a)

At a high level, I wonder if it would be possible to compile the existing code for Windows, iOS, and Android for starters, then the .NET SDK could link against whatever platform it needs to?
Admittedly, I haven't caught up with how you can link against native libraries in Xamarin, but I believe it's possible from the reading I've done.
I could see a something like this in .NET in the future: 

#if IOS_PLATFORM
using System.Data.SQLite.SpatiaLite.iOS;
#endif
#if ANDROID_PLATFORM
//etc.
#endif

I don't know where Microsoft is going, and what resources the SpatiaLite community needs in terms of funding or developers.
But I certainly would be ecstatic to see a spatial database ADO.NET compatible on multiple platforms!

br...@frogmouth.net

unread,
Oct 23, 2018, 5:18:47 PM10/23/18
to spatiali...@googlegroups.com

Collin,

 

I don’t understand what you are asking.

 

If you want to compile spatialite (and dependencies, which is the harder part), then just do it – you have the source code, and presumably you have the tools for the platforms you care about. Have you tried this?

 

I’m also not sure I understand the “link” part for spatialite. You should be thinking of “load plugin at runtime”, not “link at compile time”, for most usages. That is: link sqlite, load spatialite.

 

If you have a specific problem, can you please provide a minimal, compilable, self-contained example of that problem?

 

Brad

 

Collin Tewalt

unread,
Oct 23, 2018, 7:10:55 PM10/23/18
to SpatiaLite Users
OK - yes I understand "link" SQLite, and "load" SpatiaLite at runtime. 
What I'm not sure of is how much you're allowed to load code and execute at runtime in iOS (because of Apple App store limitations)

In short, I guess the request is to be able to use SpatiaLite with the ADO.NET implementation of SQLite (System.Data.SQLite) on any platform via Xamarin.

I have compiled the source code for SpatiaLite (and its dependencies [see previous link]), but I don't know how to get an app written in C# in the Xamarin environment with System.Data.SQLite to load SpatiaLite.

If you already have a C#/.NET app in a Windows environment that uses System.Data.SQLite and loads the mod_spatialite.dll, but you want to get that code to work on another platform, at this point you'd have to re-implement everything in C.
Isn't that what you were getting at in your original question, Plamen?

br...@frogmouth.net

unread,
Oct 23, 2018, 7:19:42 PM10/23/18
to spatiali...@googlegroups.com

I still don’t understand. If there is an App Store policy problem, how will ADO.NET help?

 

Spatialite (and its dependencies) are C or C++ (i.e. native code). You need to build them for the platform you are running on.

In general, SQLite “Loadable extensions are C-code.” - https://www.sqlite.org/loadext.html#compiling_a_loadable_extension

 

What are you expecting instead?

 

Brad

--
You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialite-use...@googlegroups.com.
To post to this group, send email to spatiali...@googlegroups.com.
Visit this group at https://groups.google.com/group/spatialite-users.
For more options, visit https://groups.google.com/d/optout.

Plamen Ivanov

unread,
Oct 30, 2018, 12:48:49 PM10/30/18
to SpatiaLite Users
Hi all,

My original question was about building SpatiaLite for different platforms. Let me clarify it.

See for example how it works for SQLite. It has official binaries for download built from the same source code at the same time for every supported platform. That way:
1. Everyone can use them and not build its own (using complicated building settings)
2. Everyone using official build get the same results when using it (no different build settings)
3. Binaries can be used from other libraries (and not directly in application)
4. VERY IMPORTANT - Binaries have same functionality across the platforms because they are built from the same source code

What I asked is only to have official binaries to download for mentioned platforms just like SQLite. Currently there are such official binaries only for x86/x64. For Android they are from official site, but for older version (i.e. not in par with latest source code) and for iOS there are only binaries from other projects, probably again from different source code.

When we have these binaries, .NET community will extend current projects (mod_spatialite) to support all platforms. I believe then problem with load_extension also will be solved (if it exists at all).

Just to re-iterate: no need to port/build nothing more than SpatiaLite engine binaries and extensions. No GUI support is needed - we do not need user to be able to browse database on device using GUI. It is sufficient that app can open database and query/read/write to it.

Plamen

mj10777

unread,
Oct 30, 2018, 1:15:20 PM10/30/18
to SpatiaLite Users


On Tuesday, 30 October 2018 17:48:49 UTC+1, Plamen Ivanov wrote:
Hi all,

My original question was about building SpatiaLite for different platforms. Let me clarify it.

See for example how it works for SQLite. It has official binaries for download built from the same source code at the same time for every supported platform.
For which they have the resources, which SpatiaLite does not have
- that is the main point that must be taken into consideration here.

Mark
Reply all
Reply to author
Forward
0 new messages