@@ -64,15 +64,26 @@ void addToTileIndexPolyline(OutputObject &oo, map< uint, vector<OutputObject> >
6464}
6565
6666// Read requested attributes from a shapefile, and encode into an OutputObject
67- void addShapefileAttributes (DBFHandle &dbf, OutputObject &oo, int recordNum, unordered_map<int ,string> &columnMap, unordered_map<int ,int > &columnTypeMap) {
67+ void addShapefileAttributes (
68+ DBFHandle &dbf,
69+ OutputObject &oo,
70+ int recordNum, unordered_map<int ,string> &columnMap, unordered_map<int ,int > &columnTypeMap,
71+ OSMObject &osmObject) {
72+
6873 for (auto it : columnMap) {
6974 int pos = it.first ;
7075 string key = it.second ;
7176 vector_tile::Tile_Value v;
7277 switch (columnTypeMap[pos]) {
73- case 1 : v.set_int_value (DBFReadIntegerAttribute (dbf, recordNum, pos)); break ;
74- case 2 : v.set_double_value (DBFReadDoubleAttribute (dbf, recordNum, pos)); break ;
75- default : v.set_string_value (DBFReadStringAttribute (dbf, recordNum, pos)); break ;
78+ case 1 : v.set_int_value (DBFReadIntegerAttribute (dbf, recordNum, pos));
79+ osmObject.setVectorLayerMetadata (oo.layer , key, 1 );
80+ break ;
81+ case 2 : v.set_double_value (DBFReadDoubleAttribute (dbf, recordNum, pos));
82+ osmObject.setVectorLayerMetadata (oo.layer , key, 1 );
83+ break ;
84+ default : v.set_string_value (DBFReadStringAttribute (dbf, recordNum, pos));
85+ osmObject.setVectorLayerMetadata (oo.layer , key, 3 );
86+ break ;
7687 }
7788 oo.addAttribute (key, v);
7889 }
@@ -84,9 +95,11 @@ void readShapefile(string filename,
8495 vector<string> &columns,
8596 Box &clippingBox,
8697 map< uint, vector<OutputObject> > &tileIndex,
87- vector<Geometry> &cachedGeometries, map< uint, string > &cachedGeometryNames,
98+ vector<Geometry> &cachedGeometries,
99+ OSMObject &osmObject,
88100 uint baseZoom, uint layerNum, string &layerName,
89- bool isIndexed, map<string,RTree> &indices, string &indexName) {
101+ bool isIndexed,
102+ string &indexName) {
90103
91104 // open shapefile
92105 SHPHandle shp = SHPOpen (filename.c_str (), " rb" );
@@ -124,12 +137,12 @@ void readShapefile(string filename,
124137 uint tiley = latp2tiley (p.y (), baseZoom);
125138 cachedGeometries.push_back (p);
126139 OutputObject oo (CACHED_POINT, layerNum, cachedGeometries.size ()-1 );
127- addShapefileAttributes (dbf,oo,i,columnMap,columnTypeMap);
140+ addShapefileAttributes (dbf,oo,i,columnMap,columnTypeMap,osmObject );
128141 tileIndex[tilex*65536 +tiley].push_back (oo);
129142 if (isIndexed) {
130143 uint id = cachedGeometries.size ()-1 ;
131- geom::envelope (p, box); indices[ layerName] .insert (std::make_pair (box, id));
132- if (indexField>-1 ) { cachedGeometryNames[id] =DBFReadStringAttribute (dbf, i, indexField); }
144+ geom::envelope (p, box); osmObject. indices -> at ( layerName) .insert (std::make_pair (box, id));
145+ if (indexField>-1 ) { osmObject. cachedGeometryNames -> operator [](id) =DBFReadStringAttribute (dbf, i, indexField); }
133146 }
134147 }
135148
@@ -146,12 +159,12 @@ void readShapefile(string filename,
146159 for (MultiLinestring::const_iterator it = out.begin (); it != out.end (); ++it) {
147160 cachedGeometries.push_back (*it);
148161 OutputObject oo (CACHED_LINESTRING, layerNum, cachedGeometries.size ()-1 );
149- addShapefileAttributes (dbf,oo,i,columnMap,columnTypeMap);
162+ addShapefileAttributes (dbf,oo,i,columnMap,columnTypeMap,osmObject );
150163 addToTileIndexPolyline (oo, tileIndex, baseZoom, *it);
151164 if (isIndexed) {
152165 uint id = cachedGeometries.size ()-1 ;
153- geom::envelope (*it, box); indices[ layerName] .insert (std::make_pair (box, id));
154- if (indexField>-1 ) { cachedGeometryNames[id] =DBFReadStringAttribute (dbf, i, indexField); }
166+ geom::envelope (*it, box); osmObject. indices -> at ( layerName) .insert (std::make_pair (box, id));
167+ if (indexField>-1 ) { osmObject. cachedGeometryNames -> operator [](id) =DBFReadStringAttribute (dbf, i, indexField); }
155168 }
156169 }
157170 }
@@ -212,15 +225,15 @@ void readShapefile(string filename,
212225 // create OutputObject
213226 cachedGeometries.push_back (out);
214227 OutputObject oo (CACHED_POLYGON, layerNum, cachedGeometries.size ()-1 );
215- addShapefileAttributes (dbf,oo,i,columnMap,columnTypeMap);
228+ addShapefileAttributes (dbf,oo,i,columnMap,columnTypeMap,osmObject );
216229 // add to tile index
217230 geom::model::box<Point> box;
218231 geom::envelope (out, box);
219232 addToTileIndexByBbox (oo, tileIndex, baseZoom, box.min_corner ().get <0 >(), box.min_corner ().get <1 >(), box.max_corner ().get <0 >(), box.max_corner ().get <1 >());
220233 if (isIndexed) {
221234 uint id = cachedGeometries.size ()-1 ;
222- indices[ layerName] .insert (std::make_pair (box, id));
223- if (indexField>-1 ) { cachedGeometryNames[id] =DBFReadStringAttribute (dbf, i, indexField); }
235+ osmObject. indices -> at ( layerName) .insert (std::make_pair (box, id));
236+ if (indexField>-1 ) { osmObject. cachedGeometryNames -> operator [](id) =DBFReadStringAttribute (dbf, i, indexField); }
224237 }
225238 }
226239
0 commit comments