Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /branches/libroutino/src/osmxmlparse.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1711 - (show annotations) (download) (as text)
Tue Jun 16 19:05:31 2015 UTC (9 years, 9 months ago) by amb
File MIME type: text/x-csrc
File size: 21989 byte(s)
Audit the use of file static variables to make sure that there are no
implicit assumptions about initialisation conditions that would be
wrong for library usage.  Fix problems and add comments for clarity.

1 /***************************************
2 OSM XML file parser (either JOSM or planet)
3
4 Part of the Routino routing software.
5 ******************/ /******************
6 This file Copyright 2008-2015 Andrew M. Bishop
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
17
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ***************************************/
21
22
23 #include <stdlib.h>
24 #include <string.h>
25 #include <inttypes.h>
26 #include <stdint.h>
27
28 #include "osmparser.h"
29 #include "xmlparse.h"
30 #include "tagging.h"
31 #include "logging.h"
32
33
34 /* Local parsing variables (re-initialised for each file) */
35
36 static int current_mode=MODE_NORMAL;
37
38 static uint64_t nnodes,nways,nrelations;
39
40 static TagList *current_tags;
41
42
43 /* The XML tag processing function prototypes */
44
45 //static int xmlDeclaration_function(const char *_tag_,int _type_,const char *version,const char *encoding);
46 static int osmType_function(const char *_tag_,int _type_,const char *version);
47 static int osmChangeType_function(const char *_tag_,int _type_,const char *version);
48 //static int boundsType_function(const char *_tag_,int _type_);
49 //static int boundType_function(const char *_tag_,int _type_);
50 static int changesetType_function(const char *_tag_,int _type_);
51 static int modifyType_function(const char *_tag_,int _type_);
52 static int createType_function(const char *_tag_,int _type_);
53 static int deleteType_function(const char *_tag_,int _type_);
54 static int nodeType_function(const char *_tag_,int _type_,const char *id,const char *lat,const char *lon);
55 static int wayType_function(const char *_tag_,int _type_,const char *id);
56 static int relationType_function(const char *_tag_,int _type_,const char *id);
57 static int tagType_function(const char *_tag_,int _type_,const char *k,const char *v);
58 static int ndType_function(const char *_tag_,int _type_,const char *ref);
59 static int memberType_function(const char *_tag_,int _type_,const char *type,const char *ref,const char *role);
60
61
62 /* The XML tag definitions (forward declarations) */
63
64 static xmltag xmlDeclaration_tag;
65 static xmltag osmType_tag;
66 static xmltag osmChangeType_tag;
67 static xmltag boundsType_tag;
68 static xmltag boundType_tag;
69 static xmltag changesetType_tag;
70 static xmltag modifyType_tag;
71 static xmltag createType_tag;
72 static xmltag deleteType_tag;
73 static xmltag nodeType_tag;
74 static xmltag wayType_tag;
75 static xmltag relationType_tag;
76 static xmltag tagType_tag;
77 static xmltag ndType_tag;
78 static xmltag memberType_tag;
79
80
81 /* The XML tag definition values */
82
83 /*+ The complete set of tags at the top level for OSM. +*/
84 static xmltag *xml_osm_toplevel_tags[]={&xmlDeclaration_tag,&osmType_tag,NULL};
85
86 /*+ The complete set of tags at the top level for OSC. +*/
87 static xmltag *xml_osc_toplevel_tags[]={&xmlDeclaration_tag,&osmChangeType_tag,NULL};
88
89 /*+ The xmlDeclaration type tag. +*/
90 static xmltag xmlDeclaration_tag=
91 {"xml",
92 2, {"version","encoding"},
93 NULL,
94 {NULL}};
95
96 /*+ The osmType type tag. +*/
97 static xmltag osmType_tag=
98 {"osm",
99 1, {"version"},
100 osmType_function,
101 {&boundsType_tag,&boundType_tag,&changesetType_tag,&nodeType_tag,&wayType_tag,&relationType_tag,NULL}};
102
103 /*+ The osmChangeType type tag. +*/
104 static xmltag osmChangeType_tag=
105 {"osmChange",
106 1, {"version"},
107 osmChangeType_function,
108 {&boundsType_tag,&modifyType_tag,&createType_tag,&deleteType_tag,NULL}};
109
110 /*+ The boundsType type tag. +*/
111 static xmltag boundsType_tag=
112 {"bounds",
113 0, {NULL},
114 NULL,
115 {NULL}};
116
117 /*+ The boundType type tag. +*/
118 static xmltag boundType_tag=
119 {"bound",
120 0, {NULL},
121 NULL,
122 {NULL}};
123
124 /*+ The changesetType type tag. +*/
125 static xmltag changesetType_tag=
126 {"changeset",
127 0, {NULL},
128 changesetType_function,
129 {&tagType_tag,NULL}};
130
131 /*+ The modifyType type tag. +*/
132 static xmltag modifyType_tag=
133 {"modify",
134 0, {NULL},
135 modifyType_function,
136 {&nodeType_tag,&wayType_tag,&relationType_tag,NULL}};
137
138 /*+ The createType type tag. +*/
139 static xmltag createType_tag=
140 {"create",
141 0, {NULL},
142 createType_function,
143 {&nodeType_tag,&wayType_tag,&relationType_tag,NULL}};
144
145 /*+ The deleteType type tag. +*/
146 static xmltag deleteType_tag=
147 {"delete",
148 0, {NULL},
149 deleteType_function,
150 {&nodeType_tag,&wayType_tag,&relationType_tag,NULL}};
151
152 /*+ The nodeType type tag. +*/
153 static xmltag nodeType_tag=
154 {"node",
155 3, {"id","lat","lon"},
156 nodeType_function,
157 {&tagType_tag,NULL}};
158
159 /*+ The wayType type tag. +*/
160 static xmltag wayType_tag=
161 {"way",
162 1, {"id"},
163 wayType_function,
164 {&ndType_tag,&tagType_tag,NULL}};
165
166 /*+ The relationType type tag. +*/
167 static xmltag relationType_tag=
168 {"relation",
169 1, {"id"},
170 relationType_function,
171 {&memberType_tag,&tagType_tag,NULL}};
172
173 /*+ The tagType type tag. +*/
174 static xmltag tagType_tag=
175 {"tag",
176 2, {"k","v"},
177 tagType_function,
178 {NULL}};
179
180 /*+ The ndType type tag. +*/
181 static xmltag ndType_tag=
182 {"nd",
183 1, {"ref"},
184 ndType_function,
185 {NULL}};
186
187 /*+ The memberType type tag. +*/
188 static xmltag memberType_tag=
189 {"member",
190 3, {"type","ref","role"},
191 memberType_function,
192 {NULL}};
193
194
195 /* The XML tag processing functions */
196
197
198 /*++++++++++++++++++++++++++++++++++++++
199 The function that is called when the XML declaration is seen
200
201 int xmlDeclaration_function Returns 0 if no error occured or something else otherwise.
202
203 const char *_tag_ Set to the name of the element tag that triggered this function call.
204
205 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
206
207 const char *version The contents of the 'version' attribute (or NULL if not defined).
208
209 const char *encoding The contents of the 'encoding' attribute (or NULL if not defined).
210 ++++++++++++++++++++++++++++++++++++++*/
211
212 //static int xmlDeclaration_function(const char *_tag_,int _type_,const char *version,const char *encoding)
213 //{
214 // return(0);
215 //}
216
217
218 /*++++++++++++++++++++++++++++++++++++++
219 The function that is called when the osmType XSD type is seen
220
221 int osmType_function Returns 0 if no error occured or something else otherwise.
222
223 const char *_tag_ Set to the name of the element tag that triggered this function call.
224
225 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
226
227 const char *version The contents of the 'version' attribute (or NULL if not defined).
228 ++++++++++++++++++++++++++++++++++++++*/
229
230 static int osmType_function(const char *_tag_,int _type_,const char *version)
231 {
232 /* Print the initial message */
233
234 if(_type_&XMLPARSE_TAG_START)
235 printf_first("Read: Lines=%"PRIu64" Nodes=%"PRIu64" Ways=%"PRIu64" Relations=%"PRIu64,ParseXML_LineNumber(),nnodes=0,nways=0,nrelations=0);
236
237 /* Check the tag values */
238
239 if(_type_&XMLPARSE_TAG_START)
240 {
241 current_mode=MODE_NORMAL;
242
243 if(!version || strcmp(version,"0.6"))
244 XMLPARSE_MESSAGE(_tag_,"Invalid value for 'version' (only '0.6' accepted)");
245 }
246
247 /* Print the final message */
248
249 if(_type_&XMLPARSE_TAG_END)
250 printf_last("Read: Lines=%"PRIu64" Nodes=%"PRIu64" Ways=%"PRIu64" Relations=%"PRIu64,ParseXML_LineNumber(),nnodes,nways,nrelations);
251
252 return(0);
253 }
254
255
256 /*++++++++++++++++++++++++++++++++++++++
257 The function that is called when the osmChangeType XSD type is seen
258
259 int osmChangeType_function Returns 0 if no error occured or something else otherwise.
260
261 const char *_tag_ Set to the name of the element tag that triggered this function call.
262
263 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
264
265 const char *version The contents of the 'version' attribute (or NULL if not defined).
266 ++++++++++++++++++++++++++++++++++++++*/
267
268 static int osmChangeType_function(const char *_tag_,int _type_,const char *version)
269 {
270 /* Print the initial message */
271
272 if(_type_&XMLPARSE_TAG_START)
273 printf_first("Read: Lines=%"PRIu64" Nodes=%"PRIu64" Ways=%"PRIu64" Relations=%"PRIu64,ParseXML_LineNumber(),nnodes=0,nways=0,nrelations=0);
274
275 /* Check the tag values */
276
277 if(_type_&XMLPARSE_TAG_START)
278 {
279 if(!version || strcmp(version,"0.6"))
280 XMLPARSE_MESSAGE(_tag_,"Invalid value for 'version' (only '0.6' accepted)");
281 }
282
283 /* Print the final message */
284
285 if(_type_&XMLPARSE_TAG_END)
286 printf_last("Read: Lines=%"PRIu64" Nodes=%"PRIu64" Ways=%"PRIu64" Relations=%"PRIu64,ParseXML_LineNumber(),nnodes,nways,nrelations);
287
288 return(0);
289 }
290
291
292 /*++++++++++++++++++++++++++++++++++++++
293 The function that is called when the boundsType XSD type is seen
294
295 int boundsType_function Returns 0 if no error occured or something else otherwise.
296
297 const char *_tag_ Set to the name of the element tag that triggered this function call.
298
299 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
300 ++++++++++++++++++++++++++++++++++++++*/
301
302 //static int boundsType_function(const char *_tag_,int _type_)
303 //{
304 // return(0);
305 //}
306
307
308 /*++++++++++++++++++++++++++++++++++++++
309 The function that is called when the boundType XSD type is seen
310
311 int boundType_function Returns 0 if no error occured or something else otherwise.
312
313 const char *_tag_ Set to the name of the element tag that triggered this function call.
314
315 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
316 ++++++++++++++++++++++++++++++++++++++*/
317
318 //static int boundType_function(const char *_tag_,int _type_)
319 //{
320 // return(0);
321 //}
322
323
324 /*++++++++++++++++++++++++++++++++++++++
325 The function that is called when the changesetType XSD type is seen
326
327 int changesetType_function Returns 0 if no error occured or something else otherwise.
328
329 const char *_tag_ Set to the name of the element tag that triggered this function call.
330
331 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
332 ++++++++++++++++++++++++++++++++++++++*/
333
334 static int changesetType_function(const char *_tag_,int _type_)
335 {
336 current_tags=NULL;
337
338 return(0);
339 }
340
341
342 /*++++++++++++++++++++++++++++++++++++++
343 The function that is called when the modifyType XSD type is seen
344
345 int modifyType_function Returns 0 if no error occured or something else otherwise.
346
347 const char *_tag_ Set to the name of the element tag that triggered this function call.
348
349 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
350 ++++++++++++++++++++++++++++++++++++++*/
351
352 static int modifyType_function(const char *_tag_,int _type_)
353 {
354 if(_type_&XMLPARSE_TAG_START)
355 current_mode=MODE_MODIFY;
356
357 return(0);
358 }
359
360
361 /*++++++++++++++++++++++++++++++++++++++
362 The function that is called when the createType XSD type is seen
363
364 int createType_function Returns 0 if no error occured or something else otherwise.
365
366 const char *_tag_ Set to the name of the element tag that triggered this function call.
367
368 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
369 ++++++++++++++++++++++++++++++++++++++*/
370
371 static int createType_function(const char *_tag_,int _type_)
372 {
373 if(_type_&XMLPARSE_TAG_START)
374 current_mode=MODE_CREATE;
375
376 return(0);
377 }
378
379
380 /*++++++++++++++++++++++++++++++++++++++
381 The function that is called when the deleteType XSD type is seen
382
383 int deleteType_function Returns 0 if no error occured or something else otherwise.
384
385 const char *_tag_ Set to the name of the element tag that triggered this function call.
386
387 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
388 ++++++++++++++++++++++++++++++++++++++*/
389
390 static int deleteType_function(const char *_tag_,int _type_)
391 {
392 if(_type_&XMLPARSE_TAG_START)
393 current_mode=MODE_DELETE;
394
395 return(0);
396 }
397
398
399 /*++++++++++++++++++++++++++++++++++++++
400 The function that is called when the nodeType XSD type is seen
401
402 int nodeType_function Returns 0 if no error occured or something else otherwise.
403
404 const char *_tag_ Set to the name of the element tag that triggered this function call.
405
406 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
407
408 const char *id The contents of the 'id' attribute (or NULL if not defined).
409
410 const char *lat The contents of the 'lat' attribute (or NULL if not defined).
411
412 const char *lon The contents of the 'lon' attribute (or NULL if not defined).
413 ++++++++++++++++++++++++++++++++++++++*/
414
415 static int nodeType_function(const char *_tag_,int _type_,const char *id,const char *lat,const char *lon)
416 {
417 static int64_t llid; /* static variable to store attributes from <node> tag until </node> tag */
418 static double latitude,longitude; /* static variable to store attributes from <node> tag until </node> tag */
419
420 if(_type_&XMLPARSE_TAG_START)
421 {
422 nnodes++;
423
424 if(!(nnodes%10000))
425 printf_middle("Reading: Lines=%"PRIu64" Nodes=%"PRIu64" Ways=%"PRIu64" Relations=%"PRIu64,ParseXML_LineNumber(),nnodes,nways,nrelations);
426
427 current_tags=NewTagList();
428
429 /* Handle the node information */
430
431 XMLPARSE_ASSERT_INTEGER(_tag_,id); llid=atoll(id); /* need int64_t conversion */
432
433 if(current_mode!=MODE_DELETE)
434 {
435 XMLPARSE_ASSERT_FLOATING(_tag_,lat); latitude =atof(lat);
436 XMLPARSE_ASSERT_FLOATING(_tag_,lon); longitude=atof(lon);
437 }
438 }
439
440 if(_type_&XMLPARSE_TAG_END)
441 {
442 TagList *result=ApplyNodeTaggingRules(current_tags,llid);
443
444 ProcessNodeTags(result,llid,latitude,longitude,current_mode);
445
446 DeleteTagList(current_tags); current_tags=NULL;
447 DeleteTagList(result);
448 }
449
450 return(0);
451 }
452
453
454 /*++++++++++++++++++++++++++++++++++++++
455 The function that is called when the wayType XSD type is seen
456
457 int wayType_function Returns 0 if no error occured or something else otherwise.
458
459 const char *_tag_ Set to the name of the element tag that triggered this function call.
460
461 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
462
463 const char *id The contents of the 'id' attribute (or NULL if not defined).
464 ++++++++++++++++++++++++++++++++++++++*/
465
466 static int wayType_function(const char *_tag_,int _type_,const char *id)
467 {
468 static int64_t llid; /* static variable to store attributes from <way> tag until </way> tag */
469
470 if(_type_&XMLPARSE_TAG_START)
471 {
472 nways++;
473
474 if(!(nways%1000))
475 printf_middle("Reading: Lines=%"PRIu64" Nodes=%"PRIu64" Ways=%"PRIu64" Relations=%"PRIu64,ParseXML_LineNumber(),nnodes,nways,nrelations);
476
477 current_tags=NewTagList();
478
479 AddWayRefs(0);
480
481 /* Handle the way information */
482
483 XMLPARSE_ASSERT_INTEGER(_tag_,id); llid=atoll(id); /* need int64_t conversion */
484 }
485
486 if(_type_&XMLPARSE_TAG_END)
487 {
488 TagList *result=ApplyWayTaggingRules(current_tags,llid);
489
490 ProcessWayTags(result,llid,current_mode);
491
492 DeleteTagList(current_tags); current_tags=NULL;
493 DeleteTagList(result);
494 }
495
496 return(0);
497 }
498
499
500 /*++++++++++++++++++++++++++++++++++++++
501 The function that is called when the relationType XSD type is seen
502
503 int relationType_function Returns 0 if no error occured or something else otherwise.
504
505 const char *_tag_ Set to the name of the element tag that triggered this function call.
506
507 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
508
509 const char *id The contents of the 'id' attribute (or NULL if not defined).
510 ++++++++++++++++++++++++++++++++++++++*/
511
512 static int relationType_function(const char *_tag_,int _type_,const char *id)
513 {
514 static int64_t llid; /* static variable to store attributes from <relation> tag until </relation> tag */
515
516 if(_type_&XMLPARSE_TAG_START)
517 {
518 nrelations++;
519
520 if(!(nrelations%1000))
521 printf_middle("Reading: Lines=%"PRIu64" Nodes=%"PRIu64" Ways=%"PRIu64" Relations=%"PRIu64,ParseXML_LineNumber(),nnodes,nways,nrelations);
522
523 current_tags=NewTagList();
524
525 AddRelationRefs(0,0,0,NULL);
526
527 /* Handle the relation information */
528
529 XMLPARSE_ASSERT_INTEGER(_tag_,id); llid=atoll(id); /* need int64_t conversion */
530 }
531
532 if(_type_&XMLPARSE_TAG_END)
533 {
534 TagList *result=ApplyRelationTaggingRules(current_tags,llid);
535
536 ProcessRelationTags(result,llid,current_mode);
537
538 DeleteTagList(current_tags); current_tags=NULL;
539 DeleteTagList(result);
540 }
541
542 return(0);
543 }
544
545
546 /*++++++++++++++++++++++++++++++++++++++
547 The function that is called when the tagType XSD type is seen
548
549 int tagType_function Returns 0 if no error occured or something else otherwise.
550
551 const char *_tag_ Set to the name of the element tag that triggered this function call.
552
553 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
554
555 const char *k The contents of the 'k' attribute (or NULL if not defined).
556
557 const char *v The contents of the 'v' attribute (or NULL if not defined).
558 ++++++++++++++++++++++++++++++++++++++*/
559
560 static int tagType_function(const char *_tag_,int _type_,const char *k,const char *v)
561 {
562 if(_type_&XMLPARSE_TAG_START && current_tags)
563 {
564 XMLPARSE_ASSERT_STRING(_tag_,k);
565 XMLPARSE_ASSERT_STRING(_tag_,v);
566
567 AppendTag(current_tags,k,v);
568 }
569
570 return(0);
571 }
572
573
574 /*++++++++++++++++++++++++++++++++++++++
575 The function that is called when the ndType XSD type is seen
576
577 int ndType_function Returns 0 if no error occured or something else otherwise.
578
579 const char *_tag_ Set to the name of the element tag that triggered this function call.
580
581 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
582
583 const char *ref The contents of the 'ref' attribute (or NULL if not defined).
584 ++++++++++++++++++++++++++++++++++++++*/
585
586 static int ndType_function(const char *_tag_,int _type_,const char *ref)
587 {
588 if(_type_&XMLPARSE_TAG_START)
589 {
590 int64_t llid;
591
592 XMLPARSE_ASSERT_INTEGER(_tag_,ref); llid=atoll(ref); /* need int64_t conversion */
593
594 AddWayRefs(llid);
595 }
596
597 return(0);
598 }
599
600
601 /*++++++++++++++++++++++++++++++++++++++
602 The function that is called when the memberType XSD type is seen
603
604 int memberType_function Returns 0 if no error occured or something else otherwise.
605
606 const char *_tag_ Set to the name of the element tag that triggered this function call.
607
608 int _type_ Set to XMLPARSE_TAG_START at the start of a tag and/or XMLPARSE_TAG_END at the end of a tag.
609
610 const char *type The contents of the 'type' attribute (or NULL if not defined).
611
612 const char *ref The contents of the 'ref' attribute (or NULL if not defined).
613
614 const char *role The contents of the 'role' attribute (or NULL if not defined).
615 ++++++++++++++++++++++++++++++++++++++*/
616
617 static int memberType_function(const char *_tag_,int _type_,const char *type,const char *ref,const char *role)
618 {
619 if(_type_&XMLPARSE_TAG_START)
620 {
621 int64_t llid;
622
623 XMLPARSE_ASSERT_STRING(_tag_,type);
624 XMLPARSE_ASSERT_INTEGER(_tag_,ref); llid=atoll(ref); /* need int64_t conversion */
625
626 if(!strcmp(type,"node"))
627 AddRelationRefs(llid,0,0,role);
628 else if(!strcmp(type,"way"))
629 AddRelationRefs(0,llid,0,role);
630 else if(!strcmp(type,"relation"))
631 AddRelationRefs(0,0,llid,role);
632 }
633
634 return(0);
635 }
636
637
638 /*++++++++++++++++++++++++++++++++++++++
639 Parse an OSM XML file (from JOSM or planet download).
640
641 int ParseOSMFile Returns 0 if OK or something else in case of an error.
642
643 int fd The file descriptor of the file to read from.
644
645 NodesX *OSMNodes The data structure of nodes to fill in.
646
647 WaysX *OSMWays The data structure of ways to fill in.
648
649 RelationsX *OSMRelations The data structure of relations to fill in.
650 ++++++++++++++++++++++++++++++++++++++*/
651
652 int ParseOSMFile(int fd,NodesX *OSMNodes,WaysX *OSMWays,RelationsX *OSMRelations)
653 {
654 int retval;
655
656 /* Initialise the parser */
657
658 InitialiseParser(OSMNodes,OSMWays,OSMRelations);
659
660 /* Parse the file */
661
662 nnodes=0,nways=0,nrelations=0;
663
664 current_tags=NULL;
665
666 retval=ParseXML(fd,xml_osm_toplevel_tags,XMLPARSE_UNKNOWN_ATTR_IGNORE);
667
668 /* Cleanup the parser */
669
670 CleanupParser();
671
672 return(retval);
673 }
674
675
676 /*++++++++++++++++++++++++++++++++++++++
677 Parse an OSC XML file (from planet download).
678
679 int ParseOSCFile Returns 0 if OK or something else in case of an error.
680
681 int fd The file descriptor of the file to read from.
682
683 NodesX *OSMNodes The data structure of nodes to fill in.
684
685 WaysX *OSMWays The data structure of ways to fill in.
686
687 RelationsX *OSMRelations The data structure of relations to fill in.
688 ++++++++++++++++++++++++++++++++++++++*/
689
690 int ParseOSCFile(int fd,NodesX *OSMNodes,WaysX *OSMWays,RelationsX *OSMRelations)
691 {
692 int retval;
693
694 /* Initialise the parser */
695
696 InitialiseParser(OSMNodes,OSMWays,OSMRelations);
697
698 /* Parse the file */
699
700 nnodes=0,nways=0,nrelations=0;
701
702 current_tags=NULL;
703
704 retval=ParseXML(fd,xml_osc_toplevel_tags,XMLPARSE_UNKNOWN_ATTR_IGNORE);
705
706 /* Cleanup the parser */
707
708 CleanupParser();
709
710 return(retval);
711 }

Properties

Name Value
cvs:description OSM XML file parser.
svn:mergeinfo /branches/2.0.3-dev/src/osmparser.c:814-823 /branches/2.3.1-dev/src/osmparser.c:1046-1079 /branches/2.3.2-dev/src/osmparser.c:1080-1086 /branches/2.4.1-dev/src/osmparser.c:1211-1215 /tags/2.0.2/src/osmparser.c:802-813 /tags/2.0.3/src/osmparser.c:824-827 /tags/2.3/src/osmparser.c:1027-1045 /tags/2.4/src/osmparser.c:1184-1210