Class: Neo4j::Spatial::SHPExporter

Inherits:
Object
  • Object
show all
Includes:
Database
Defined in:
lib/neo4j/spatial/shp.rb

Overview

This class facilitates exporting datasets in the ESRI Shapefile format

Instance Method Summary collapse

Methods included from Database

#batch_inserter, #database, #list_all, #normal_database, #spatial

Constructor Details

#initialize(options = {}) ⇒ SHPExporter

Returns a new instance of SHPExporter.



32
33
34
35
36
37
# File 'lib/neo4j/spatial/shp.rb', line 32

def initialize(options={})
  options[:dir] ||= "target/export"
  database(options)
  @exporter = org.neo4j.gis.spatial.ShapefileExporter.new(normal_database)
  @exporter.setExportDir(options[:dir])
end

Instance Method Details

#export(layer_name, options = {}) ⇒ Object



38
39
40
41
42
43
# File 'lib/neo4j/spatial/shp.rb', line 38

def export(layer_name,options={})
  @layer_name = layer_name
  options[:path] ||= layer_name+'.shp'
  puts "Exporting #{layer_name} to #{options[:path]}"
  @exporter.exportLayer(layer_name, options[:path])
end

#formatObject



44
45
46
# File 'lib/neo4j/spatial/shp.rb', line 44

def format
  "ESRI Shapefile"
end

#to_sObject



47
48
49
# File 'lib/neo4j/spatial/shp.rb', line 47

def to_s
  @layer_name || format
end