readosm  1.1.0a
readosm.h
Go to the documentation of this file.
1 /*
2 / readosm.h
3 /
4 / public declarations
5 /
6 / version 1.1.0, 2017 September 25
7 /
8 / Author: Sandro Furieri a.furieri@lqt.it
9 /
10 / ------------------------------------------------------------------------------
11 /
12 / Version: MPL 1.1/GPL 2.0/LGPL 2.1
13 /
14 / The contents of this file are subject to the Mozilla Public License Version
15 / 1.1 (the "License"); you may not use this file except in compliance with
16 / the License. You may obtain a copy of the License at
17 / http://www.mozilla.org/MPL/
18 /
19 / Software distributed under the License is distributed on an "AS IS" basis,
20 / WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
21 / for the specific language governing rights and limitations under the
22 / License.
23 /
24 / The Original Code is the ReadOSM library
25 /
26 / The Initial Developer of the Original Code is Alessandro Furieri
27 /
28 / Portions created by the Initial Developer are Copyright (C) 2012-2017
29 / the Initial Developer. All Rights Reserved.
30 /
31 / Contributor(s):
32 /
33 / Alternatively, the contents of this file may be used under the terms of
34 / either the GNU General Public License Version 2 or later (the "GPL"), or
35 / the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
36 / in which case the provisions of the GPL or the LGPL are applicable instead
37 / of those above. If you wish to allow use of your version of this file only
38 / under the terms of either the GPL or the LGPL, and not to allow others to
39 / use your version of this file under the terms of the MPL, indicate your
40 / decision by deleting the provisions above and replace them with the notice
41 / and other provisions required by the GPL or the LGPL. If you do not delete
42 / the provisions above, a recipient may use your version of this file under
43 / the terms of any one of the MPL, the GPL or the LGPL.
44 /
45 */
46 
52 #ifndef DOXYGEN_SHOULD_SKIP_THIS
53 #ifdef _WIN32
54 #ifdef DLL_EXPORT
55 #define READOSM_DECLARE __declspec(dllexport)
56 #define READOSM_PRIVATE
57 #else
58 #define READOSM_DECLARE extern
59 #define READOSM_PRIVATE
60 #endif
61 #else
62 #define READOSM_DECLARE __attribute__ ((visibility("default")))
63 #define READOSM_PRIVATE __attribute__ ((visibility("hidden")))
64 #endif
65 #endif
66 
67 #ifndef _READOSM_H
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69 #define _READOSM_H
70 #endif
71 
72 #ifdef __cplusplus
73 extern "C"
74 {
75 #endif
76 
77 /* constants */
79 #define READOSM_UNDEFINED -1234567890
81 #define READOSM_MEMBER_NODE 7361
83 #define READOSM_MEMBER_WAY 6731
85 #define READOSM_MEMBER_RELATION 3671
86 
87 /* Error codes */
88 #define READOSM_OK 0
89 #define READOSM_INVALID_SUFFIX -1
90 #define READOSM_FILE_NOT_FOUND -2
92 #define READOSM_NULL_HANDLE -3
93 #define READOSM_INVALID_HANDLE -4
94 #define READOSM_INSUFFICIENT_MEMORY -5
96 #define READOSM_CREATE_XML_PARSER_ERROR -6
97 #define READOSM_READ_ERROR -7
98 #define READOSM_XML_ERROR -8
99 #define READOSM_INVALID_PBF_HEADER -9
100 #define READOSM_UNZIP_ERROR -10
101 #define READOSM_ABORT -11
110  {
111 
112  const char *key;
113  const char *value;
114  };
115 
121  typedef struct readosm_tag_struct readosm_tag;
122 
133  {
134  const long long id;
135  const double latitude;
136  const double longitude;
137  const int version;
138  const long long changeset;
139  const char *user;
140  const int uid;
141  const char *timestamp;
142  const int tag_count;
143  const readosm_tag *tags;
144  };
145 
151  typedef struct readosm_node_struct readosm_node;
152 
166  {
167  const long long id;
168  const int version;
169  const long long changeset;
170  const char *user;
171  const int uid;
172  const char *timestamp;
173  const int node_ref_count;
174  const long long *node_refs;
175  const int tag_count;
176  const readosm_tag *tags;
177  };
178 
184  typedef struct readosm_way_struct readosm_way;
185 
193  {
194 
195  const int member_type;
196  const long long id;
197  const char *role;
198  };
199 
205  typedef struct readosm_member_struct readosm_member;
206 
207 
220  {
221  const long long id;
222  const int version;
223  const long long changeset;
224  const char *user;
225  const int uid;
226  const char *timestamp;
227  const int member_count;
229  const int tag_count;
230  const readosm_tag *tags;
231  };
232 
239 
241  typedef int (*readosm_node_callback) (const void *user_data,
242  const readosm_node * node);
243 
245  typedef int (*readosm_way_callback) (const void *user_data,
246  const readosm_way * way);
247 
249  typedef int (*readosm_relation_callback) (const void *user_data,
250  const readosm_relation *
251  relation);
252 
266  READOSM_DECLARE int readosm_open (const char *path,
267  const void **osm_handle);
268 
280  READOSM_DECLARE int readosm_close (const void *osm_handle);
281 
300  READOSM_DECLARE int readosm_parse (const void *osm_handle,
301  const void *user_data,
302  readosm_node_callback node_fnct,
303  readosm_way_callback way_fnct,
304  readosm_relation_callback relation_fnct);
305 
311  READOSM_DECLARE const char * readosm_version (void);
312 
318  READOSM_DECLARE const char * readosm_expat_version (void);
319 
325  READOSM_DECLARE const char * readosm_zlib_version (void);
326 
327 #ifdef __cplusplus
328 }
329 #endif
330 
331 #endif /* _READOSM_H */
int(* readosm_relation_callback)(const void *user_data, const readosm_relation *relation)
callback function handling RELATION objects
Definition: readosm.h:249
READOSM_DECLARE int readosm_parse(const void *osm_handle, const void *user_data, readosm_node_callback node_fnct, readosm_way_callback way_fnct, readosm_relation_callback relation_fnct)
Close the .osm or .pbf file and release any allocated resource.
int(* readosm_way_callback)(const void *user_data, const readosm_way *way)
callback function handling WAY objects
Definition: readosm.h:245
READOSM_DECLARE const char * readosm_version(void)
Return the current ReadOSM version.
READOSM_DECLARE int readosm_close(const void *osm_handle)
Close the .osm or .pbf file and release any allocated resource.
int(* readosm_node_callback)(const void *user_data, const readosm_node *node)
callback function handling NODE objects
Definition: readosm.h:241
READOSM_DECLARE int readosm_open(const char *path, const void **osm_handle)
Open the .osm or .pbf file, preparing for future functions.
READOSM_DECLARE const char * readosm_zlib_version(void)
Return the current zlib version used by ReadOSM.
READOSM_DECLARE const char * readosm_expat_version(void)
Return the current libexpat version used by ReadOSM.
Definition: readosm.h:193
const char * role
intended role for this reference
Definition: readosm.h:197
const int member_type
can be one of: READOSM_MEMBER_NODE, READOSM_MEMBER_WAY or READOSM_MEMBER_RELATION
Definition: readosm.h:195
const long long id
ID-value identifying the referenced object.
Definition: readosm.h:196
Definition: readosm.h:133
const double longitude
geographic longitude
Definition: readosm.h:136
const readosm_tag * tags
array of TAG objects (may be NULL)
Definition: readosm.h:143
const double latitude
geographic latitude
Definition: readosm.h:135
const int uid
corresponding numeric UserID
Definition: readosm.h:140
const int version
object version
Definition: readosm.h:137
const long long id
NODE-ID (expected to be a unique value)
Definition: readosm.h:134
const int tag_count
number of associated TAGs (may be zero)
Definition: readosm.h:142
const long long changeset
ChangeSet ID.
Definition: readosm.h:138
const char * timestamp
when this NODE was defined
Definition: readosm.h:141
const char * user
name of the User defining this NODE
Definition: readosm.h:139
Definition: readosm.h:220
const readosm_tag * tags
array of TAG objects (may be NULL)
Definition: readosm.h:230
const readosm_member * members
array of MEMBER objects (may be NULL)
Definition: readosm.h:228
const int tag_count
number of associated TAGs (may be zero)
Definition: readosm.h:229
const long long id
RELATION-ID (expected to be a unique value)
Definition: readosm.h:221
const long long changeset
ChangeSet ID.
Definition: readosm.h:223
const int version
object version
Definition: readosm.h:222
const int member_count
number of associated MEMBERs (may be zero)
Definition: readosm.h:227
const char * timestamp
when this RELATION was defined
Definition: readosm.h:226
const char * user
name of the User defining this RELATION
Definition: readosm.h:224
const int uid
corresponding numeric UserID
Definition: readosm.h:225
Definition: readosm.h:110
const char * key
the KEY
Definition: readosm.h:112
const char * value
the VALUE
Definition: readosm.h:113
Definition: readosm.h:166
const long long * node_refs
array of NODE-IDs (may be NULL)
Definition: readosm.h:174
const int version
object version
Definition: readosm.h:168
const char * user
name of the User defining this WAY
Definition: readosm.h:170
const int uid
corresponding numeric UserID
Definition: readosm.h:171
const long long changeset
ChangeSet ID.
Definition: readosm.h:169
const long long id
WAY-ID (expected to be a unique value)
Definition: readosm.h:167
const char * timestamp
when this WAY was defined
Definition: readosm.h:172
const int node_ref_count
number of referenced NODE-IDs (may be zero)
Definition: readosm.h:173
const readosm_tag * tags
array of TAG objects (may be NULL)
Definition: readosm.h:176
const int tag_count
number of associated TAGs (may be zero)
Definition: readosm.h:175