forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeatureTypeInfo.cs
More file actions
377 lines (337 loc) · 12.4 KB
/
FeatureTypeInfo.cs
File metadata and controls
377 lines (337 loc) · 12.4 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
// WFS provider by Peter Robineau (peter.robineau@gmx.at)
// This file can be redistributed and/or modified under the terms of the GNU Lesser General Public License.
using System;
using System.Collections.Generic;
using GeoAPI;
using GeoAPI.Geometries;
namespace SharpMap.Utilities.Wfs
{
/// <summary>
/// Web Feature Service geometry types
/// </summary>
public enum GeometryTypeEnum
{
/// <summary>
/// Point
/// </summary>
PointPropertyType,
/// <summary>
/// Linestring
/// </summary>
LineStringPropertyType,
/// <summary>
/// Curve
/// </summary>
CurvePropertyType,
/// <summary>
/// Polygon
/// </summary>
PolygonPropertyType,
/// <summary>
/// Surface
/// </summary>
SurfacePropertyType,
/// <summary>
/// Multipoint
/// </summary>
MultiPointPropertyType,
/// <summary>
/// MultiLinestring
/// </summary>
MultiLineStringPropertyType,
/// <summary>
/// Multicurve
/// </summary>
MultiCurvePropertyType,
/// <summary>
/// MultiPolygon
/// </summary>
MultiPolygonPropertyType,
/// <summary>
/// MultiSurface
/// </summary>
MultiSurfacePropertyType,
/// <summary>
/// Unknown
/// </summary>
Unknown
};
/// <summary>
/// Web Feature Type info class
/// </summary>
public class WfsFeatureTypeInfo
{
#region Fields with Properties
internal IGeometryFactory Factory { get; private set; }
private BoundingBox _BoundingBox = new BoundingBox();
private string _Cs = ",";
private string _DecimalDel = ".";
private string _FeatureTypeNamespace = string.Empty;
private GeometryInfo _Geometry = new GeometryInfo();
private string _Name = string.Empty;
private string _Prefix = string.Empty;
private string _ServiceURI = string.Empty;
private string _SRID;
private string _Ts = " ";
private readonly List<ElementInfo> _elements = new List<ElementInfo>();
/// <summary>
/// Gets the elements associated to the feature.
/// </summary>
public List<ElementInfo> Elements
{
get { return _elements; }
}
/// <summary>
/// Gets or sets the name of the featuretype.
/// This argument is obligatory for data retrieving.
/// </summary>
/// <value>The name.</value>
public string Name
{
get { return _Name; }
set { _Name = value; }
}
/// <summary>
/// Gets or sets the prefix of the featuretype and it's nested elements.
/// This argument is obligatory for data retrieving, if the featuretype is declared with a
/// prefix in 'GetCapabilities'.
/// </summary>
/// <value>The prefix.</value>
public string Prefix
{
get { return _Prefix; }
set { _Prefix = value; }
}
/// <summary>
/// Gets or sets the featuretype namespace.
/// This argument is obligatory for data retrieving, except when using the quick geometries option.
/// </summary>
public string FeatureTypeNamespace
{
get { return _FeatureTypeNamespace; }
set { _FeatureTypeNamespace = value; }
}
/// <summary>
/// Gets the qualified name of the featuretype (with namespace URI).
/// </summary>
internal string QualifiedName
{
get { return _FeatureTypeNamespace + _Name; }
}
/// <summary>
/// Gets or sets the service URI for WFS 'GetFeature' request.
/// This argument is obligatory for data retrieving.
/// </summary>
public string ServiceURI
{
get { return _ServiceURI; }
set { _ServiceURI = value; }
}
/// <summary>
/// Gets or sets information about the geometry of the featuretype.
/// Setting at least the geometry name is obligatory for data retrieving.
/// </summary>
public GeometryInfo Geometry
{
get { return _Geometry; }
set { _Geometry = value; }
}
/// <summary>
/// Gets or sets the spatial extent of the featuretype - defined as minimum bounding rectangle.
/// </summary>
public BoundingBox BBox
{
get { return _BoundingBox; }
set { _BoundingBox = value; }
}
/// <summary>
/// Gets or sets the spatial reference ID
/// </summary>
public string SRID
{
get { return _SRID; }
set
{
if (string.IsNullOrEmpty(value))
value = "4326";
if (string.Compare(_SRID, value, StringComparison.InvariantCultureIgnoreCase) != 0)
{
Factory = GeometryServiceProvider.Instance.CreateGeometryFactory(int.Parse(value));
_SRID = value;
}
}
}
//Coordinates can be included in a single string, but there is no
//facility for validating string content. The value of the 'cs' attribute
//is the separator for coordinate values, and the value of the 'ts'
//attribute gives the tuple separator (a single space by default); the
//default values may be changed to reflect local usage.
/// <summary>
/// Decimal separator (for gml:coordinates)
/// </summary>
public string DecimalDel
{
get { return _DecimalDel; }
set { _DecimalDel = value; }
}
/// <summary>
/// Separator for coordinate values (for gml:coordinates)
/// </summary>
public string Cs
{
get { return _Cs; }
set { _Cs = value; }
}
/// <summary>
/// Tuple separator (for gml:coordinates)
/// </summary>
public string Ts
{
get { return _Ts; }
set { _Ts = value; }
}
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="WfsFeatureTypeInfo"/> class.
/// </summary>
/// <param name="serviceUri">
/// The Web Feature Service URI
/// </param>
/// <param name="nsPrefix">
/// Use an empty string or 'null', if there is no prefix for the featuretype.
/// </param>
/// <param name="featureTypeNamespace">
/// Use an empty string or 'null', if there is no namespace for the featuretype.
/// You don't need to know the namespace of the feature type, if you use the quick geometries option.
/// </param>
/// <param name="featureType">
/// The feature type name
/// </param>
/// <param name="geometryName">
/// The geometry name is the property of the featuretype from which geometry information can be obtained from.
/// Usually this property is called something like 'Shape' or 'geom'. It is absolutely necessary to give this parameter.
/// </param>
/// <param name="geometryType">
/// Specifying the geometry type helps to accelerate the rendering process.
/// </param>
public WfsFeatureTypeInfo(string serviceUri, string nsPrefix, string featureTypeNamespace, string featureType,
string geometryName, GeometryTypeEnum geometryType)
:this()
{
_ServiceURI = serviceUri;
_Prefix = nsPrefix;
_FeatureTypeNamespace = string.IsNullOrEmpty(featureTypeNamespace) ? string.Empty : featureTypeNamespace;
_Name = featureType;
_Geometry._GeometryName = geometryName;
_Geometry._GeometryType = geometryType.ToString();
}
/// <summary>
/// Initializes a new instance of the <see cref="WfsFeatureTypeInfo"/> class.
/// </summary>
/// <param name="serviceUri">
/// The Web Feature Service URI
/// </param>
/// <param name="nsPrefix">
/// Use an empty string or 'null', if there is no prefix for the featuretype.
/// </param>
/// <param name="featureTypeNamespace">
/// Use an empty string or 'null', if there is no namespace for the featuretype.
/// You don't need to know the namespace of the feature type, if you use the quick geometries option.
/// </param>
/// <param name="featureType">
/// The feature type name
/// </param>
/// <param name="geometryName">
/// The geometry name is the property of the featuretype from which geometry information can be obtained from.
/// Usually this property is called something like 'Shape' or 'geom'. It is absolutely necessary to give this parameter.
/// </param>
public WfsFeatureTypeInfo(string serviceUri, string nsPrefix, string featureTypeNamespace, string featureType,
string geometryName)
: this(serviceUri, nsPrefix, featureTypeNamespace, featureType, geometryName, GeometryTypeEnum.Unknown)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="WfsFeatureTypeInfo"/> class.
/// </summary>
public WfsFeatureTypeInfo()
{
SRID = "4326";
}
#endregion
#region Nested Types
#region BoundingBox
/// <summary>
/// The bounding box defines the spatial extent of a featuretype.
/// </summary>
public class BoundingBox
{
/// <summary>
/// Maximum latitude
/// </summary>
public double _MaxLat;
/// <summary>
/// Maximum longitude
/// </summary>
public double _MaxLong;
/// <summary>
/// Minimum latitude
/// </summary>
public double _MinLat;
/// <summary>
/// Minimum longitude
/// </summary>
public double _MinLong;
}
#endregion
#region GeometryInfo
/// <summary>
/// The geometry info comprises the name of the geometry attribute (e.g. 'Shape" or 'geom')
/// and the type of the featuretype's geometry.
/// </summary>
public class GeometryInfo
{
/// <summary>
/// The name of the geometry, may be 'shape' or 'geom'
/// </summary>
public string _GeometryName = string.Empty;
/// <summary>
/// The type of the features's geometry
/// </summary>
public string _GeometryType = string.Empty;
}
#endregion
#region ElementInfo
/// <summary>
/// The element info associated to the feature.
/// </summary>
[Serializable]
public class ElementInfo
{
/// <summary>
/// Creates an instance of this class
/// </summary>
/// <param name="name">The name of the element</param>
/// <param name="dataType">The data type of the element</param>
public ElementInfo(string name, string dataType)
{
if (name == null)
throw new ArgumentNullException("name");
if (dataType == null)
throw new ArgumentNullException("dataType");
Name = name;
DataType = dataType;
}
/// <summary>
/// Gets the name of the element
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Gets the type of the element
/// </summary>
public string DataType { get; private set; }
}
#endregion
#endregion
}
}