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

Class line_adaptor

mapagg.h:36–86  ·  view source on GitHub ↗

* interface to a shapeObj representing lines, providing the functions * needed by the agg rasterizer. treats shapeObjs with multiple linestrings. */

Source from the content-addressed store, hash-verified

34 * needed by the agg rasterizer. treats shapeObjs with multiple linestrings.
35 */
36class line_adaptor {
37public:
38 line_adaptor(shapeObj *shape):s(shape)
39 {
40 m_line=s->line; /*first line*/
41 m_point=m_line->point; /*current vertex is first vertex of first line*/
42 m_lend=&(s->line[s->numlines]); /*pointer to after last line*/
43 m_pend=&(m_line->point[m_line->numpoints]); /*pointer to after last vertex of first line*/
44 }
45
46 /* a class with virtual functions should also provide a virtual destructor */
47 virtual ~line_adaptor() {}
48
49 void rewind(unsigned) {
50 m_line=s->line; /*first line*/
51 m_point=m_line->point; /*current vertex is first vertex of first line*/
52 m_pend=&(m_line->point[m_line->numpoints]); /*pointer to after last vertex of first line*/
53 }
54
55 virtual unsigned vertex(double* x, double* y)
56 {
57 if(m_point < m_pend)
58 {
59 /*here we treat the case where a real vertex is returned*/
60 bool first = m_point == m_line->point; /*is this the first vertex of a line*/
61 *x = m_point->x;
62 *y = m_point->y;
63 m_point++;
64 return first ? mapserver::path_cmd_move_to : mapserver::path_cmd_line_to;
65 }
66 /*if here, we're at the end of a line*/
67 m_line++;
68 *x = *y = 0.0;
69 if(m_line>=m_lend) /*is this the last line of the shapObj. normally,
70 (m_line==m_lend) should be a sufficient test, as the caller should not call
71 this function if a previous call returned path_cmd_stop.*/
72 return mapserver::path_cmd_stop; /*no more points to process*/
73
74 /*if here, there are more lines in the shapeObj, continue with next one*/
75 m_point=m_line->point; /*pointer to first point of next line*/
76 m_pend=&(m_line->point[m_line->numpoints]); /*pointer to after last point of next line*/
77
78 return vertex(x,y); /*this will return the first point of the next line*/
79 }
80private:
81 shapeObj *s;
82 lineObj *m_line, /*current line pointer*/
83 *m_lend; /*points to after the last line*/
84 pointObj *m_point, /*current point*/
85 *m_pend; /*points to after last point of current line*/
86};
87
88class offset_line_adaptor: public line_adaptor {
89public:

Callers 1

agg2RenderLineFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected