Class: Neo4j::Spatial::ShapefileExporter

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

Overview

This class facilitates importing 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 = {}) ⇒ ShapefileExporter

Returns a new instance of ShapefileExporter.



30
31
32
33
34
35
# File 'lib/neo4j/spatial/shapefile.rb', line 30

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

Instance Method Details

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



36
37
38
39
40
41
# File 'lib/neo4j/spatial/shapefile.rb', line 36

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



42
43
44
# File 'lib/neo4j/spatial/shapefile.rb', line 42

def format
  "ESRI Shapefile"
end

#to_sObject



45
46
47
# File 'lib/neo4j/spatial/shapefile.rb', line 45

def to_s
  @layer_name || format
end