首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Resolv::LOC::Coord

父类:Object

A Resolv::LOC::Coord

常量

正则表达式

属性

coordinatesR

原始坐标

orientationR

半球的方向为'lat'或'lon'

公共类方法

创建(arg)显示源

创建一个新的LOC :: Coord,arg其中可能是:

LOC::Coord

返回arg

arg 必须匹配LOC :: Coord :: Regex常量

代码语言:javascript
复制
# File lib/resolv.rb, line 2689
def self.create(arg)
  case arg
  when Coord
    return arg
  when String
    coordinates = ''
    if Regex =~ arg && $1.to_f < 180
      m = $~
      hemi = (m[4][/[NE]/]) || (m[4][/[SW]/]) ? 1 : -1
      coordinates = [ ((m[1].to_i*(36e5)) + (m[2].to_i*(6e4)) +
                       (m[3].to_f*(1e3))) * hemi+(2**31) ].pack("N")
      orientation = m[4][/[NS]/] ? 'lat' : 'lon'
    else
      raise ArgumentError.new("not a properly formed Coord string: " + arg)
    end
    return Coord.new(coordinates,orientation)
  else
    raise ArgumentError.new("cannot interpret as Coord: #{arg.inspect}")
  end
end

新(坐标,方向)显示源

代码语言:javascript
复制
# File lib/resolv.rb, line 2710
def initialize(coordinates,orientation)
  unless coordinates.kind_of?(String)
    raise ArgumentError.new("Coord must be a 32bit unsigned integer in hex format: #{coordinates.inspect}")
  end
  unless orientation.kind_of?(String) && orientation[/^lon$|^lat$/]
    raise ArgumentError.new('Coord expects orientation to be a String argument of "lat" or "lon"')
  end
  @coordinates = coordinates
  @orientation = orientation
end

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com