![]() |
WhirlyGlobe
1.2
A 3D interactive globe toolkit for iOS
|
00001 /* 00002 * VectorDatabase.h 00003 * WhirlyGlobeLib 00004 * 00005 * Created by Steve Gifford on 5/12/11. 00006 * Copyright 2011 mousebird consulting 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); 00009 * you may not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, 00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 * See the License for the specific language governing permissions and 00017 * limitations under the License. 00018 * 00019 */ 00020 00021 #import <math.h> 00022 #import <set> 00023 #import <map> 00024 #import "VectorData.h" 00025 #import "sqlite3.h" 00026 00027 namespace WhirlyGlobe 00028 { 00029 00030 typedef std::set<unsigned int> UIntSet; 00031 00037 class VectorDatabase 00038 { 00039 public: 00045 VectorDatabase(NSString *bundleDir,NSString *cacheDir,NSString *baseName,VectorReader *reader,const std::set<std::string> *indices,bool cache=false,bool autoload=false); 00046 ~VectorDatabase(); 00047 00050 void setAutoload(bool autoload); 00051 00053 void setMemCache(bool memCache); 00054 00056 void process(); 00057 00059 unsigned int numVectors(); 00060 00063 GeoMbr getMbr(unsigned int); 00064 00071 VectorShapeRef getVector(unsigned int,bool withAttributes=true); 00072 00074 void getVectorsWithinMbr(const GeoMbr &mbr,UIntSet &vecIds); 00075 00079 void getMatchingVectors(NSString *query,UIntSet &vecIds); 00081 void getMatchingVectors(NSString *query,ShapeSet &shapes); 00082 00085 void findArealsForPoint(const GeoCoord &coord,ShapeSet &shapes); 00086 00088 sqlite3 *getSqliteDb(); 00089 00090 protected: 00091 bool buildCaches(NSString *mbrCache,NSString *sqlDb); 00092 bool readCaches(NSString *mbrCache,NSString *sqlDb); 00093 00094 VectorReader *reader; 00095 00098 std::vector<GeoMbr> mbrs; 00099 00101 bool vecCacheOn; 00102 std::map<unsigned int,VectorShapeRef> vecCache; 00103 00105 bool autoloadOn; 00106 int autoloadWhere; 00107 00109 sqlite3 *db; 00110 }; 00111 00112 }