Re: [All] tangogps - python scripts for .kml from/to sqlite

2008-12-23 Thread Thomas des Courières
> i have use your idea and your code in my gtkaddpoi
> http://wiki.openmoko.org/wiki/Gtkaddpoi :)
>

nice to hear !
___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: [All] tangogps - python scripts for .kml from/to sqlite

2008-12-23 Thread Carlo Minucci
Thomas des Courières ha scritto:
> Hi all,
> just wanted to share some scripts I used.
> The first one is for converting a list of points out of a kml file to a 
> poi sqlite3 database which tangogps can read, and the other one is for 
> doing the reverse operation : getting the pois of the tango gps db and 
> creating a kml file.
> It might need some tweaking, as some things are hard coded.
> Note that I also extracted the points of the kml file with my favorite 
> "excel like" program into a plain file listing all points.
> Hoping that it will save someone's time,
> Thomas

i think is a good idea!!!

i have use your idea and your code in my gtkaddpoi 
http://wiki.openmoko.org/wiki/Gtkaddpoi :)

for now only for export a POI

___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


[All] tangogps - python scripts for .kml from/to sqlite

2008-12-22 Thread Thomas des Courières
Hi all,
just wanted to share some scripts I used.
The first one is for converting a list of points out of a kml file to a poi
sqlite3 database which tangogps can read, and the other one is for doing the
reverse operation : getting the pois of the tango gps db and creating a kml
file.
It might need some tweaking, as some things are hard coded.
Note that I also extracted the points of the kml file with my favorite
"excel like" program into a plain file listing all points.
Hoping that it will save someone's time,
Thomas
#!/usr/bin/python
# -*- coding: UTF-8 -*-


import os.path
import sqlite3
import time

file = '/home/root/myfile.txt'
database = sqlite3.connect('/home/root/.tangogps/poi.db', isolation_level=None)

FILE = open(file,'r')

for line in FILE:
	coords = line.split(',')
	print "Coordonnees : lat = %s, lon = %s" % (coords[0], coords[1])
	current_time = time.time()
	db_call = "INSERT INTO poi (idmd5, lat, lon, visibility, cat, subcat, keywords, desc, price_range, extended_open) VALUES (?,?,?,?,?,?,?,?,?,?) "
	print database.execute(db_call, ('%s' % current_time, coords[1], coords[0], 1, 1, 0, '', '', 3, 0)).rowcount > 0

FILE.close()

database.close()

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os.path
import sqlite3
import time

my_category = 0

database = sqlite3.connect('/home/root/.tangogps/poi.db')
pois = database.execute("SELECT * FROM POI WHERE cat=?", (my_category,) ).fetchall()
database.close()

file = '/home/root/myfile.kml'
FILE = open(file,'w')
FILE.truncate(0)

FILE.write('\n')
FILE.write('http://earth.google.com/kml/2.0";>\n')
FILE.write('\n')
FILE.write('\n')
FILE.write('Point Features\n')
FILE.write('Point Features\n')

i = 1
for poi in pois:
	print '%s : %f, %f' % (poi, poi[2],poi[1],)
	FILE.write('\n')
	FILE.write('\n' % i)
	FILE.write('\n' % (poi[1],poi[2]) )
	FILE.write('\n')
	FILE.write('%f,%f,0\n' % (poi[2],poi[1],))
	FILE.write('\n')
	FILE.write('\n')
	i = i + 1

FILE.write('\n')
FILE.write('\n')
FILE.write('\n')
FILE.close()


#	db_call = "INSERT INTO poi (idmd5, lat, lon, visibility, cat, subcat, keywords, desc, price_range, extended_open) VALUES (?,?,?,?,?,?,?,?,?,?) "


___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community