Module: Neo4j::Spatial::Database

Included in:
ImageExporter, Layer, OSMImporter, ShapefileExporter, ShapefileImporter
Defined in:
lib/neo4j/spatial/database.rb

Overview

This module is to be included in classes that wish to have instance level access to the database and spatial database extensions

Instance Method Summary collapse

Instance Method Details

#batch_inserterObject



63
64
65
66
67
68
69
70
# File 'lib/neo4j/spatial/database.rb', line 63

def batch_inserter
  unless @bi
    puts "Getting batch inserter database API access"
    @spatial = nil
    @bi = @db.restart_batch_inserter
  end
  @bi
end

#database(options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/neo4j/spatial/database.rb', line 48

def database(options={})
  options[:dbpath] ||= Neo4j::Config[:storage_path]
  if Neo4j.running? && Neo4j::Config[:storage_path] != options[:dbpath]
    raise "Database already running at different location: #{Neo4j::Config[:storage_path]} != #{options[:dbpath]}"
  end
  Neo4j::Config[:storage_path] = options[:dbpath]
  @commit = options[:commit] || 1000
  normal_database
end

#list_allObject



60
61
62
# File 'lib/neo4j/spatial/database.rb', line 60

def list_all
  spatial.layer_names
end

#normal_databaseObject



71
72
73
74
75
76
77
78
79
80
# File 'lib/neo4j/spatial/database.rb', line 71

def normal_database
  if @db && @db.is_batch?
    puts "Switch off BatchInserter access"
    @db.restart_normal_database
    @spatial = nil
    @bi = nil
  end
  @db ||= Neo4j.started_db
  @db.graph
end

#spatialObject



57
58
59
# File 'lib/neo4j/spatial/database.rb', line 57

def spatial
  @spatial ||= @db.spatial
end