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

Function msRasterizeArc

mapgeomutil.cpp:37–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36
37shapeObj *msRasterizeArc(double x0, double y0, double radius, double startAngle, double endAngle, int isSlice) {
38 static int allocated_size=100;
39 shapeObj *shape = (shapeObj*)calloc(1,sizeof(shapeObj));
40 MS_CHECK_ALLOC(shape, sizeof(shapeObj), NULL);
41 mapserver::arc arc ( x0, y0,radius,radius, startAngle*MS_DEG_TO_RAD, endAngle*MS_DEG_TO_RAD,true );
42 arc.approximation_scale ( 1 );
43 arc.rewind(1);
44 msInitShape(shape);
45
46 lineObj *line = (lineObj*)calloc(1,sizeof(lineObj));
47 if (!line) {
48 msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msRasterizeArc()" ,
49 __FILE__, __LINE__, sizeof(lineObj));
50 free(shape);
51 return NULL;
52 }
53 shape->line = line;
54 shape->numlines = 1;
55 line->point = (pointObj*)calloc(allocated_size,sizeof(pointObj));
56 if (!line->point) {
57 msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msRasterizeArc()" ,
58 __FILE__, __LINE__, allocated_size*sizeof(pointObj));
59 free(line);
60 free(shape);
61 return NULL;
62 }
63
64 line->numpoints = 0;
65
66 double x,y;
67
68 //first segment from center to first point of arc
69 if(isSlice) {
70 line->point[0].x = x0;
71 line->point[0].y = y0;
72 line->numpoints = 1;
73 }
74 while(arc.vertex(&x,&y) != mapserver::path_cmd_stop) {
75 if(line->numpoints == allocated_size) {
76 allocated_size *= 2;
77 line->point = (pointObj*)realloc(line->point, allocated_size * sizeof(pointObj));
78 if (!line->point) {
79 msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msRasterizeArc()" ,
80 __FILE__, __LINE__, allocated_size * sizeof(pointObj));
81 free(line);
82 free(shape);
83 return NULL;
84 }
85 }
86 line->point[line->numpoints].x = x;
87 line->point[line->numpoints].y = y;
88 line->numpoints++;
89 }
90
91 //make sure the shape is closed if we're doing a full circle
92 if(!isSlice && !(endAngle-startAngle)%360) {
93 if(line->point[line->numpoints-1].x != line->point[0].x ||
94 line->point[line->numpoints-1].y != line->point[0].y) {

Callers 3

msCircleDrawLineSymbolFunction · 0.85
msCircleDrawShadeSymbolFunction · 0.85
msDrawPieSliceFunction · 0.85

Calls 5

msInitShapeFunction · 0.85
msSetErrorFunction · 0.85
approximation_scaleMethod · 0.45
rewindMethod · 0.45
vertexMethod · 0.45

Tested by

no test coverage detected