source: subversion/applications/utils/export/tiledata2/test_encoding.py @ 28183

Last change on this file since 28183 was 9593, checked in by ojw, 11 years ago

tile data using sqlite and protocol buffers

File size: 875 bytes
Line 
1#!/usr/bin/python
2# -*- coding: UTF-8 -*-
3import sqlite3
4import sys
5import os
6from tilenames import *
7import mobileEncoding
8
9
10if(__name__ == "__main__"):
11  print sys.getdefaultencoding()
12
13  conn = sqlite3.connect('test.dat')
14  conn.text_factory = str
15
16  c = conn.cursor()
17  c.execute("drop table if exists test")
18  c.execute("create table test (id int, data blob)")
19 
20  data = mobileEncoding.storeWay(((1,51,10),(2,52,20),(3,53,30),(4,54,50),(5,55,50)), {"highway":"motorway","oneway":"true"})
21  #mobileEncoding.printWay(data)
22 
23  c.execute("insert into test values(?, ?)", (123, sqlite3.Binary(data),))
24  conn.commit()
25
26  c.execute('select * from test')
27  row = c.fetchone()
28  (wid,data2) = row
29
30  print "Saved %d, retrieved %d bytes" % (len(data), len(data2))
31  print wid
32  if(data != data2):
33    print "Data is different"
34 
35  mobileEncoding.printWay(data2)
36     
37   
Note: See TracBrowser for help on using the repository browser.