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

Function osGenerateArc

maporaclespatial.c:1191–1280  ·  view source on GitHub ↗

Part of this function was based on Terralib function TeGenerateArc * found in TeGeometryAlgorith.cpp (www.terralib.org). * Part of this function was based on Dr. Ialo (Univali/Cttmar) functions. */

Source from the content-addressed store, hash-verified

1189 * found in TeGeometryAlgorith.cpp (www.terralib.org).
1190 * Part of this function was based on Dr. Ialo (Univali/Cttmar) functions. */
1191static void osGenerateArc(shapeObj *shape, lineObj arcline, lineObj points, int i, int n, int data3d, int data4d)
1192{
1193 double mult, plus1, plus2, plus3, bpoint;
1194 double cx, cy;
1195 double radius, side, area, npoints;
1196 double dist1 = 0;
1197 double dist2 = 0;
1198 pointObj point5[4];
1199
1200 mult = ( points.point[i+1].x - points.point[i].x )
1201 * ( points.point[i+2].y - points.point[i].y )
1202 - ( points.point[i+1].y - points.point[i].y )
1203 * ( points.point[i+2].x - points.point[i].x );
1204
1205 if (mult)
1206 {
1207 /*point5 = (pointObj *)malloc(sizeof(pointObj)*(4));*/
1208
1209 plus1 = points.point[i].x * points.point[i].x + points.point[i].y * points.point[i].y;
1210 plus2 = points.point[i+1].x * points.point[i+1].x + points.point[i+1].y * points.point[i+1].y;
1211 plus3 = points.point[i+2].x * points.point[i+2].x + points.point[i+2].y * points.point[i+2].y;
1212
1213 bpoint = plus1 * ( points.point[i+1].y - points.point[i+2].y )
1214 + plus2 * ( points.point[i+2].y - points.point[i].y )
1215 + plus3 * ( points.point[i].y - points.point[i+1].y );
1216
1217 cx = bpoint / (2.0 * mult);
1218
1219 bpoint = plus1 * ( points.point[i+2].x - points.point[i+1].x )
1220 + plus2 * ( points.point[i].x - points.point[i+2].x )
1221 + plus3 * ( points.point[i+1].x - points.point[i].x );
1222
1223 cy = bpoint / (2.0 * mult);
1224
1225 dist1 = (points.point[i+1].x - points.point[i].x) * (cy - points.point[i].y);
1226 dist2 = (points.point[i+1].y - points.point[i].y) * (cx - points.point[i].x);
1227 side = 0;
1228
1229 if((dist1-dist2) > 0)
1230 side = 1;
1231 else
1232 {
1233 if((dist1-dist2) < 0)
1234 side = -1;
1235 }
1236
1237 point5[0] = points.point[i];
1238 point5[1] = points.point[i+1];
1239 point5[2] = points.point[i+2];
1240 point5[3].x = cx;
1241 point5[3].y = cy;
1242
1243 radius = osCalculateArcRadius(point5);
1244
1245 area = ((points.point[i].x + points.point[i+1].x) * (points.point[i+1].y - points.point[i].y))
1246 + ((points.point[i+1].x + points.point[i+2].x) * (points.point[i+2].y - points.point[i+1].y));
1247
1248 npoints = labs(area/radius);

Callers 1

osArcPolygonFunction · 0.85

Calls 3

osCalculateArcRadiusFunction · 0.85
osCalculateArcFunction · 0.85
msAddLineFunction · 0.85

Tested by

no test coverage detected