Class: Neo4j::Spatial::OSMLayer

Inherits:
Layer
  • Object
show all
Defined in:
lib/neo4j/spatial/osm.rb

Constant Summary

Constants inherited from Layer

Layer::TYPES

Instance Attribute Summary

Attributes inherited from Layer

#layer, #layer_name

Instance Method Summary collapse

Methods inherited from Layer

#describe, #empty?, exist?, find, #geometry, list, #method_missing, names, #parent, #respond_to?, #to_s, #type_name

Methods included from Database

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

Constructor Details

#initialize(layer_name, options = {}) ⇒ OSMLayer

Returns a new instance of OSMLayer.



69
70
71
72
73
74
# File 'lib/neo4j/spatial/osm.rb', line 69

def initialize(layer_name,options={})
  super(layer_name, options.merge({
    :type => org.neo4j.gis.spatial.osm.OSMLayer,
    :encoder => OSMGeometryEncoder
  }))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Neo4j::Spatial::Layer

Instance Method Details

#add_dynamic_layer(options = {}) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/neo4j/spatial/osm.rb', line 78

def add_dynamic_layer(options={})
  delete = options.delete(:delete)
  options[:default] ||= :linestring
  geometry = Geometry.new(options)
  options.delete :default
  name ||= options.delete(:layer_name) ||
    !options.empty? && options.to_a.flatten.compact.join('-').gsub(/\-+$/,'') ||
    geometry.to_s
  if list.grep(name).length > 0
    if delete
      puts "Deleting dynamic layer '#{name}'[Geometry:#{geometry}]: #{options.inspect}"
      layer.remove_dynamic_layer(name.to_s)
    else
      puts "We already have a dynamic layer called '#{name}'"
    end
  else
    if delete
      puts "No such dynamic layer found for OSM-layer '#{self}': #{name}"
    else
      puts "Creating new dynamic layer '#{name}'[Geometry:#{geometry}]: #{options.inspect}"
      layer.add_dynamic_layer_on_way_tags(name.to_s, geometry.gtype, java.util.HashMap.new(options))
    end
  end
end

#listObject

List dynamic layers associated with this layer



103
104
105
# File 'lib/neo4j/spatial/osm.rb', line 103

def list
  @layer.layer_names
end

#remove_dynamic_layer(options = {}) ⇒ Object



75
76
77
# File 'lib/neo4j/spatial/osm.rb', line 75

def remove_dynamic_layer(options={})
  add_dynamic_layer(options.merge(:delete => true))
end