@@ -13,6 +13,73 @@ use std::{convert::TryInto, ffi::CString, marker::PhantomData};
13
13
14
14
use crate :: errors:: * ;
15
15
16
+ /// Layer capabilities
17
+ pub enum LayerCaps {
18
+ /// Layer capability for random read
19
+ OLCRandomRead ,
20
+ /// Layer capability for sequential write
21
+ OLCSequentialWrite ,
22
+ /// Layer capability for random write
23
+ OLCRandomWrite ,
24
+ /// Layer capability for fast spatial filter
25
+ OLCFastSpatialFilter ,
26
+ /// Layer capability for fast feature count retrieval
27
+ OLCFastFeatureCount ,
28
+ /// Layer capability for fast extent retrieval
29
+ OLCFastGetExtent ,
30
+ /// Layer capability for field creation
31
+ OLCCreateField ,
32
+ /// Layer capability for field deletion
33
+ OLCDeleteField ,
34
+ /// Layer capability for field reordering
35
+ OLCReorderFields ,
36
+ /// Layer capability for field alteration
37
+ OLCAlterFieldDefn ,
38
+ /// Layer capability for transactions
39
+ OLCTransactions ,
40
+ /// Layer capability for feature deletiond
41
+ OLCDeleteFeature ,
42
+ /// Layer capability for setting next feature index
43
+ OLCFastSetNextByIndex ,
44
+ /// Layer capability for strings returned with UTF-8 encoding
45
+ OLCStringsAsUTF8 ,
46
+ /// Layer capability for field ignoring
47
+ OLCIgnoreFields ,
48
+ /// Layer capability for geometry field creation
49
+ OLCCreateGeomField ,
50
+ /// Layer capability for curve geometries support
51
+ OLCCurveGeometries ,
52
+ /// Layer capability for measured geometries support
53
+ OLCMeasuredGeometries ,
54
+ }
55
+
56
+ // Manage conversion to Gdal values
57
+ impl LayerCaps {
58
+ fn into_cstring ( self ) -> CString {
59
+ CString :: new ( match self {
60
+ Self :: OLCRandomRead => "RandomRead" ,
61
+ Self :: OLCSequentialWrite => "SequentialWrite" ,
62
+ Self :: OLCRandomWrite => "RandomWrite" ,
63
+ Self :: OLCFastSpatialFilter => "FastSpatialFilter" ,
64
+ Self :: OLCFastFeatureCount => "FastFeatureCount" ,
65
+ Self :: OLCFastGetExtent => "FastGetExtent" ,
66
+ Self :: OLCCreateField => "CreateField" ,
67
+ Self :: OLCDeleteField => "DeleteField" ,
68
+ Self :: OLCReorderFields => "ReorderFields" ,
69
+ Self :: OLCAlterFieldDefn => "AlterFieldDefn" ,
70
+ Self :: OLCTransactions => "Transactions" ,
71
+ Self :: OLCDeleteFeature => "DeleteFeature" ,
72
+ Self :: OLCFastSetNextByIndex => "FastSetNextByIndex" ,
73
+ Self :: OLCStringsAsUTF8 => "StringsAsUTF8" ,
74
+ Self :: OLCIgnoreFields => "IgnoreFields" ,
75
+ Self :: OLCCreateGeomField => "CreateGeomField" ,
76
+ Self :: OLCCurveGeometries => "CurveGeometries" ,
77
+ Self :: OLCMeasuredGeometries => "MeasuredGeometries" ,
78
+ } )
79
+ . unwrap ( )
80
+ }
81
+ }
82
+
16
83
/// Layer in a vector dataset
17
84
///
18
85
/// ```
@@ -101,6 +168,12 @@ impl<'a> Layer<'a> {
101
168
_string ( rv)
102
169
}
103
170
171
+ pub fn has_capability ( & self , capability : LayerCaps ) -> bool {
172
+ unsafe {
173
+ gdal_sys:: OGR_L_TestCapability ( self . c_layer , capability. into_cstring ( ) . as_ptr ( ) ) == 1
174
+ }
175
+ }
176
+
104
177
pub fn defn ( & self ) -> & Defn {
105
178
& self . defn
106
179
}
0 commit comments