Class: SmoOsBngGrids::ShapefileWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/smo_os_bng_grids/shapefile_writer.rb

Overview

Writes a set of BNG grid squares to ESRI Shapefile format (.shp/.shx/.dbf/.prj). Pure Ruby, no external dependencies. Output CRS: OSGB36 British National Grid (EPSG:27700).

Constant Summary collapse

SHAPE_TYPE_POLYGON =
5
DBF_VERSION =
0x03

Instance Method Summary collapse

Instance Method Details

#write(entries, path) ⇒ Object

Parameters:

  • entries (Array<Hash>)

    from Lister#list: [min_e:, min_n:, max_e:, max_n:]

  • path (String)

    output path WITHOUT extension, e.g. “/tmp/ns_10km”



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/smo_os_bng_grids/shapefile_writer.rb', line 15

def write(entries, path)
  FileUtils.mkdir_p(File.dirname(path))
  write_shp_shx(entries, path)
  write_dbf(entries, path)
  write_prj(path)
  puts "Written #{entries.size} features to:"
  puts "  #{path}.shp"
  puts "  #{path}.shx"
  puts "  #{path}.dbf"
  puts "  #{path}.prj"
end