Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/osmparser.c
Parent Directory
|
Revision Log
Revision 313 -
(show annotations)
(download)
(as text)
Sun Dec 13 16:43:35 2009 UTC (15 years, 3 months ago) by amb
File MIME type: text/x-csrc
File size: 21428 byte(s)
Sun Dec 13 16:43:35 2009 UTC (15 years, 3 months ago) by amb
File MIME type: text/x-csrc
File size: 21428 byte(s)
Add bridge and tunnel to highway properties.
1 | /*************************************** |
2 | $Header: /home/amb/CVS/routino/src/osmparser.c,v 1.62 2009-12-13 16:43:35 amb Exp $ |
3 | |
4 | OSM XML file parser (either JOSM or planet) |
5 | |
6 | Part of the Routino routing software. |
7 | ******************/ /****************** |
8 | This file Copyright 2008,2009 Andrew M. Bishop |
9 | |
10 | This program is free software: you can redistribute it and/or modify |
11 | it under the terms of the GNU Affero General Public License as published by |
12 | the Free Software Foundation, either version 3 of the License, or |
13 | (at your option) any later version. |
14 | |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public License |
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | ***************************************/ |
23 | |
24 | |
25 | #include <stdio.h> |
26 | #include <stdlib.h> |
27 | #include <string.h> |
28 | #include <ctype.h> |
29 | |
30 | #include "typesx.h" |
31 | #include "functionsx.h" |
32 | #include "nodesx.h" |
33 | #include "segmentsx.h" |
34 | #include "waysx.h" |
35 | #include "ways.h" |
36 | |
37 | |
38 | /*+ The length of the buffer and the size increment for reading lines from the file. +*/ |
39 | #define BUFFSIZE 256 |
40 | |
41 | #define ISTRUE(xx) (!strcmp(xx,"true") || !strcmp(xx,"yes") || !strcmp(xx,"1")) |
42 | |
43 | #define ISALLOWED(xx) (!strcmp(xx,"true") || !strcmp(xx,"yes") || !strcmp(xx,"1") || \ |
44 | !strcmp(xx,"permissive") || !strcmp(xx,"designated") || !strcmp(xx,"destination")) |
45 | |
46 | /* Local functions */ |
47 | |
48 | static char *fgets_realloc(char *buffer,FILE *file); |
49 | |
50 | |
51 | /*++++++++++++++++++++++++++++++++++++++ |
52 | Parse an OSM XML file (from JOSM or planet download). |
53 | |
54 | int ParseXML Returns 0 if OK or something else in case of an error. |
55 | |
56 | FILE *file The file to read from. |
57 | |
58 | NodesX *OSMNodes The array of nodes to fill in. |
59 | |
60 | SegmentsX *OSMSegments The array of segments to fill in. |
61 | |
62 | WaysX *OSMWays The arrray of ways to fill in. |
63 | |
64 | Profile *profile A profile of the allowed transport types and included/excluded highway types. |
65 | ++++++++++++++++++++++++++++++++++++++*/ |
66 | |
67 | int ParseXML(FILE *file,NodesX *OSMNodes,SegmentsX *OSMSegments,WaysX *OSMWays,Profile *profile) |
68 | { |
69 | char *line=NULL; |
70 | long nlines=0; |
71 | long nnodes=0,nways=0,nrelations=0; |
72 | int isnode=0,isway=0,isrelation=0; |
73 | way_t way_id=0; |
74 | wayallow_t way_allow_no=0,way_allow_yes=0; |
75 | int way_oneway=0,way_roundabout=0; |
76 | int way_paved=0,way_multilane=0,way_bridge=0,way_tunnel=0; |
77 | speed_t way_maxspeed=0; |
78 | weight_t way_maxweight=0; |
79 | height_t way_maxheight=0; |
80 | width_t way_maxwidth=0; |
81 | length_t way_maxlength=0; |
82 | char *way_highway=NULL,*way_name=NULL,*way_ref=NULL; |
83 | node_t *way_nodes=NULL; |
84 | int way_nnodes=0,way_nalloc=0; |
85 | |
86 | printf("\rReading: Lines=0 Nodes=0 Ways=0 Relations=0"); |
87 | fflush(stdout); |
88 | |
89 | /* Parse the file */ |
90 | |
91 | while((line=fgets_realloc(line,file))) |
92 | { |
93 | char *l=line,*m; |
94 | |
95 | nlines++; |
96 | |
97 | while(isspace(*l)) |
98 | l++; |
99 | |
100 | if(!strncmp(l,"<node",5)) /* The start of a node */ |
101 | { |
102 | node_t id; |
103 | double latitude,longitude; |
104 | |
105 | nnodes++; |
106 | |
107 | isnode=1; isway=0; isrelation=0; |
108 | |
109 | m=strstr(l,"id="); m+=4; if(*m=='"' || *m=='\'') m++; id=atoll(m); |
110 | m=strstr(l,"lat="); m+=5; if(*m=='"' || *m=='\'') m++; latitude=degrees_to_radians(atof(m)); |
111 | m=strstr(l,"lon="); m+=4; if(*m=='"' || *m=='\'') m++; longitude=degrees_to_radians(atof(m)); |
112 | |
113 | AppendNode(OSMNodes,id,latitude,longitude); |
114 | |
115 | if(strstr(l,"/>")) /* The end of a node */ |
116 | { |
117 | isnode=0; isway=0; isrelation=0; |
118 | } |
119 | } |
120 | else if(!strncmp(l,"</node",6)) /* The end of a node */ |
121 | { |
122 | isnode=0; isway=0; isrelation=0; |
123 | } |
124 | else if(!strncmp(l,"<way",4)) /* The start of a way */ |
125 | { |
126 | nways++; |
127 | |
128 | isnode=0; isway=1; isrelation=0; |
129 | |
130 | m=strstr(l,"id="); m+=4; if(*m=='"' || *m=='\'') m++; way_id=atoll(m); |
131 | |
132 | way_allow_no=0; way_allow_yes=0; |
133 | way_oneway=0; way_roundabout=0; |
134 | way_paved=0; way_multilane=0; way_bridge=0; way_tunnel=0; |
135 | way_maxspeed=0; way_maxweight=0; way_maxheight=0; way_maxwidth=0; |
136 | way_maxlength=0; |
137 | way_highway=NULL; way_name=NULL; way_ref=NULL; |
138 | way_nnodes=0; |
139 | } |
140 | else if(!strncmp(l,"</way",5)) /* The end of a way */ |
141 | { |
142 | isnode=0; isway=0; isrelation=0; |
143 | |
144 | if(way_highway) |
145 | { |
146 | Way way={0}; |
147 | |
148 | way.type=HighwayType(way_highway); |
149 | |
150 | if(profile->highway[way.type]) |
151 | { |
152 | switch(way.type) |
153 | { |
154 | case Way_Motorway: |
155 | way.type|=Way_OneWay; |
156 | way.allow=Allow_Motorbike|Allow_Motorcar|Allow_PSV|Allow_Goods|Allow_HGV; |
157 | way.props=Properties_Paved|Properties_Multilane; |
158 | break; |
159 | case Way_Trunk: |
160 | way.allow=Allow_Bicycle|Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_PSV|Allow_Goods|Allow_HGV; |
161 | way.props=Properties_Paved; |
162 | break; |
163 | case Way_Primary: |
164 | way.allow=Allow_Foot|Allow_Horse|Allow_Bicycle|Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_PSV|Allow_Goods|Allow_HGV; |
165 | way.props=Properties_Paved; |
166 | break; |
167 | case Way_Secondary: |
168 | way.allow=Allow_Foot|Allow_Horse|Allow_Bicycle|Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_PSV|Allow_Goods|Allow_HGV; |
169 | way.props=Properties_Paved; |
170 | break; |
171 | case Way_Tertiary: |
172 | way.allow=Allow_Foot|Allow_Horse|Allow_Bicycle|Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_PSV|Allow_Goods|Allow_HGV; |
173 | way.props=Properties_Paved; |
174 | break; |
175 | case Way_Unclassified: |
176 | way.allow=Allow_Foot|Allow_Horse|Allow_Bicycle|Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_PSV|Allow_Goods|Allow_HGV; |
177 | way.props=Properties_Paved; |
178 | break; |
179 | case Way_Residential: |
180 | way.allow=Allow_Foot|Allow_Horse|Allow_Bicycle|Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_PSV|Allow_Goods|Allow_HGV; |
181 | way.props=Properties_Paved; |
182 | break; |
183 | case Way_Service: |
184 | way.allow=Allow_Foot|Allow_Horse|Allow_Bicycle|Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_PSV|Allow_Goods|Allow_HGV; |
185 | way.props=Properties_Paved; |
186 | break; |
187 | case Way_Track: |
188 | way.allow=Allow_Foot|Allow_Horse|Allow_Bicycle; |
189 | way.props=0; |
190 | break; |
191 | case Way_Cycleway: |
192 | way.allow=Allow_Foot|Allow_Bicycle; |
193 | way.props=Properties_Paved; |
194 | break; |
195 | case Way_Path: |
196 | if(!strcmp(way_highway,"bridleway")) |
197 | way.allow=Allow_Foot|Allow_Horse|Allow_Bicycle; /* Special case for "bridleway". */ |
198 | else |
199 | way.allow=Allow_Foot; /* Only allow bicycle and horse if so indicated. */ |
200 | way.props=0; |
201 | break; |
202 | case Way_Steps: |
203 | way.allow=Allow_Foot; |
204 | way.props=0; |
205 | break; |
206 | default: |
207 | way.allow=0; |
208 | way.props=0; |
209 | break; |
210 | } |
211 | |
212 | if(way_allow_no) /* Remove the ones explicitly denied (e.g. private) */ |
213 | way.allow&=~way_allow_no; |
214 | |
215 | if(way_allow_yes) /* Add the ones explicitly allowed (e.g. footpath along private) */ |
216 | way.allow|=way_allow_yes; |
217 | |
218 | if(way.allow & profile->allow) |
219 | { |
220 | char *refname; |
221 | int i; |
222 | |
223 | if(way_oneway) |
224 | way.type|=Way_OneWay; |
225 | |
226 | if(way_roundabout) |
227 | way.type|=Way_Roundabout; |
228 | |
229 | if(profile->props_yes[Property_Paved]) |
230 | { |
231 | if(way_paved>0) |
232 | way.props|=Properties_Paved; |
233 | else if(way_paved<0) |
234 | way.props&=~Properties_Paved; |
235 | } |
236 | |
237 | if(profile->props_yes[Property_Multilane]) |
238 | { |
239 | if(way_multilane>1) |
240 | way.props|=Properties_Multilane; |
241 | else if(way_paved==1) |
242 | way.props&=~Properties_Multilane; |
243 | } |
244 | |
245 | if(profile->props_yes[Property_Bridge]) |
246 | { |
247 | if(way_bridge) |
248 | way.props|=Properties_Bridge; |
249 | } |
250 | |
251 | if(profile->props_yes[Property_Tunnel]) |
252 | { |
253 | if(way_tunnel) |
254 | way.props|=Properties_Tunnel; |
255 | } |
256 | |
257 | if(way_ref && way_name) |
258 | { |
259 | refname=(char*)malloc(strlen(way_ref)+strlen(way_name)+4); |
260 | sprintf(refname,"%s (%s)",way_name,way_ref); |
261 | } |
262 | else if(way_ref && !way_name && way_roundabout) |
263 | { |
264 | refname=(char*)malloc(strlen(way_ref)+14); |
265 | sprintf(refname,"%s (roundabout)",way_ref); |
266 | } |
267 | else if(way_ref && !way_name) |
268 | refname=way_ref; |
269 | else if(!way_ref && way_name) |
270 | refname=way_name; |
271 | else if(way_roundabout) |
272 | { |
273 | refname=(char*)malloc(strlen(way_highway)+14); |
274 | sprintf(refname,"%s (roundabout)",way_highway); |
275 | } |
276 | else /* if(!way_ref && !way_name && !way_roundabout) */ |
277 | refname=way_highway; |
278 | |
279 | way.speed =way_maxspeed; |
280 | way.weight=way_maxweight; |
281 | way.height=way_maxheight; |
282 | way.width =way_maxwidth; |
283 | way.length=way_maxlength; |
284 | |
285 | AppendWay(OSMWays,way_id,&way,refname); |
286 | |
287 | if(refname!=way_ref && refname!=way_name && refname!=way_highway) |
288 | free(refname); |
289 | |
290 | for(i=1;i<way_nnodes;i++) |
291 | { |
292 | node_t from=way_nodes[i-1]; |
293 | node_t to =way_nodes[i]; |
294 | |
295 | if(way_oneway>0) |
296 | { |
297 | AppendSegment(OSMSegments,way_id,from,to,ONEWAY_1TO2); |
298 | AppendSegment(OSMSegments,way_id,to,from,ONEWAY_2TO1); |
299 | } |
300 | else if(way_oneway<0) |
301 | { |
302 | AppendSegment(OSMSegments,way_id,from,to,ONEWAY_2TO1); |
303 | AppendSegment(OSMSegments,way_id,to,from,ONEWAY_1TO2); |
304 | } |
305 | else |
306 | { |
307 | AppendSegment(OSMSegments,way_id,from,to,0); |
308 | AppendSegment(OSMSegments,way_id,to,from,0); |
309 | } |
310 | } |
311 | } |
312 | } |
313 | } |
314 | |
315 | if(way_highway) free(way_highway); |
316 | if(way_name) free(way_name); |
317 | if(way_ref) free(way_ref); |
318 | } |
319 | else if(!strncmp(l,"<relation",9)) /* The start of a relation */ |
320 | { |
321 | nrelations++; |
322 | |
323 | isnode=0; isway=0; isrelation=1; |
324 | } |
325 | else if(!strncmp(l,"</relation",10)) /* The end of a relation */ |
326 | { |
327 | isnode=0; isway=0; isrelation=0; |
328 | } |
329 | else if(isnode) /* The middle of a node */ |
330 | { |
331 | } |
332 | else if(isway) /* The middle of a way */ |
333 | { |
334 | node_t id; |
335 | |
336 | if(!strncmp(l,"<nd",3)) /* The start of a node specifier */ |
337 | { |
338 | m=strstr(l,"ref="); m+=4; if(*m=='"' || *m=='\'') m++; id=atoll(m); |
339 | |
340 | if(way_nnodes==way_nalloc) |
341 | way_nodes=(node_t*)realloc((void*)way_nodes,(way_nalloc+=256)*sizeof(node_t)); |
342 | |
343 | way_nodes[way_nnodes++]=id; |
344 | } |
345 | |
346 | if(!strncmp(l,"<tag",4)) /* The start of a tag specifier */ |
347 | { |
348 | char delimiter,*k="",*v=""; |
349 | |
350 | m=strstr(l,"k="); m+=2; delimiter=*m; m++; k=m; |
351 | while(*m!=delimiter) m++; *m=0; l=m+1; |
352 | |
353 | m=strstr(l,"v="); m+=2; delimiter=*m; m++; v=m; |
354 | while(*m!=delimiter) m++; *m=0; |
355 | |
356 | switch(*k) |
357 | { |
358 | case 'a': |
359 | if(!strcmp(k,"access")) |
360 | { |
361 | if(ISALLOWED(v)) |
362 | ; |
363 | else |
364 | way_allow_no=Allow_ALL; |
365 | } |
366 | break; |
367 | |
368 | case 'b': |
369 | if(!strcmp(k,"bicycle")) |
370 | { |
371 | if(ISALLOWED(v)) |
372 | way_allow_yes|=Allow_Bicycle; |
373 | else |
374 | way_allow_no |=Allow_Bicycle; |
375 | } |
376 | |
377 | if(!strcmp(k,"bridge")) |
378 | way_bridge=ISTRUE(v); |
379 | break; |
380 | |
381 | case 'd': |
382 | if(!strcmp(k,"designation")) |
383 | { |
384 | if(!strcmp(v,"bridleway")) |
385 | way_allow_yes|=Allow_Foot|Allow_Horse|Allow_Bicycle; |
386 | else if(!strcmp(v,"byway")) |
387 | way_allow_yes|=Allow_Foot|Allow_Horse|Allow_Bicycle; |
388 | else if(!strcmp(v,"footpath")) |
389 | way_allow_yes|=Allow_Foot; |
390 | } |
391 | break; |
392 | |
393 | case 'f': |
394 | if(!strcmp(k,"foot")) |
395 | { |
396 | if(ISALLOWED(v)) |
397 | way_allow_yes|=Allow_Foot; |
398 | else |
399 | way_allow_no |=Allow_Foot; |
400 | } |
401 | break; |
402 | |
403 | case 'g': |
404 | if(!strcmp(k,"goods")) |
405 | { |
406 | if(ISALLOWED(v)) |
407 | way_allow_yes|=Allow_Goods; |
408 | else |
409 | way_allow_no |=Allow_Goods; |
410 | } |
411 | break; |
412 | |
413 | case 'h': |
414 | if(!strcmp(k,"highway")) |
415 | way_highway=strcpy((char*)malloc(strlen(v)+1),v); |
416 | |
417 | if(!strcmp(k,"horse")) |
418 | { |
419 | if(ISALLOWED(v)) |
420 | way_allow_yes|=Allow_Horse; |
421 | else |
422 | way_allow_no |=Allow_Horse; |
423 | } |
424 | |
425 | if(!strcmp(k,"hgv")) |
426 | { |
427 | if(ISALLOWED(v)) |
428 | way_allow_yes|=Allow_HGV; |
429 | else |
430 | way_allow_no |=Allow_HGV; |
431 | } |
432 | break; |
433 | |
434 | case 'j': |
435 | if(!strcmp(k,"junction")) |
436 | if(!strcmp(v,"roundabout")) |
437 | {way_oneway=1; way_roundabout=1;} |
438 | break; |
439 | |
440 | case 'l': |
441 | if(!strcmp(k,"lanes")) |
442 | way_multilane=atoi(v); |
443 | |
444 | case 'm': |
445 | if(!strcmp(k,"maxspeed")) |
446 | { |
447 | if(strstr(v,"mph")) |
448 | way_maxspeed=kph_to_speed(1.609*atof(v)); |
449 | else |
450 | way_maxspeed=kph_to_speed(atof(v)); |
451 | } |
452 | |
453 | if(!strcmp(k,"maxspeed:mph")) |
454 | way_maxspeed=kph_to_speed(1.609*atof(v)); |
455 | |
456 | if(!strcmp(k,"maxweight")) |
457 | { |
458 | if(strstr(v,"kg")) |
459 | way_maxweight=tonnes_to_weight(atof(v)/1000); |
460 | else |
461 | way_maxweight=tonnes_to_weight(atof(v)); |
462 | } |
463 | |
464 | if(!strcmp(k,"maxheight")) |
465 | { |
466 | if(strchr(v,'\'')) |
467 | { |
468 | int feet,inches; |
469 | |
470 | if(sscanf(v,"%d'%d\"",&feet,&inches)==2) |
471 | way_maxheight=metres_to_height((feet+(double)inches/12.0)*0.254); |
472 | else if(sscanf(v,"%d'",&feet)==1) |
473 | way_maxheight=metres_to_height((feet+(double)inches/12.0)*0.254); |
474 | } |
475 | else if(strstr(v,"ft") || strstr(v,"feet")) |
476 | way_maxheight=metres_to_height(atof(v)*0.254); |
477 | else |
478 | way_maxheight=metres_to_height(atof(v)); |
479 | } |
480 | |
481 | if(!strcmp(k,"maxwidth")) |
482 | { |
483 | if(strchr(v,'\'')) |
484 | { |
485 | int feet,inches; |
486 | |
487 | if(sscanf(v,"%d'%d\"",&feet,&inches)==2) |
488 | way_maxwidth=metres_to_height((feet+(double)inches/12.0)*0.254); |
489 | else if(sscanf(v,"%d'",&feet)==1) |
490 | way_maxwidth=metres_to_height((feet+(double)inches/12.0)*0.254); |
491 | } |
492 | else if(strstr(v,"ft") || strstr(v,"feet")) |
493 | way_maxwidth=metres_to_width(atof(v)*0.254); |
494 | else |
495 | way_maxwidth=metres_to_width(atof(v)); |
496 | } |
497 | |
498 | if(!strcmp(k,"maxlength")) |
499 | { |
500 | if(strchr(v,'\'')) |
501 | { |
502 | int feet,inches; |
503 | |
504 | if(sscanf(v,"%d'%d\"",&feet,&inches)==2) |
505 | way_maxlength=metres_to_height((feet+(double)inches/12.0)*0.254); |
506 | else if(sscanf(v,"%d'",&feet)==1) |
507 | way_maxlength=metres_to_height((feet+(double)inches/12.0)*0.254); |
508 | } |
509 | else if(strstr(v,"ft") || strstr(v,"feet")) |
510 | way_maxlength=metres_to_length(atof(v)*0.254); |
511 | else |
512 | way_maxlength=metres_to_length(atof(v)); |
513 | } |
514 | |
515 | if(!strcmp(k,"moped")) |
516 | { |
517 | if(ISALLOWED(v)) |
518 | way_allow_yes|=Allow_Moped; |
519 | else |
520 | way_allow_no |=Allow_Moped; |
521 | } |
522 | |
523 | if(!strcmp(k,"motorbike")) |
524 | { |
525 | if(ISALLOWED(v)) |
526 | way_allow_yes|=Allow_Motorbike; |
527 | else |
528 | way_allow_no |=Allow_Motorbike; |
529 | } |
530 | |
531 | if(!strcmp(k,"motorcar")) |
532 | { |
533 | if(ISALLOWED(v)) |
534 | way_allow_yes|=Allow_Motorcar; |
535 | else |
536 | way_allow_no |=Allow_Motorcar; |
537 | } |
538 | |
539 | if(!strcmp(k,"motor_vehicle")) |
540 | { |
541 | if(ISALLOWED(v)) |
542 | way_allow_yes|=Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_Goods|Allow_HGV|Allow_PSV; |
543 | else |
544 | way_allow_no |=Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_Goods|Allow_HGV|Allow_PSV; |
545 | } |
546 | break; |
547 | |
548 | case 'n': |
549 | if(!strcmp(k,"name")) |
550 | way_name=strcpy((char*)malloc(strlen(v)+1),v); |
551 | break; |
552 | |
553 | case 'o': |
554 | if(!strcmp(k,"oneway")) |
555 | { |
556 | if(ISTRUE(v)) |
557 | way_oneway=1; |
558 | else if(!strcmp(v,"-1")) |
559 | way_oneway=-1; |
560 | } |
561 | break; |
562 | |
563 | case 'p': |
564 | if(!strcmp(k,"paved")) |
565 | { |
566 | if(ISTRUE(v)) |
567 | way_paved=1; |
568 | else |
569 | way_paved=-1; |
570 | } |
571 | |
572 | if(!strcmp(k,"psv")) |
573 | { |
574 | if(ISALLOWED(v)) |
575 | way_allow_yes|=Allow_PSV; |
576 | else |
577 | way_allow_no |=Allow_PSV; |
578 | } |
579 | break; |
580 | |
581 | case 'r': |
582 | if(!strcmp(k,"ref")) |
583 | way_ref=strcpy((char*)malloc(strlen(v)+1),v); |
584 | break; |
585 | |
586 | case 's': |
587 | if(!strcmp(k,"surface")) |
588 | { |
589 | if(!strcmp(v,"paved") || !strcmp(v,"asphalt") || !strcmp(v,"concrete")) |
590 | way_paved=1; |
591 | else |
592 | way_paved=-1; |
593 | } |
594 | break; |
595 | |
596 | case 't': |
597 | if(!strcmp(k,"tunnel")) |
598 | way_tunnel=ISTRUE(v); |
599 | break; |
600 | |
601 | case 'v': |
602 | if(!strcmp(k,"vehicle")) |
603 | { |
604 | if(ISALLOWED(v)) |
605 | way_allow_yes|=Allow_Bicycle|Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_Goods|Allow_HGV|Allow_PSV; |
606 | else |
607 | way_allow_no |=Allow_Bicycle|Allow_Moped|Allow_Motorbike|Allow_Motorcar|Allow_Goods|Allow_HGV|Allow_PSV; |
608 | } |
609 | break; |
610 | |
611 | default: |
612 | ; |
613 | } |
614 | } |
615 | } |
616 | else if(isrelation) /* The middle of a relation */ |
617 | { |
618 | } |
619 | |
620 | if(!(nlines%10000)) |
621 | { |
622 | printf("\rReading: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld",nlines,nnodes,nways,nrelations); |
623 | fflush(stdout); |
624 | } |
625 | } |
626 | |
627 | printf("\rRead: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld \n",nlines,nnodes,nways,nrelations); |
628 | fflush(stdout); |
629 | |
630 | if(line) |
631 | free(line); |
632 | |
633 | if(way_nalloc) |
634 | free(way_nodes); |
635 | |
636 | return(0); |
637 | } |
638 | |
639 | |
640 | /*++++++++++++++++++++++++++++++++++++++ |
641 | Call fgets and realloc the buffer as needed to get a whole line. |
642 | |
643 | char *fgets_realloc Returns the modified buffer (NULL at the end of the file). |
644 | |
645 | char *buffer The current buffer. |
646 | |
647 | FILE *file The file to read from. |
648 | ++++++++++++++++++++++++++++++++++++++*/ |
649 | |
650 | static char *fgets_realloc(char *buffer,FILE *file) |
651 | { |
652 | int n=0; |
653 | char *buf; |
654 | |
655 | if(!buffer) |
656 | buffer=(char*)malloc(BUFFSIZE+1); |
657 | |
658 | while((buf=fgets(&buffer[n],BUFFSIZE,file))) |
659 | { |
660 | int s=strlen(buf); |
661 | n+=s; |
662 | |
663 | if(buffer[n-1]=='\n') |
664 | break; |
665 | else |
666 | buffer=(char*)realloc(buffer,n+BUFFSIZE+1); |
667 | } |
668 | |
669 | if(!buf) |
670 | {free(buffer);buffer=NULL;} |
671 | |
672 | return(buffer); |
673 | } |
Properties
Name | Value |
---|---|
cvs:description | OSM XML file parser. |