1 : /******************************************************************************
2 : * $Id: ogr_elastic.h 25311 2012-12-15 12:48:14Z rouault $
3 : *
4 : * Project: ElasticSearch Translator
5 : * Purpose:
6 : * Author:
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2011, Adam Estrada
10 : *
11 : * Permission is hereby granted, free of charge, to any person obtaining a
12 : * copy of this software and associated documentation files (the "Software"),
13 : * to deal in the Software without restriction, including without limitation
14 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 : * and/or sell copies of the Software, and to permit persons to whom the
16 : * Software is furnished to do so, subject to the following conditions:
17 : *
18 : * The above copyright notice and this permission notice shall be included
19 : * in all copies or substantial portions of the Software.
20 : *
21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 : * DEALINGS IN THE SOFTWARE.
28 : ****************************************************************************/
29 :
30 : #ifndef _OGR_ELASTIC_H_INCLUDED
31 : #define _OGR_ELASTIC_H_INCLUDED
32 :
33 : #include "ogrsf_frmts.h"
34 : #include "ogr_p.h"
35 : #include "cpl_hash_set.h"
36 :
37 : class OGRElasticDataSource;
38 :
39 : /************************************************************************/
40 : /* OGRElasticLayer */
41 : /************************************************************************/
42 :
43 : class OGRElasticLayer : public OGRLayer {
44 : OGRFeatureDefn* poFeatureDefn;
45 : OGRSpatialReference* poSRS;
46 : OGRElasticDataSource* poDS;
47 : CPLString sIndex;
48 : void* pAttributes;
49 : char* pszLayerName;
50 :
51 : public:
52 : OGRElasticLayer(const char *pszFilename,
53 : const char* layerName,
54 : OGRElasticDataSource* poDS,
55 : OGRSpatialReference *poSRSIn,
56 : int bWriteMode = FALSE);
57 : ~OGRElasticLayer();
58 :
59 : void ResetReading();
60 : OGRFeature * GetNextFeature();
61 :
62 : OGRErr CreateFeature(OGRFeature *poFeature);
63 : OGRErr CreateField(OGRFieldDefn *poField, int bApproxOK);
64 :
65 : OGRFeatureDefn * GetLayerDefn();
66 :
67 : int TestCapability(const char *);
68 :
69 : OGRSpatialReference *GetSpatialRef();
70 :
71 : int GetFeatureCount(int bForce);
72 :
73 : void PushIndex();
74 : CPLString BuildMap();
75 : };
76 :
77 : /************************************************************************/
78 : /* OGRElasticDataSource */
79 : /************************************************************************/
80 :
81 : class OGRElasticDataSource : public OGRDataSource {
82 : char* pszName;
83 :
84 : OGRElasticLayer** papoLayers;
85 : int nLayers;
86 :
87 : public:
88 : OGRElasticDataSource();
89 : ~OGRElasticDataSource();
90 :
91 : int Open(const char * pszFilename,
92 : int bUpdate);
93 :
94 : int Create(const char *pszFilename,
95 : char **papszOptions);
96 :
97 7 : const char* GetName() {
98 7 : return pszName;
99 : }
100 :
101 0 : int GetLayerCount() {
102 0 : return nLayers;
103 : }
104 : OGRLayer* GetLayer(int);
105 :
106 : OGRLayer * CreateLayer(const char * pszLayerName,
107 : OGRSpatialReference *poSRS,
108 : OGRwkbGeometryType eType,
109 : char ** papszOptions);
110 :
111 : int TestCapability(const char *);
112 :
113 : void UploadFile(const CPLString &url, const CPLString &data);
114 : void DeleteIndex(const CPLString &url);
115 :
116 : int bOverwrite;
117 : int nBulkUpload;
118 : char* pszWriteMap;
119 : char* pszMapping;
120 : };
121 :
122 : /************************************************************************/
123 : /* OGRElasticDriver */
124 : /************************************************************************/
125 :
126 226 : class OGRElasticDriver : public OGRSFDriver {
127 : public:
128 : ~OGRElasticDriver();
129 :
130 : const char* GetName();
131 : OGRDataSource* Open(const char *, int);
132 : OGRDataSource* CreateDataSource(const char * pszName, char **papszOptions);
133 : int TestCapability(const char *);
134 :
135 : };
136 :
137 :
138 : #endif /* ndef _OGR_Elastic_H_INCLUDED */
|