Class: ActiveRoad::OsmPbfImporterLevelDb::SimpleWay

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
app/models/active_road/osm_pbf_importer_level_db.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(boundary_id, old_physical_road_id, old_physical_road_objectid, old_physical_road_tags, old_physical_road_geometry, old_departure_objectid, old_departure_geometry, old_arrival_objectid, old_arrival_geometry, geometry) ⇒ SimpleWay

Returns a new instance of SimpleWay.



602
603
604
605
606
607
608
609
610
611
612
613
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 602

def initialize(boundary_id, old_physical_road_id, old_physical_road_objectid, old_physical_road_tags, old_physical_road_geometry, old_departure_objectid, old_departure_geometry, old_arrival_objectid, old_arrival_geometry, geometry)
  @boundary_id = boundary_id
  @old_physical_road_id = old_physical_road_id
  @old_physical_road_objectid = old_physical_road_objectid
  @old_physical_road_tags = old_physical_road_tags || ""
  @old_physical_road_geometry = old_physical_road_geometry
  @old_departure_objectid = old_departure_objectid
  @old_departure_geometry = old_departure_geometry
  @old_arrival_objectid = old_arrival_objectid
  @old_arrival_geometry = old_arrival_geometry
  @geometry = geometry       
end

Instance Attribute Details

#arrival_objectidObject

Returns the value of attribute arrival_objectid.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def arrival_objectid
  @arrival_objectid
end

#boundary_idObject

Returns the value of attribute boundary_id.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def boundary_id
  @boundary_id
end

#departure_objectidObject

Returns the value of attribute departure_objectid.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def departure_objectid
  @departure_objectid
end

#geometryObject

Returns the value of attribute geometry.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def geometry
  @geometry
end

#nextObject

Returns the value of attribute next.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def next
  @next
end

#old_arrival_geometryObject

Returns the value of attribute old_arrival_geometry.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def old_arrival_geometry
  @old_arrival_geometry
end

#old_arrival_objectidObject

Returns the value of attribute old_arrival_objectid.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def old_arrival_objectid
  @old_arrival_objectid
end

#old_departure_geometryObject

Returns the value of attribute old_departure_geometry.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def old_departure_geometry
  @old_departure_geometry
end

#old_departure_objectidObject

Returns the value of attribute old_departure_objectid.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def old_departure_objectid
  @old_departure_objectid
end

#old_physical_road_geometryObject

Returns the value of attribute old_physical_road_geometry.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def old_physical_road_geometry
  @old_physical_road_geometry
end

#old_physical_road_idObject

Returns the value of attribute old_physical_road_id.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def old_physical_road_id
  @old_physical_road_id
end

#old_physical_road_objectidObject

Returns the value of attribute old_physical_road_objectid.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def old_physical_road_objectid
  @old_physical_road_objectid
end

#old_physical_road_tagsObject

Returns the value of attribute old_physical_road_tags.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def old_physical_road_tags
  @old_physical_road_tags
end

#previousObject

Returns the value of attribute previous.



600
601
602
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 600

def previous
  @previous
end

Instance Method Details

#<=>(another) ⇒ Object



642
643
644
645
646
647
648
649
650
651
652
653
654
655
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 642

def <=>(another)
  # puts "self : #{self.departure.inspect}, #{self.arrival.inspect}"
  # puts "another : #{another.departure.inspect}, #{another.arrival.inspect}"
  # puts old_physical_road_geometry.points.inspect
  # puts old_physical_road_geometry.points.index(another.arrival).inspect
  # puts old_physical_road_geometry.points.index(self.departure).inspect
  if self.departure == another.arrival || old_physical_road_geometry.points.index(another.arrival) < old_physical_road_geometry.points.index(self.departure)         
    1
  elsif self.arrival == another.departure || old_physical_road_geometry.points.index(self.arrival) < old_physical_road_geometry.points.index(another.departure)
    -1
  else
    nil
  end
end

#arrivalObject



630
631
632
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 630

def arrival
  geometry.points.last if geometry
end

#default_arrival_objectidObject



638
639
640
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 638

def default_arrival_objectid
  "#{old_departure_objectid}-#{old_arrival_objectid}"
end

#default_departure_objectidObject



634
635
636
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 634

def default_departure_objectid
  "#{old_departure_objectid}-#{old_arrival_objectid}"
end

#departureObject



625
626
627
628
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 625

def departure
  #puts "geometry class #{geometry.class}, value #{geometry.inspect}"
  geometry.points.first if geometry
end

#old_physical_road_tags_hashObject



615
616
617
618
619
620
621
622
623
# File 'app/models/active_road/osm_pbf_importer_level_db.rb', line 615

def old_physical_road_tags_hash
  #Fix tags build from string
  tags = {}.tap do |tags| 
    old_physical_road_tags.split(',').each do |pair|                    
      key, value = pair.split("=>")
      tags[key.gsub(/\W/, "")] = value.gsub(/\W/, "")
    end
  end
end