Class: When::Coordinates::Spatial::Range
- Inherits:
-
Object
- Object
- When::Coordinates::Spatial::Range
- Defined in:
- lib/when_exe/spatial.rb
Overview
イベント管理用範囲オブジェクト
Instance Attribute Summary collapse
-
#alt ⇒ ::Range
readonly
上下の範囲.
-
#bottom ⇒ Numeric
readonly
下の境界.
-
#east ⇒ Numeric
readonly
東の境界.
-
#first ⇒ When::Coordinates::Spatial
readonly
西南下の境界.
-
#last ⇒ When::Coordinates::Spatial
readonly
東北上の境界.
-
#lat ⇒ ::Range
readonly
南北の範囲.
-
#long ⇒ ::Range
readonly
東西の範囲.
-
#north ⇒ Numeric
readonly
北の境界.
-
#south ⇒ Numeric
readonly
南の境界.
-
#top ⇒ Numeric
readonly
上の境界.
-
#west ⇒ Numeric
readonly
西の境界.
Class Method Summary collapse
-
.[](name) ⇒ When::Coordinates::Spatial
(also: _instance)
地名を空間座標化する.
-
.[]=(name, locations) ⇒ Object
地名に空間座標を設定する.
Instance Method Summary collapse
-
#exclude_end? ⇒ Boolean
終端を除外するか?(ダミー).
-
#include?(target) ⇒ Boolean
指定オブジェクトが範囲内か?.
-
#initialize(first, last) ⇒ Range
constructor
イベント管理用範囲オブジェクトの生成.
-
#is_complex? ⇒ Boolean
範囲の重なりの判断が複雑になるか?(ダミー).
-
#is_overlaped?(range) ⇒ Boolean
範囲の重なりの判断.
Constructor Details
#initialize(first, last) ⇒ Range
イベント管理用範囲オブジェクトの生成
596 597 598 599 600 601 602 603 604 605 606 607 608 |
# File 'lib/when_exe/spatial.rb', line 596 def initialize(first, last) @first = first.kind_of?(Range) ? first.first : first @last = last.kind_of?(Range) ? last.last : last @west = @first.long @south = @first.lat @bottom = @first.alt @east = @last.long @north = @last.lat @top = @last.alt @long = ::Range.new(@west, @east, false) @lat = ::Range.new(@south, @north, false) @alt = ::Range.new(@bottom, @top, false) end |
Instance Attribute Details
#alt ⇒ ::Range (readonly)
上下の範囲
535 536 537 |
# File 'lib/when_exe/spatial.rb', line 535 def alt @alt end |
#bottom ⇒ Numeric (readonly)
下の境界
493 494 495 |
# File 'lib/when_exe/spatial.rb', line 493 def bottom @bottom end |
#east ⇒ Numeric (readonly)
東の境界
505 506 507 |
# File 'lib/when_exe/spatial.rb', line 505 def east @east end |
#first ⇒ When::Coordinates::Spatial (readonly)
西南下の境界
475 476 477 |
# File 'lib/when_exe/spatial.rb', line 475 def first @first end |
#last ⇒ When::Coordinates::Spatial (readonly)
東北上の境界
499 500 501 |
# File 'lib/when_exe/spatial.rb', line 499 def last @last end |
#lat ⇒ ::Range (readonly)
南北の範囲
529 530 531 |
# File 'lib/when_exe/spatial.rb', line 529 def lat @lat end |
#long ⇒ ::Range (readonly)
東西の範囲
523 524 525 |
# File 'lib/when_exe/spatial.rb', line 523 def long @long end |
#north ⇒ Numeric (readonly)
北の境界
511 512 513 |
# File 'lib/when_exe/spatial.rb', line 511 def north @north end |
#south ⇒ Numeric (readonly)
南の境界
487 488 489 |
# File 'lib/when_exe/spatial.rb', line 487 def south @south end |
#top ⇒ Numeric (readonly)
上の境界
517 518 519 |
# File 'lib/when_exe/spatial.rb', line 517 def top @top end |
#west ⇒ Numeric (readonly)
西の境界
481 482 483 |
# File 'lib/when_exe/spatial.rb', line 481 def west @west end |
Class Method Details
.[](name) ⇒ When::Coordinates::Spatial Also known as: _instance
地名を空間座標化する
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'lib/when_exe/spatial.rb', line 401 def [](name) source = name.strip case source when /\A(.+)\.\.(.+)\z/ ; return self.new(_instance($1), _instance($2)) when /\A([\d.]+)([SN])([\d.]+)([WE])([-+\d.]+)?\z/i ; lat, sn, long, we, alt = $~[1..5] when /\A([\d.]+)([WE])([\d.]+)([SN])([-+\d.]+)?\z/i, /\A([-+\d.]+)(_)([-+\d.]+)(_)?([-+\d.]+)?\z/ ; long, we, lat, sn, alt = $~[1..5] end locations = if long [[ When::Coordinates.to_deg_225("#{long}#{we}", 'EW', 1), When::Coordinates.to_deg_225("#{lat }#{sn}", 'NS', 1), (alt || 0).to_f ]] else t = When::Coordinates::LocationTable keys = [source] keys.concat(name.names.values) if name.kind_of?(When::BasicTypes::M17n) keys_to_location(keys, t) end return locations unless locations.kind_of?(Array) locations = locations.map {|location| When::Coordinates::Spatial.new({'long'=>location[0], 'lat'=>location[1], 'alt'=>location[2], 'degree'=>1}) } locations = locations.size > 1 ? self.new(*locations) : locations.first if t keys.each do |key| t[0][key] = locations end end locations end |
.[]=(name, locations) ⇒ Object
地名に空間座標を設定する
441 442 443 444 445 446 447 |
# File 'lib/when_exe/spatial.rb', line 441 def []=(name, locations) keys = [source] keys.concat(name.names.values) if name.kind_of?(When::BasicTypes::M17n) keys.each do |key| When::Coordinates::LocationTable[0][key] = locations end end |
Instance Method Details
#exclude_end? ⇒ Boolean
終端を除外するか?(ダミー)
549 550 551 |
# File 'lib/when_exe/spatial.rb', line 549 def exclude_end? false end |
#include?(target) ⇒ Boolean
指定オブジェクトが範囲内か?
559 560 561 562 563 564 565 566 567 568 569 |
# File 'lib/when_exe/spatial.rb', line 559 def include?(target) case target when When::Coordinates::Spatial @long.include?(target.long) && @lat.include?(target.lat) && @alt.include?(target.alt) when Range @long.include?(target.west) && @lat.include?(target.south) && @alt.include?(target.bottom) && @long.include?(target.east) && @lat.include?(target.north) && @alt.include?(target.top) else false end end |
#is_complex? ⇒ Boolean
範囲の重なりの判断が複雑になるか?(ダミー)
541 542 543 |
# File 'lib/when_exe/spatial.rb', line 541 def is_complex? false end |
#is_overlaped?(range) ⇒ Boolean
範囲の重なりの判断
578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/when_exe/spatial.rb', line 578 def is_overlaped?(range) case target when When::Coordinates::Spatial @long.include?(target.long) && @lat.include?(target.lat) && @alt.include?(target.alt) when Range @west >= target.east && @north >= target.south && @top >= target.bottom && @east <= target.west && @south <= target.north && @bottom <= target.top else false end end |