45use,
INTRINSIC :: iso_c_binding
50INTEGER,
PARAMETER :: READOSM_UNDEFINED = -1234567890
51INTEGER,
PARAMETER :: READOSM_MEMBER_NODE = 7361
52INTEGER,
PARAMETER :: READOSM_MEMBER_WAY = 6731
53INTEGER,
PARAMETER :: READOSM_MEMBER_RELATION = 3671
54INTEGER,
PARAMETER :: READOSM_OK = 0
55INTEGER,
PARAMETER :: READOSM_INVALID_SUFFIX = -1
56INTEGER,
PARAMETER :: READOSM_FILE_NOT_FOUND = -2
57INTEGER,
PARAMETER :: READOSM_NULL_HANDLE = -3
58INTEGER,
PARAMETER :: READOSM_INVALID_HANDLE = -4
59INTEGER,
PARAMETER :: READOSM_INSUFFICIENT_MEMORY = -5
60INTEGER,
PARAMETER :: READOSM_CREATE_XML_PARSER_ERROR = -6
61INTEGER,
PARAMETER :: readosm_read_error = -7
62INTEGER,
PARAMETER :: readosm_xml_error = -8
63INTEGER,
PARAMETER :: readosm_invalid_pbf_header = -9
64INTEGER,
PARAMETER :: readosm_unzip_error = -10
65INTEGER,
PARAMETER :: readosm_abort = -11
76 CHARACTER(kind=c_char,len=1),
ALLOCATABLE :: key(:)
77 CHARACTER(kind=c_char,len=1),
ALLOCATABLE ::
value(:)
90TYPE,
BIND(C) :: readosm_node
91 INTEGER(kind=c_long_long) :: id
92 REAL(kind=c_double) :: latitude
93 REAL(kind=c_double) :: longitude
94 INTEGER(kind=c_int) :: version
95 INTEGER(kind=c_long_long) :: changeset
97 INTEGER(kind=c_int) :: uid
98 TYPE(c_ptr) :: timestamp
99 INTEGER(kind=c_int) :: tag_count
105 INTEGER(kind=c_long_long) :: id=0
106 REAL(kind=c_double) :: latitude
107 REAL(kind=c_double) :: longitude
108 INTEGER(kind=c_int) :: version
109 INTEGER(kind=c_long_long) :: changeset
111 INTEGER(kind=c_int) :: uid
130 INTEGER(kind=c_long_long) :: id
131 INTEGER(kind=c_int) :: version;
132 INTEGER(kind=c_long_long) :: changeset
134 INTEGER(kind=c_int) :: uid
135 TYPE(c_ptr) :: timestamp;
136 INTEGER(kind=c_int) :: node_ref_count
137 TYPE(c_ptr) :: node_refs
138 INTEGER(kind=c_int) :: tag_count
144 INTEGER(kind=c_long_long) :: id=0
145 INTEGER(kind=c_int) :: version;
146 INTEGER(kind=c_long_long) :: changeset;
148 INTEGER(kind=c_int) :: uid
150 INTEGER(kind=c_long_long),
ALLOCATABLE :: node_refs(:)
162 INTEGER(kind=c_int) :: member_type
163 INTEGER(kind=c_long_long) :: id
169 INTEGER(kind=c_int) :: member_type=readosm_undefined
170 INTEGER(kind=c_long_long) :: id
171 CHARACTER(kind=c_char,len=1),
ALLOCATABLE :: role(:)
187 INTEGER(kind=c_long_long) :: id
188 INTEGER(kind=c_int) :: version;
189 INTEGER(kind=c_long_long) :: changeset;
191 INTEGER(kind=c_int) :: uid
192 TYPE(c_ptr) :: timestamp;
193 INTEGER(kind=c_int) :: member_count
194 TYPE(c_ptr) :: members
195 INTEGER(kind=c_int) :: tag_count;
201 INTEGER(kind=c_long_long) :: id
202 INTEGER(kind=c_int) :: version;
203 INTEGER(kind=c_long_long) :: changeset;
205 INTEGER(kind=c_int) :: uid
214#undef ARRAYOF_ORIGTYPE
216#define ARRAYOF_ORIGTYPE TYPE(readosm_node_f)
217#define ARRAYOF_TYPE arrayof_readosm_node_f
218#include "arrayof_pre.F90"
220#undef ARRAYOF_ORIGTYPE
222#define ARRAYOF_ORIGTYPE TYPE(readosm_way_f)
223#define ARRAYOF_TYPE arrayof_readosm_way_f
224#include "arrayof_pre.F90"
226#undef ARRAYOF_ORIGTYPE
228#define ARRAYOF_ORIGTYPE TYPE(readosm_relation_f)
229#define ARRAYOF_TYPE arrayof_readosm_relation_f
230#include "arrayof_pre.F90"
253 CHARACTER(kind=c_char),
INTENT(in) :: path(*)
254 TYPE(c_ptr),
INTENT(out) :: osm_handle
268 TYPE(c_ptr),
VALUE :: osm_handle
269 INTEGER(kind=c_int) :: readosm_close
286 FUNCTION readosm_parse(osm_handle, user_data, node_fnct, way_fnct, &
287 relation_fnct) bind(C,name='readosm_parse')
289 TYPE(c_ptr),
VALUE :: osm_handle
290 TYPE(c_ptr),
VALUE :: user_data
291 TYPE(c_funptr),
VALUE :: node_fnct
292 TYPE(c_funptr),
VALUE :: way_fnct
293 TYPE(c_funptr),
VALUE :: relation_fnct
294 INTEGER(kind=c_int) :: readosm_parse
297 MODULE PROCEDURE readosm_parse_f
301INTERFACE readosm_object_f
302 MODULE PROCEDURE readosm_object_f_node, readosm_object_f_way, &
303 readosm_object_f_relation
304END INTERFACE readosm_object_f
310PRIVATE readosm_object_f_node, readosm_object_f_way, &
311 readosm_object_f_relation
322FUNCTION readosm_parse_f(osm_handle, user_data, node_fnct, way_fnct, &
324TYPE(c_ptr),
VALUE :: osm_handle
325TYPE(c_ptr),
VALUE :: user_data
326INTERFACE !< callback
function intended to consume node objects (may be NULL if processing NODEs is not an interesting option)
327 FUNCTION node_fnct(user_data, node)
BIND(C)
329 TYPE(c_ptr),
VALUE :: user_data
330 TYPE(readosm_node) :: node
331 INTEGER(kind=c_int) :: node_fnct
332 END FUNCTION node_fnct
337 FUNCTION way_fnct(user_data, way)
BIND(C)
339 TYPE(c_ptr),
VALUE :: user_data
341 INTEGER(kind=c_int) :: way_fnct
342 END FUNCTION way_fnct
347 FUNCTION relation_fnct(user_data, relation)
BIND(C)
349 TYPE(c_ptr),
VALUE :: user_data
351 INTEGER(kind=c_int) :: relation_fnct
352 END FUNCTION relation_fnct
357OPTIONAL :: relation_fnct
358INTEGER(kind=c_int) :: readosm_parse_f
360TYPE(c_funptr) :: nf, wf, rf
362IF (
present(node_fnct))
THEN
363 nf = c_funloc(node_fnct)
367IF (
present(way_fnct))
THEN
368 wf = c_funloc(way_fnct)
372IF (
present(relation_fnct))
THEN
373 rf = c_funloc(relation_fnct)
378readosm_parse_f =
readosm_parse(osm_handle, user_data, nf, wf, rf)
380END FUNCTION readosm_parse_f
386SUBROUTINE readosm_object_f_tags(tags, tag_count, f_type)
388INTEGER(kind=c_int) :: tag_count;
395IF (tag_count > 0 .AND. c_associated(tags))
THEN
396 CALL c_f_pointer(tags, tmptags, (/tag_count/))
397 ALLOCATE(f_type(tag_count))
399 f_type(i)%key = tmptags(i)%key
400 f_type(i)%value = tmptags(i)%value
406END SUBROUTINE readosm_object_f_tags
412SUBROUTINE readosm_object_f_members(members, member_count, f_type)
413TYPE(c_ptr) :: members
414INTEGER(kind=c_int) :: member_count;
421IF (member_count > 0 .AND. c_associated(members))
THEN
422 CALL c_f_pointer(members, tmpmembers, (/member_count/))
423 ALLOCATE(f_type(member_count))
424 DO i = 1, member_count
425 f_type(i)%member_type = tmpmembers(i)%member_type
426 f_type(i)%id = tmpmembers(i)%id
427 f_type(i)%role = tmpmembers(i)%role
433END SUBROUTINE readosm_object_f_members
436FUNCTION readosm_object_f_node(c_type)
RESULT(f_type)
442f_type%latitude = c_type%latitude
443f_type%longitude = c_type%longitude
444f_type%version = c_type%version
445f_type%changeset = c_type%changeset
447f_type%uid = c_type%uid
449CALL readosm_object_f_tags(c_type%tags, c_type%tag_count, f_type%tags)
452END FUNCTION readosm_object_f_node
455FUNCTION readosm_object_f_way(c_type)
RESULT(f_type)
460INTEGER(kind=c_long_long),
POINTER :: node_refs(:)
463f_type%version = c_type%version
464f_type%changeset = c_type%changeset
466f_type%uid = c_type%uid
468IF (c_type%node_ref_count > 0 .AND. c_associated(c_type%node_refs))
THEN
469 CALL c_f_pointer(c_type%node_refs, node_refs, (/c_type%node_ref_count/))
470 f_type%node_refs = node_refs
472 ALLOCATE(f_type%node_refs(0))
474CALL readosm_object_f_tags(c_type%tags, c_type%tag_count, f_type%tags)
477END FUNCTION readosm_object_f_way
480FUNCTION readosm_object_f_relation(c_type)
RESULT(f_type)
486f_type%version = c_type%version
487f_type%changeset = c_type%changeset
489f_type%uid = c_type%uid
491CALL readosm_object_f_members(c_type%members, c_type%member_count, f_type%members)
492CALL readosm_object_f_tags(c_type%tags, c_type%tag_count, f_type%tags)
495END FUNCTION readosm_object_f_relation
501#undef ARRAYOF_ORIGTYPE
503#define ARRAYOF_ORIGTYPE TYPE(readosm_node_f)
504#define ARRAYOF_TYPE arrayof_readosm_node_f
505#include "arrayof_post.F90"
507#undef ARRAYOF_ORIGTYPE
509#define ARRAYOF_ORIGTYPE TYPE(readosm_way_f)
510#define ARRAYOF_TYPE arrayof_readosm_way_f
511#include "arrayof_post.F90"
513#undef ARRAYOF_ORIGTYPE
515#define ARRAYOF_ORIGTYPE TYPE(readosm_relation_f)
516#define ARRAYOF_TYPE arrayof_readosm_relation_f
517#include "arrayof_post.F90"
529FUNCTION readosm_parse_full_f(osm_handle, fulldata)
530TYPE(c_ptr),
VALUE :: osm_handle
531TYPE(readosm_full_f),
INTENT(inout),
TARGET :: fulldata
532INTEGER :: readosm_parse_full_f
535readosm_parse_full_f =
readosm_parse(osm_handle, c_loc(fulldata), &
536 readosm_full_node, readosm_full_way, readosm_full_relation)
542END FUNCTION readosm_parse_full_f
548FUNCTION readosm_full_node(user_data, node)
BIND(C)
549TYPE(c_ptr),
VALUE :: user_data
550TYPE(readosm_node) :: node
551INTEGER(kind=c_int) :: readosm_full_node
553TYPE(readosm_full_f),
POINTER :: fulldata
557CALL c_f_pointer(user_data, fulldata)
558CALL insert(fulldata%nodes, readosm_object_f(node))
560readosm_full_node = readosm_ok
562END FUNCTION readosm_full_node
568FUNCTION readosm_full_way(user_data, way)
BIND(C)
569TYPE(c_ptr),
VALUE :: user_data
571INTEGER(kind=c_int) :: readosm_full_way
577CALL c_f_pointer(user_data, fulldata)
578CALL insert(fulldata%ways, readosm_object_f(way))
580readosm_full_way = readosm_ok
582END FUNCTION readosm_full_way
588FUNCTION readosm_full_relation(user_data, relation)
BIND(C)
589TYPE(c_ptr),
VALUE :: user_data
591INTEGER(kind=c_int) :: readosm_full_relation
597CALL c_f_pointer(user_data, fulldata)
598CALL insert(fulldata%relations, readosm_object_f(relation))
600readosm_full_relation = readosm_ok
602END FUNCTION readosm_full_relation
Quick method to append an element to the array.
Destructor for finalizing an array object.
Method for inserting elements of the array at a desired position.
Method for packing the array object reducing at a minimum the memory occupation, without destroying i...
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.
Method for removing elements of the array at a desired position.
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.
Derived type defining a dynamically extensible array of TYPE(readosm_node_f) elements.
Derived type defining a dynamically extensible array of TYPE(readosm_relation_f) elements.
Derived type defining a dynamically extensible array of TYPE(readosm_way_f) elements.
Derived type for performing a prepackaged full parsing of an osm file.
A more Fortran-friendly object describing a RELATION-MEMEBER structure.
Object describing a RELATION-MEMBER structure.
A more Fortran-friendly object describing a NODE structure.
Object describing a NODE structure.
A more Fortran-friendly object describing a RELATION structure.
Object describing a RELATION structure.
A more Fortran-friendly object describing a TAG structure.
Object describing a TAG structure.
A more Fortran-friendly object describing a WAY structure.
Object describing a WAY structure.