Changeset 12473 in genesis


Ignore:
Timestamp:
Oct 17, 2013, 9:11:57 PM (11 years ago)
Author:
rick
Message:

No more rdnap remote fetching using python module instead.

Location:
tools
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r12441 r12473  
    2424# WSGIScriptAlias /hello /var/www/cgi-bin/genesis/tools/gformat.py
    2525#
     26# Package dependencies list:
     27# yum install python-yaml pyproj proj-epsg python-jinja2
    2628#
    2729# Rick van der Zwet <info@rickvanderzwet.nl>
     
    4244import math
    4345import random
    44 import rdnap
    4546import re
    4647import socket
     
    4950import time
    5051import urlparse
     52import pyproj
    5153
    5254from pprint import pprint
     
    145147    return DHCP_SERVER
    146148
    147 
     149def etrs2rd(lat, lon):
     150  p1 = pyproj.Proj(proj='latlon',datum='WGS84')
     151  p2 = pyproj.Proj(init='EPSG:28992')
     152  RDx, RDy = pyproj.transform(p1,p2,lon, lat)
     153  return (RDx, RDy)
     154
     155def rd2etrs(RDx, RDy):
     156  p1 = pyproj.Proj(init='EPSG:28992')
     157  p2 = pyproj.Proj(proj='latlon',datum='WGS84')
     158  lon, lat = pyproj.transform(p1,p2, RDx, RDy)
     159  return (lat, lon)
    148160
    149161def get_yaml(item,add_version_info=True):
     
    18261838
    18271839          if datadump['rdnap_x'] and datadump['rdnap_y']:
    1828             datadump['latitude'], datadump['longitude'] = rdnap.rd2etrs(datadump['rdnap_x'], datadump['rdnap_y'])
     1840            datadump['latitude'], datadump['longitude'] = map(lambda x: "%.5f" % x, rd2etrs(datadump['rdnap_x'], datadump['rdnap_y']))
    18291841          elif datadump['latitude'] and datadump['longitude']:
    1830             datadump['rdnap_x'], datadump['rdnap_y'] = rdnap.etrs2rd(datadump['latitude'], datadump['longitude'])
     1842            datadump['rdnap_x'], datadump['rdnap_y'] = etrs2rd(datadump['latitude'], datadump['longitude'])
    18311843
    18321844          if datadump['nodename'].startswith('Proxy'):
Note: See TracChangeset for help on using the changeset viewer.