IExportShape.hpp
1 #ifndef DM_IO_EXPORT_SHAPE_HPP_INCLUDED
2 #define DM_IO_EXPORT_SHAPE_HPP_INCLUDED
3 
4 #ifdef _MSC_VER
5  #pragma once
6 #endif
7 
8 //DM
9 #include "DM/config.hpp"
10 #include "DM/AutoLink.hpp" //enable autolink
11 
12 #include "DM/ColumnTypes.hpp"
13 #include "DM/IAddInfoLayout.hpp"
14 #include "DM/IO/IExport.hpp"
15 #include "DM/IO/IShapeTableDefinition.hpp"
16 
17 DM_NAMESPACE_BEGIN
18 
19 namespace ShapeGeometry {
20  enum Type {
21  none = 0,
22 
23  point2d = 1,
24  polyline2d = 3,
25  polygon2d = 5,
26  pointSet2d = 8,
27 
28  point = 11,
29  polyline = 13,
30  polygon = 15,
31  pointSet = 18
32 
33  //SHPT_POINTM 21
34  //SHPT_ARCM 23
35  //SHPT_POLYGONM 25
36  //SHPT_MULTIPOINTM 28
37  //SHPT_MULTIPATCH 31
38  };
39 }
40 
41 /// Specific import class for handling shape file imports
42 class DM_API IExportShape : public virtual IExport
43 {
44 public:
45  static IExportShape* New( const char *file, FilterHandle filter = FilterHandle(), ControlObjectHandle control = ControlObjectHandle(),
46  const AddInfoLayoutHandle &layout = AddInfoLayoutHandle(),
48  int idCountIdx = -1,
49  int semanticColIdx = -1,
50  unsigned mapSize = 0, std::pair<int, const char*> *translationMap = 0);
51 
52 protected:
53  virtual ~IExportShape() {}
54 
55 public:
56  /// \brief set shape geometry type (optional)
57  /** The shape format only one geometry type. Setting the corresponding type is not necessary, since it is automatically determined
58  based on the first geometry that is exported. Please note that point data are usually exported as pointsets using a default chunk
59  size of 1000 points. To force each point written as a separate object, set type ShapeGeometry::point (or ShapeGeometry::point2d).
60  This allows exporting attributes (within the dbf file) for each point.
61  NOTE: this function must be called before the first object is exported
62  */
63  virtual void setShapeGeometryType(ShapeGeometry::Type type) = 0;
64 
65  /// \brief setting this flag prevents the export of throwing an exception if geometries that do not match the shape geometry type are tried to export
66  virtual void setSkipUnmatchTypesFlag(bool skipUnmatchTypes) = 0;
67 
68  /// \brief set a mapping between dbf attributes and an add info layout for importing the attribute information as well
69  /** This is optional import definition must be set before the first element (and file header) is read. If nothing is set no
70  dbf attributes will be imported.
71  \param[in] layout layout that should be attached to each geometry object
72  \param[in] dbfTable size of the idxMap, which has to be a corresponding C array
73  \param[in] idCounterIdx output a counter id at the given column index
74  */
75  virtual void setAttributeMapping(AddInfoLayoutHandle layout, ShapeTableDefinitionHandle dbfTable, int idCounterIdx = -1) = 0;
76 
77  /// \brief set a translation map between the scop sematic and dbf attribute value
78  /** This is optional import definition must be set before the first element (and file header) is read.
79  \param[in] columnIdx index of the dbf attribute to be used
80  \param[in] mapSize size of the idxMap, which has to be a corresponding C array
81  \param[in] translationMap C array mapping string values (first value of std::pair) to the scop semantic (second value of std::pair)
82  */
83  virtual void setSemanticTranslation(unsigned columnIdx, unsigned mapSize, std::pair<int, const char*> *translationMap ) = 0;
84 
85 };
86 
88 
89 DM_NAMESPACE_END
90 
91 #endif //DM_IO_EXPORT_SHAPE_HPP_INCLUDED