ST_Intersection vs Intersection

122 views
Skip to first unread message

Justyna Dębicka

unread,
May 19, 2018, 8:49:49 AM5/19/18
to SpatiaLite Users
Hi,
I found that Spatialite propose two functions for intersection:

Intersection( geom1 Geometry , geom2 Geometry ) : Geometry
ST_Intersection( geom1 Geometry , geom2 Geometry ) : Geometry

what is the difference between them?

If I use the function like below:

select intersection_function(poligons_geom,polylines_geom) from poligons, polylines;

does the query use spatial indexes from poligons and polylines table?

Thanks :)
Justyna

br...@frogmouth.net

unread,
May 19, 2018, 9:18:37 AM5/19/18
to spatiali...@googlegroups.com

The only difference is the amount of typing, as shown in http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html#p12

 

You can always check the “reality” by inspecting the source code.

In this case, from https://www.gaia-gis.it/fossil/libspatialite/artifact/d7f7c17a2d5a8c53 you can see:

    sqlite3_create_function_v2 (db, "Intersection", 2,

                               SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,

                               fnct_Intersection, 0, 0, 0);

    sqlite3_create_function_v2 (db, "ST_Intersection", 2,

                               SQLITE_UTF8 | SQLITE_DETERMINISTIC, cache,

                               fnct_Intersection, 0, 0, 0);

 

That these are different names for the same implementation.

 

Spatial indices are not used “automagically” in spatialite. There is a good description of how to do this in the documentation: http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/rtree.html (possibly working through other parts of the cookbook first if that isn’t obvious).

 

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.

mj10777

unread,
May 19, 2018, 9:19:18 AM5/19/18
to SpatiaLite Users


On Saturday, 19 May 2018 14:49:49 UTC+2, Justyna Dębicka wrote:
Hi,
I found that Spatialite propose two functions for intersection:

Intersection( geom1 Geometry , geom2 Geometry ) : Geometry
ST_Intersection( geom1 Geometry , geom2 Geometry ) : Geometry

what is the difference between them?
'ST_' are standard commands that are (I believe) defined in ISO/IEC 13249-3 SQL/MM Part 3 and are expected to work / return a result in a specific way. 
- when there is a command without the 'ST_' it only an alternative name (they all call the same internal functions)

Commands that have no 'ST_' are Spatialite specific

a.fu...@lqt.it

unread,
May 19, 2018, 4:05:15 PM5/19/18
to spatiali...@googlegroups.com
On Sat, 19 May 2018 06:19:18 -0700 (PDT), 'mj10777' via SpatiaLite
Users wrote:
> 'ST_' are standard commands that are (I believe) defined in ISO/IEC
> 13249-3 SQL/MM Part 3 and are expected to work / return a result in a
> specific way. 
> - when there is a command without the 'ST_' it only an alternative
> name (they all call the same internal functions)
>
> Commands that have no 'ST_' are Spatialite specific
>

this basic rule is generally true, but there are several exceptions
to be taken in account.

PostGIS tends to use the "ST_" prefix also for functions that are not
defined by any standard. and in all these cases SpatiaLite is
practically
forced to adopt such "unorthodox" names so to not break the
compatibility
with PostGIS. just few examples:

ST_HausdorffDistance(), ST_OffsetCurve(), ST_SingleSidedBuffer(),
ST_SharedPaths(), ST_ClosestPoint(), ST_DelaunayTriangulation(),
ST_VoronojDiagram() etc

bye Sandro

artkraw

unread,
May 20, 2018, 4:42:26 PM5/20/18
to SpatiaLite Users
Justyno,

You can find the answer in this document: http://portal.opengeospatial.org/files/?artifact_id=25355

This "ST_" means  "SQL Geometry Types"

Note that this standard also says:
"Class names in SQL / MM have the" ST_ "prefix. This is optional and implementations may choose to drop this prefix, as it was done in different places in the standard."

For example, Spatial option from M$SQL Server doesn't use the "_" from "ST_"  , eg. the point geometry is named STPoint  ;-) 

Artur 

Justyna Dębicka

unread,
May 20, 2018, 5:03:09 PM5/20/18
to SpatiaLite Users
Thank you all for answers :)
Reply all
Reply to author
Forward
0 new messages