18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/hk_geo/converter.rb', line 18
def self.convert(north, east, from_coord_system=SYSTEM_HK80, to_coord_system=SYSTEM_ITRF96, unit_type=UNIT_DEC)
agent = Mechanize.new do |agent|
agent.user_agent_alias = 'Mac Safari'
end
page = agent.get(SERVICE_URL)
form = page.form_with(:name => 'form1')
form.DropDownList1 = "in#{from_coord_system}"
form.DropDownList2 = "out#{to_coord_system}"
form.TextBox12 = north.to_s
form.TextBox13 = east.to_s
form.radiobuttons_with(:name => 'RadioButtonList1')[UNITS.index(unit_type)].check
result = form.submit(form.buttons.first)
doc = Nokogiri::HTML(result.body)
[doc.css("#Label16").text, doc.css("#Label17").text]
end
|