MCPcopy Create free account
hub / github.com/MapServer/MapServer / path_length

Function path_length

renderers/agg/include/agg_path_length.h:23–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21{
22 template<class VertexSource>
23 double path_length(VertexSource& vs, unsigned path_id = 0)
24 {
25 double len = 0.0;
26 double start_x = 0.0;
27 double start_y = 0.0;
28 double x1 = 0.0;
29 double y1 = 0.0;
30 double x2 = 0.0;
31 double y2 = 0.0;
32 bool first = true;
33
34 unsigned cmd;
35 vs.rewind(path_id);
36 while(!is_stop(cmd = vs.vertex(&x2, &y2)))
37 {
38 if(is_vertex(cmd))
39 {
40 if(first || is_move_to(cmd))
41 {
42 start_x = x2;
43 start_y = y2;
44 }
45 else
46 {
47 len += calc_distance(x1, y1, x2, y2);
48 }
49 x1 = x2;
50 y1 = y2;
51 first = false;
52 }
53 else
54 {
55 if(is_close(cmd) && !first)
56 {
57 len += calc_distance(x1, y1, start_x, start_y);
58 }
59 }
60 }
61 return len;
62 }
63}
64
65#endif

Callers

nothing calls this directly

Calls 7

is_stopFunction · 0.85
is_vertexFunction · 0.85
is_move_toFunction · 0.85
calc_distanceFunction · 0.85
is_closeFunction · 0.85
rewindMethod · 0.45
vertexMethod · 0.45

Tested by

no test coverage detected