ToolMap
Loading...
Searching...
No Matches
tmimport.h
1/***************************************************************************
2 tmimport.h
3 -------------------
4 copyright : (C) 2010 CREALP Lucien Schreiber
5 ***************************************************************************/
6
7/***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef _TMIMPORT_H
17#define _TMIMPORT_H
18
19#include <wx/wxprec.h>
20
21#ifndef WX_PRECOMP
22#include <wx/wx.h>
23#endif
24
25#include <wx/filename.h>
26#include <wx/progdlg.h>
27
28#include "../core/prjdefmemmanage.h"
29#include "../core/projectdefmemory.h"
30#include "tmlayerpropertiesdef.h"
31
32class DataBaseTM;
33
34enum tmImportFileType {
35 tmIMPORT_TYPE_SHP = 0,
36 tmIMPORT_TYPE_CSV
37};
38
39class tmImport {
40 protected:
41 wxFileName m_FileName;
42 tmImportFileType m_FileType;
43 TM_GIS_SPATIAL_TYPES m_GeometryType;
44 long m_FeatureCount;
45 int m_FieldsCount;
46 TOC_GENERIC_NAME m_ImportTarget;
47 wxString m_LayerName;
48 wxString m_FieldKind;
49 wxArrayString m_SkipKinds;
50 wxArrayString m_FileKinds;
51 wxArrayString m_DbKinds;
52 wxArrayString m_FileAttributes;
53 wxArrayString m_DbAttributes;
54 wxArrayInt m_AttributeTypes;
55 wxArrayString m_FileEnumsAttName;
56 wxArrayString m_FileEnums;
57 wxArrayString m_DbEnums;
58
59 bool ShouldSkipObjectKind(const wxArrayString& fileValues);
60
61 bool SetObjectKind(DataBaseTM* database, PrjDefMemManage* prj, const wxArrayString& fileValues,
62 const wxArrayLong& oids);
63
64 bool SetAttributes(DataBaseTM* database, PrjDefMemManage* prj, const wxArrayString& fileValues, wxArrayLong& oids);
65
66 public:
67 tmImport();
68
69 virtual ~tmImport();
70
71 virtual bool Open(const wxFileName& filename);
72
73 virtual bool IsOk();
74
75 virtual bool Import(DataBaseTM* database, PrjDefMemManage* prj, wxProgressDialog* progress = nullptr) {
76 return false;
77 }
78
79 virtual bool GetExistingAttributeValues(const wxString& attName, wxArrayString& values) {
80 return false;
81 }
82
83 inline const wxFileName GetFileName() const;
84
85 inline const tmImportFileType GetFileType() const;
86
87 inline const TM_GIS_SPATIAL_TYPES GetGeometryType() const;
88
89 inline const long GetFeatureCount() const;
90
91 inline const int GetFieldCount() const;
92
93 virtual bool GetFieldNames(wxArrayString& Fields) {
94 return false;
95 }
96
97 inline const TOC_GENERIC_NAME GetTarget() const;
98
99 void SetTarget(TOC_GENERIC_NAME value);
100
101 virtual wxArrayInt GetTargetSupported() {
102 return wxArrayInt();
103 }
104
105 virtual wxArrayString GetTargetSupportedName();
106
107 void SetLayerName(const wxString& value);
108
109 wxString GetLayerName();
110
111 void SetFieldKind(const wxString& value);
112
113 wxString GetFieldKind();
114
115 void SkipObjectKind(const wxString& fileKind);
116
117 void AddObjectKindMatch(const wxString& fileKind, const wxString& dbKind);
118
119 void ClearObjectKindMatches();
120
121 void AddAttributeMatch(const wxString& fileAttribute, const wxString& dbAttribute, PRJDEF_FIELD_TYPE type);
122
123 void ClearAttributeMatches();
124
125 void AddEnumerationMatch(const wxString& attributeName, const wxString& fileEnum, const wxString& dbEnum);
126
127 void ClearEnumerationMatches();
128
129 int GetAttributesMatchesCount() const;
130
131 bool AttributeIsEnum(int index) const;
132
133 wxString GetAttributeNameInDB(int index) const;
134
135 wxString GetAttributeNameInFile(int index) const;
136
137 bool HasEnumAttributes() const;
138};
139
140inline const wxFileName tmImport::GetFileName() const {
141 return m_FileName;
142}
143
144inline const tmImportFileType tmImport::GetFileType() const {
145 return m_FileType;
146}
147
148inline const TM_GIS_SPATIAL_TYPES tmImport::GetGeometryType() const {
149 return m_GeometryType;
150}
151
152inline const long tmImport::GetFeatureCount() const {
153 return m_FeatureCount;
154}
155
156inline const int tmImport::GetFieldCount() const {
157 return m_FieldsCount;
158}
159
160inline const TOC_GENERIC_NAME tmImport::GetTarget() const {
161 return m_ImportTarget;
162}
163
164#endif
Definition database_tm.h:80
Definition prjdefmemmanage.h:54
Definition tmimport.h:39