lib/grid_ref.rb in radiant-event_map-extension-1.3.5 vs lib/grid_ref.rb in radiant-event_map-extension-1.3.6

- old
+ new

@@ -1,8 +1,9 @@ # adapted from Geography::NationalGrid by and (c) P Kent # with reference to the Ordnance Survey guide to coordinate systems in the UK # http://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinatesystemsinfo/guidecontents/ + class Ellipsoid attr_accessor :a, :b, :e2 def initialize(a,b) @a = a @@ -258,35 +259,8 @@ private def sec(radians) 1 / Math.cos(radians) - end - -end - -class String - def is_gridref? - !!(self.upcase =~ /^(H(P|T|U|Y|Z)|N(A|B|C|D|F|G|H|J|K|L|M|N|O|R|S|T|U|W|X|Y|Z)|OV|S(C|D|E|G|H|J|K|M|N|O|P|R|S|T|U|W|X|Y|Z)|T(A|F|G|L|M|Q|R|V)){1}\d{4}(NE|NW|SE|SW)?$|((H(P|T|U|Y|Z)|N(A|B|C|D|F|G|H|J|K|L|M|N|O|R|S|T|U|W|X|Y|Z)|OV|S(C|D|E|G|H|J|K|M|N|O|P|R|S|T|U|W|X|Y|Z)|T(A|F|G|L|M|Q|R|V)){1}(\d{4}|\d{6}|\d{8}|\d{10}))$/) - end - - def is_latlng? - !!(self =~ /(-?\d+\.\d+)[,\s]+(-?\d+\.\d+)/) - end - - def to_latlng(options = {}) - if is_latlng? - self - elsif is_gridref? - GridRef.new(self, options).to_latlng - end - end - - def to_wgs84(options = {}) - if is_latlng? - self - elsif is_gridref? - GridRef.new(self, options.merge(:datum => :wgs84)).to_latlng - end end end