-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GeoJSON as alternative to shapefiles (#630)
- Loading branch information
Showing
12 changed files
with
423 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/*! \file */ | ||
#ifndef _GEOJSON_PROCESSOR_H | ||
#define _GEOJSON_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" | ||
|
||
class GeoJSONProcessor { | ||
|
||
public: | ||
GeoJSONProcessor(Box &clippingBox, | ||
uint threadNum, | ||
class ShpMemTiles &shpMemTiles, | ||
OsmLuaProcessing &osmLuaProcessing) : | ||
clippingBox(clippingBox), threadNum(threadNum), | ||
shpMemTiles(shpMemTiles), osmLuaProcessing(osmLuaProcessing) | ||
{} | ||
|
||
void read(class LayerDef &layer, uint layerNum); | ||
|
||
private: | ||
Box clippingBox; | ||
unsigned threadNum; | ||
ShpMemTiles &shpMemTiles; | ||
OsmLuaProcessing &osmLuaProcessing; | ||
std::mutex attributeMutex; | ||
|
||
template <bool Flag, typename T> | ||
void processFeature(rapidjson::GenericObject<Flag, T> feature, class LayerDef &layer, uint layerNum); | ||
|
||
template <bool Flag, typename T> | ||
Polygon polygonFromGeoJSONArray(const rapidjson::GenericArray<Flag, T> &coords); | ||
|
||
template <bool Flag, typename T> | ||
std::vector<Point> pointsFromGeoJSONArray(const rapidjson::GenericArray<Flag, T> &arr); | ||
|
||
AttributeIndex readProperties(const rapidjson::Value &pr, bool &hasName, std::string &name, LayerDef &layer, unsigned &minzoom); | ||
}; | ||
|
||
#endif //_GEOJSON_PROCESSOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
|
Oops, something went wrong.