vurbanism/vurbanism/importMyMaps.py
2010-03-15 17:00:31 +05:30

20 lines
618 B
Python

import elementtree.ElementTree as ET
from django.contrib.gis.geos import Point
from flyovers.models import *
def parseXml(fname):
root = ET.parse(fname).getroot()
channel = root.find('channel')
for item in channel.findall('item'):
title = item.find('title').text
description = item.find('description').text or ''
pt = item.find("{http://www.georss.org/georss}point").text.strip().split(" ")
lat = float(pt[0])
lng = float(pt[1])
point = Point(lng, lat,)
print point
f = Flyover(name=title, txt=description, point=point)
f.save()
# pt = item.find('georss:point').text