-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSHPInterface.h
More file actions
89 lines (68 loc) · 2.19 KB
/
Copy pathSHPInterface.h
File metadata and controls
89 lines (68 loc) · 2.19 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* \file
* \author Karsten Rink
* \date 2010-01-25
* \brief Implementation of the SHPInterface class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
* @file SHPInterface.h
* @date 25/01/2010
* @author Karsten Rink
*/
#ifndef SHPINTERFACE_H
#define SHPINTERFACE_H
#include <string>
#include <vector>
//ShapeLib includes
#include "shape/shapefil.h"
namespace GeoLib {
class GEOObjects;
class Polyline;
}
namespace MeshLib {
class Mesh;
}
namespace FileIO
{
/**
* \brief Manages the import of ESRI shape files into GeoLib.
*/
class SHPInterface
{
public:
/// Connection between ESRI type system for shape files and OGS GeoLib.
enum class OGSType
{
UNDEFINED = 0,
POINT = 1,
STATION = 2,
POLYLINE = 3,
POLYGON = 4
};
/// Constructor
SHPInterface(GeoLib::GEOObjects* geoObjects) : _geoObjects(geoObjects) {}
/// Reads the header of the shape file.
bool readSHPInfo(const std::string &filename, int &shapeType, int &numberOfEntities);
/// Reads data from the shape file.
void readSHPFile(const std::string &filename, OGSType choice, const std::string &listName);
/// Writes a 2D mesh into a shapefile using one polygon for every element
/// (based on request by AS, open for discussion)
static bool write2dMeshToSHP(const std::string &file_name, const MeshLib::Mesh &mesh);
private:
/// Reads points into a vector of Point objects.
void readPoints (const SHPHandle &hSHP, int numberOfElements, std::string listName);
/// Reads points into a vector of Point objects and marks them as Station.
void readStations (const SHPHandle &hSHP, int numberOfElements, std::string listName);
/// Reads lines into a vector of Polyline objects.
void readPolylines (const SHPHandle &hSHP, int numberOfElements, std::string listName);
/// Reads lines into a vector of Polyline and Surface objects.
void readPolygons (const SHPHandle &hSHP, int numberOfElements, const std::string& listName);
GeoLib::GEOObjects* _geoObjects;
};
}
#endif //SHPINTERFACE_H