Module: Isnet93

Defined in:
lib/isnet93.rb,
lib/isnet93/version.rb

Constant Summary collapse

EARTH_RADIUS =
6378137.0
FLATTENING =
1/298.257222101
LAMBERT_LOWER_PARALLEL =
64.25
LAMBERT_UPPER_PARALLEL =

should be 64.15 ¿?

65.75
CENTRAL_MERIDIAN_LAT =

should be 65.45 ¿?

65.00
CENTRAL_MERIDIAN_LNG =
19.00
FALSE_NORTHING =
500000.0
FALSE_EASTING =
500000.0
EPS =
0.00000000001
FIRST_ECCENTRICITY =
Math.sqrt(FLATTENING * (2 - FLATTENING))
RHO =
45/Math.atan2(1.0, 1.0)
VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.to_wgs84(east_coordinate, north_coordinate) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/isnet93.rb', line 19

def self.to_wgs84(east_coordinate, north_coordinate)
  dum = isometric(Math.sin(LAMBERT_LOWER_PARALLEL/RHO)) - isometric(Math.sin(LAMBERT_UPPER_PARALLEL/RHO))
  sint = 2 * (Math.log(fx(LAMBERT_LOWER_PARALLEL)) - Math.log(fx(LAMBERT_UPPER_PARALLEL))) / dum
  f2sin1 = isometric(Math.sin(LAMBERT_LOWER_PARALLEL / RHO))
  pol1 = fx(LAMBERT_LOWER_PARALLEL) / sint
  polc = f3(CENTRAL_MERIDIAN_LAT, pol1, f2sin1, sint) + FALSE_NORTHING
  peq = EARTH_RADIUS * Math.cos(CENTRAL_MERIDIAN_LAT/RHO) / (sint * Math.exp(sint*Math.log((45-CENTRAL_MERIDIAN_LAT/2)/RHO)))
  pol = Math.sqrt(((east_coordinate - FALSE_NORTHING)**2) + ((polc - north_coordinate)**2))
  lat = 90 - 2*RHO*Math.atan(Math.exp(Math.log(pol/peq)/sint))
  fact = RHO * Math.cos(lat/RHO) / sint / pol
  delta = 1.0
  while delta.abs > EPS
    delta = (f3(lat, pol1, f2sin1, sint) - pol) * fact
    lat += delta
  end
  lon = -(CENTRAL_MERIDIAN_LNG + RHO*Math.atan((FALSE_EASTING - east_coordinate)/(polc - north_coordinate))/sint)

  # http://gis.stackexchange.com/questions/8650/how-to-measure-the-accuracy-of-latitude-and-longitude
  # The eighth decimal place is worth up to 1.1 mm: this is good for charting motions of tectonic
  # plates and movements of volcanoes. Permanent, corrected, constantly-running GPS base stations
  # might be able to achieve this level of accuracy.
  # Max. estimated accuracy of any surveying device.
  [lat.round(8), lon.round(8)]
end