File: shp_processor.h

package info (click to toggle)
tilemaker 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,488 kB
  • sloc: cpp: 29,461; ansic: 12,510; makefile: 229; ruby: 77; sh: 43
file content (52 lines) | stat: -rw-r--r-- 1,623 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*! \file */ 
#ifndef _SHP_PROCESSOR_H
#define _SHP_PROCESSOR_H

#include <unordered_map>
#include <string>
#include <vector>
#include <map>
#include "geom.h"
#include "output_object.h"
#include "osm_lua_processing.h"
#include "attribute_store.h"

// Shapelib
#include "shapefil.h"

class ShpProcessor {

public:
	ShpProcessor(Box &clippingBox, 
	             uint threadNum,
	             class ShpMemTiles &shpMemTiles,
	             OsmLuaProcessing &osmLuaProcessing) : 
		 clippingBox(clippingBox), threadNum(threadNum),
		 shpMemTiles(shpMemTiles), osmLuaProcessing(osmLuaProcessing)
	{}

	// Read shapefile, and create OutputObjects for all objects within the specified bounding box
	void read(class LayerDef &layer, uint layerNum);

private:	
	Box clippingBox;
	unsigned threadNum;
	ShpMemTiles &shpMemTiles;
	OsmLuaProcessing &osmLuaProcessing;
	std::mutex attributeMutex;

	void fillPointArrayFromShapefile(std::vector<Point> *points, SHPObject *shape, uint part);

	// Read requested attributes from a shapefile, and encode into an OutputObject
	AttributeIndex readShapefileAttributes(DBFHandle &dbf, int recordNum, 
	                                       std::unordered_map<int,std::string> &columnMap,
	                                       std::unordered_map<int,int> &columnTypeMap,
	                                       LayerDef &layer, uint &minzoom);

	// Process an individual shapefile record
	void processShapeGeometry(SHPObject* shape, AttributeIndex attrIdx, 
	                          const LayerDef &layer, uint layerNum, bool hasName, const std::string &name);
};

#endif //_SHP_PROCESSOR_H