Routino SVN Repository Browser

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

ViewVC logotype

Annotation of /trunk/src/visualiser.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 681 - (hide annotations) (download) (as text)
Sun Apr 24 18:01:24 2011 UTC (13 years, 11 months ago) by amb
File MIME type: text/x-csrc
File size: 19559 byte(s)
Make the comments more consistent.

1 amb 184 /***************************************
2     Extract data from Routino.
3    
4     Part of the Routino routing software.
5     ******************/ /******************
6 amb 598 This file Copyright 2008-2011 Andrew M. Bishop
7 amb 184
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 <stdio.h>
24     #include <stdlib.h>
25     #include <string.h>
26    
27     #include "types.h"
28     #include "visualiser.h"
29     #include "nodes.h"
30     #include "segments.h"
31     #include "ways.h"
32 amb 623 #include "relations.h"
33 amb 184
34    
35     #define SPEED_LIMIT 1
36     #define WEIGHT_LIMIT 2
37     #define HEIGHT_LIMIT 3
38     #define WIDTH_LIMIT 4
39     #define LENGTH_LIMIT 5
40    
41     /* Local types */
42    
43 amb 219 typedef void (*callback_t)(index_t node,double latitude,double longitude);
44 amb 184
45     /* Local variables */
46    
47 amb 623 static Nodes *OSMNodes;
48     static Segments *OSMSegments;
49     static Ways *OSMWays;
50     static Relations *OSMRelations;
51 amb 184
52 amb 219 static double LatMin;
53     static double LatMax;
54     static double LonMin;
55     static double LonMax;
56 amb 217
57 amb 184 static int limit_type=0;
58    
59     /* Local functions */
60    
61 amb 217 static void find_all_nodes(Nodes *nodes,callback_t callback);
62 amb 219 static void output_junctions(index_t node,double latitude,double longitude);
63     static void output_super(index_t node,double latitude,double longitude);
64     static void output_oneway(index_t node,double latitude,double longitude);
65 amb 623 static void output_turnrestriction(index_t node,double latitude,double longitude);
66 amb 219 static void output_limits(index_t node,double latitude,double longitude);
67 amb 184
68    
69     /*++++++++++++++++++++++++++++++++++++++
70     Output the data for junctions.
71    
72     Nodes *nodes The set of nodes to use.
73    
74     Segments *segments The set of segments to use.
75    
76     Ways *ways The set of ways to use.
77    
78 amb 680 Relations *relations The set of relations to use.
79 amb 623
80 amb 219 double latmin The minimum latitude.
81 amb 184
82 amb 219 double latmax The maximum latitude.
83 amb 184
84 amb 219 double lonmin The minimum longitude.
85 amb 184
86 amb 219 double lonmax The maximum longitude.
87 amb 184 ++++++++++++++++++++++++++++++++++++++*/
88    
89 amb 623 void OutputJunctions(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,double latmin,double latmax,double lonmin,double lonmax)
90 amb 184 {
91     /* Use local variables so that the callback doesn't need to pass them backwards and forwards */
92    
93     OSMNodes=nodes;
94     OSMSegments=segments;
95     OSMWays=ways;
96 amb 623 OSMRelations=relations;
97 amb 184
98 amb 217 LatMin=latmin;
99     LatMax=latmax;
100     LonMin=lonmin;
101     LonMax=lonmax;
102    
103 amb 184 /* Iterate through the nodes and process them */
104    
105 amb 217 find_all_nodes(nodes,(callback_t)output_junctions);
106 amb 184 }
107    
108    
109     /*++++++++++++++++++++++++++++++++++++++
110 amb 680 Process a single node as a junction (called as a callback).
111 amb 184
112     index_t node The node to output.
113    
114 amb 219 double latitude The latitude of the node.
115 amb 184
116 amb 219 double longitude The longitude of the node.
117 amb 184 ++++++++++++++++++++++++++++++++++++++*/
118    
119 amb 219 static void output_junctions(index_t node,double latitude,double longitude)
120 amb 184 {
121     Segment *segment;
122     Way *firstway;
123     int count=0,difference=0;
124    
125     segment=FirstSegment(OSMSegments,OSMNodes,node);
126 amb 460 firstway=LookupWay(OSMWays,segment->way,1);
127 amb 184
128     do
129     {
130 amb 460 Way *way=LookupWay(OSMWays,segment->way,2);
131 amb 184
132     if(IsNormalSegment(segment))
133     count++;
134    
135 amb 201 if(WaysCompare(firstway,way))
136 amb 184 difference=1;
137    
138     segment=NextSegment(OSMSegments,segment,node);
139     }
140     while(segment);
141    
142     if(count!=2 || difference)
143 amb 198 printf("%.6f %.6f %d\n",radians_to_degrees(latitude),radians_to_degrees(longitude),count);
144 amb 184 }
145    
146    
147     /*++++++++++++++++++++++++++++++++++++++
148     Output the data for super-nodes and super-segments.
149    
150     Nodes *nodes The set of nodes to use.
151    
152     Segments *segments The set of segments to use.
153    
154     Ways *ways The set of ways to use.
155    
156 amb 680 Relations *relations The set of relations to use.
157 amb 623
158 amb 219 double latmin The minimum latitude.
159 amb 184
160 amb 219 double latmax The maximum latitude.
161 amb 184
162 amb 219 double lonmin The minimum longitude.
163 amb 184
164 amb 219 double lonmax The maximum longitude.
165 amb 184 ++++++++++++++++++++++++++++++++++++++*/
166    
167 amb 623 void OutputSuper(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,double latmin,double latmax,double lonmin,double lonmax)
168 amb 184 {
169     /* Use local variables so that the callback doesn't need to pass them backwards and forwards */
170    
171     OSMNodes=nodes;
172     OSMSegments=segments;
173     OSMWays=ways;
174 amb 623 OSMRelations=relations;
175 amb 184
176 amb 217 LatMin=latmin;
177     LatMax=latmax;
178     LonMin=lonmin;
179     LonMax=lonmax;
180    
181 amb 184 /* Iterate through the nodes and process them */
182    
183 amb 217 find_all_nodes(nodes,(callback_t)output_super);
184 amb 184 }
185    
186    
187     /*++++++++++++++++++++++++++++++++++++++
188 amb 680 Process a single node as a super-node (called as a callback).
189 amb 184
190     index_t node The node to output.
191    
192 amb 219 double latitude The latitude of the node.
193 amb 184
194 amb 219 double longitude The longitude of the node.
195 amb 184 ++++++++++++++++++++++++++++++++++++++*/
196    
197 amb 219 static void output_super(index_t node,double latitude,double longitude)
198 amb 184 {
199     Segment *segment;
200    
201 amb 598 if(!IsSuperNode(LookupNode(OSMNodes,node,1)))
202 amb 184 return;
203    
204 amb 198 printf("%.6f %.6f n\n",radians_to_degrees(latitude),radians_to_degrees(longitude));
205 amb 188
206 amb 184 segment=FirstSegment(OSMSegments,OSMNodes,node);
207    
208     do
209     {
210     if(IsSuperSegment(segment))
211     {
212     index_t othernode=OtherNode(segment,node);
213 amb 219 double lat,lon;
214 amb 184
215 amb 217 GetLatLong(OSMNodes,othernode,&lat,&lon);
216 amb 184
217 amb 217 if(node>othernode || (lat<LatMin || lat>LatMax || lon<LonMin || lon>LonMax))
218 amb 198 printf("%.6f %.6f s\n",radians_to_degrees(lat),radians_to_degrees(lon));
219 amb 184 }
220    
221     segment=NextSegment(OSMSegments,segment,node);
222     }
223     while(segment);
224     }
225    
226    
227     /*++++++++++++++++++++++++++++++++++++++
228     Output the data for one-way segments.
229    
230     Nodes *nodes The set of nodes to use.
231    
232     Segments *segments The set of segments to use.
233    
234     Ways *ways The set of ways to use.
235    
236 amb 680 Relations *relations The set of relations to use.
237 amb 623
238 amb 219 double latmin The minimum latitude.
239 amb 184
240 amb 219 double latmax The maximum latitude.
241 amb 184
242 amb 219 double lonmin The minimum longitude.
243 amb 184
244 amb 219 double lonmax The maximum longitude.
245 amb 184 ++++++++++++++++++++++++++++++++++++++*/
246    
247 amb 623 void OutputOneway(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,double latmin,double latmax,double lonmin,double lonmax)
248 amb 184 {
249     /* Use local variables so that the callback doesn't need to pass them backwards and forwards */
250    
251     OSMNodes=nodes;
252     OSMSegments=segments;
253     OSMWays=ways;
254 amb 623 OSMRelations=relations;
255 amb 184
256 amb 217 LatMin=latmin;
257     LatMax=latmax;
258     LonMin=lonmin;
259     LonMax=lonmax;
260    
261 amb 184 /* Iterate through the nodes and process them */
262    
263 amb 217 find_all_nodes(nodes,(callback_t)output_oneway);
264 amb 184 }
265    
266    
267     /*++++++++++++++++++++++++++++++++++++++
268 amb 680 Process a single node and all connected one-way segments (called as a callback).
269 amb 184
270     index_t node The node to output.
271    
272 amb 219 double latitude The latitude of the node.
273 amb 184
274 amb 219 double longitude The longitude of the node.
275 amb 184 ++++++++++++++++++++++++++++++++++++++*/
276    
277 amb 219 static void output_oneway(index_t node,double latitude,double longitude)
278 amb 184 {
279     Segment *segment;
280    
281     segment=FirstSegment(OSMSegments,OSMNodes,node);
282    
283     do
284     {
285     if(IsNormalSegment(segment))
286     {
287     index_t othernode=OtherNode(segment,node);
288    
289     if(node>othernode)
290     {
291 amb 219 double lat,lon;
292 amb 184
293     GetLatLong(OSMNodes,othernode,&lat,&lon);
294    
295     if(IsOnewayFrom(segment,node))
296 amb 198 printf("%.6f %.6f %.6f %.6f\n",radians_to_degrees(latitude),radians_to_degrees(longitude),radians_to_degrees(lat),radians_to_degrees(lon));
297 amb 184 else if(IsOnewayFrom(segment,othernode))
298 amb 198 printf("%.6f %.6f %.6f %.6f\n",radians_to_degrees(lat),radians_to_degrees(lon),radians_to_degrees(latitude),radians_to_degrees(longitude));
299 amb 184 }
300     }
301    
302     segment=NextSegment(OSMSegments,segment,node);
303     }
304     while(segment);
305     }
306    
307    
308     /*++++++++++++++++++++++++++++++++++++++
309 amb 623 Output the data for turn restrictions.
310    
311     Nodes *nodes The set of nodes to use.
312    
313     Segments *segments The set of segments to use.
314    
315     Ways *ways The set of ways to use.
316    
317 amb 680 Relations *relations The set of relations to use.
318 amb 623
319     double latmin The minimum latitude.
320    
321     double latmax The maximum latitude.
322    
323     double lonmin The minimum longitude.
324    
325     double lonmax The maximum longitude.
326     ++++++++++++++++++++++++++++++++++++++*/
327    
328     void OutputTurnRestrictions(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,double latmin,double latmax,double lonmin,double lonmax)
329     {
330     /* Use local variables so that the callback doesn't need to pass them backwards and forwards */
331    
332     OSMNodes=nodes;
333     OSMSegments=segments;
334     OSMWays=ways;
335     OSMRelations=relations;
336    
337     LatMin=latmin;
338     LatMax=latmax;
339     LonMin=lonmin;
340     LonMax=lonmax;
341    
342     /* Iterate through the nodes and process them */
343    
344     find_all_nodes(nodes,(callback_t)output_turnrestriction);
345     }
346    
347    
348     /*++++++++++++++++++++++++++++++++++++++
349 amb 680 Process a single node as the 'via' node for a turn restriction (called as a callback).
350 amb 623
351     index_t node The node to output.
352    
353     double latitude The latitude of the node.
354    
355     double longitude The longitude of the node.
356     ++++++++++++++++++++++++++++++++++++++*/
357    
358     static void output_turnrestriction(index_t node,double latitude,double longitude)
359     {
360     index_t turnrelation=NO_RELATION;
361    
362     if(!IsTurnRestrictedNode(LookupNode(OSMNodes,node,1)))
363     return;
364    
365     turnrelation=FindFirstTurnRelation1(OSMRelations,node);
366    
367     do
368     {
369     TurnRelation *relation;
370     Segment *from_segment,*to_segment;
371     index_t from_node,to_node;
372     double from_lat,from_lon,to_lat,to_lon;
373    
374     relation=LookupTurnRelation(OSMRelations,turnrelation,1);
375    
376     from_segment=LookupSegment(OSMSegments,relation->from,1);
377     to_segment=LookupSegment(OSMSegments,relation->to,2);
378    
379     from_node=OtherNode(from_segment,node);
380     to_node=OtherNode(to_segment,node);
381    
382     GetLatLong(OSMNodes,from_node,&from_lat,&from_lon);
383     GetLatLong(OSMNodes,to_node,&to_lat,&to_lon);
384    
385     printf("%.6f %.6f %.6f %.6f %.6f %.6f\n",radians_to_degrees(from_lat),radians_to_degrees(from_lon),
386     radians_to_degrees(latitude),radians_to_degrees(longitude),
387     radians_to_degrees(to_lat),radians_to_degrees(to_lon));
388    
389     turnrelation=FindNextTurnRelation1(OSMRelations,turnrelation);
390     }
391     while(turnrelation!=NO_RELATION);
392     }
393    
394    
395     /*++++++++++++++++++++++++++++++++++++++
396 amb 184 Output the data for speed limits.
397    
398     Nodes *nodes The set of nodes to use.
399    
400     Segments *segments The set of segments to use.
401    
402     Ways *ways The set of ways to use.
403    
404 amb 680 Relations *relations The set of relations to use.
405 amb 623
406 amb 219 double latmin The minimum latitude.
407 amb 184
408 amb 219 double latmax The maximum latitude.
409 amb 184
410 amb 219 double lonmin The minimum longitude.
411 amb 184
412 amb 219 double lonmax The maximum longitude.
413 amb 184 ++++++++++++++++++++++++++++++++++++++*/
414    
415 amb 623 void OutputSpeedLimits(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,double latmin,double latmax,double lonmin,double lonmax)
416 amb 184 {
417     /* Use local variables so that the callback doesn't need to pass them backwards and forwards */
418    
419     OSMNodes=nodes;
420     OSMSegments=segments;
421     OSMWays=ways;
422 amb 623 OSMRelations=relations;
423 amb 184
424 amb 217 LatMin=latmin;
425     LatMax=latmax;
426     LonMin=lonmin;
427     LonMax=lonmax;
428    
429 amb 184 /* Iterate through the nodes and process them */
430    
431     limit_type=SPEED_LIMIT;
432    
433 amb 217 find_all_nodes(nodes,(callback_t)output_limits);
434 amb 184 }
435    
436    
437     /*++++++++++++++++++++++++++++++++++++++
438     Output the data for weight limits.
439    
440     Nodes *nodes The set of nodes to use.
441    
442     Segments *segments The set of segments to use.
443    
444     Ways *ways The set of ways to use.
445    
446 amb 680 Relations *relations The set of relations to use.
447 amb 623
448 amb 219 double latmin The minimum latitude.
449 amb 184
450 amb 219 double latmax The maximum latitude.
451 amb 184
452 amb 219 double lonmin The minimum longitude.
453 amb 184
454 amb 219 double lonmax The maximum longitude.
455 amb 184 ++++++++++++++++++++++++++++++++++++++*/
456    
457 amb 623 void OutputWeightLimits(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,double latmin,double latmax,double lonmin,double lonmax)
458 amb 184 {
459     /* Use local variables so that the callback doesn't need to pass them backwards and forwards */
460    
461     OSMNodes=nodes;
462     OSMSegments=segments;
463     OSMWays=ways;
464 amb 623 OSMRelations=relations;
465 amb 184
466 amb 217 LatMin=latmin;
467     LatMax=latmax;
468     LonMin=lonmin;
469     LonMax=lonmax;
470    
471 amb 184 /* Iterate through the nodes and process them */
472    
473     limit_type=WEIGHT_LIMIT;
474    
475 amb 217 find_all_nodes(nodes,(callback_t)output_limits);
476 amb 184 }
477    
478    
479     /*++++++++++++++++++++++++++++++++++++++
480     Output the data for height limits.
481    
482     Nodes *nodes The set of nodes to use.
483    
484     Segments *segments The set of segments to use.
485    
486     Ways *ways The set of ways to use.
487    
488 amb 680 Relations *relations The set of relations to use.
489 amb 623
490 amb 219 double latmin The minimum latitude.
491 amb 184
492 amb 219 double latmax The maximum latitude.
493 amb 184
494 amb 219 double lonmin The minimum longitude.
495 amb 184
496 amb 219 double lonmax The maximum longitude.
497 amb 184 ++++++++++++++++++++++++++++++++++++++*/
498    
499 amb 623 void OutputHeightLimits(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,double latmin,double latmax,double lonmin,double lonmax)
500 amb 184 {
501     /* Use local variables so that the callback doesn't need to pass them backwards and forwards */
502    
503     OSMNodes=nodes;
504     OSMSegments=segments;
505     OSMWays=ways;
506 amb 623 OSMRelations=relations;
507 amb 184
508 amb 217 LatMin=latmin;
509     LatMax=latmax;
510     LonMin=lonmin;
511     LonMax=lonmax;
512    
513 amb 184 /* Iterate through the nodes and process them */
514    
515     limit_type=HEIGHT_LIMIT;
516    
517 amb 217 find_all_nodes(nodes,(callback_t)output_limits);
518 amb 184 }
519    
520    
521     /*++++++++++++++++++++++++++++++++++++++
522     Output the data for width limits.
523    
524     Nodes *nodes The set of nodes to use.
525    
526     Segments *segments The set of segments to use.
527    
528     Ways *ways The set of ways to use.
529    
530 amb 680 Relations *relations The set of relations to use.
531 amb 623
532 amb 219 double latmin The minimum latitude.
533 amb 184
534 amb 219 double latmax The maximum latitude.
535 amb 184
536 amb 219 double lonmin The minimum longitude.
537 amb 184
538 amb 219 double lonmax The maximum longitude.
539 amb 184 ++++++++++++++++++++++++++++++++++++++*/
540    
541 amb 623 void OutputWidthLimits(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,double latmin,double latmax,double lonmin,double lonmax)
542 amb 184 {
543     /* Use local variables so that the callback doesn't need to pass them backwards and forwards */
544    
545     OSMNodes=nodes;
546     OSMSegments=segments;
547     OSMWays=ways;
548 amb 623 OSMRelations=relations;
549 amb 184
550 amb 217 LatMin=latmin;
551     LatMax=latmax;
552     LonMin=lonmin;
553     LonMax=lonmax;
554    
555 amb 184 /* Iterate through the nodes and process them */
556    
557     limit_type=WIDTH_LIMIT;
558    
559 amb 217 find_all_nodes(nodes,(callback_t)output_limits);
560 amb 184 }
561    
562    
563     /*++++++++++++++++++++++++++++++++++++++
564     Output the data for length limits.
565    
566     Nodes *nodes The set of nodes to use.
567    
568     Segments *segments The set of segments to use.
569    
570     Ways *ways The set of ways to use.
571    
572 amb 680 Relations *relations The set of relations to use.
573 amb 623
574 amb 219 double latmin The minimum latitude.
575 amb 184
576 amb 219 double latmax The maximum latitude.
577 amb 184
578 amb 219 double lonmin The minimum longitude.
579 amb 184
580 amb 219 double lonmax The maximum longitude.
581 amb 184 ++++++++++++++++++++++++++++++++++++++*/
582    
583 amb 623 void OutputLengthLimits(Nodes *nodes,Segments *segments,Ways *ways,Relations *relations,double latmin,double latmax,double lonmin,double lonmax)
584 amb 184 {
585     /* Use local variables so that the callback doesn't need to pass them backwards and forwards */
586    
587     OSMNodes=nodes;
588     OSMSegments=segments;
589     OSMWays=ways;
590 amb 623 OSMRelations=relations;
591 amb 184
592 amb 217 LatMin=latmin;
593     LatMax=latmax;
594     LonMin=lonmin;
595     LonMax=lonmax;
596    
597 amb 184 /* Iterate through the nodes and process them */
598    
599     limit_type=LENGTH_LIMIT;
600    
601 amb 217 find_all_nodes(nodes,(callback_t)output_limits);
602 amb 184 }
603    
604    
605     /*++++++++++++++++++++++++++++++++++++++
606 amb 680 Process a single node as a speed, weight, height, length, width limit (called as a callback).
607 amb 184
608     index_t node The node to output.
609    
610 amb 219 double latitude The latitude of the node.
611 amb 184
612 amb 219 double longitude The longitude of the node.
613 amb 184 ++++++++++++++++++++++++++++++++++++++*/
614    
615 amb 219 static void output_limits(index_t node,double latitude,double longitude)
616 amb 184 {
617     Segment *segment,*segments[16];
618     Way *ways[16];
619     int limits[16];
620     int count=0;
621     int i,j,same=0;
622    
623     segment=FirstSegment(OSMSegments,OSMNodes,node);
624    
625     do
626     {
627     if(IsNormalSegment(segment) && count<16)
628     {
629 amb 460 ways [count]=LookupWay(OSMWays,segment->way,1);
630 amb 184 segments[count]=segment;
631    
632     switch(limit_type)
633     {
634     case SPEED_LIMIT: limits[count]=ways[count]->speed; break;
635     case WEIGHT_LIMIT: limits[count]=ways[count]->weight; break;
636     case HEIGHT_LIMIT: limits[count]=ways[count]->height; break;
637     case WIDTH_LIMIT: limits[count]=ways[count]->width; break;
638     case LENGTH_LIMIT: limits[count]=ways[count]->length; break;
639     }
640    
641 amb 217 if(limits[count] || ways[count]->type<Way_Track)
642     count++;
643 amb 184 }
644    
645     segment=NextSegment(OSMSegments,segment,node);
646     }
647     while(segment);
648    
649     /* Nodes with only one limit are not interesting */
650    
651     if(count==1)
652     return;
653    
654     /* Nodes with all segments the same limit is not interesting */
655    
656     same=0;
657     for(j=0;j<count;j++)
658     if(limits[0]==limits[j])
659     same++;
660    
661     if(same==count)
662     return;
663    
664     /* Display the interesting speed limits */
665    
666 amb 198 printf("%.6f %.6f\n",radians_to_degrees(latitude),radians_to_degrees(longitude));
667 amb 184
668     for(i=0;i<count;i++)
669     {
670     same=0;
671     for(j=0;j<count;j++)
672     if(limits[i]==limits[j])
673     same++;
674    
675     if(count==2 || same!=(count-1))
676     {
677 amb 219 double lat,lon;
678 amb 184
679     GetLatLong(OSMNodes,OtherNode(segments[i],node),&lat,&lon);
680    
681     switch(limit_type)
682     {
683     case SPEED_LIMIT:
684 amb 219 printf("%.6f %.6f %d\n",radians_to_degrees(lat),radians_to_degrees(lon),speed_to_kph(limits[i]));
685 amb 184 break;
686     case WEIGHT_LIMIT:
687 amb 198 printf("%.6f %.6f %.1f\n",radians_to_degrees(lat),radians_to_degrees(lon),weight_to_tonnes(limits[i]));
688 amb 184 break;
689     case HEIGHT_LIMIT:
690 amb 198 printf("%.6f %.6f %.1f\n",radians_to_degrees(lat),radians_to_degrees(lon),height_to_metres(limits[i]));
691 amb 184 break;
692     case WIDTH_LIMIT:
693 amb 198 printf("%.6f %.6f %.1f\n",radians_to_degrees(lat),radians_to_degrees(lon),width_to_metres(limits[i]));
694 amb 184 break;
695     case LENGTH_LIMIT:
696 amb 198 printf("%.6f %.6f %.1f\n",radians_to_degrees(lat),radians_to_degrees(lon),length_to_metres(limits[i]));
697 amb 184 break;
698     }
699     }
700     }
701     }
702    
703    
704     /*++++++++++++++++++++++++++++++++++++++
705     A function to iterate through all nodes and call a callback function for each one.
706    
707 amb 681 Nodes *nodes The set of nodes to use.
708 amb 184
709     callback_t callback The callback function for each node.
710     ++++++++++++++++++++++++++++++++++++++*/
711    
712 amb 217 static void find_all_nodes(Nodes *nodes,callback_t callback)
713 amb 184 {
714 amb 453 int32_t latminbin=latlong_to_bin(radians_to_latlong(LatMin))-nodes->file.latzero;
715     int32_t latmaxbin=latlong_to_bin(radians_to_latlong(LatMax))-nodes->file.latzero;
716     int32_t lonminbin=latlong_to_bin(radians_to_latlong(LonMin))-nodes->file.lonzero;
717     int32_t lonmaxbin=latlong_to_bin(radians_to_latlong(LonMax))-nodes->file.lonzero;
718 amb 184 int latb,lonb,llbin;
719 amb 462 index_t i,index1,index2;
720 amb 184
721     /* Loop through all of the nodes. */
722    
723     for(latb=latminbin;latb<=latmaxbin;latb++)
724     for(lonb=lonminbin;lonb<=lonmaxbin;lonb++)
725     {
726 amb 453 llbin=lonb*nodes->file.latbins+latb;
727 amb 184
728 amb 453 if(llbin<0 || llbin>(nodes->file.latbins*nodes->file.lonbins))
729 amb 184 continue;
730    
731 amb 462 index1=LookupNodeOffset(nodes,llbin);
732     index2=LookupNodeOffset(nodes,llbin+1);
733    
734     for(i=index1;i<index2;i++)
735 amb 184 {
736 amb 453 Node *node=LookupNode(nodes,i,1);
737 amb 184
738 amb 453 double lat=latlong_to_radians(bin_to_latlong(nodes->file.latzero+latb)+off_to_latlong(node->latoffset));
739     double lon=latlong_to_radians(bin_to_latlong(nodes->file.lonzero+lonb)+off_to_latlong(node->lonoffset));
740    
741 amb 217 if(lat>LatMin && lat<LatMax && lon>LonMin && lon<LonMax)
742 amb 453 (*callback)(i,lat,lon);
743 amb 184 }
744     }
745     }

Properties

Name Value
cvs:description Functions for data visualisation.