Ov2-files
From OpenTom
ov2 files contain point of interest (POI) data.
File formats
The are two different file format types: encrypted and non-encrypted ones.
The file formats of the Itinerary and POI files used can be found here: http://www.tomtom.com/support/ce/downloads/ttnavsdk3_manual.pdf
Here is a simple X11-Basic program, which shows the ov2-file content:
' This program converts .ov2 POI data files to an ASCII format on stdout
' (c) Markus Hoffmann 2008
' written in X11-Basic
'
' Usage: xbasic ov2show.bas <filename.ov2>
'
i=1
while len(param$(i))
f$=param$(i)
inc i
wend
if not exist(f$)
print f$;" existiert nicht."
quit
endif
print "# ";f$;" converted by ov2show "+date$+" "+time$
open "I",#1,f$
level=0
dim skipperlen(100)
clr poicount,areacount
while not eof(#1)
typ=inp(#1)
length=cvl(input$(#1,4)) and 0xffffff
if level
print space$(level*2);
endif
print "Typ=";typ;" Len=";length;" ";
if typ=1
data$=input$(#1,16)
else
data$=input$(#1,length-5)
endif
if typ=10000
else if typ=0
x=lpeek(varptr(data$))/100000
y=lpeek(varptr(data$)+4)/100000
name$=mid$(data$,9,len(data$)-8-1)
print "!DELETE! x=";x;" ";
print "y=";y;" ";
print "name="+chr$(34)+name$+chr$(34)+" ";
else if typ=1
skipperlen(level)=length
length=16+5
x1=lpeek(varptr(data$))/100000
y1=lpeek(varptr(data$)+4)/100000
x2=lpeek(varptr(data$)+8)/100000
y2=lpeek(varptr(data$)+12)/100000
print "(SKIPPER) x1=";x1;" ";
print "y1=";y1;" ";
print "x2=";x2;" ";
print "y2=";y2;" {";
inc areacount
' box x1*20,(y1-45)*20,x2*20,(y2-45)*20
' vsync
inc level
else if typ=2
x=lpeek(varptr(data$))/100000
y=lpeek(varptr(data$)+4)/100000
name$=mid$(data$,9,len(data$)-8-1)
print "x=";x;" ";
print "y=";y;" ";
print "name="+chr$(34)+name$+chr$(34)+" ";
' plot x*20,(y-45)*20
inc poicount
else
print "data="+chr$(34);
for i=0 to len(data$)-1
print hex$(peek(varptr(data$)+i) and 255,2,1);" ";
next i
for i=0 to len(data$)-1
if chr$(peek(varptr(data$)+i))>=" "
print chr$(peek(varptr(data$)+i));
else
print ".";
endif
next i
endif
print
if level
for i=0 to level-1
skipperlen(i)=skipperlen(i)-length
if skipperlen(i)<0
print "ERROR !!!"
endif
next i
while skipperlen(level-1)=0
print space$(level*2-2);"}"
dec level
exit if level=0
wend
endif
wend
close
print "# ";poicount;" POIs in ";areacount;" areas."
' pause 3
quit
Here is another simple Program, which converts the ASCII output back to ov2 files:
' creates ov2 files from ascii input
' (c) Markus Hoffmann 2008
'
' written in X11-basic
'
' Version 1.02 now does the map-Patitioning (new optimized algorithm)
' The algorithm is not yet heavily tested. (c) Markus Hoffmann
' latest modification 27.03.2008
'
dim skipper(100)
maxpoiinarea=16
minpoiinarea=maxpoiinarea/4
i=1
outputfilename$="a.ov2"
' sizew ,700,700
WHILE LEN(PARAM$(i))
IF LEFT$(PARAM$(i))="-"
IF PARAM$(i)="--help" OR PARAM$(i)="-h"
@intro
@using
ELSE IF PARAM$(i)="--version"
@intro
QUIT
ELSE IF PARAM$(i)="-o"
INC i
IF LEN(PARAM$(i))
outputfilename$=PARAM$(i)
ENDIF
ENDIF
ELSE
inputfile$=param$(i)
if not exist(inputfile$)
print "a2ov2: "+inputfile$+": file or path not found"
clr inputfile$
ENDIF
ENDIF
INC i
WEND
if len(inputfile$)
if exist(outputfilename$)
print "a2ov2: Outputfilename already exists: ";outputfilename$
else
@convert
endif
else
print "a2ov2: No input files"
endif
quit
procedure intro
print "ASCII POINT OF INTEREST to ov2 file Converter V.1.10 (c) Markus Hoffmann 2008-2008"
version
return
procedure using
print "Usage: a2ov2 [options] file..."
print "Options:"
print " -h, --help Display this information"
print " -o <file> Place the output into <file>"
return
procedure convert
local t$
anzzeilen=0
print "PASS 0"
open "I",#1,inputfile$
while not eof(#1)
lineinput #1,t$
t$=xtrim$(t$)
if len(t$)
if left$(t$)<>"#"
inc anzzeilen
endif
endif
wend
close #1
dim zeilen$(anzzeilen)
print "PASS 1"
anzzeilen=0
open "I",#1,inputfile$
while not eof(#1)
lineinput #1,t$
t$=xtrim$(t$)
if len(t$)
if left$(t$)<>"#"
zeilen$(anzzeilen)=t$
pointarray$=pointarray$+mkl$(anzzeilen)
inc anzzeilen
endif
endif
wend
close #1
print "PASS 2"
open "O",#2,outputfilename$
@doit(pointarray$)
close #2
print poicount;" POIs in ";areacount;" areas."
return
procedure doit(array$)
local area$,area1$,area2$,area3$,area4$
local ar1$,ar2$,ar3$,ar4$
local x1,x2,y1,y2
if len(array$)/4<minpoiinarea
@writepois(array$)
else
area$=@makearea$(array$)
@openskipper(area$)
x1=cvl(mid$(area$,0*4+1,4))
y1=cvl(mid$(area$,1*4+1,4))
x2=cvl(mid$(area$,2*4+1,4))
y2=cvl(mid$(area$,3*4+1,4))
area1$=mkl$(x1)+mkl$(y1)+mkl$((x2-x1)/2+x1)+mkl$((y2-y1)/2+y1)
area2$=mkl$((x2-x1)/2+x1)+mkl$(y1)+mkl$(x2)+mkl$((y2-y1)/2+y1)
area3$=mkl$(x1)+mkl$((y2-y1)/2+y1)+mkl$((x2-x1)/2+x1)+mkl$(y2)
area4$=mkl$((x2-x1)/2+x1)+mkl$((y2-y1)/2+y1)+mkl$(x2)+mkl$(y2)
ar1$=@selectpois$(area1$,array$)
ar2$=@selectpois$(area2$,array$)
ar3$=@selectpois$(area3$,array$)
ar4$=@selectpois$(area4$,array$)
@doit(ar1$)
@doit(ar2$)
@doit(ar3$)
@doit(ar4$)
@closeskipper
endif
return
procedure openskipper(a$)
print "{"
skipper(level)=LOC(#2)
inc level
inc areacount
print #2,chr$(1);mkl$(0xdeadface);right$(a$,8);left$(a$,8);
return
procedure closeskipper
dec level
tt=loc(#2)
seek #2,skipper(level)+1
print #2,mkl$(tt-loc(#2)+1);
seek #2,tt
print space$(level*2);"}"
return
function selectpois$(aa$,idx$)
local oo$,x1,x2,y1,y2,i,t$,typ,x,y,j
oo$=""
x1=cvl(mid$(aa$,0*4+1,4))
y1=cvl(mid$(aa$,1*4+1,4))
x2=cvl(mid$(aa$,2*4+1,4))
y2=cvl(mid$(aa$,3*4+1,4))
for i=0 to len(idx$)/4-1
j=cvl(mid$(idx$,i*4+1,4))
t$=zeilen$(j)
typ=val(@getval$(t$,"TYP"))
if typ=2
x=round(val(@getval$(t$,"X"))*100000) ! there is a strange roundoff error without round...
y=round(val(@getval$(t$,"Y"))*100000)
if x>=x1 and x<x2 and y>=y1 and y<y2
oo$=oo$+mkl$(j)
endif
else
print "skipped typ=";typ
endif
next i
return oo$
endfunction
procedure writepois(idx$)
local i,t$,j
if len(idx$)/4
print space$(level*2);"WRITEPOIS ";len(idx$)/4
for i=0 to len(idx$)/4-1
j=cvl(mid$(idx$,i*4+1,4))
t$=zeilen$(j)
@processline(t$)
next i
endif
return
function makearea$(idx$)
local a$,i,xmin,xmay,ymin,ymax,t$,x,y,j
print space$(level*2);"MAKEAREA ";
xmin=360*100000
ymin=360*100000
xmax=-360*100000
ymax=-360*100000
for i=0 to len(idx$)/4-1
j=cvl(mid$(idx$,i*4+1,4))
t$=zeilen$(j)
typ=val(@getval$(t$,"TYP"))
if typ=2
x=round(val(@getval$(t$,"X"))*100000) ! there is a strange roundoff error without round...
y=round(val(@getval$(t$,"Y"))*100000)
xmin=min(xmin,x)
ymin=min(ymin,y)
xmax=max(xmax,x)
ymax=max(ymax,y)
else
print "skipped typ=";typ
endif
next i
add xmax,1
add ymax,1
sub xmin,1
sub ymin,1
a$=mkl$(xmin)+mkl$(ymin)+mkl$(xmax)+mkl$(ymax)
' box (xmin-500000)/2000,(ymin-4600000)/2000,(xmax-500000)/2000,(ymax-4600000)/2000
' vsync
return a$
endfunction
procedure processline(t$)
record$=""
typ=val(@getval$(t$,"TYP"))
if typ=2 or typ=0
x=round(val(@getval$(t$,"X"))*100000) ! there is a strange roundoff error without round...
y=round(val(@getval$(t$,"Y"))*100000)
name$=@getval$(t$,"NAME")
if left$(name$)=chr$(34) and right$(name$)=chr$(34)
name$=right$(name$,len(name$)-1)
name$=left$(name$,len(name$)-1)
endif
name$=name$+chr$(0)
record$=chr$(typ)+mkl$(len(name$)+5+8)+mkl$(x)+mkl$(y)+name$
inc poicount
else if typ=1
print "Error, this file cannot be processed!"
quit
else
data$=@getval$(t$,"DATA")
if left$(data$)=chr$(34) and right$(data$)=chr$(34)
data$=right$(data$,len(data$)-1)
data$=left$(data$,len(data$)-1)
endif
data$=xtrim$(data$)
while len(data$)
wort_sep data$," ",0,a$,data$
record$=record$+chr$(val("0x"+a$))
wend
record$=chr$(typ)+mkl$(len(record$)+5)+record$
endif
print #2,record$;
inc recordcount
return
function getval$(t$,f$)
local a$,val$
val$=""
wort_sep t$," ",1,a$,t$
while len(a$)
a$=trim$(a$)
wort_sep a$,"=",1,name$,val$
exit if upper$(name$)=upper$(f$)
val$=""
wort_sep t$," ",1,a$,t$
wend
return val$
endfunction
See also: X11-Basic
Merge two ov2 files together
It is possible to merge two .ov2 files by simply concating them:
cat a.ov2 b.ov2 > c.ov2
will merge a.ov2 and b.ov2 together into the file c.ov2.
Of course the result need to be of one single category.
Modifying ov2 files
You can use the two scripts shown above and a simple text editor to modyfy the contents of all ov2 files.
xbasic ov2show.bas myfile.ov2 > editme.txt pico editme.txt xbasic a2ov2.bas -o mynewfile.ov2 editme.txt
Thats it. Very useful is also the cut-and-paste function...
And, last but not least, you can do all of that on the TomTom device itself, without using a PC.

