Class: OsmImport::Target::PgBase::TargetEntry
- Inherits:
-
Object
- Object
- OsmImport::Target::PgBase::TargetEntry
- Defined in:
- lib/osm_import/target/pg_base.rb
Instance Attribute Summary collapse
-
#assigns ⇒ Object
readonly
Returns the value of attribute assigns.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#name_mapping ⇒ Object
readonly
Returns the value of attribute name_mapping.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#type_mapping ⇒ Object
readonly
Returns the value of attribute type_mapping.
-
#types_mapping ⇒ Object
readonly
Returns the value of attribute types_mapping.
Instance Method Summary collapse
- #geometry_expr ⇒ Object
-
#initialize(target, conn, table) ⇒ TargetEntry
constructor
A new instance of TargetEntry.
- #name ⇒ Object
- #osm_id_expr ⇒ Object
- #osm_type_expr(t = table.type) ⇒ Object
Constructor Details
#initialize(target, conn, table) ⇒ TargetEntry
Returns a new instance of TargetEntry.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/osm_import/target/pg_base.rb', line 50 def initialize(target, conn, table) @target = target @conn = conn @table = table @type_mapping = table.type_mapper.expression @types_mapping = table.type_mapper.expression_multi @name_mapping = "NULLIF(COALESCE(src.tags->'name:ru', src.tags->'name', src.tags->'int_name'), '')" @fields = table.type_mapper.fields.merge :id => 'INT8 PRIMARY KEY', :name => 'VARCHAR(255)', :tags => 'HSTORE', :osm_type => 'VARCHAR(10)' @assigns = table.type_mapper.assigns.merge :id => osm_id_expr, :name => name_mapping, :tags => 'src.tags', :osm_type => osm_type_expr @conditions = table.type_mapper.conditions table.mappers.each do |key, mapper| @fields.merge! mapper.fields @assigns.merge! mapper.assigns end end |
Instance Attribute Details
#assigns ⇒ Object (readonly)
Returns the value of attribute assigns.
48 49 50 |
# File 'lib/osm_import/target/pg_base.rb', line 48 def assigns @assigns end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
48 49 50 |
# File 'lib/osm_import/target/pg_base.rb', line 48 def conditions @conditions end |
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
48 49 50 |
# File 'lib/osm_import/target/pg_base.rb', line 48 def conn @conn end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
48 49 50 |
# File 'lib/osm_import/target/pg_base.rb', line 48 def fields @fields end |
#name_mapping ⇒ Object (readonly)
Returns the value of attribute name_mapping.
48 49 50 |
# File 'lib/osm_import/target/pg_base.rb', line 48 def name_mapping @name_mapping end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
48 49 50 |
# File 'lib/osm_import/target/pg_base.rb', line 48 def table @table end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
48 49 50 |
# File 'lib/osm_import/target/pg_base.rb', line 48 def target @target end |
#type_mapping ⇒ Object (readonly)
Returns the value of attribute type_mapping.
48 49 50 |
# File 'lib/osm_import/target/pg_base.rb', line 48 def type_mapping @type_mapping end |
#types_mapping ⇒ Object (readonly)
Returns the value of attribute types_mapping.
48 49 50 |
# File 'lib/osm_import/target/pg_base.rb', line 48 def types_mapping @types_mapping end |
Instance Method Details
#geometry_expr ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/osm_import/target/pg_base.rb', line 77 def geometry_expr if table.type =~ /^multi/ 'ST_Multi(way)' else 'way' end end |
#name ⇒ Object
85 86 87 |
# File 'lib/osm_import/target/pg_base.rb', line 85 def name "#{target.new_prefix}#{table.name}" end |
#osm_id_expr ⇒ Object
69 70 71 |
# File 'lib/osm_import/target/pg_base.rb', line 69 def osm_id_expr "ABS(src.osm_id)" end |
#osm_type_expr(t = table.type) ⇒ Object
73 74 75 |
# File 'lib/osm_import/target/pg_base.rb', line 73 def osm_type_expr(t = table.type) "CASE WHEN src.osm_id < 0 THEN 'relation' ELSE '#{if t.to_s == 'point' then 'node' else 'way' end}' END" end |