OPEN FOR DIRECTORY
Sept 1, 2022 19:14:33 GMT 1
Post by alexfish on Sept 1, 2022 19:14:33 GMT 1
HI Peter
I am having a problem with open directory ,as in nested like openstreetmaps
the bugs
if asking does if happen in all directories ,no at present 8 an 12 zoom levels
example zoom 9
OPEN Dir : /home/pi/bacon-osm-maps/9/. gets skip as does the ..
only thing of note = 12/./ and that 1210.png is in the next directory /12/257/1210.png , note 12 & 1210.png
and zoom 8 would be /8/257/81.png , note the 8 & 81.png
if happen at the start of the read
and have the '.' and '..' notation
for other readers , to see this
do a ls -a
This is the program
BR
Alex
I am having a problem with open directory ,as in nested like openstreetmaps
the bugs
Dir : /home/pi/bacon-osm-maps/8/./
Dir : /home/pi/bacon-osm-maps/8/81.png/
Runtime error: statement 'OPEN FOR DIRECTORY' at line 33 in '/home/pi/Downloads/seamap_converter.bac': Error opening file: No such file or directory
/home/pi/bacon-osm-maps/12/
Dir : /home/pi/bacon-osm-maps/12/./
Dir : /home/pi/bacon-osm-maps/12/1210.png
Runtime error: statement 'OPEN FOR DIRECTORY' at line 33 in '/home/pi/Downloads/seamap_converter.bac': Error opening file: No such file or directory
if asking does if happen in all directories ,no at present 8 an 12 zoom levels
example zoom 9
OPEN Dir : /home/pi/bacon-osm-maps/9/. gets skip as does the ..
only thing of note = 12/./ and that 1210.png is in the next directory /12/257/1210.png , note 12 & 1210.png
and zoom 8 would be /8/257/81.png , note the 8 & 81.png
if happen at the start of the read
and have the '.' and '..' notation
for other readers , to see this
do a ls -a
This is the program
'=================================================================================
' File seamap_converter.bac
OPTION PARSE FALSE
'===========================================
PRAGMA LDFLAGS `pkg-config --libs gdk-pixbuf-2.0`
PRAGMA OPTIONS `pkg-config --cflags gdk-pixbuf-2.0`
'OSMDIR$ = HOME$ & "/bacon-osm-maps/" & STR$(ZOOM) & "/"
'===========================================
PRAGMA INCLUDE <gdk-pixbuf-2.0/gdk-pixbuf/gdk-pixbuf.h>
SUB UPDATE_SEAMAPS(OSMDIR$,ZOOM,REBUILD)
OSMDIR$ =OSMDIR$ & STR$(ZOOM) & "/"
LOCAL first
LOCAL myfile$
OPEN OSMDIR$ FOR DIRECTORY AS mydir
PRINT OSMDIR$
REPEAT
GETFILE myfile$ FROM mydir
getfile$= OSMDIR$ & myfile$
OPEN getfile$ FOR DIRECTORY AS mydir2
REPEAT
GETFILE getfile$ FROM mydir2
' miss the zoom file if have used the original navigation app
IF getfile$ = "zoom" THEN
ELSE
myfile$ = OSMDIR$ & getfile$ & "/"
DIRS$ = getfile$ & "/"
FDIR$ = OSMDIR$ & getfile$ & "/"
DIRT$ = myfile$
PRINT "OPEN Dir : " ,myfile$
OPEN myfile$ FOR DIRECTORY AS mydir3
REPEAT
GETFILE myfile$ FROM mydir3
IF RIGHT$(DIRS$ & myfile$,4) = ".png" THEN
PRINT " Get png"
Searchdir$ = OSMDIR$ & DIRS$
INCR first
IF NOT(INSTR(myfile$,"S")) THEN
DESTINATION$ = FDIR$ & myfile$
SOURCER$ = FDIR$ & "S" & myfile$
IF NOT(FILEEXISTS(SOURCER$)) THEN
OSMTILE$ = "https://a.tile.openstreetmap.org/" & STR$(ZOOM) & "/" & DIRS$ & myfile$
TILE$ ="http://t1.openseamap.org/seamark/" & STR$(ZOOM) & "/" & DIRS$ & myfile$
PRINT TILE$
IF REBUILD THEN
Cmd$ = "wget " & OSMTILE$ & " -O " & FDIR$ & myfile$
SYSTEM(Cmd$)
END IF
Cmd$ = "wget " & TILE$ & " -O " & FDIR$ & "S" & myfile$
SYSTEM(Cmd$)
LOCAL im1 , im2 TYPE GdkPixbuf*
im1 = gdk_pixbuf_new_from_file(DESTINATION$ , NULL)
im2 = gdk_pixbuf_new_from_file(SOURCER$, NULL)
w = gdk_pixbuf_get_width(im2)
h = gdk_pixbuf_get_height(im2)
IF w = -1 THEN
ELSE
gdk_pixbuf_composite(im2, im1, 0, 0, w, h, 0,0, 1,1, 0,255)
gdk_pixbuf_save (im1,DESTINATION$, "png", 0, NULL, NULL, NULL)
END IF
g_object_unref(im1)
g_object_unref(im2)
PRINT "========================================"
END IF
END IF
END IF
UNTIL ISFALSE(LEN(myfile$))
END IF
UNTIL ISFALSE(LEN(getfile$))
UNTIL ISFALSE(LEN(myfile$))
PRINT "converted : " , first
CLOSE DIRECTORY mydir
CLOSE DIRECTORY mydir3
CLOSE DIRECTORY mydir2
END SUB
'Dir : /home/pi/bacon-osm-maps/8/./
'/home/pi/bacon-osm-maps/8/
/*
Dir : /home/pi/bacon-osm-maps/8/./
Dir : /home/pi/bacon-osm-maps/8/81.png/
Runtime error: statement 'OPEN FOR DIRECTORY' at line 33 in '/home/pi/Downloads/seamap_converter.bac': Error opening file: No such file or directory
*/
' EXAMPLE ================================="
HOME$ = GETENVIRON$("HOME")
SEARCHDIR$ = HOME$ & "/bacon-osm-maps/"
'search dir , zoom ,rebuild TRUE/FALSE)
'FOR T = 13 TO 16
'UPDATE_SEAMAPS(SEARCHDIR$,9,0)
'NEXT
BR
Alex