| SpatiaLite
    5.0.1
    | 
This is a sample C source showing how to manipulate GEOMETRY within Spatialite. It essentially follows on from the functionality shown in the demo1.c example, and covers:
Note that this does not require a database command line argument. Here is a typical run:
$ ./demo2 
step#1: POINT           Dimension=0 IsValid=1
                        POINT 0/1 x=1.5000 y=2.7500
step#2: LINESTRING      Dimension=1 IsValid=1
                        LINESTRING 0/1 has 5 vertices
                                vertex 0/5 x=1.0000 y=1.0000
                                vertex 1/5 x=2.0000 y=1.0000
                                vertex 2/5 x=2.0000 y=2.0000
                                vertex 3/5 x=100.0000 y=2.0000
                                vertex 4/5 x=100.0000 y=100.0000
step#3: POLYGON Dimension=2 IsValid=1
                        POLYGON 0/1 has 2 holes
                                ExteriorRing has 5 vertices
                                        vertex 0/5 x=0.0000 y=0.0000
                                        vertex 1/5 x=50.0000 y=0.0000
                                        vertex 2/5 x=50.0000 y=50.0000
                                        vertex 3/5 x=0.0000 y=50.0000
                                        vertex 4/5 x=0.0000 y=0.0000
                                InteriorRing 0/2 has 5 vertices
                                        vertex 0/5 x=40.0000 y=40.0000
                                        vertex 1/5 x=41.0000 y=40.0000
                                        vertex 2/5 x=41.0000 y=41.0000
                                        vertex 3/5 x=40.0000 y=41.0000
                                        vertex 4/5 x=40.0000 y=40.0000
                                InteriorRing 1/2 has 5 vertices
                                        vertex 0/5 x=30.0000 y=30.0000
                                        vertex 1/5 x=31.0000 y=30.0000
                                        vertex 2/5 x=31.0000 y=31.0000
                                        vertex 3/5 x=30.0000 y=31.0000
                                        vertex 4/5 x=30.0000 y=30.0000
step#4: MULTIPOINT      Dimension=0 IsValid=1
                        POINT 0/5 x=5.0000 y=5.0000
                        POINT 1/5 x=15.0000 y=5.0000
                        POINT 2/5 x=5.0000 y=15.0000
                        POINT 3/5 x=25.0000 y=5.0000
                        POINT 4/5 x=5.0000 y=25.0000
step#5: MULTILINESTRING Dimension=1 IsValid=1
                        LINESTRING 0/2 has 2 vertices
                                vertex 0/2 x=30.0000 y=10.0000
                                vertex 1/2 x=10.0000 y=30.0000
                        LINESTRING 1/2 has 2 vertices
                                vertex 0/2 x=40.0000 y=50.0000
                                vertex 1/2 x=50.0000 y=40.0000
step#6: MULTIPOLYGON    Dimension=2 IsValid=1
                        POLYGON 0/2 has 0 holes
                                ExteriorRing has 5 vertices
                                        vertex 0/5 x=60.0000 y=60.0000
                                        vertex 1/5 x=70.0000 y=60.0000
                                        vertex 2/5 x=70.0000 y=70.0000
                                        vertex 3/5 x=60.0000 y=70.0000
                                        vertex 4/5 x=60.0000 y=60.0000
                        POLYGON 1/2 has 0 holes
                                ExteriorRing has 5 vertices
                                        vertex 0/5 x=80.0000 y=80.0000
                                        vertex 1/5 x=90.0000 y=80.0000
                                        vertex 2/5 x=90.0000 y=90.0000
                                        vertex 3/5 x=80.0000 y=90.0000
                                        vertex 4/5 x=80.0000 y=80.0000
step#7: GEOMETRYCOLLECTION      Dimension=2 IsValid=1
                        POINT 0/2 x=100.0000 y=100.0000
                        POINT 1/2 x=100.0000 y=0.0000
                        LINESTRING 0/2 has 2 vertices
                                vertex 0/2 x=130.0000 y=110.0000
                                vertex 1/2 x=110.0000 y=130.0000
                        LINESTRING 1/2 has 2 vertices
                                vertex 0/2 x=140.0000 y=150.0000
                                vertex 1/2 x=150.0000 y=140.0000
                        POLYGON 0/2 has 0 holes
                                ExteriorRing has 5 vertices
                                        vertex 0/5 x=160.0000 y=160.0000
                                        vertex 1/5 x=170.0000 y=160.0000
                                        vertex 2/5 x=170.0000 y=170.0000
                                        vertex 3/5 x=160.0000 y=170.0000
                                        vertex 4/5 x=160.0000 y=160.0000
                        POLYGON 1/2 has 0 holes
                                ExteriorRing has 5 vertices
                                        vertex 0/5 x=180.0000 y=180.0000
                                        vertex 1/5 x=190.0000 y=180.0000
                                        vertex 2/5 x=190.0000 y=190.0000
                                        vertex 3/5 x=180.0000 y=190.0000
                                        vertex 4/5 x=180.0000 y=180.0000
step#8: checking WKT representations
GEOMETRYCOLLECTION(POINT(1.5 2.75))
GEOMETRYCOLLECTION(LINESTRING(1 1, 2 1, 2 2, 100 2, 100 100))
GEOMETRYCOLLECTION(POLYGON((0 0, 50 0, 50 50, 0 50, 0 0), (40 40, 41 40, 41 41, 40 41, 40 40), (30 30, 31 30, 31 31, 30 31, 30 30)))
GEOMETRYCOLLECTION(POINT(5 5), POINT(15 5), POINT(5 15), POINT(25 5), POINT(5 25))
GEOMETRYCOLLECTION(LINESTRING(30 10, 10 30), LINESTRING(40 50, 50 40))
GEOMETRYCOLLECTION(POLYGON((60 60, 70 60, 70 70, 60 70, 60 60)), POLYGON((80 80, 90 80, 90 90, 80 90, 80 80)))
GEOMETRYCOLLECTION(POINT(100 100), POINT(100 0), LINESTRING(130 110, 110 130), LINESTRING(140 150, 150 140), POLYGON((160 160, 170 160, 170 170, 160 170, 160 160)), POLYGON((180 180, 190 180, 190 190, 180 190, 180 180)))