Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created September 7, 2011 17:50
Show Gist options
  • Save springmeyer/1201238 to your computer and use it in GitHub Desktop.
Save springmeyer/1201238 to your computer and use it in GitHub Desktop.
Index: plugins/input/sqlite/sqlite_datasource.cpp
===================================================================
--- plugins/input/sqlite/sqlite_datasource.cpp (revision 3280)
+++ plugins/input/sqlite/sqlite_datasource.cpp (working copy)
@@ -632,11 +632,12 @@
Use rtree to limit record id's to a given bbox
then a btree to pull the records for those ids.
*/
+
std::ostringstream spatial_sql;
- spatial_sql << std::setprecision(16);
- spatial_sql << " WHERE " << key_field_ << " IN (SELECT pkid FROM " << index_table_;
- spatial_sql << " WHERE xmax>=" << e.minx() << " AND xmin<=" << e.maxx() ;
- spatial_sql << " AND ymax>=" << e.miny() << " AND ymin<=" << e.maxy() << ")";
+ spatial_sql << std::setprecision(16)
+ << " WHERE " << key_field_ << " IN (SELECT pkid FROM " << index_table_
+ << " WHERE xmax>" << e.minx() - 1e-11 << " AND xmin<" << e.maxx() + 1e-11
+ << " AND ymax>" << e.miny() - 1e-11 << " AND ymin<" << e.maxy() + 1e-11 << ")";
if (boost::algorithm::ifind_first(query, "WHERE"))
{
boost::algorithm::ireplace_first(query, "WHERE", spatial_sql.str() + " AND ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment