Ok,<br><br>during the weekend I&#39;ve started the implementation of a &quot;sqlite spatial&quot; class according to FDO specifications (<a href="http://trac.osgeo.org/fdo/wiki/FDORfc16" target="_blank">http://trac.osgeo.org/fdo/wiki/FDORfc16</a>).<br>
<br>Thanks for the suggestions,<br>Luca<br><br><div class="gmail_quote">2010/6/11 Benjamin Ducke <span dir="ltr">&lt;<a href="mailto:benjamin.ducke@oxfordarch.co.uk">benjamin.ducke@oxfordarch.co.uk</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Good point.<br>
<br>
When the features are read in from BLOBs, their coordinates<br>
can be checked and filtered. So the spatial index is not absolutely<br>
necessary -- but it would certainly speed up the operation a lot!<br>
<br>
So it would be good to be make use of spatial indices for SpatiaLite<br>
format geometries.<br>
<br>
The &quot;raw&quot; WKB/WKT format (<a href="http://trac.osgeo.org/fdo/wiki/FDORfc16" target="_blank">http://trac.osgeo.org/fdo/wiki/FDORfc16</a>)<br>
does not include a proposal for a stored spatial index. Instead,<br>
it suggests to build the index in memory the first time a spatial<br>
filter is run on the data.<br>
<br>
Ben<br>
<div><div></div><div class="h5"><br>
----- Original Message -----<br>
&gt; &gt; The SpatiaLite format as such has no particular advantage in a gvSIG<br>
&gt; &gt; context. SpatiaLite implements things such as topology queries and<br>
&gt; &gt; spatial indices. But gvSIG already has all of that, so no need to<br>
&gt; &gt; reinvent those things!<br>
&gt;<br>
&gt; Being able to use the spatial indexes provided by the DB is important!<br>
&gt; For example, how do you select only the features needed by a certain<br>
&gt; viewport? For example, the OracleSpatial driver select statement asks<br>
&gt; for features through a spatial filter (sdo_filter and sdo_relate)<br>
&gt; which uses the oracle internal spatial index...<br>
&gt;<br>
&gt; Giovanni<br>
&gt;<br>
&gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; ----- Original Message -----<br>
&gt; &gt;&gt; Hi all,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I&#39;d like discussing a couple of things with you after all the tests<br>
&gt; &gt;&gt; I&#39;ve done during this first time past for finding out which was the<br>
&gt; &gt;&gt; most reasonable approach to get SQLite and SpatiaLite support into<br>
&gt; &gt;&gt; gvSIG.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Brief introduction:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I&#39;ve tested all the approaches and resources we&#39;ve discussed [1]<br>
&gt; &gt;&gt; and all those I could find asking around and scanning the web.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Results:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; SQLITE SUPPORT<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; - The Xerial SQLite driver[2], derived from the Zentus&#39;one [3],<br>
&gt; &gt;&gt; developed and mantained by Taro L. Saito of the University of Tokyo<br>
&gt; &gt;&gt; looks to be the most suitable for accomplishing our tasks.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; The reasons are mainly:<br>
&gt; &gt;&gt; - it&#39;s kept updated and recompiled with every new version of SQLite<br>
&gt; &gt;&gt; - it has some improvements and some fixing<br>
&gt; &gt;&gt; - you need to include in your project just one file<br>
&gt; &gt;&gt; (sqlite-jdbc.jar) in order to use it<br>
&gt; &gt;&gt; - as far as it&#39;s a java jar it&#39;s multiplatform<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; SPATIALITE<br>
&gt; &gt;&gt; - you can import the libspatialite.* file (according to your<br>
&gt; &gt;&gt; system) with Xerial sqlite-JDBC driver(see above)[2] and reading<br>
&gt; &gt;&gt; data from a<br>
&gt; &gt;&gt; SpatiaLite database<br>
&gt; &gt;&gt; - I&#39;ve found many bugs in doing Spatialite&#39;s operations (due<br>
&gt; &gt;&gt; probably<br>
&gt; &gt;&gt; to bugs in memory handling of SpatiaLite functions into<br>
&gt; &gt;&gt; java-driver): that means I can do any SELECT with SpatiaLite&#39;s<br>
&gt; &gt;&gt; functions (I&#39;ve<br>
&gt; &gt;&gt; tested many of them) retrieving the data I want BUT with a silly<br>
&gt; &gt;&gt; workaround that avoids the crash of the JVM (usually in connection<br>
&gt; &gt;&gt; closing / statment reset)<br>
&gt; &gt;&gt; - I can&#39;t write data at the moment (I&#39;ve found no<br>
&gt; &gt;&gt; workarounds/fixing yet) because of other errors in memory handling.<br>
&gt; &gt;&gt; I&#39;ve got in touch with Taro L. Saito but I guess he has not found<br>
&gt; &gt;&gt; any fixing for that segmentation fault.<br>
&gt; &gt;&gt; I will try to write him again hoping he has time to fix this<br>
&gt; &gt;&gt; problem.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; CONCLUSIONS<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I guess that thanks to SQLite-JDBC driver [2] including SQLite<br>
&gt; &gt;&gt; support into gvSIG should be quite quick (Cèsar has suggested me to<br>
&gt; &gt;&gt; see the<br>
&gt; &gt;&gt; libFMap_daldb for understanding how MySQL, etc are already<br>
&gt; &gt;&gt; supported in our application).<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; SpatiaLite support needs to be discussed a little bit because the<br>
&gt; &gt;&gt; reading it&#39;s quite straightforward (keeping in mind we can make it<br>
&gt; &gt;&gt; work with a workaround. That&#39;s not proper but as a temporary<br>
&gt; &gt;&gt; solution could be partially acceptable), including the proper<br>
&gt; &gt;&gt; library (according to OS and architecture) thanks to the<br>
&gt; &gt;&gt; SQLite-JDBC driver as<br>
&gt; &gt;&gt; well.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; SOLUTION I PROPOSE ABOUT SPATIALITE<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Well, I&#39;d need hearing your ideas about this matter anyway and<br>
&gt; &gt;&gt; discuss together about which whould be the better way to get<br>
&gt; &gt;&gt; spatialite support.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; However I&#39;ve a proposal to get finally a much better work in my<br>
&gt; &gt;&gt; opinion: I&#39;ve almost finished the code for decoding the SPATIALITE<br>
&gt; &gt;&gt; BLOB[5] (that&#39;s the particular structure that stores every<br>
&gt; &gt;&gt; Spatialite infos) and I guess the better thing would be<br>
&gt; &gt;&gt; implementing a Java<br>
&gt; &gt;&gt; version of SpatiaLite or at least of its most common<br>
&gt; &gt;&gt; functionalities. For many of them we could have help from JTS[4]<br>
&gt; &gt;&gt; (as partially<br>
&gt; &gt;&gt; suggested by Juan Lucas [1]).<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Firstly it would let us having just one file (a common java jar)<br>
&gt; &gt;&gt; for every OS and architecture, instead of having a lib file for<br>
&gt; &gt;&gt; each most<br>
&gt; &gt;&gt; common machine.<br>
&gt; &gt;&gt; It would avoid the necessity of trying to wrap a C lib into a JAVA<br>
&gt; &gt;&gt; interface with all the problems we have already with the memory<br>
&gt; &gt;&gt; handling in importing libspatialite.* into the already fully<br>
&gt; &gt;&gt; working driver [2].<br>
&gt; &gt;&gt; It would take some time BUT finally we will have a much cleaner and<br>
&gt; &gt;&gt; multiplatform solution.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Sorry for the maybe too long paper,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Cheers,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Luca<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; [1]<br>
&gt; &gt;&gt; <a href="http://osgeo-org.1803224.n2.nabble.com/New-Student-for-GVSIG-within-Google-Summer-Of-Code-2010-quick-introduction-td5014112.html#a5014112" target="_blank">http://osgeo-org.1803224.n2.nabble.com/New-Student-for-GVSIG-within-Google-Summer-Of-Code-2010-quick-introduction-td5014112.html#a5014112</a><br>

&gt; &gt;&gt; [2] <a href="http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC" target="_blank">http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC</a><br>
&gt; &gt;&gt; [3] <a href="http://www.zentus.com/sqlitejdbc/" target="_blank">http://www.zentus.com/sqlitejdbc/</a><br>
&gt; &gt;&gt; [4] <a href="http://www.vividsolutions.com/jts/jtshome.htm" target="_blank">http://www.vividsolutions.com/jts/jtshome.htm</a><br>
&gt; &gt;&gt; [5]<br>
&gt; &gt;&gt; <a href="http://www.gaia-gis.it/spatialite/spatialite-manual-2.3.1.html#t3.3" target="_blank">http://www.gaia-gis.it/spatialite/spatialite-manual-2.3.1.html#t3.3</a><br>
&gt; &gt;&gt; _______________________________________________ Gvsig_internacional<br>
&gt; &gt;&gt; mailing list<br>
&gt; &gt;&gt; <a href="mailto:Gvsig_internacional@listserv.gva.es">Gvsig_internacional@listserv.gva.es</a><br>
&gt; &gt;&gt; <a href="http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" target="_blank">http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; ------ Files attached to this email may be in ISO 26300 format<br>
&gt; &gt; (OASIS Open Document Format). If you have difficulty opening them,<br>
&gt; &gt; please visit <a href="http://iso26300.info" target="_blank">http://iso26300.info</a> for more information.<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________ Gvsig_internacional<br>
&gt; &gt; mailing list<br>
&gt; &gt; <a href="mailto:Gvsig_internacional@listserv.gva.es">Gvsig_internacional@listserv.gva.es</a><br>
&gt; &gt; <a href="http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" target="_blank">http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</a><br>
&gt; &gt;<br>
&gt; _______________________________________________ Gvsig_internacional<br>
&gt; mailing list<br>
&gt; <a href="mailto:Gvsig_internacional@listserv.gva.es">Gvsig_internacional@listserv.gva.es</a><br>
&gt; <a href="http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" target="_blank">http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</a><br>
<br>
<br>
------<br>
Files attached to this email may be in ISO 26300 format (OASIS Open Document Format). If you have difficulty opening them, please visit <a href="http://iso26300.info" target="_blank">http://iso26300.info</a> for more information.<br>

<br>
_______________________________________________<br>
Gvsig_internacional mailing list<br>
<a href="mailto:Gvsig_internacional@listserv.gva.es">Gvsig_internacional@listserv.gva.es</a><br>
<a href="http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional" target="_blank">http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</a><br>
</div></div></blockquote></div><br>