-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android and iOS binaries #6
Comments
I was able to compile SpatiaLite C-style Library in iOS using this tutorial here. https://gist.github.com/aaronpk/0252426d5161bc9650d8 I don't know if/how you could load the extension in iOS. You can embed iOS dynamic frameworks. I'm not sure how System.Data.SQLite loads extensions, but I'm assuming it's a dynamic load of a binary at runtime - I could be wrong but I think that kind of thing is harder to do "correctly" in a way that would make it through the Apple App Store review process. (Since they have stricter rules about dynamically loading and executing binary code, etc.) It would be sweet to use SpatiaLite functionality purely through the System.Data.SQLite library calls! |
The biggest problem seems to be the licensing right? LGPL/GPL would be a big problem for the app stores. |
I don't know anything about native iOS development, but when you execute https://github.com/sqlite/sqlite/blob/master/src/loadext.c#L528 ...which I believe just calls dlopen: https://github.com/sqlite/sqlite/blob/master/src/os_unix.c#L6369-L6372 So is it just a matter of deploying libmod_spatialite.dylib (lol, is it even dylib on iOS??) to the right directory? I believe NuGet and Xamarin will do this for us if we put it under |
Hmm... maybe not. Looks like SQLitePCL.raw uses a shim assembly with sqlite3.a embedded. (looking at the SQLitePCLRaw.lib.e_sqlite3.ios package) |
I believe we only just need to compile mod_spatialite.so |
Finally I've managed to build the dll! |
I just re-distribute the msys 2 binaries. I can dig into what they use... |
That would be awesome! |
Though I'd also like to ask about licensing.. It seems to me that depending on how the spatialite configure parameters are used, we might have to use a LGPL or GPL license which isn't very good for the Android app store right? |
Oh I forgot, I'm working on the Android build - will try to build for ios later |
libs.zip |
Licensing is a mess. I've collected the ones involved here: https://github.com/bricelam/mod_spatialite-NuGet/blob/master/src/mod_spatialite/NOTICE.md Statically linking everything into one library may be problematic...
You can send a PR here. Maybe we can automate everything using GitHub Actions or something. |
I guess it's finally time for me to buy a Mac mini... |
Here is the MSYS2 package script: https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-libspatialite/PKGBUILD |
First of all I've used https://github.com/geopaparazzi/libjsqlite-spatialite-android and removed all unnecessary projects, so I think we should mention geopaparazzi wherever we put this build (he basically unwittingly did the largest part of the work). I created a build-able zip containing only the projects that are included in my build. So I've removed So if we look at the licenses: The lowest common denominator is LGPL, meaning that the mod_sqlite.so.so files are basically LGPL. I hope I understand this correctly. |
I found something else: android/ndk#702 Do you know of a way to deploy different so files depending on the api level? |
spatialite_efcore2.6_api28.zip Spatialite using the built in iconv lib (API Level >= 28) |
I'm sure there's a way. I see a RID for |
I like the idea of stripping it down to only what EF Core needs. I'm going to take a stab at this on Windows/MSYS2. I'm also going to start setting up GitHub Actions to automate building for different platforms and bundling everything up into a NuGet package. |
The GEOS library is still a headache since it's LGPL, do you know if there is an alternative that we can replace it with? (Will be more work but it would remove the issues especially with the Apple App Store) If no such library exists I think we should see if anyone would implement one. (I would do it but I don't have the resources right now - at least as long as I want to have some private life XD) |
I doubt we can replace GEOS. It’s the heart of the spatial logic used by both SpatiaLite and PostGIS. It’s a C++ port of JTS (like NTS is a C# port) What’s the issue with the Apple App Store and the LGPL? |
We've run up against this problem as well. It has to do with something
about static linking if I remember right.
https://trac.ffmpeg.org/ticket/1229
https://lists.osgeo.org/pipermail/geos-devel/2012-August/005980.html
…________________
Collin Tewalt
ctewalt@gmail.com
On Sun, Sep 22, 2019 at 11:29 AM Brice Lambson ***@***.***> wrote:
I doubt we can replace GEOS. It’s the heart of the spatial logic used by
both SpatiaLite and PostGIS. It’s a C++ port of JTS (like NTS is a C# port)
What’s the issue with the Apple App Store and the LGPL?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6?email_source=notifications&email_token=AAH5GPW6VWN2PWU745LZCJTQK6TQRA5CNFSM4F6O5W4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7JK5WY#issuecomment-533901019>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAH5GPVZKKH4NOW4CQNSRETQK6TQRANCNFSM4F6O5W4A>
.
|
Maybe (far in the future) a managed sqlite implementation that uses NetTopologySuite might be a better solution? |
No easy path forward here. I’ll see what (if anything) works without GEOS. |
technically, the NuGet package wouldn’t be violating anything, just everyone using the NuGet package |
Since GEOS and NetTopologySuite are basically the same thing, it would be nice to replace GEOS with NetTopologySuite. Here is an explanation: https://stackoverflow.com/a/57534869 I thisnk this would actually even be better than GEOS since using both GEOS and NetTopologySuite is basically code duplication (more or less XD) We do need NetStandard support first though.... |
https://docs.microsoft.com/en-us/xamarin/tools/dotnet-embedding/ trying this out now ;) |
Well seems like there is no point form me to continue since |
Seems like we need an initiative to create an MIT licensed library to do a
full rewrite of Geos or NTS. I don’t know how realistic this is for someone
like Microsoft to do, but I know this would really open the door for a lot
of folks who are trying to make apps with a reliable fully featured cross
platform spatial database.
My guess is if the initiative was there, a bunch of developers would come
out of the woodwork to crank it out.
--
…________________
Collin Tewalt
ctewalt@gmail.com
|
Well i think the quickest way to get to a proper license would be to use NTS 2.0 (which as BSD and no other dependencies) - it seems like there is already an Mono Android version supported by .NETStandard 2.0. I did start to try and replace the code but I think we'd need someone who knows spatialite better than myself. Just to let you see how the NetTopologySuite.h looks like using the Embeddinator: Though obviously a proper managed implementation of the whole thing would be much, much better. Also the shared library (libNetTopologysuite.so) is 1.87MB large... |
So I've come to think that it may be less work if we created something in place of spatialite, since ef core only uses a fraction of the functions anyway AND we basically when doing statements we convert nettopologysuite objects into strings/binaries to create sqlite queries that are parsed and used by the geos lib and then we get strings/binaries back that we convert to nettopologysuite again If we create a plugin for this: We can implement the geo functions more easily AND it will run on any platform since its fully managed c# code -> also we don't even have to serialize the nettopologysuite objects and can use them within the query directly (if we implement it that way) The disadvantage right now is that the project is currently not maintained, but I think if we'd include it within EF Core the community is sure to maintain it. |
Since https://www.openhub.net/p/csharp-sqlite is no longer maintained, I forked the code from someone on github, removed all unnecessary projects, migrated to netstandard2.1 and did some minor code fixes and it builds properly. Also NetTopologySuite has a rtree implementation that could be used for the index as well ;) |
Thinking about this some more, you can do a lot without SpatiaLite. You could use an EF Core value converter to store geometries as WKT/B and implement the spatial operations as UDFs backed by NTS. There would be a lot of conversation to/from WKT and you couldn’t leverage spatial indexes, but at least it would be functional... |
Thank you for the information! |
SpatiaLite's spatial indexes are actually pretty hard to use right. They require JOINs to the R*Tree index virtual table or using the RTreeIntersects or RTreeDistWithin functions in your queries. None of it is well supported by EF Core. BUT, as far as I can tell they don't require GEOS... |
My current plan of iOS:
My bigger plan:
|
Thank's again for the information.
If this is the way to go with IOS, I think we should use that same c code for Android as well - since it won't be much additional work AND solve the LGPL issues. |
@bricelam |
Are there any work arounds for getting NTS to work on android? I'm not sure how to build mod_spatialite for android myself. Can you guys point me in the right direction ? |
Sorry, the last time I compiled for Android was over ten years ago. 😁 |
See the link - you can use this for compiling |
@groege, I have downloaded your zips, because I'm trying to generate I would like to know, what I need to do to generate that file? |
you need to rename the libspatialite.so to mod_libspatialite.so then it should work |
@bricelam Any update on this? Since EF6 seems like very much work (I'll be surprised with a November release without any cuts to planned features), can I guess that before EF7 there will probably not much happen with this issue? |
No updates. This work is currently very low priority for the EF team. I may look into it again as part of dotnet/efcore#22138 whenever that becomes a priority. I'm worried that even after I finally figure out how to compile the binaries and add them to the NuGet package, I'll run into the same NuGet/runtime limitations that I hit on Linux and macOS... |
I have a working set of binaries for spatialite on iOS, Android, & macOS. It did require some additions beyond the traditional SqliteConnection.LoadExtension("mod_spatialite") It feels hacky... there may be some licensing concerns... and the binaries are not built via a script. I did it with some manual compiles and copying over the binaries from brew. I've got it in a closed source repo at the moment. Would you like to see if this is something we can add to this library to centralize everything? |
@aritchie If it can be automated in a shell script or GitHub Actions, I think there's value in putting those here. Even if we don't distribute the binaries, it will give others a good starting place for their own experiments. |
@aritchie can u please share the link to working set of binaries for spatialite on iOS, Android, & macOS. |
@asim27 I'm unable to share at the moment due to a project constraint. The project also isn't using 5.0. I stuck to v4 due to some noted issues with 5 |
I'm not sure if there are SpatiaLite ports available for these, but it would be awesome to make Xamarin work if there are.
The text was updated successfully, but these errors were encountered: