31 double temp2 = radius / 6371;
32 double temp1 = sin(temp2 / 2.0) * sin(temp2 / 2.0);
34 double max_delta_latitude = asin(sqrt(temp1)) * 360.0 /
PI;
37 double my_pow = pow(my_cos, 2);
38 double max_delta_longitude = asin(sqrt(temp1 / my_pow)) * 360.0 /
PI;
40 std::uniform_real_distribution<double> dist_longitude(-max_delta_longitude, max_delta_longitude);
41 std::uniform_real_distribution<double> dist_latitude(-max_delta_latitude, max_delta_latitude);
45 double new_longitude = coord.
m_longitude + dist_longitude(rng);
46 double new_latitude = coord.
m_latitude + dist_latitude(rng);
51 this->convertToRegularCoordinates(new_latitude, new_longitude);
53 }
while (getDistance(coord, random_coordinate) > radius);
54 return random_coordinate;
67 double lon_diff = lon2_rad - lon1_rad;
68 double x = cos(lat2_rad) * cos(lon_diff);
69 double y = cos(lat2_rad) * sin(lon_diff);
71 double center_lat = atan2(sin(lat1_rad) + sin(lat2_rad),
72 sqrt((cos(lat1_rad) + x) * (cos(lat1_rad) + x) + y * y));
73 double center_lon = lon1_rad + atan2(y, cos(lat1_rad) + x);
78 void convertToRegularCoordinates(
double& latitude,
double& longitude)
const;
Time Dependent Person DataType.
GeoCoordinate generateRandomCoord(const GeoCoordinate &coord, double radius, T rng) const
Result is in kilometers Uses the haversine formula See: http://www.movable-type.co.uk/scripts/latlong.html.
GeoCoordinate getMiddle(const GeoCoordinate &coord1, const GeoCoordinate &coord2) const
radius is in kilometres TODO make the distribution fair