Changeset 8587 in genesis


Ignore:
Timestamp:
Oct 30, 2010, 2:27:36 AM (14 years ago)
Author:
rick
Message:

Python friendly name (does not like the dashes)

File:
1 moved

Legend:

Unmodified
Added
Removed
  • nodes/make_map.py

    r8577 r8587  
    2929
    3030def etrs2rd(lam, phi):
    31   """ Convert rd to etrs """
    32  
    33   item = dict()
    34   (remainder, item['lam_deg']) = math.modf(lam)
    35   remainder *= 60
    36   (remainder, item['lam_min']) = math.modf(remainder)
    37   item['lam_sec'] = remainder * 60
    38 
    39   (remainder, item['phi_deg']) = math.modf(phi)
    40   remainder *= 60
    41   (remainder, item['phi_min']) = math.modf(remainder)
    42   item['phi_sec'] = remainder * 60
    43 
     31  """ Convert etrs to rd """
     32 
     33  item['lam'] = lam
     34  item['phi'] = phi
    4435  item['func'] = 'etrs2rd'
    45 
    46   args = "&".join(["%s=%s" % (k,v) for k,v in item.iteritems()])
    47   url = 'http://www.rdnap.nl/cgi-bin/rdetrs.pl?%s' % args
    48   print "### Fetching coordinate %s, %s using: %s" % (phi, lam, url)
     36  url = 'http://vanderzwet.net/rdnap/%(func)s/%(xrd)s/%(yrd)s/0/' % item
     37
    4938  f = urllib.urlopen(url)
    5039  raw = f.read()
    5140 
    52   r = re.compile('name="([a-z_]+)" value="([0-9\.]+)"')
    53   for i in r.finditer(raw):
    54     name, value = i.group(1,2)
    55     value = float(value)
    56     item[name] = value
    57   return (item['xrd'], item['yrd'])
     41  rdnap_x,rdnap_y,rdnap_h = raw.split('/')
     42  return (rdnap_x, rdnap_y)
     43
    5844
    5945
    6046def rd2etrs(xrd, yrd, hnap=0.0):
    61   """ Convert rd to etrs """
     47  """
     48  Convert rd to etrs
     49  JavaScript Version: https://rdinfo.kadaster.nl/rd/transformator.html
     50  """
    6251  # Get cache is exists
    6352  global coordinates
     
    8170  item['hnap'] = hnap
    8271  item['func'] = 'rd2etrs'
    83   args = "&".join(["%s=%s" % (k,v) for k,v in item.iteritems()])
    84   url = 'http://www.rdnap.nl/cgi-bin/rdetrs.pl?%s' % args
     72  url = 'http://vanderzwet.net/rdnap/%(func)s/%(xrd)s/%(yrd)s/%(hnap)s/' % item
    8573  print "### Not in Cache, Fetching coordinate %s, %s from %s" % (xrd, yrd, url)
    8674  f = urllib.urlopen(url)
    8775  raw = f.read()
    8876 
    89   r = re.compile('name="([a-z_]+)" value="([0-9\.]+)"')
    90   for i in r.finditer(raw):
    91     name, value = i.group(1,2)
    92     value = float(value)
    93     item[name] = value
    94  
    95   lam = item['lam_deg'] + (item['lam_min'] + (item['lam_sec'] / 60)) / 60
    96   phi = item['phi_deg'] + (item['phi_min'] + (item['phi_sec'] / 60)) / 60
     77  lam,phi,h = raw.split('/')
    9778  coordinates[(xrd, yrd)] = (lam, phi)
    9879  write_yaml(CACHE_FILE, coordinates)
Note: See TracChangeset for help on using the changeset viewer.