File: decompile_correction.py

package info (click to toggle)
twms 0.03e-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 424 kB
  • sloc: python: 1,527; sh: 111; makefile: 9
file content (29 lines) | stat: -rw-r--r-- 993 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-
import sys

tiles_cache = "/var/www/latlon/wms/cache/"
layers = ["irs", "yhsat", "DGsat", "yasat"]

out = sys.stdout

for lay in layers:
    nid, wid = 1, 1
    out = open(lay+".osm","w")
    corrfile = tiles_cache + lay+ "/rectify.txt"
    corr = open(corrfile, "r")
    print >> out, '<osm version="0.6">'
    for line in corr:
       d,c,b,a,user,ts = line.split()
       d,c,b,a = (float(d),float(c),float(b),float(a))
       print >> out, '<node id="-%s" lon="%s" lat="%s" version="1" />'%(nid, d, c)
       nid += 1
       print >> out, '<node id="-%s" lon="%s" lat="%s" version="1" />'%(nid, b, a)
       nid += 1
       print >> out, '<way id="-%s" version="1">'%(wid)
       print >> out,' <nd ref="-%s" />'%(nid-2)
       print >> out,' <nd ref="-%s" />'%(nid-1)
       print >> out,' <tag k="%s" v="%s" />"'%("user", user)
       print >> out,' <tag k="%s" v="%s" />"'%("timestamp", ts)
       print >> out,"</way>"
       wid += 1
    print >> out, '</osm>'