I was recently asked (by @
PABLO2013) how to select polygon points from a spatialite table.
Using the existing spatialite library it seemed as though creating a query using AsText on the geometry column was the only solution.
That returns the geometry as a string to b4a and that string requires parsing to extract the required info.
The b4a code to parse that string needed to be able to handle simple polygons, complex multi polygons, polygons with inner rings etc.
Not a straightforward task.
So i wrapped a small part of the Vivid Solutions
JTS Topology Suite library.
The parts i wrapped were mainly the
WKBReader and
WKTReader classes - and the classes required in order to work with WTBReader and WKTReader.
Now i can select a geometry using AsBinary and pass each row of the resultset to the JTS WTBReader's Read method.
The Read method accepts an array of Bytes - AsBinary selects the geometry as an array of Bytes.
The Read method returns a
Geometry object.
The Geomtery object makes it easy to work with complex geometries such as multi polygons - no more hit and miss parsing of strings.
I've uploaded a reference document for my partial implementation of the JTS Topology Suite to here:
http://b4a.martinpearman.co.uk/jts/JTS.html.
If there's any interest from forum members i'll upload my JTS library and an example project.
Martin.