Changeset 8587 in genesis
- Timestamp:
- Oct 30, 2010, 2:27:36 AM (14 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
nodes/make_map.py
r8577 r8587 29 29 30 30 def 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 44 35 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 49 38 f = urllib.urlopen(url) 50 39 raw = f.read() 51 40 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 58 44 59 45 60 46 def 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 """ 62 51 # Get cache is exists 63 52 global coordinates … … 81 70 item['hnap'] = hnap 82 71 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 85 73 print "### Not in Cache, Fetching coordinate %s, %s from %s" % (xrd, yrd, url) 86 74 f = urllib.urlopen(url) 87 75 raw = f.read() 88 76 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('/') 97 78 coordinates[(xrd, yrd)] = (lam, phi) 98 79 write_yaml(CACHE_FILE, coordinates)
Note:
See TracChangeset
for help on using the changeset viewer.