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

Function osCalculateArc

maporaclespatial.c:1080–1186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1078}
1079
1080static void osCalculateArc(pointObj *pnt, int data3d, int data4d, double area, double radius, double npoints, int side, lineObj arcline, shapeObj *shape)
1081{
1082 double length, ctrl, angle;
1083 double divbas, plusbas, cosbas, sinbas = 0;
1084#ifdef USE_POINT_Z_M
1085 double zrange = 0;
1086#endif /* USE_POINT_Z_M */
1087 int i = 0;
1088
1089 if ( npoints > 0 )
1090 {
1091 length = sqrt(((pnt[1].x-pnt[0].x)*(pnt[1].x-pnt[0].x))+((pnt[1].y-pnt[0].y)*(pnt[1].y-pnt[0].y)));
1092 ctrl = length/(2*radius);
1093
1094#ifdef USE_POINT_Z_M
1095 if (data3d||data4d)
1096 {
1097 zrange = labs(pnt[0].z-pnt[1].z)/npoints;
1098 if ((pnt[0].z > pnt[1].z) && side == 1)
1099 zrange *= -1;
1100 else if ((pnt[0].z < pnt[1].z) && side == 1)
1101 zrange = zrange;
1102 else if ((pnt[0].z > pnt[1].z) && side != 1)
1103 zrange *= -1;
1104 else if ((pnt[0].z < pnt[1].z) && side != 1)
1105 zrange = zrange;
1106 }
1107#endif /* USE_POINT_Z_M */
1108
1109 if( ctrl <= 1 )
1110 {
1111 divbas = 2 * asin(ctrl);
1112 plusbas = divbas/(npoints);
1113 cosbas = (pnt[0].x-pnt[3].x)/radius;
1114 sinbas = (pnt[0].y-pnt[3].y)/radius;
1115 angle = plusbas;
1116
1117 arcline.point = (pointObj *)malloc(sizeof(pointObj)*(npoints+1));
1118 arcline.point[0].x = pnt[0].x;
1119 arcline.point[0].y = pnt[0].y;
1120#ifdef USE_POINT_Z_M
1121 if (data3d||data4d)
1122 arcline.point[0].z = pnt[0].z;
1123#endif /* USE_POINT_Z_M */
1124
1125 for (i = 1; i <= npoints; i++)
1126 {
1127 if( side == 1)
1128 {
1129 arcline.point[i].x = pnt[3].x + radius * ((cosbas*cos(angle))-(sinbas*sin(angle)));
1130 arcline.point[i].y = pnt[3].y + radius * ((sinbas*cos(angle))+(cosbas*sin(angle)));
1131#ifdef USE_POINT_Z_M
1132 if (data3d||data4d)
1133 arcline.point[i].z = pnt[0].z + (zrange*i);
1134#endif /* USE_POINT_Z_M */
1135 }
1136 else
1137 {

Callers 1

osGenerateArcFunction · 0.85

Calls 1

msAddLineFunction · 0.85

Tested by

no test coverage detected