~zorba-coders/zorba/1189803-geoproj-module

« back to all changes in this revision

Viewing changes to src/org/expath/ns/geo.xq.src/geo_module.cpp

  • Committer: Juan Zacarias
  • Date: 2012-08-07 19:49:24 UTC
  • Revision ID: juan457@gmail.com-20120807194924-w8pmqsrf510fq3yv
Tags: zorba-2.8, zorba-2.9
RemovedĀ geosĀ module

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2006-2008 The FLWOR Foundation.
3
 
 * 
4
 
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 
 * you may not use this file except in compliance with the License.
6
 
 * You may obtain a copy of the License at
7
 
 * 
8
 
 * http://www.apache.org/licenses/LICENSE-2.0
9
 
 * 
10
 
 * Unless required by applicable law or agreed to in writing, software
11
 
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 
 * See the License for the specific language governing permissions and
14
 
 * limitations under the License.
15
 
 */
16
 
 
17
 
#include "geo_module.h"
18
 
#include "geo_functions.h"
19
 
 
20
 
namespace zorba { namespace geomodule {
21
 
 
22
 
  ItemFactory* GeoModule::theFactory = 0;
23
 
 
24
 
#ifdef WIN32
25
 
#  define DLL_EXPORT __declspec(dllexport)
26
 
#else
27
 
#  define DLL_EXPORT __attribute__ ((visibility("default")))
28
 
#endif
29
 
 
30
 
extern "C" DLL_EXPORT zorba::ExternalModule* createModule() {
31
 
  return new zorba::geomodule::GeoModule();
32
 
}
33
 
 
34
 
GeoModule::~GeoModule()
35
 
{
36
 
  for (FuncMap_t::const_iterator lIter = theFunctions.begin();
37
 
       lIter != theFunctions.end(); ++lIter) {
38
 
    delete lIter->second;
39
 
  }
40
 
  theFunctions.clear();
41
 
}
42
 
  
43
 
ExternalFunction*
44
 
GeoModule::getExternalFunction(const String& aLocalname)
45
 
{
46
 
  ExternalFunction*& lFunc = theFunctions[aLocalname];
47
 
  if (!lFunc) {
48
 
    if (1 == 0) {
49
 
 
50
 
    }
51
 
    else if (aLocalname == "dimension") {
52
 
      lFunc = new SFDimensionFunction(this);
53
 
    }
54
 
    else if (aLocalname == "coordinate-dimension") {
55
 
      lFunc = new SFCoordinateDimensionFunction(this);
56
 
    }
57
 
    else if (aLocalname == "geometry-type") {
58
 
      lFunc = new SFGeometryTypeFunction(this);
59
 
    }
60
 
    else if (aLocalname == "srid") {
61
 
      lFunc = new SFSridFunction(this);
62
 
    }
63
 
    else if (aLocalname == "num-geometries") {
64
 
      lFunc = new SFNumGeometriesFunction(this);
65
 
    }
66
 
    else if (aLocalname == "geometry-n") {
67
 
      lFunc = new SFGeometryNFunction(this);
68
 
    }
69
 
    else if (aLocalname == "envelope") {
70
 
      lFunc = new SFEnvelopeFunction(this);
71
 
    }
72
 
    else if (aLocalname == "as-text") {
73
 
      lFunc = new SFAsTextFunction(this);
74
 
    }
75
 
    else if (aLocalname == "as-binary") {
76
 
      lFunc = new SFAsBinaryFunction(this);
77
 
    }
78
 
    else if (aLocalname == "is-empty") {
79
 
      lFunc = new SFIsEmptyFunction(this);
80
 
    }
81
 
    else if (aLocalname == "is-simple") {
82
 
      lFunc = new SFIsSimpleFunction(this);
83
 
    }
84
 
    else if (aLocalname == "is-3d") {
85
 
      lFunc = new SFIs3DFunction(this);
86
 
    }
87
 
    else if (aLocalname == "is-measured") {
88
 
      lFunc = new SFIsMeasuredFunction(this);
89
 
    }
90
 
    else if (aLocalname == "boundary") {
91
 
      lFunc = new SFBoundaryFunction(this);
92
 
    }
93
 
    else if (aLocalname == "equals") {
94
 
      lFunc = new SFEqualsFunction(this);
95
 
    }
96
 
    else if (aLocalname == "covers") {
97
 
      lFunc = new SFCoversFunction(this);
98
 
    }
99
 
    else if (aLocalname == "disjoint") {
100
 
      lFunc = new SFDisjointFunction(this);
101
 
    }
102
 
    else if (aLocalname == "intersects") {
103
 
      lFunc = new SFIntersectsFunction(this);
104
 
    }
105
 
    else if (aLocalname == "touches") {
106
 
      lFunc = new SFTouchesFunction(this);
107
 
    }
108
 
    else if (aLocalname == "crosses") {
109
 
      lFunc = new SFCrossesFunction(this);
110
 
    }
111
 
    else if (aLocalname == "within") {
112
 
      lFunc = new SFWithinFunction(this);
113
 
    }
114
 
    else if (aLocalname == "contains") {
115
 
      lFunc = new SFContainsFunction(this);
116
 
    }
117
 
    else if (aLocalname == "overlaps") {
118
 
      lFunc = new SFOverlapsFunction(this);
119
 
    }
120
 
    else if (aLocalname == "relate") {
121
 
      lFunc = new SFRelateFunction(this);
122
 
    }
123
 
    else if (aLocalname == "distance") {
124
 
      lFunc = new SFDistanceFunction(this);
125
 
    }
126
 
    else if (aLocalname == "buffer") {
127
 
      lFunc = new SFBufferFunction(this);
128
 
    }
129
 
    else if (aLocalname == "convex-hull") {
130
 
      lFunc = new SFConvexHullFunction(this);
131
 
    }
132
 
    else if (aLocalname == "intersection") {
133
 
      lFunc = new SFIntersectionFunction(this);
134
 
    }
135
 
    else if (aLocalname == "union") {
136
 
      lFunc = new SFUnionFunction(this);
137
 
    }
138
 
    else if (aLocalname == "difference") {
139
 
      lFunc = new SFDifferenceFunction(this);
140
 
    }
141
 
    else if (aLocalname == "sym-difference") {
142
 
      lFunc = new SFSymDifferenceFunction(this);
143
 
    }
144
 
    else if (aLocalname == "area") {
145
 
      lFunc = new SFAreaFunction(this);
146
 
    }
147
 
    else if (aLocalname == "length") {
148
 
      lFunc = new SFLengthFunction(this);
149
 
    }
150
 
    else if (aLocalname == "is-within-distance") {
151
 
      lFunc = new SFIsWithinDistanceFunction(this);
152
 
    }
153
 
    else if (aLocalname == "centroid") {
154
 
      lFunc = new SFCentroidFunction(this);
155
 
    }
156
 
    else if (aLocalname == "point-on-surface") {
157
 
      lFunc = new SFPointOnSurfaceFunction(this);
158
 
    }
159
 
    else if (aLocalname == "x") {
160
 
      lFunc = new SFXFunction(this);
161
 
    }
162
 
    else if (aLocalname == "y") {
163
 
      lFunc = new SFYFunction(this);
164
 
    }
165
 
    else if (aLocalname == "z") {
166
 
      lFunc = new SFZFunction(this);
167
 
    }
168
 
    else if (aLocalname == "m") {
169
 
      lFunc = new SFMFunction(this);
170
 
    }
171
 
    else if (aLocalname == "start-point") {
172
 
      lFunc = new SFStartPointFunction(this);
173
 
    }
174
 
    else if (aLocalname == "end-point") {
175
 
      lFunc = new SFEndPointFunction(this);
176
 
    }
177
 
    else if (aLocalname == "is-closed") {
178
 
      lFunc = new SFIsClosedFunction(this);
179
 
    }
180
 
    else if (aLocalname == "is-ring") {
181
 
      lFunc = new SFIsRingFunction(this);
182
 
    }
183
 
    else if (aLocalname == "num-points") {
184
 
      lFunc = new SFNumPointsFunction(this);
185
 
    }
186
 
    else if (aLocalname == "point-n") {
187
 
      lFunc = new SFPointNFunction(this);
188
 
    }
189
 
    else if (aLocalname == "exterior-ring") {
190
 
      lFunc = new SFExteriorRingFunction(this);
191
 
    }
192
 
    else if (aLocalname == "num-interior-ring") {
193
 
      lFunc = new SFNumInteriorRingFunction(this);
194
 
    }
195
 
    else if (aLocalname == "interior-ring-n") {
196
 
      lFunc = new SFInteriorRingNFunction(this);
197
 
    }
198
 
    else if (aLocalname == "num-patches") {
199
 
      lFunc = new SFNumPatchesFunction(this);
200
 
    }
201
 
    else if (aLocalname == "patch-n") {
202
 
      lFunc = new SFPatchNFunction(this);
203
 
    }
204
 
    else if (aLocalname == "bounding-polygons") {
205
 
      lFunc = new SFBoundingPolygonsFunction(this);
206
 
    }
207
 
  }
208
 
  return lFunc;
209
 
}
210
 
 
211
 
void
212
 
GeoModule::destroy()
213
 
{
214
 
  if (!dynamic_cast<GeoModule*>(this)) {
215
 
    return;
216
 
  }
217
 
  delete this;
218
 
}
219
 
 
220
 
} /* namespace GeoModule */ } /* namespace zorba */