4 use,
INTRINSIC :: iso_c_binding
10 SUBROUTINE readosm_test_setup()
14 CHARACTER(len=512) :: file
16 CALL get_command_argument(1, file)
17 IF (len_trim(file) == 0) file =
'readosm_test.osm'
20 print*,
'Opening osm file ',trim(file)
22 IF (err /= readosm_ok)
THEN
23 print*,
'Error opening osm file ',err
30 print*,
'Parsing osm file with user-defined callback'
32 node_fnct=node_callback)
33 IF (err /= readosm_ok)
THEN
34 print*,
'Error parsing osm file ',err
39 print*,
'Closing osm file'
41 IF (err /= readosm_ok)
THEN
42 print*,
'Error closing osm file ',err
46 END SUBROUTINE readosm_test_setup
50 FUNCTION node_callback(user_data, node)
51 TYPE(c_ptr),
VALUE :: user_data
52 TYPE(readosm_node) :: node
53 INTEGER(kind=c_int) :: node_callback
55 TYPE(readosm_node_f) :: node_f
59 print*,node%longitude,node%latitude
62 node_f = readosm_object_f(node)
65 IF (
ALLOCATED(node_f%tags))
THEN
66 DO i = 1,
SIZE(node_f%tags)
73 node_callback = readosm_ok
75 END FUNCTION node_callback
79 SUBROUTINE readosm_test_setup_full()
83 TYPE(readosm_full_f) :: fulldata
84 CHARACTER(len=512) :: file
86 CHARACTER(len=1),
ALLOCATABLE :: key(:), val(:)
89 IF (len_trim(file) == 0) file =
'readosm_test.osm'
92 print*,
'Opening osm file ',trim(file)
94 IF (err /= readosm_ok)
THEN
95 print*,
'Error opening osm file ',err
100 print*,
'Parsing osm file with predefined callbacks'
101 err = readosm_parse_full_f(handle, fulldata)
102 IF (err /= readosm_ok)
THEN
103 print*,
'Error parsing osm file ',err
110 DO j = 1, fulldata%nodes%arraysize
111 print*,fulldata%nodes%array(j)%longitude,fulldata%nodes%array(j)%latitude
112 IF (
ALLOCATED(fulldata%nodes%array(j)%tags))
THEN
113 DO i = 1,
SIZE(fulldata%nodes%array(j)%tags)
114 key = fulldata%nodes%array(j)%tags(i)%key
115 val = fulldata%nodes%array(j)%tags(i)%value
124 print*,
'Closing osm file'
126 IF (err /= readosm_ok)
THEN
127 print*,
'Error closing osm file ',err
133 END SUBROUTINE readosm_test_setup_full
136 END MODULE readosm_test
139 PROGRAM readosm_test_main
143 CALL readosm_test_setup()
144 CALL readosm_test_setup_full()
146 END PROGRAM readosm_test_main
Close the .osm or .pbf file and release any allocated resource.
Open the .osm or .pbf file, preparing for future functions.
Parse the corresponding file calling the selected callbacks for every entity encountered.
Utility module for supporting Fortran 2003 C language interface module.
Fortran 2003 interface to the readosm https://www.gaia-gis.it/fossil/readosm/index library.