Fix Kuntakartta.py for new format

This commit is contained in:
Mikko Ahlroth 2019-09-10 22:33:36 +03:00
parent d7aaaa9ec2
commit ecaed7d951

View file

@ -39819,22 +39819,26 @@ if rawgeocachefi == "[LIITÄ LÖYTÖTAULUKKO PAIKKAKUNNITTAIN TÄHÄN]":
print("""'Löytötaulukko paikkakunnittain' puuttuu""")
exit()
otsikko = rawgeocachefi[rawgeocachefi.find('Sija\t'):rawgeocachefi.find('Yht.\n')+4]
stats = rawgeocachefi[rawgeocachefi.find('1.\t'):rawgeocachefi.find('\n',rawgeocachefi.find(kuntia+"."))].replace(otsikko+'\n',"")
otsikko = rawgeocachefi[rawgeocachefi.find('Paikkakunta\t'):rawgeocachefi.find('Eri\n')+4]
stats = rawgeocachefi[rawgeocachefi.find('Akaa\t'):rawgeocachefi.find('\n',rawgeocachefi.find("Äänekoski"))].replace(otsikko+'\n',"")
sarake = otsikko.split('\t')
k, A = 1, 0
while k <= int(kuntia):
A = stats.find(str(k)+'.'+'\t', A)
if k > 1:
A = stats.find('\n', A) + 1
if k != int(kuntia):
B = A + stats[A:].find('\n')
else:
B = len(stats)
kunta = stats[A:B].split('\t')
PAYLOAD = kunta[0]+kunta[1]+' '+sarake[15]+' '+kunta[15]+' /'
if int(kunta[15]) > 0:
PAYLOAD = kunta[0]+' '+sarake[14]+' '+kunta[14]+' /'
if int(kunta[14]) > 0:
COLOR = '#poly-009D57-1-0'
if int(kunta[1]) > 0:
PAYLOAD = PAYLOAD+'/ '+sarake[1]+' '+kunta[1]+' '
if int(kunta[2]) > 0:
PAYLOAD = PAYLOAD+'/ '+sarake[2]+' '+kunta[2]+' '
if int(kunta[3]) > 0:
@ -39859,12 +39863,10 @@ while k <= int(kuntia):
PAYLOAD = PAYLOAD+'/ '+sarake[12]+' '+kunta[12]+' '
if int(kunta[13]) > 0:
PAYLOAD = PAYLOAD+'/ '+sarake[13]+' '+kunta[13]+' '
if int(kunta[14]) > 0:
PAYLOAD = PAYLOAD+'/ '+sarake[14]+' '+kunta[14]+' '
else:
COLOR = '#poly-DB4436-1-64'
KuntaA = kuntarajat.find('<name>'+kunta[1]+'</name>')
KuntaA = kuntarajat.find('<name>'+kunta[0]+'</name>')
SplitA = kuntarajat[KuntaA:].find('CDATA[')+KuntaA+6
SplitB = kuntarajat[KuntaA:].find(']]></description>')+KuntaA
@ -39882,5 +39884,3 @@ tiedosto = "Kuntarajat" + now.strftime("%d%m%Y") + ".kml"
with open(tiedosto, "w") as f:
f.write(kuntarajat)
print(kuntarajat)
print('VALMIS')
input()