I wrote a function in C++, and I get the following error about it:
syntax error: missing ')' before identifier 'mask
Is there something wrong with my code?
Here is the function:
auto calcTileDataForC(tile, std::map mask, double lat = 0.0, double lon = 0.0, int min_dist = 0, int hA = 0, double K = 0.0, double pixel_height = 0.0, double pixel_width = 0.0, double rectTop = 0.0, double rectLeft = 0.0)
{
const double PI = acos(-1);
const double DEG2RAD = PI / 180;
const double PI2 = PI * 2;
const double a = 6378137; // # ellipsoid semi-major axes
const double f = 1 / 298.257223563; // flattening
const double b = a * (1 - f); // ellipsoid semi-minor axes
const double e2 = 2 * f - pow(f, 2); // squared first eccentricity
const double ecc = sqrt(std::exp(1));
// WGS84.e2 הוא קנה מידה המייצג את רמת העקומה של כדור האדמה.
// point coordinates in rads
const double _rdLatA = lat * DEG2RAD;
const double _rdLonA = lon * DEG2RAD;
const double sin_rdLatA = sin(_rdLatA);
const double cos_rdLatA = cos(_rdLatA);
const double sin_rdLon = sin(_rdLonA);
const double cos_rdLon = cos(_rdLonA);
// coordinate of pixels center
std::vector center__rdLons;
const double lon_width = (a * PI2 * cos(lat * DEG2RAD)) / 360;
const double lat_height = 40000000 / 360;
std::vector sin_rdLonB;
std::vector cos_rdLonB;
std::vector sin_rdLonBA;
std::vector cos_rdLonBA;
// x loop
for (int x = 0; x < tile[0].size() + 1; x++)
{
double _rdLonB = pixels2mapForC(0, x, pixel_height, pixel_width, rectTop, rectLeft, true).second * DEG2RAD;
sin_rdLonBA[x] = sin(_rdLonB - _rdLonA);
cos_rdLonBA[x] = cos(_rdLonB - _rdLonA);
if (tile[0].size() == x)
break;
center__rdLons[x] = _rdLonB + pixel_width / 2;
double ref_corr_center__rdLons = (center__rdLons[x] - _rdLonA) * (1 - K) + _rdLonA;
sin_rdLonB[x] = sin(ref_corr_center__rdLons);
cos_rdLonB[x] = cos(ref_corr_center__rdLons);
}
std::vector _rdLatB;
std::vector cos_rdLatB;
std::vector sin_rdLatB;
std::vector sin_rdLatB1;
std::vector cos_rdLatB1;
std::vector N_rdLatB;
std::vector ff;
// y loop
for (int y = 0; y < tile.size(); y++)
{
_rdLatB[y] = pixels2mapForC(y, 0, pixel_height, pixel_width, rectTop, rectLeft, true).first * DEG2RAD;
cos_rdLatB[y] = cos(_rdLatB[y]);
sin_rdLatB[y] = sin(_rdLatB[y]);
double center__rdLats = _rdLatB[y] + pixel_height / 2;
ff[y] = pow(((center__rdLats / DEG2RAD - lat) * lat_height), 2);
double ref_corr_center__rdLats =
(center__rdLats - _rdLatA) * (1 - K) + _rdLatA;
sin_rdLatB1[y] = sin(ref_corr_center__rdLats);
cos_rdLatB1[y] = cos(ref_corr_center__rdLats);
N_rdLatB[y] =
a / sqrt(pow(1 - e2 * sin(ref_corr_center__rdLats), 2));
}
double N_rdLat = a / sqrt(pow(1 - e2 * sin(_rdLatA), 2));
const double xA = (N_rdLat + hA) * cos_rdLon * cos_rdLatA;
const double yA = (N_rdLat + hA) * sin_rdLon * cos_rdLatA;
const double zA = (N_rdLat * (1 - e2) + hA) * sin_rdLatA;
// calculate te normal to the tangent plane at point(lat, lon) on the geoid
vector Na{cos_rdLon * cos_rdLatA, sin_rdLon * cos_rdLatA, sin_rdLatA};
const int n = 360;
std::vector horizon_pointsY;
std::vector horizon_pointsX;
std::vector horizon;
for (int y = 0; y < tile.size(); y++)
{
for (int x = 0; x < tile[0].size() + 1; x++)
{
if (y >= mask["ystart"] && y <= mask["yend"] && x >= mask["xstart"] && x <= mask["xend"])
continue;
// calculate azimuth...
double colIn = 0.0;
double colOut = 0.0;
for (int yy = y; yy < y + 2; yy++)
{
for (int xx = x; xx < x + 2; xx++)
{
double b = cos_rdLonBA[xx] * cos_rdLatB[yy] * sin_rdLatA;
double d = cos_rdLatA * sin_rdLatB[yy] - b;
double azs = atan((sin_rdLonBA[xx] * cos_rdLatB[yy]) / d);
double n_1 = azs + (d < 0 ? 1 : 0) * PI;
double az = (n_1 < 0 ? PI2 : 0) + (n_1 < 0 ? -(std::fmod(std::abs(n_1), PI2)) : (std::fmod(n_1, PI2)));
double res = isnan(az) ? 0 : az;
if (colIn == 0.0 || colIn > res)
colIn = res;
if (colOut == 0.0 || colOut < res)
colOut = res;
}
}
double in_az = colOut - colIn > PI ? colOut : colIn;
double out_az = colOut - colIn > PI ? colIn : colOut;
// # calcutlate horizon
double rounded_in = std::floor((in_az * n) / PI2);
double rounded_out = std::ceil((out_az * n) / PI2);
if (rounded_in >= rounded_out)
continue;
// calculate ang...
// # flat all point in min_daist radius
double dist =
pow((pow(((center__rdLons[x] / DEG2RAD - lon) * lon_width), 2) + ff[y]), (1 / 2));
// flat in min_distance...
double hB = dist > min_dist ? tile[y][x] : 0;
// calculate angular elevations...
double N_rdLatB_hB = hB + N_rdLatB[y];
double xB = N_rdLatB_hB * (cos_rdLatB1[y] * cos_rdLonB[x]);
double yB = N_rdLatB_hB * (cos_rdLatB1[y] * sin_rdLonB[x]);
double zB = (N_rdLatB[y] * (1 - e2) + hB) * sin_rdLatB1[y];
std::vector AB = {xB - xA, yB - yA, zB - zA};
double dot = 0;
for (int i = 0; i < AB.size(); i++)
{
dot += AB[i] * Na[i];
}
double norm = 0;
for (int i = 0; i < AB.size(); i++)
{
norm += AB[i] * AB[i];
}
norm = sqrt(norm);
const double ang = asin(dot / norm);
for (int az = rounded_in - 1; az < rounded_out + 1; az++)
{
if (
(az <= rounded_in && az + 1 >= rounded_out) ||
(az >= rounded_in && az + 1 <= rounded_out))
{
if (horizon[az] == 0 || horizon[az] < ang)
{
horizon[az] = ang;
horizon_pointsX[az] = x;
horizon_pointsY[az] = y;
}
}
}
}
}
// auto res = {horizon, horizon_pointsX, horizon_pointsY};
auto res = horizon;
return res;
}