An object returned from ShpFile#transaction. Buffers updates to a Shapefile
add a ShpRecord at the end
# File lib/geo_ruby/shp4r/shp.rb, line 363 def add(record) record_type = to_shp_type(record.geometry) raise IncompatibleGeometryException.new("Incompatible type") unless record_type==@shp.shp_type @added << record end
updates the physical files
# File lib/geo_ruby/shp4r/shp.rb, line 370 def commit @shp.close @shp_r = open(@shp.file_root + ".shp", "rb") @dbf_r = open(@shp.file_root + ".dbf", "rb") @shp_io = open(@shp.file_root + ".shp.tmp.shp", "wb") @shx_io = open(@shp.file_root + ".shx.tmp.shx", "wb") @dbf_io = open(@shp.file_root + ".dbf.tmp.dbf", "wb") index = commit_delete min_x,max_x,min_y,max_y,min_z,max_z,min_m,max_m = commit_add(index) commit_finalize(min_x,max_x,min_y,max_y,min_z,max_z,min_m,max_m) @shp_r.close @dbf_r.close @dbf_io.close @shp_io.close @shx_io.close FileUtils.move(@shp.file_root + ".shp.tmp.shp", @shp.file_root + ".shp") FileUtils.move(@shp.file_root + ".shx.tmp.shx", @shp.file_root + ".shx") FileUtils.move(@shp.file_root + ".dbf.tmp.dbf", @shp.file_root + ".dbf") @deleted = Hash.new @added = Array.new @shp.reload! end
delete a record. Does not take into account the records added in the current transaction
# File lib/geo_ruby/shp4r/shp.rb, line 351 def delete(i) raise UnexistantRecordException.new("Invalid index : #{i}") if @shp.record_count <= i @deleted[i] = true end
Generated with the Darkfish Rdoc Generator 2.