ffi-ogr 0.1.0.pre3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13b41cc924b4743e41c0150552df569562607f64
4
- data.tar.gz: e182a8233fc3a02461b9ea28ad71c5f1de7e8d5f
3
+ metadata.gz: 8a3a8d64038c8ee681dc456b3639a3ba21d4fe2b
4
+ data.tar.gz: 5363e299ae53a198be3772c21742b63b6707a534
5
5
  SHA512:
6
- metadata.gz: 5fbd885e368f57a20b2cad4d0c6739c33e573de7ef118895a67fb5be6e09586124829dcb892ec0af4c5da31aa8c7464eafb9cfcbc256f6ba9a8cbb5337a590ee
7
- data.tar.gz: 23f45a8bd769c8a5b5c7c0df527f9316bff65aa679c02665f4f5f8c89c3b3afe6dc390d13aad91bc0a090a7dee787c1f88f13c1fce524203813ebc50a0e2792e
6
+ metadata.gz: d91119cd6f24f8a516fa8b47728328a8b8d8310c48ab277669c713a23346e36cc96ff0e31a242039f78f85520acff23d2d32ac8584a0607114678ffd6b5d49a2
7
+ data.tar.gz: fe146c60301d9555e9b004968d5d176f050d4cfe7384a722253794c720d51cd8cb3d5711a2ac9becd238a3afffce4484510eb8f8d224fc2d6963563b7d59ac65
data/README.md CHANGED
@@ -4,8 +4,9 @@
4
4
  GDAL must be installed:
5
5
 
6
6
  Mac:
7
+ NOTE: Add other flags, e.g. --with-postgresql, as desired
7
8
  ```
8
- brew install gdal
9
+ brew install gdal --complete --enable-unsupported --with-libkml
9
10
  ```
10
11
 
11
12
  Ubuntu:
@@ -59,8 +60,8 @@ shp.to_json
59
60
  shp.to_json true
60
61
  # => Output GeoJSON string (pretty print)
61
62
 
62
- # from_epsg(integer), from_proj4(string), from_wkt(string)
63
- new_sr = OGR::SpatialReference.from_epsg 3857
63
+ # epsg => import_sr(integer) or import_sr(integer, 'epsg'), proj4 => import_sr(string, 'proj4'), wkt => import_sr(string, 'wkt'), esri => import_sr(string, 'esri')
64
+ new_sr = OGR.import_sr 3857
64
65
  # => #<OGR::SpatialReference:0x007fd859a0e6f8 @ptr=#<FFI::AutoPointer address=0x007fd85a11c100>>
65
66
 
66
67
  shp.to_shp '~/Desktop/reprojected_shp.shp', {spatial_ref: new_sr}
@@ -78,8 +79,8 @@ shp = writer.ptr
78
79
  # currently does not handle spatial reference, will automatically be nil
79
80
  layer = shp.add_layer 'first_layer', :point
80
81
 
81
- # add field to layer : add_field(name, field_type, width) NOTE: width defaults to 32
82
- layer.add_field 'name', :string
82
+ # add field to layer : add_field(name, field_type, options) NOTE: options are width and precision, defaulting to 32 and 1 respectively.
83
+ layer.add_field 'name', :string, width: 255
83
84
 
84
85
  # create feature on layer
85
86
  feature = layer.create_feature
@@ -10,7 +10,8 @@ module OGR
10
10
  'geojson' => 'GeoJSON',
11
11
  'json' => 'GeoJSON',
12
12
  'csv' => 'CSV',
13
- 'kml' => 'KML'
13
+ 'kml' => 'LIBKML',
14
+ 'kml_lite' => 'KML'
14
15
  }
15
16
 
16
17
  autoload :Reader, File.join(OGR_BASE, 'reader')
@@ -76,8 +77,6 @@ module OGR
76
77
 
77
78
  extend ::FFI::Library
78
79
 
79
- ffi_lib(gdal_library_path)
80
-
81
80
  enum :ogr_field_type, [
82
81
  :integer, 0,
83
82
  :integer_list, 1,
@@ -119,197 +118,211 @@ module OGR
119
118
  :right, 2
120
119
  ]
121
120
 
122
- attach_function :GDALVersionInfo, [:string], :string
121
+ OGR_FUNCTIONS = {
122
+ GDALVersionInfo: [[:string], :string],
123
+ CPLSetConfigOption: [[:string, :string], :void],
124
+ CPLSetThreadLocalConfigOption: [[:string, :string], :void],
125
+
126
+ OGRRegisterAll: [[], :void],
127
+ OGR_Dr_GetName: [[:pointer], :string],
128
+ OGR_Dr_Open: [[:pointer, :string, :int], :pointer],
129
+ OGR_Dr_TestCapability: [[:pointer, :string], :int],
130
+ OGR_Dr_CreateDataSource: [[:pointer, :string, :pointer], :pointer],
131
+ OGR_Dr_CopyDataSource: [[:pointer, :pointer, :string, :pointer], :pointer],
132
+ OGR_Dr_DeleteDataSource: [[:pointer, :string], :pointer],
133
+ OGRGetDriverCount: [[], :int],
134
+ OGRGetDriver: [[:int], :pointer],
135
+ OGRGetDriverByName: [[:string], :pointer],
136
+ OGROpen: [[:string, :int, :pointer], :pointer],
137
+ OGR_DS_Destroy: [[:pointer], :void],
138
+ OGR_DS_GetName: [[:pointer], :string],
139
+ OGR_DS_GetLayerCount: [[:pointer], :int],
140
+ OGR_DS_GetLayer: [[:pointer, :int], :pointer],
141
+ OGR_DS_GetLayerByName: [[:pointer, :string], :pointer],
142
+ OGR_DS_DeleteLayer: [[:pointer, :int], :pointer],
143
+ OGR_DS_GetDriver: [[:pointer], :pointer],
144
+ OGR_DS_CreateLayer: [[:pointer, :string, :pointer, :ogr_geometry_type, :pointer], :pointer],
145
+ OGR_DS_CopyLayer: [[:pointer, :pointer, :string, :string], :pointer],
146
+ OGR_DS_TestCapability: [[:pointer, :string], :int],
147
+ OGR_DS_ExecuteSQL: [[:pointer, :string, :pointer, :string], :pointer],
148
+ OGR_DS_ReleaseResultSet: [[:pointer, :pointer], :void],
149
+ OGR_DS_SyncToDisk: [[:pointer], :pointer],
150
+ OGR_L_GetGeomType: [[:pointer], :ogr_geometry_type],
151
+ OGR_L_GetName: [[:pointer], :string],
152
+ OGR_L_GetSpatialFilter: [[:pointer], :pointer],
153
+ OGR_L_SetSpatialFilter: [[:pointer, :pointer], :void],
154
+ OGR_L_SetSpatialFilterRect: [[:pointer, :double, :double, :double, :double], :void],
155
+ OGR_L_SetAttributeFilter: [[:pointer, :string], :pointer],
156
+ OGR_L_ResetReading: [[:pointer], :void],
157
+ OGR_L_GetNextFeature: [[:pointer], :pointer],
158
+ OGR_L_SetNextByIndex: [[:pointer, :long], :pointer],
159
+ OGR_L_GetFeature: [[:pointer, :long], :pointer],
160
+ OGR_L_SetFeature: [[:pointer, :pointer], :pointer],
161
+ OGR_L_CreateFeature: [[:pointer, :pointer], :pointer],
162
+ OGR_L_DeleteFeature: [[:pointer, :long], :pointer],
163
+ OGR_L_GetLayerDefn: [[:pointer], :pointer],
164
+ OGR_L_GetSpatialRef: [[:pointer], :pointer],
165
+ OGR_L_GetFeatureCount: [[:pointer, :int], :int],
166
+ OGR_L_GetExtent: [[:pointer, :pointer, :int], :pointer],
167
+ OGR_L_CreateField: [[:pointer, :pointer, :int], :pointer],
168
+ OGR_L_SyncToDisk: [[:pointer], :pointer],
169
+ OGR_FD_GetFieldCount: [[:pointer], :int],
170
+ OGR_FD_GetFieldDefn: [[:pointer, :int], :pointer],
171
+ OGR_Fld_Create: [[:string, :ogr_field_type], :pointer],
172
+ OGR_Fld_Destroy: [[:pointer], :void],
173
+ OGR_Fld_SetName: [[:pointer, :string], :void],
174
+ OGR_Fld_GetNameRef: [[:pointer], :string],
175
+ OGR_Fld_GetType: [[:pointer], :ogr_field_type],
176
+ OGR_Fld_SetType: [[:pointer, :ogr_field_type], :void],
177
+ OGR_Fld_GetJustify: [[:pointer], :ogr_justification],
178
+ OGR_Fld_SetJustify: [[:pointer, :ogr_justification], :void],
179
+ OGR_Fld_GetWidth: [[:pointer], :int],
180
+ OGR_Fld_SetWidth: [[:pointer, :int], :void],
181
+ OGR_Fld_GetPrecision: [[:pointer], :int],
182
+ OGR_Fld_SetPrecision: [[:pointer, :int], :void],
183
+ OGR_Fld_Set: [[:pointer, :string, :ogr_field_type, :int, :int, :ogr_justification], :void],
184
+ OGR_Fld_IsIgnored: [[:pointer], :int],
185
+ OGR_Fld_SetIgnored: [[:pointer, :int], :void],
186
+ OGR_F_Create: [[:pointer], :pointer],
187
+ OGR_F_GetFieldAsInteger: [[:pointer, :int], :int],
188
+ OGR_F_GetFieldAsDouble: [[:pointer, :int], :double],
189
+ OGR_F_GetFieldAsString: [[:pointer, :int], :string],
190
+ OGR_F_GetFieldAsIntegerList: [[:pointer, :int, :pointer], :pointer],
191
+ OGR_F_GetFieldAsDoubleList: [[:pointer, :int, :pointer], :pointer],
192
+ OGR_F_GetFieldAsStringList: [[:pointer, :int], :pointer],
193
+ OGR_F_GetFieldAsBinary: [[:pointer, :int, :pointer], :pointer],
194
+ OGR_F_GetFieldAsDateTime: [[:pointer, :int, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer], :pointer],
195
+ OGR_F_SetFieldInteger: [[:pointer, :int, :int], :void],
196
+ OGR_F_SetFieldDouble: [[:pointer, :int, :double], :void],
197
+ OGR_F_SetFieldString: [[:pointer, :int, :string], :void],
198
+ OGR_F_SetFieldIntegerList: [[:pointer, :int, :int, :pointer], :void],
199
+ OGR_F_SetFieldDoubleList: [[:pointer, :int, :int, :pointer], :void],
200
+ OGR_F_SetFieldStringList: [[:pointer, :int, :int, :pointer], :void],
201
+ OGR_F_SetFieldRaw: [[:pointer, :int, :pointer], :void],
202
+ OGR_F_SetFieldBinary: [[:pointer, :int, :int, :pointer], :void],
203
+ OGR_F_SetFieldDateTime: [[:pointer, :int, :int, :int, :int, :int, :int, :int, :int], :void],
204
+ OGR_F_GetDefnRef: [[:pointer], :pointer],
205
+ OGR_F_GetFieldCount: [[:pointer], :int],
206
+ OGR_F_GetFieldDefnRef: [[:pointer, :int], :pointer],
207
+ OGR_F_GetFieldIndex: [[:pointer, :string], :int],
208
+ OGR_F_IsFieldSet: [[:pointer, :int], :int],
209
+ OGR_F_GetGeometryRef: [[:pointer], :pointer],
210
+ OGR_F_GetFID: [[:pointer], :long],
211
+ OGR_F_SetFID: [[:pointer, :long], :pointer],
212
+ OGR_F_StealGeometry: [[:pointer], :pointer],
213
+ OGR_F_SetGeometry: [[:pointer, :pointer], :pointer],
214
+ OGR_F_SetGeometryDirectly: [[:pointer, :pointer], :pointer],
215
+ OGR_G_CreateFromWkb: [[:pointer, :pointer, :pointer, :int], :pointer],
216
+ OGR_G_CreateFromWkt: [[:pointer, :pointer, :pointer], :pointer],
217
+ OGR_G_DestroyGeometry: [[:pointer], :void],
218
+ OGR_G_CreateGeometry: [[:ogr_geometry_type], :pointer],
219
+ OGR_G_ApproximateArcAngles: [[:double, :double, :double, :double, :double, :double, :double, :double, :double], :pointer],
220
+ OGR_G_ForceToPolygon: [[:pointer], :pointer],
221
+ #OGR_G_ForceToLineString: [[:pointer], :pointer],
222
+ OGR_G_ForceToMultiPolygon: [[:pointer], :pointer],
223
+ OGR_G_ForceToMultiPoint: [[:pointer], :pointer],
224
+ OGR_G_ForceToMultiLineString: [[:pointer], :pointer],
225
+ OGR_G_GetDimension: [[:pointer], :int],
226
+ OGR_G_GetCoordinateDimension: [[:pointer], :int],
227
+ OGR_G_SetCoordinateDimension: [[:pointer, :int], :void],
228
+ OGR_G_Clone: [[:pointer], :pointer],
229
+ OGR_G_GetEnvelope: [[:pointer, :pointer], :void],
230
+ OGR_G_GetEnvelope3D: [[:pointer, :pointer], :void],
231
+ OGR_G_ImportFromWkb: [[:pointer, :pointer, :int], :pointer],
232
+ OGR_G_ExportToWkb: [[:pointer, :pointer, :pointer], :pointer],
233
+ OGR_G_WkbSize: [[:pointer], :int],
234
+ OGR_G_ImportFromWkt: [[:pointer, :string], :pointer],
235
+ OGR_G_ExportToWkt: [[:pointer, :pointer], :pointer],
236
+ OGR_G_GetGeometryType: [[:pointer], :ogr_geometry_type],
237
+ OGR_G_GetGeometryName: [[:pointer], :string],
238
+ OGR_G_DumpReadable: [[:pointer, :pointer, :string], :void],
239
+ OGR_G_FlattenTo2D: [[:pointer], :void],
240
+ OGR_G_CloseRings: [[:pointer], :void],
241
+ OGR_G_CreateFromGML: [[:string], :pointer],
242
+ OGR_G_ExportToGML: [[:pointer], :string],
243
+ #OGR_G_ExportToGMLEx: [[:pointer, :pointer], :string],
244
+ OGR_G_ExportToKML: [[:pointer, :string], :string],
245
+ OGR_G_ExportToJson: [[:pointer], :string],
246
+ OGR_G_ExportToJsonEx: [[:pointer, :string], :string],
247
+ OGR_G_AssignSpatialReference: [[:pointer, :pointer], :void],
248
+ OGR_G_GetSpatialReference: [[:pointer], :pointer],
249
+ OGR_G_Transform: [[:pointer, :pointer], :pointer],
250
+ OGR_G_TransformTo: [[:pointer, :pointer], :pointer],
251
+ OGR_G_Simplify: [[:pointer, :double], :pointer],
252
+ OGR_G_SimplifyPreserveTopology: [[:pointer, :double], :pointer],
253
+ OGR_G_Segmentize: [[:pointer, :double], :pointer],
254
+ OGR_G_Intersects: [[:pointer, :pointer], :int],
255
+ OGR_G_Equals: [[:pointer, :pointer], :int],
256
+ OGR_G_Disjoint: [[:pointer, :pointer], :int],
257
+ OGR_G_Touches: [[:pointer, :pointer], :int],
258
+ OGR_G_Crosses: [[:pointer, :pointer], :int],
259
+ OGR_G_Within: [[:pointer, :pointer], :int],
260
+ OGR_G_Contains: [[:pointer, :pointer], :int],
261
+ OGR_G_Overlaps: [[:pointer, :pointer], :int],
262
+ OGR_G_Boundary: [[:pointer], :pointer],
263
+ OGR_G_ConvexHull: [[:pointer], :pointer],
264
+ OGR_G_Buffer: [[:pointer, :double, :int], :pointer],
265
+ OGR_G_Intersection: [[:pointer, :pointer], :pointer],
266
+ OGR_G_Union: [[:pointer, :pointer], :pointer],
267
+ OGR_G_UnionCascaded: [[:pointer], :pointer],
268
+ #OGR_G_PointOnSurface: [[:pointer], :pointer],
269
+ OGR_G_Difference: [[:pointer, :pointer], :pointer],
270
+ OGR_G_SymDifference: [[:pointer, :pointer], :pointer],
271
+ OGR_G_Distance: [[:pointer, :pointer], :double],
272
+ OGR_G_Length: [[:pointer], :double],
273
+ OGR_G_Area: [[:pointer], :double],
274
+ OGR_G_Centroid: [[:pointer, :pointer], :int],
275
+ OGR_G_Empty: [[:pointer], :void],
276
+ OGR_G_IsEmpty: [[:pointer], :int],
277
+ OGR_G_IsValid: [[:pointer], :int],
278
+ OGR_G_IsSimple: [[:pointer], :int],
279
+ OGR_G_IsRing: [[:pointer], :int],
280
+ OGR_G_Polygonize: [[:pointer], :pointer],
281
+ OGR_G_GetPointCount: [[:pointer], :int],
282
+ OGR_G_GetPoints: [[:pointer, :pointer, :int, :pointer, :int, :pointer, :int], :int],
283
+ OGR_G_GetX: [[:pointer, :int], :double],
284
+ OGR_G_GetY: [[:pointer, :int], :double],
285
+ OGR_G_GetZ: [[:pointer, :int], :double],
286
+ OGR_G_GetPoint: [[:pointer, :int, :pointer, :pointer, :pointer], :void],
287
+ OGR_G_SetPoint: [[:pointer, :int, :double, :double, :double], :void],
288
+ OGR_G_SetPoint_2D: [[:pointer, :int, :double, :double], :void],
289
+ OGR_G_AddPoint: [[:pointer, :double, :double, :double], :void],
290
+ OGR_G_AddPoint_2D: [[:pointer, :double, :double], :void],
291
+ OGR_G_GetGeometryCount: [[:pointer], :int],
292
+ OGR_G_GetGeometryRef: [[:pointer, :int], :pointer],
293
+ OGR_G_AddGeometry: [[:pointer, :pointer], :pointer],
294
+ OGR_G_AddGeometryDirectly: [[:pointer, :pointer], :pointer],
295
+ OGR_G_RemoveGeometry: [[:pointer, :int, :int], :pointer],
296
+ OGR_F_Destroy: [[:pointer], :void],
123
297
 
124
- attach_function :CPLSetConfigOption, [:string, :string], :void
125
- attach_function :CPLSetThreadLocalConfigOption, [:string, :string], :void
298
+ #SRS Functions
126
299
 
127
- attach_function :OGRRegisterAll, [], :void
128
- attach_function :OGR_Dr_GetName, [:pointer], :string
129
- attach_function :OGR_Dr_Open, [:pointer, :string, :int], :pointer
130
- attach_function :OGR_Dr_TestCapability, [:pointer, :string], :int
131
- attach_function :OGR_Dr_CreateDataSource, [:pointer, :string, :pointer], :pointer
132
- attach_function :OGR_Dr_CopyDataSource, [:pointer, :pointer, :string, :pointer], :pointer
133
- attach_function :OGR_Dr_DeleteDataSource, [:pointer, :string], :pointer
134
- attach_function :OGRGetDriverCount, [], :int
135
- attach_function :OGRGetDriver, [:int], :pointer
136
- attach_function :OGRGetDriverByName, [:string], :pointer
137
- attach_function :OGROpen, [:string, :int, :pointer], :pointer
138
- attach_function :OGR_DS_Destroy, [:pointer], :void
139
- attach_function :OGR_DS_GetName, [:pointer], :string
140
- attach_function :OGR_DS_GetLayerCount, [:pointer], :int
141
- attach_function :OGR_DS_GetLayer, [:pointer, :int], :pointer
142
- attach_function :OGR_DS_GetLayerByName, [:pointer, :string], :pointer
143
- attach_function :OGR_DS_DeleteLayer, [:pointer, :int], :pointer
144
- attach_function :OGR_DS_GetDriver, [:pointer], :pointer
145
- attach_function :OGR_DS_CreateLayer, [:pointer, :string, :pointer, :ogr_geometry_type, :pointer], :pointer
146
- attach_function :OGR_DS_CopyLayer, [:pointer, :pointer, :string, :string], :pointer
147
- attach_function :OGR_DS_TestCapability, [:pointer, :string], :int
148
- attach_function :OGR_DS_ExecuteSQL, [:pointer, :string, :pointer, :string], :pointer
149
- attach_function :OGR_DS_ReleaseResultSet, [:pointer, :pointer], :void
150
- attach_function :OGR_DS_SyncToDisk, [:pointer], :pointer
151
- attach_function :OGR_L_GetGeomType, [:pointer], :ogr_geometry_type
152
- attach_function :OGR_L_GetName, [:pointer], :string
153
- attach_function :OGR_L_GetSpatialFilter, [:pointer], :pointer
154
- attach_function :OGR_L_SetSpatialFilter, [:pointer, :pointer], :void
155
- attach_function :OGR_L_SetSpatialFilterRect, [:pointer, :double, :double, :double, :double], :void
156
- attach_function :OGR_L_SetAttributeFilter, [:pointer, :string], :pointer
157
- attach_function :OGR_L_ResetReading, [:pointer], :void
158
- attach_function :OGR_L_GetNextFeature, [:pointer], :pointer
159
- attach_function :OGR_L_SetNextByIndex, [:pointer, :long], :pointer
160
- attach_function :OGR_L_GetFeature, [:pointer, :long], :pointer
161
- attach_function :OGR_L_SetFeature, [:pointer, :pointer], :pointer
162
- attach_function :OGR_L_CreateFeature, [:pointer, :pointer], :pointer
163
- attach_function :OGR_L_DeleteFeature, [:pointer, :long], :pointer
164
- attach_function :OGR_L_GetLayerDefn, [:pointer], :pointer
165
- attach_function :OGR_L_GetSpatialRef, [:pointer], :pointer
166
- attach_function :OGR_L_GetFeatureCount, [:pointer, :int], :int
167
- attach_function :OGR_L_GetExtent, [:pointer, :pointer, :int], :pointer
168
- attach_function :OGR_L_CreateField, [:pointer, :pointer, :int], :pointer
169
- attach_function :OGR_L_SyncToDisk, [:pointer], :pointer
170
- attach_function :OGR_FD_GetFieldCount, [:pointer], :int
171
- attach_function :OGR_FD_GetFieldDefn, [:pointer, :int], :pointer
172
- attach_function :OGR_Fld_Create, [:string, :ogr_field_type], :pointer
173
- attach_function :OGR_Fld_Destroy, [:pointer], :void
174
- attach_function :OGR_Fld_SetName, [:pointer, :string], :void
175
- attach_function :OGR_Fld_GetNameRef, [:pointer], :string
176
- attach_function :OGR_Fld_GetType, [:pointer], :ogr_field_type
177
- attach_function :OGR_Fld_SetType, [:pointer, :ogr_field_type], :void
178
- attach_function :OGR_Fld_GetJustify, [:pointer], :ogr_justification
179
- attach_function :OGR_Fld_SetJustify, [:pointer, :ogr_justification], :void
180
- attach_function :OGR_Fld_GetWidth, [:pointer], :int
181
- attach_function :OGR_Fld_SetWidth, [:pointer, :int], :void
182
- attach_function :OGR_Fld_GetPrecision, [:pointer], :int
183
- attach_function :OGR_Fld_SetPrecision, [:pointer, :int], :void
184
- attach_function :OGR_Fld_Set, [:pointer, :string, :ogr_field_type, :int, :int, :ogr_justification], :void
185
- attach_function :OGR_Fld_IsIgnored, [:pointer], :int
186
- attach_function :OGR_Fld_SetIgnored, [:pointer, :int], :void
187
- attach_function :OGR_F_Create, [:pointer], :pointer
188
- attach_function :OGR_F_GetFieldAsInteger, [:pointer, :int], :int
189
- attach_function :OGR_F_GetFieldAsDouble, [:pointer, :int], :double
190
- attach_function :OGR_F_GetFieldAsString, [:pointer, :int], :string
191
- attach_function :OGR_F_GetFieldAsIntegerList, [:pointer, :int, :pointer], :pointer
192
- attach_function :OGR_F_GetFieldAsDoubleList, [:pointer, :int, :pointer], :pointer
193
- attach_function :OGR_F_GetFieldAsStringList, [:pointer, :int], :pointer
194
- attach_function :OGR_F_GetFieldAsBinary, [:pointer, :int, :pointer], :pointer
195
- attach_function :OGR_F_GetFieldAsDateTime, [:pointer, :int, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer], :pointer
196
- attach_function :OGR_F_SetFieldInteger, [:pointer, :int, :int], :void
197
- attach_function :OGR_F_SetFieldDouble, [:pointer, :int, :double], :void
198
- attach_function :OGR_F_SetFieldString, [:pointer, :int, :string], :void
199
- attach_function :OGR_F_SetFieldIntegerList, [:pointer, :int, :int, :pointer], :void
200
- attach_function :OGR_F_SetFieldDoubleList, [:pointer, :int, :int, :pointer], :void
201
- attach_function :OGR_F_SetFieldStringList, [:pointer, :int, :int, :pointer], :void
202
- attach_function :OGR_F_SetFieldRaw, [:pointer, :int, :pointer], :void
203
- attach_function :OGR_F_SetFieldBinary, [:pointer, :int, :int, :pointer], :void
204
- attach_function :OGR_F_SetFieldDateTime, [:pointer, :int, :int, :int, :int, :int, :int, :int, :int], :void
205
- attach_function :OGR_F_GetDefnRef, [:pointer], :pointer
206
- attach_function :OGR_F_GetFieldCount, [:pointer], :int
207
- attach_function :OGR_F_GetFieldDefnRef, [:pointer, :int], :pointer
208
- attach_function :OGR_F_GetFieldIndex, [:pointer, :string], :int
209
- attach_function :OGR_F_IsFieldSet, [:pointer, :int], :int
210
- attach_function :OGR_F_GetGeometryRef, [:pointer], :pointer
211
- attach_function :OGR_F_GetFID, [:pointer], :long
212
- attach_function :OGR_F_SetFID, [:pointer, :long], :pointer
213
- attach_function :OGR_F_StealGeometry, [:pointer], :pointer
214
- attach_function :OGR_F_SetGeometry, [:pointer, :pointer], :pointer
215
- attach_function :OGR_F_SetGeometryDirectly, [:pointer, :pointer], :pointer
216
- attach_function :OGR_G_CreateFromWkb, [:pointer, :pointer, :pointer, :int], :pointer
217
- attach_function :OGR_G_CreateFromWkt, [:pointer, :pointer, :pointer], :pointer
218
- attach_function :OGR_G_DestroyGeometry, [:pointer], :void
219
- attach_function :OGR_G_CreateGeometry, [:ogr_geometry_type], :pointer
220
- attach_function :OGR_G_ApproximateArcAngles, [:double, :double, :double, :double, :double, :double, :double, :double, :double], :pointer
221
- attach_function :OGR_G_ForceToPolygon, [:pointer], :pointer
222
- #attach_function :OGR_G_ForceToLineString, [:pointer], :pointer
223
- attach_function :OGR_G_ForceToMultiPolygon, [:pointer], :pointer
224
- attach_function :OGR_G_ForceToMultiPoint, [:pointer], :pointer
225
- attach_function :OGR_G_ForceToMultiLineString, [:pointer], :pointer
226
- attach_function :OGR_G_GetDimension, [:pointer], :int
227
- attach_function :OGR_G_GetCoordinateDimension, [:pointer], :int
228
- attach_function :OGR_G_SetCoordinateDimension, [:pointer, :int], :void
229
- attach_function :OGR_G_Clone, [:pointer], :pointer
230
- attach_function :OGR_G_GetEnvelope, [:pointer, :pointer], :void
231
- attach_function :OGR_G_GetEnvelope3D, [:pointer, :pointer], :void
232
- attach_function :OGR_G_ImportFromWkb, [:pointer, :pointer, :int], :pointer
233
- attach_function :OGR_G_ExportToWkb, [:pointer, :pointer, :pointer], :pointer
234
- attach_function :OGR_G_WkbSize, [:pointer], :int
235
- attach_function :OGR_G_ImportFromWkt, [:pointer, :string], :pointer
236
- attach_function :OGR_G_ExportToWkt, [:pointer, :pointer], :pointer
237
- attach_function :OGR_G_GetGeometryType, [:pointer], :ogr_geometry_type
238
- attach_function :OGR_G_GetGeometryName, [:pointer], :string
239
- attach_function :OGR_G_DumpReadable, [:pointer, :pointer, :string], :void
240
- attach_function :OGR_G_FlattenTo2D, [:pointer], :void
241
- attach_function :OGR_G_CloseRings, [:pointer], :void
242
- attach_function :OGR_G_CreateFromGML, [:string], :pointer
243
- attach_function :OGR_G_ExportToGML, [:pointer], :string
244
- #attach_function :OGR_G_ExportToGMLEx, [:pointer, :pointer], :string
245
- attach_function :OGR_G_ExportToKML, [:pointer, :string], :string
246
- attach_function :OGR_G_ExportToJson, [:pointer], :string
247
- attach_function :OGR_G_ExportToJsonEx, [:pointer, :string], :string
248
- attach_function :OGR_G_AssignSpatialReference, [:pointer, :pointer], :void
249
- attach_function :OGR_G_GetSpatialReference, [:pointer], :pointer
250
- attach_function :OGR_G_Transform, [:pointer, :pointer], :pointer
251
- attach_function :OGR_G_TransformTo, [:pointer, :pointer], :pointer
252
- attach_function :OGR_G_Simplify, [:pointer, :double], :pointer
253
- attach_function :OGR_G_SimplifyPreserveTopology, [:pointer, :double], :pointer
254
- attach_function :OGR_G_Segmentize, [:pointer, :double], :pointer
255
- attach_function :OGR_G_Intersects, [:pointer, :pointer], :int
256
- attach_function :OGR_G_Equals, [:pointer, :pointer], :int
257
- attach_function :OGR_G_Disjoint, [:pointer, :pointer], :int
258
- attach_function :OGR_G_Touches, [:pointer, :pointer], :int
259
- attach_function :OGR_G_Crosses, [:pointer, :pointer], :int
260
- attach_function :OGR_G_Within, [:pointer, :pointer], :int
261
- attach_function :OGR_G_Contains, [:pointer, :pointer], :int
262
- attach_function :OGR_G_Overlaps, [:pointer, :pointer], :int
263
- attach_function :OGR_G_Boundary, [:pointer], :pointer
264
- attach_function :OGR_G_ConvexHull, [:pointer], :pointer
265
- attach_function :OGR_G_Buffer, [:pointer, :double, :int], :pointer
266
- attach_function :OGR_G_Intersection, [:pointer, :pointer], :pointer
267
- attach_function :OGR_G_Union, [:pointer, :pointer], :pointer
268
- attach_function :OGR_G_UnionCascaded, [:pointer], :pointer
269
- #attach_function :OGR_G_PointOnSurface, [:pointer], :pointer
270
- attach_function :OGR_G_Difference, [:pointer, :pointer], :pointer
271
- attach_function :OGR_G_SymDifference, [:pointer, :pointer], :pointer
272
- attach_function :OGR_G_Distance, [:pointer, :pointer], :double
273
- attach_function :OGR_G_Length, [:pointer], :double
274
- attach_function :OGR_G_Area, [:pointer], :double
275
- attach_function :OGR_G_Centroid, [:pointer, :pointer], :int
276
- attach_function :OGR_G_Empty, [:pointer], :void
277
- attach_function :OGR_G_IsEmpty, [:pointer], :int
278
- attach_function :OGR_G_IsValid, [:pointer], :int
279
- attach_function :OGR_G_IsSimple, [:pointer], :int
280
- attach_function :OGR_G_IsRing, [:pointer], :int
281
- attach_function :OGR_G_Polygonize, [:pointer], :pointer
282
- attach_function :OGR_G_GetPointCount, [:pointer], :int
283
- attach_function :OGR_G_GetPoints, [:pointer, :pointer, :int, :pointer, :int, :pointer, :int], :int
284
- attach_function :OGR_G_GetX, [:pointer, :int], :double
285
- attach_function :OGR_G_GetY, [:pointer, :int], :double
286
- attach_function :OGR_G_GetZ, [:pointer, :int], :double
287
- attach_function :OGR_G_GetPoint, [:pointer, :int, :pointer, :pointer, :pointer], :void
288
- attach_function :OGR_G_SetPoint, [:pointer, :int, :double, :double, :double], :void
289
- attach_function :OGR_G_SetPoint_2D, [:pointer, :int, :double, :double], :void
290
- attach_function :OGR_G_AddPoint, [:pointer, :double, :double, :double], :void
291
- attach_function :OGR_G_AddPoint_2D, [:pointer, :double, :double], :void
292
- attach_function :OGR_G_GetGeometryCount, [:pointer], :int
293
- attach_function :OGR_G_GetGeometryRef, [:pointer, :int], :pointer
294
- attach_function :OGR_G_AddGeometry, [:pointer, :pointer], :pointer
295
- attach_function :OGR_G_AddGeometryDirectly, [:pointer, :pointer], :pointer
296
- attach_function :OGR_G_RemoveGeometry, [:pointer, :int, :int], :pointer
297
- attach_function :OGR_F_Destroy, [:pointer], :void
300
+ OSRNewSpatialReference: [[:pointer], :pointer],
301
+ OSRImportFromWkt: [[:pointer, :pointer], :pointer],
302
+ OSRImportFromProj4: [[:pointer, :string], :pointer],
303
+ OSRImportFromEPSG: [[:pointer, :int], :pointer],
304
+ OSRImportFromESRI: [[:pointer, :pointer], :pointer],
305
+ OSRExportToWkt: [[:pointer, :pointer], :pointer],
306
+ OSRExportToPrettyWkt: [[:pointer, :pointer, :int], :pointer],
307
+ OSRExportToProj4: [[:pointer, :pointer], :pointer],
308
+ OSRDestroySpatialReference: [[:pointer], :void],
309
+ OCTNewCoordinateTransformation: [[:pointer, :pointer], :pointer],
310
+ OCTDestroyCoordinateTransformation: [[:pointer], :void]
311
+ }
298
312
 
299
- # SRS Functions
313
+ begin
314
+ ffi_lib gdal_library_path
300
315
 
301
- attach_function :OSRNewSpatialReference, [:pointer], :pointer
302
- attach_function :OSRImportFromWkt, [:pointer, :pointer], :pointer
303
- attach_function :OSRImportFromProj4, [:pointer, :string], :pointer
304
- attach_function :OSRImportFromEPSG, [:pointer, :int], :pointer
305
- attach_function :OSRExportToWkt, [:pointer, :pointer], :pointer
306
- attach_function :OSRExportToPrettyWkt, [:pointer, :pointer, :int], :pointer
307
- attach_function :OSRExportToProj4, [:pointer, :pointer], :pointer
308
- attach_function :OSRDestroySpatialReference, [:pointer], :void
309
- attach_function :OCTNewCoordinateTransformation, [:pointer, :pointer], :pointer
310
- attach_function :OCTDestroyCoordinateTransformation, [:pointer], :void
316
+ OGR_FUNCTIONS.each do |func, params|
317
+ attach_function func, params.first, params.last
318
+ end
311
319
 
312
- OGRRegisterAll() # register all available OGR drivers
320
+ # register all available OGR drivers
321
+ # also verifies library is loaded
322
+ OGRRegisterAll()
323
+ rescue LoadError, NoMethodError
324
+ raise LoadError.new('Could not load GDAL library')
325
+ end
313
326
  end
314
327
 
315
328
  class << self
@@ -318,14 +331,11 @@ module OGR
318
331
  end
319
332
 
320
333
  def get_available_drivers
321
- drivers = []
322
- count = FFIOGR.OGRGetDriverCount
323
-
324
- for i in 0...count
325
- drivers << FFIOGR.OGR_Dr_GetName(FFIOGR.OGRGetDriver(i))
334
+ [].tap do |drivers|
335
+ for i in 0...FFIOGR.OGRGetDriverCount
336
+ drivers << FFIOGR.OGR_Dr_GetName(FFIOGR.OGRGetDriver(i))
337
+ end
326
338
  end
327
-
328
- drivers
329
339
  end
330
340
  alias_method :drivers, :get_available_drivers
331
341
 
@@ -341,10 +351,7 @@ module OGR
341
351
 
342
352
  def get_writer(source)
343
353
  extension = source.split('.').last
344
- driver = DRIVER_TYPES[extension]
345
-
346
- raise RuntimeError.new "Could not find appropriate driver" if driver.nil?
347
-
354
+ driver = get_driver_by_extension extension
348
355
  Writer.new(driver)
349
356
  end
350
357
 
@@ -356,19 +363,33 @@ module OGR
356
363
  writer
357
364
  end
358
365
 
366
+ def get_driver_by_extension(extension)
367
+ driver = unless extension == 'kml'
368
+ DRIVER_TYPES[extension]
369
+ else
370
+ drivers.include?('LIBKML') ? 'LIBKML' : 'KML'
371
+ end
372
+
373
+ raise RuntimeError.new "Could not find appropriate driver" if driver.nil?
374
+
375
+ driver
376
+ end
377
+
359
378
  def read(source)
360
379
  case source
361
380
  when /http:|https:/
362
381
  HttpReader.new.read source
363
382
  else
364
- extension = source.split('.').last
365
- driver = DRIVER_TYPES[extension]
366
-
383
+ driver = get_driver_by_extension source.split('.').last
367
384
  raise RuntimeError.new "Could not determine file type" if driver.nil?
368
-
369
385
  Reader.new(driver).read source
370
386
  end
371
387
  end
388
+
389
+ def import_spatial_ref(sr_import, format = 'epsg')
390
+ OGR::SpatialReference.import(sr_import, format)
391
+ end
392
+ alias_method :import_sr, :import_spatial_ref
372
393
  end
373
394
  end
374
395
 
@@ -15,14 +15,14 @@ module OGR
15
15
  FFIOGR.OGR_DS_Destroy(@ptr)
16
16
  end
17
17
 
18
- def copy(output_type, output_path, driver_options=nil)
19
- driver = OGRGetDriverByName(OGR::DRIVER_TYPES[output_type.downcase])
18
+ def copy(driver_name, output_path, driver_options=nil)
19
+ driver = OGRGetDriverByName driver_name
20
20
  new_ds = FFIOGR.OGR_Dr_CopyDataSource(driver, @ptr, File.expand_path(output_path), driver_options)
21
21
  FFIOGR.OGR_DS_Destroy(new_ds)
22
22
  end
23
23
 
24
- def copy_with_transform(output_type, output_path, spatial_ref=nil, driver_options=nil)
25
- writer = OGR::GenericWriter.new(OGR::DRIVER_TYPES[output_type.downcase])
24
+ def copy_with_transform(driver_name, output_path, spatial_ref=nil, driver_options=nil)
25
+ writer = OGR::Writer.new driver_name
26
26
  writer.set_output(output_path)
27
27
  out = writer.ptr
28
28
 
@@ -47,12 +47,16 @@ module OGR
47
47
  name = FFIOGR.OGR_Fld_GetNameRef(fd)
48
48
  type = FFIOGR.OGR_Fld_GetType(fd)
49
49
 
50
- opts = {}
51
-
52
- opts[:precision] = FFIOGR.OGR_Fld_GetPrecision(fd) if type == :real
53
- opts[:width] = FFIOGR.OGR_Fld_GetWidth(fd) if type == :string
50
+ opts = {}.tap do |o|
51
+ case type
52
+ when :real
53
+ o[:precision] = FFIOGR.OGR_Fld_GetPrecision fd
54
+ when :string
55
+ o[:width] = FFIOGR.OGR_Fld_GetWidth fd
56
+ end
57
+ end
54
58
 
55
- new_layer.add_field name, type
59
+ new_layer.add_field name, type, opts
56
60
  end
57
61
 
58
62
  layer.features.each do |feature|
@@ -129,75 +133,85 @@ module OGR
129
133
  end
130
134
  alias_method :fields, :get_fields
131
135
 
132
- def to_format(format, output_path, spatial_ref=nil)
136
+ def to_format(format, output_path, options={})
133
137
  raise RuntimeError.new("Output path not specified.") if output_path.nil?
134
138
 
135
- # TODO: handle parsing of spatial_ref -> copy options
139
+ spatial_ref = options.delete :spatial_ref
140
+
141
+ driver_options = parse_driver_options options
142
+
143
+ driver_name = OGR::DRIVER_TYPES[format]
136
144
 
137
145
  unless spatial_ref
138
- copy format, output_path, spatial_ref
146
+ copy driver_name, output_path, driver_options
139
147
  else
140
- if spatial_ref[:spatial_ref].instance_of? OGR::SpatialReference
141
- copy_with_transform format, output_path, spatial_ref[:spatial_ref]
148
+ if spatial_ref.instance_of? OGR::SpatialReference
149
+ copy_with_transform driver_name, output_path, spatial_ref, driver_options
142
150
  else
143
151
  raise RuntimeError.new("Invalid spatial reference specified.")
144
152
  end
145
153
  end
146
154
  end
147
155
 
148
- def to_shp(output_path, spatial_ref=nil)
149
- to_format('shapefile', output_path, spatial_ref)
156
+ def to_shp(output_path, options={})
157
+ to_format('shapefile', output_path)
150
158
  end
151
159
 
152
- def to_csv(output_path, spatial_ref=nil)
153
- to_format('csv', output_path, spatial_ref)
160
+ def to_csv(output_path, options={})
161
+ to_format('csv', output_path)
154
162
  end
155
163
 
156
- def to_kml(output_path, spatial_ref=nil)
157
- warn "KML output will always be in EPSG:4326" unless spatial_ref.nil?
158
- to_format('kml', output_path, spatial_ref)
164
+ def to_kml(output_path, options={})
165
+ format = OGR.drivers.include?('LIBKML') ? 'kml' : 'kml_lite'
166
+
167
+ warn "GDAL is compiled without LIBKML support. Without LIBKML support KML output will always be in EPSG:4326" if format == 'kml_lite'
168
+
169
+ to_format(format, output_path, options)
159
170
  end
160
171
 
161
- def to_geojson(output_path, options=nil)
162
- raise RuntimeError.new("Output path not specified.") if output_path.nil?
172
+ def to_geojson(output_path, options={})
173
+ to_format('geojson', output_path, options)
174
+ end
163
175
 
164
- unless options.nil?
165
- spatial_ref = options[:spatial_ref] ? options[:spatial_ref] : nil
176
+ def parse_driver_options(options)
177
+ tf_values = {
178
+ true => "YES",
179
+ false => "NO"
180
+ }
166
181
 
167
- if options[:bbox]
168
- # this segfaults -- working on solution
169
- bbox = FFI::MemoryPointer.from_string "WRITE_BBOX=YES"
170
- driver_options = FFI::MemoryPointer.new :pointer, 1
171
- driver_options[0].put_pointer 0, bbox
172
- else
173
- driver_options = nil
182
+ pointers = [].tap do |ptrs|
183
+ options.each do |k,v|
184
+ tf_value = tf_values[v] || v
185
+ ptrs << FFI::MemoryPointer.from_string("#{k.to_s.upcase}=#{tf_value.upcase}")
174
186
  end
187
+ end
175
188
 
176
- if spatial_ref
177
- copy_with_transform('geojson', output_path, spatial_ref, driver_options)
178
- else
179
- copy('geojson', output_path, driver_options)
180
- end
181
- else
182
- copy('geojson', output_path, nil)
189
+ pointers << nil
190
+
191
+ driver_options = FFI::MemoryPointer.new :pointer, pointers.size
192
+
193
+ pointers.each_with_index do |ptr, i|
194
+ driver_options[i].put_pointer 0, ptr
183
195
  end
196
+
197
+ driver_options
184
198
  end
185
199
 
186
200
  def to_json(pretty=false)
187
201
  h = {
188
202
  type: 'FeatureCollection',
189
- bbox: nil,
190
203
  features: []
191
204
  }
192
205
 
193
206
  layers.each do |layer|
194
- h[:bbox] = layer.envelope.to_a true
195
- geometry_type = layer.geometry_type.to_s.capitalize
196
-
197
- layer.features.each do |feature|
198
- properties = feature.fields
199
- geometry = OGR::Tools.cast_geometry(feature.geometry).to_geojson
200
- h[:features] << {type: geometry_type, geometry: geometry, properties: properties}
207
+ h[:features].tap do |features|
208
+ layer.features.each do |feature|
209
+ features << {
210
+ type: 'Feature',
211
+ geometry: OGR::Tools.cast_geometry(feature.geometry).to_geojson,
212
+ properties: feature.fields
213
+ }
214
+ end
201
215
  end
202
216
  end
203
217
 
@@ -209,3 +223,4 @@ module OGR
209
223
  end
210
224
  end
211
225
  end
226
+
@@ -4,6 +4,14 @@ require 'faraday'
4
4
 
5
5
  module OGR
6
6
  class HttpReader
7
+
8
+ TF_MAP = {
9
+ true => 1,
10
+ false => 0,
11
+ 1 => true,
12
+ 0 => false
13
+ }
14
+
7
15
  def read(url, writeable=false)
8
16
  file_extension = url.split('.').last
9
17
  driver = OGR::DRIVER_TYPES[file_extension]
@@ -18,19 +26,10 @@ module OGR
18
26
  end
19
27
  end
20
28
 
21
- file_name = "#{SecureRandom.urlsafe_base64}.#{file_extension}"
22
-
23
- http_resource = Faraday.get(url).body
24
-
25
- File.open(file_name, 'wb') do |f|
26
- f.write http_resource
27
- end
28
-
29
- ds = Reader.new(driver).read(file_name, writeable)
30
-
31
- FileUtils.rm file_name
32
-
33
- ds
29
+ http_data = Faraday.get(url).body
30
+ ogr_driver = OGR::FFIOGR::OGRGetDriverByName driver
31
+ data_source = OGR::FFIOGR::OGR_Dr_Open ogr_driver, http_data, TF_MAP[writeable]
32
+ OGR::Tools.cast_data_source data_source
34
33
  end
35
34
  end
36
35
  end
@@ -13,41 +13,62 @@ module OGR
13
13
  FFIOGR.OSRDestroySpatialReference(@ptr)
14
14
  end
15
15
 
16
- def self.create
17
- OGR::Tools.cast_spatial_reference(FFIOGR.OSRNewSpatialReference(nil))
16
+ def check_int(sr_import, format = 'epsg')
17
+ begin
18
+ Integer(sr_import)
19
+ rescue => ex
20
+ raise RuntimeError.new "Format: #{format} requires an integer value"
21
+ end
18
22
  end
19
23
 
20
- def self.from_wkt(wkt)
21
- sr = OGR::Tools.cast_spatial_reference(FFIOGR.OSRNewSpatialReference(nil))
22
- sr.import_wkt(wkt)
23
- sr
24
+ def check_string(sr_import, format)
25
+ raise RuntimeError.new "Format: #{format} requires a string value" unless sr_import.instance_of? String
24
26
  end
25
27
 
26
- def self.from_proj4(proj4)
28
+ def self.import(sr_import, format = 'epsg')
27
29
  sr = OGR::Tools.cast_spatial_reference(FFIOGR.OSRNewSpatialReference(nil))
28
- sr.import_proj4(proj4)
29
- sr
30
- end
31
30
 
32
- def self.from_epsg(epsg_code)
33
- sr = OGR::Tools.cast_spatial_reference(FFIOGR.OSRNewSpatialReference(nil))
34
- sr.import_epsg(epsg_code)
31
+ case format
32
+ when 'epsg'
33
+ sr.import_epsg sr_import
34
+ when 'wkt'
35
+ sr.import_wkt sr_import
36
+ when 'proj4'
37
+ sr.import_proj4 sr_import
38
+ when 'esri'
39
+ sr.import_esri sr_import
40
+ else
41
+ raise RuntimeError.new "Format: #{format} is not currently supported"
42
+ end
43
+
35
44
  sr
36
45
  end
37
46
 
38
47
  def import_wkt(wkt)
48
+ check_string wkt, 'wkt'
39
49
  wkt_ptr = FFI::MemoryPointer.from_string wkt
40
50
  wkt_ptr_ptr = FFI::MemoryPointer.new :pointer
41
51
  wkt_ptr_ptr.put_pointer 0, wkt_ptr
42
- FFIOGR.OSRImportFromWkt(@ptr, wkt_ptr_ptr)
52
+ FFIOGR.OSRImportFromWkt @ptr, wkt_ptr_ptr
43
53
  end
44
54
 
45
- def import_proj4(proj4)
46
- FFIOGR.OSRImportFromProj4(@ptr, proj4)
55
+ def import_proj4(proj4_string)
56
+ check_string proj4_string, 'proj4'
57
+ FFIOGR.OSRImportFromProj4 @ptr, proj4_string
47
58
  end
48
59
 
49
60
  def import_epsg(epsg_code)
50
- FFIOGR.OSRImportFromEPSG(@ptr, epsg_code)
61
+ epsg_code = check_int epsg_code, 'epsg'
62
+ FFIOGR.OSRImportFromEPSG @ptr, epsg_code
63
+ end
64
+
65
+ def import_esri(esri_string)
66
+ check_string esri_string, 'esri'
67
+ esri_ptr = FFI::MemoryPointer.from_string esri_string
68
+ esri_ptr_ptr = FFI::MemoryPointer.new :pointer, 2
69
+ esri_ptr_ptr[0].put_pointer 0, esri_ptr
70
+ esri_ptr_ptr[1].put_pointer 0, nil
71
+ FFIOGR.OSRImportFromESRI @ptr, esri_ptr_ptr
51
72
  end
52
73
 
53
74
  def to_wkt(pretty=false)
@@ -79,3 +100,4 @@ module OGR
79
100
  end
80
101
  end
81
102
  end
103
+
@@ -1,3 +1,3 @@
1
1
  module OGR
2
- VERSION = '0.1.0.pre3'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-ogr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scooter Wadsworth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-08 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.7.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.7.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.8.7
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.8.7
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: FFI wrapper for OGR
@@ -104,6 +104,7 @@ extra_rdoc_files: []
104
104
  files:
105
105
  - README.md
106
106
  - bin/ogr_console
107
+ - lib/ffi-ogr.rb
107
108
  - lib/ffi-ogr/coordinate_transformation.rb
108
109
  - lib/ffi-ogr/csv.rb
109
110
  - lib/ffi-ogr/data_source.rb
@@ -136,7 +137,6 @@ files:
136
137
  - lib/ffi-ogr/tools.rb
137
138
  - lib/ffi-ogr/version.rb
138
139
  - lib/ffi-ogr/writer.rb
139
- - lib/ffi-ogr.rb
140
140
  homepage: https://github.com/scooterw/ffi-ogr
141
141
  licenses:
142
142
  - MIT
@@ -147,17 +147,17 @@ require_paths:
147
147
  - lib
148
148
  required_ruby_version: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: 1.9.2
153
153
  required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
- - - '>='
155
+ - - ">="
156
156
  - !ruby/object:Gem::Version
157
157
  version: 1.3.6
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.0.3
160
+ rubygems_version: 2.2.2
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: Convenient access to OGR functionality from Ruby