5

I am working with last spatialite versions on both Windows (7) and Ubuntu (13.10).

I installed these from reference spatialite website. For both, version that I downloaded is 4.1.1 (nevertheless in Ubuntu, at spatialite start up, i get a version number : 4.1.0 ; I assume this is a little bug)

Details on the packages :

  • binaries for windows: spatialite-4.1.1-win-x86.zip
  • source for ubuntu: libspatialite-4.1.1.tar.gz and all other usefull ressources

I then developped a sql script on windows, notably using azimuth /st_azimuth this works fine on this OS. I have problems when I use it on Ubuntu and get the following error:

no such function: Azimuth

after some search, I undesrtood that this could be related to a missing lib: liblwgeom.

I had some more search to get this lib installed properly (at least no error message at the end) using the procedure described here (I effectively did the make and make install), but this does not seem to help.

Questions:

  • is the "wrong" version number for spatialite 4.1.1 a known bug?
  • is the missing Azimuth a know problem (i could not find any info)
  • is installing liblwgeom the solution to my probleùm ?
  • how to know if the liblwgeom install properly working ?
  • what may I have missed in the process ?

Thanks for your help and pieces of advice

  • So the only way to get a working copy of Spatialite with liblwgeom support enabled is by compiling the code? There is no way to enable liblwgeom support by using (say) Ubuntugis packages? – Giovanni Manghi Nov 27 '14 at 22:54
5

Answer from Sandro Fueri, posted on the spatialite users group https://groups.google.com/forum/#!topic/spatialite-users/wx0RAFTA2tM

Hi Pascal,

the most recent versions of SpatiaLite support several interesting "advanced" functions based on LWGEOM: ST_Azimuth(), ST_MakeValid(), ST_Split() and so on. anyway enabling or not LWGEOM is a configurable option; and the default setting is --disable-lwgeom=yes (i.e. always disable LWGEOM, if not explicitly required)

the liblwgeom library is a self-standing independent module, but it isn't directly available as such. it is integral part of PostGIS, and the unique supported way to get liblwgeom installed (or built) is the one to install (or build) a very recent version of PostGIS (v.2.0 or v.2.1)

if you wish to get a full fledged version of libspatialite-4.1.1 on any Linux system you have to accomplish the following steps: - install (or build) PostGIS 2.x - install (or build) libxml2 - configure and then build libspatialite-4.1.1 by enabling both lwgeom and libxml2

./configure --enable-lwgeom=yes --enable-libxml2=yes make sudo make-install

PLEASE NOTE WELL: liblwgeom is released under the GPL licence; due to cross-license constraints, building libspatialite with liblwgeom enabled make libspatialite (and any further sw depending on libspatialite) to become implicitly GPLed.

bye Sandro

  • Looks like liblwgeom has been replaced by librttopo in newer versions of spatiliate. – GlennS Feb 22 '17 at 14:09
3

If you have to use an older version of spatialite, here is the SQL equivalent for the postgis ST_Azimuth(A,B):

case
    when X(A) == X(B) then case
        when Y(A)  Y(B) then 3.141592653589793
        else 0
        end
    when Y(A) == Y(B) then case 
        when X(A)  X(B) then 3.141592653589793 + 3.141592653589793/2
        else 0
        end
    when X(A)  Y(B) then atan( abs(X(A) - X(B)) / abs(Y(A) - Y(B)) ) + 3.141592653589793
        else atan( abs(Y(A) - Y(B)) / abs(X(A) - X(B)) ) + 3.141592653589793 + 3.141592653589793/2
        end
    end

Not completely equivalent since it won't return an error if A==B.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.