![]() |
WhirlyGlobe
1.2
A 3D interactive globe toolkit for iOS
|
#include <VectorDatabase.h>
Public Member Functions | |
VectorDatabase (NSString *bundleDir, NSString *cacheDir, NSString *baseName, VectorReader *reader, const std::set< std::string > *indices, bool cache=false, bool autoload=false) | |
void | setAutoload (bool autoload) |
void | setMemCache (bool memCache) |
Turn memory caching on or off. | |
void | process () |
If you want the vector db to autoload, call this periodically. | |
unsigned int | numVectors () |
Total number of vectors in the database. | |
GeoMbr | getMbr (unsigned int) |
VectorShapeRef | getVector (unsigned int, bool withAttributes=true) |
void | getVectorsWithinMbr (const GeoMbr &mbr, UIntSet &vecIds) |
Return a list of all the features that overlap. | |
void | getMatchingVectors (NSString *query, UIntSet &vecIds) |
void | getMatchingVectors (NSString *query, ShapeSet &shapes) |
This version returns a set of shapes. | |
void | findArealsForPoint (const GeoCoord &coord, ShapeSet &shapes) |
sqlite3 * | getSqliteDb () |
Return a pointer to the SQLite DB. For read only please. | |
Protected Member Functions | |
bool | buildCaches (NSString *mbrCache, NSString *sqlDb) |
bool | readCaches (NSString *mbrCache, NSString *sqlDb) |
Protected Attributes | |
VectorReader * | reader |
std::vector< GeoMbr > | mbrs |
bool | vecCacheOn |
If we're caching in memory, this is the cache. | |
std::map< unsigned int, VectorShapeRef > | vecCache |
bool | autoloadOn |
If we're slowly loading data in, this is how we keep track. | |
int | autoloadWhere |
sqlite3 * | db |
Open SQLite database. |
The Vector Database is used to keep vector data out of memory until needed. It will initialize itself if its cache files aren't there. That can be slow, so ideally initialize it offline. It builds both a file of MBRs and a sqlite database with the attributes
WhirlyGlobe::VectorDatabase::VectorDatabase | ( | NSString * | bundleDir, |
NSString * | cacheDir, | ||
NSString * | baseName, | ||
VectorReader * | reader, | ||
const std::set< std::string > * | indices, | ||
bool | cache = false , |
||
bool | autoload = false |
||
) |
Either initialize from or build the cache info for a vector db. cacheDir is where the cache files are or you want them to be. baseName should correspond to the file being read. reader is a vector reader that can seek. Will delete this on destruction. indices are sqlite columns to make indices if we're constructing this thing
void WhirlyGlobe::VectorDatabase::findArealsForPoint | ( | const GeoCoord & | coord, |
ShapeSet & | shapes | ||
) |
Return any areals that surround the given point. The caller is responsible for deletion
void WhirlyGlobe::VectorDatabase::getMatchingVectors | ( | NSString * | query, |
UIntSet & | vecIds | ||
) |
Run a SQL query, returning the list of IDs that match. Pass in the where clause, essentially. This version returns a set of IDs
GeoMbr WhirlyGlobe::VectorDatabase::getMbr | ( | unsigned | int | ) |
Fetch an MBR for the given vector. This is cheap because it's in memory
VectorShapeRef WhirlyGlobe::VectorDatabase::getVector | ( | unsigned | int, |
bool | withAttributes = true |
||
) |
Fetch the corresponding vector. This probably isn't cheap since we're going out to "disk". We can also read the attributes, or not This is returning a reference counted shape so keep it around until you're done with it.
void WhirlyGlobe::VectorDatabase::setAutoload | ( | bool | autoload | ) |
Turn automatic loading on or off If it's on, you need to call process
std::vector<GeoMbr> WhirlyGlobe::VectorDatabase::mbrs [protected] |
Flat list of the vectors and their MBRs. Need a spatial index here, ideally an R-Tree