4use,
INTRINSIC :: iso_c_binding
10SUBROUTINE readosm_test_setup()
14CHARACTER(len=512) :: file
16CALL get_command_argument(1, file)
17IF (len_trim(file) == 0) file =
'readosm_test.osm'
20print*,
'Opening osm file ',trim(file)
22IF (err /= readosm_ok)
THEN
23 print*,
'Error opening osm file ',err
30print*,
'Parsing osm file with user-defined callback'
32 node_fnct=node_callback)
33IF (err /= readosm_ok)
THEN
34 print*,
'Error parsing osm file ',err
39print*,
'Closing osm file'
41IF (err /= readosm_ok)
THEN
42 print*,
'Error closing osm file ',err
46END SUBROUTINE readosm_test_setup
50FUNCTION node_callback(user_data, node)
51TYPE(c_ptr),
VALUE :: user_data
52TYPE(readosm_node) :: node
53INTEGER(kind=c_int) :: node_callback
55TYPE(readosm_node_f) :: node_f
59print*,node%longitude,node%latitude
62node_f = readosm_object_f(node)
65IF (
ALLOCATED(node_f%tags))
THEN
66 DO i = 1,
SIZE(node_f%tags)
73node_callback = readosm_ok
75END FUNCTION node_callback
79SUBROUTINE readosm_test_setup_full()
83TYPE(readosm_full_f) :: fulldata
84CHARACTER(len=512) :: file
86CHARACTER(len=1),
ALLOCATABLE :: key(:), val(:)
89IF (len_trim(file) == 0) file =
'readosm_test.osm'
92print*,
'Opening osm file ',trim(file)
94IF (err /= readosm_ok)
THEN
95 print*,
'Error opening osm file ',err
100print*,
'Parsing osm file with predefined callbacks'
101err = readosm_parse_full_f(handle, fulldata)
102IF (err /= readosm_ok)
THEN
103 print*,
'Error parsing osm file ',err
110DO 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
124print*,
'Closing osm file'
126IF (err /= readosm_ok)
THEN
127 print*,
'Error closing osm file ',err
133END SUBROUTINE readosm_test_setup_full
136END MODULE readosm_test
139PROGRAM readosm_test_main
143CALL readosm_test_setup()
144CALL readosm_test_setup_full()
146END 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.