Class: OsmImport::Target::PgViews

Inherits:
PgBase
  • Object
show all
Defined in:
lib/osm_import/target/pg_views.rb

Defined Under Namespace

Classes: TargetView

Constant Summary

Constants inherited from PgBase

OsmImport::Target::PgBase::GEOTYPES

Instance Attribute Summary

Attributes inherited from PgBase

#options

Instance Method Summary collapse

Methods inherited from PgBase

#geometry_type, #prefix, #projection, #raw_prefix

Instance Method Details

#import(schema) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/osm_import/target/pg_views.rb', line 9

def import(schema)
  conn = Connection.new options
  conn.exec "BEGIN TRANSACTION"

  puts "Preparing target views"
  tvs = schema.tables.map{|table| TargetView.new self, conn, table }

  puts "Dropping old views"
  tvs.each(&:drop!)

  puts "Creating views"
  tvs.each(&:create!)

  puts "Restoring geometry columns"
  conn.exec "TRUNCATE geometry_columns"
  conn.exec "SELECT probe_geometry_columns()"

  puts "Commiting"
  conn.exec "COMMIT"
  conn.close
end

#new_prefixObject



5
6
7
# File 'lib/osm_import/target/pg_views.rb', line 5

def new_prefix
  prefix
end