Class: Spacialdb::Command::Layers

Inherits:
Base
  • Object
show all
Defined in:
lib/spacialdb/command/layers.rb

Overview

manage layers (list, create, destroy)

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, namespace, #spacialdb

Methods included from Helpers

#ask, #confirm_command, #display, #echo_off, #echo_on, #error, #home_directory, #json_decode, #json_encode, #longest, #redisplay

Constructor Details

This class inherits a constructor from Spacialdb::Command::Base

Instance Method Details

#addObject

layers:add NAME

add a new layer to a database

NAME should be the name of the layer.

–db DATABASE # name of the database –tablename TABLENAME # name of the table in the database (defaults to NAME) –srid SRID # srid (defaults to 4326)



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/spacialdb/command/layers.rb', line 25

def add
  tablename = extract_option('--tablename', nil)
  srid = extract_option('--srid') || 4326 
  srid = srid.to_i rescue 4326

  name    = args.shift.downcase.strip rescue ''
  raise(Spacialdb::Command::CommandFailed, "Invalid name.") if name == ''

  database = extract_option('--db', nil)
  raise(Spacialdb::Command::CommandFailed, "Invalid database.") if database == nil

  display spacialdb.add_layer(name, database, tablename, srid)
end

#indexObject

layers

list your layers



11
12
13
# File 'lib/spacialdb/command/layers.rb', line 11

def index
  display spacialdb.list_layers.join("\n")
end

#infoObject

layers:info NAME

show the layer info

NAME should be the name of the layer.



45
46
47
48
49
50
# File 'lib/spacialdb/command/layers.rb', line 45

def info
  name    = args.shift.downcase.strip rescue ''
  raise(Spacialdb::Command::CommandFailed, "Invalid name.") if name == ''

  display spacialdb.show_layer(name)
end

#removeObject

layers:remove NAME

remove a layer

NAME should be the name of the layer.



58
59
60
61
62
63
# File 'lib/spacialdb/command/layers.rb', line 58

def remove
  name    = args.shift.downcase.strip rescue ''
  raise(Spacialdb::Command::CommandFailed, "Invalid name.") if name == ''

  display spacialdb.remove_layer(name)
end