Beispiel #1
0
bool geohashBoundingBox(double latitude, double longitude, double radius_meters,
                        double *bounds) {
    if (!bounds)
        return false;

    double latr, lonr;
    latr = deg_rad(latitude);
    lonr = deg_rad(longitude);

    double distance = radius_meters / EARTH_RADIUS_IN_METERS;
    double min_latitude = latr - distance;
    double max_latitude = latr + distance;

    /* Note: we're being lazy and not accounting for coordinates near poles */
    double min_longitude, max_longitude;
    double difference_longitude = asin(sin(distance) / cos(latr));
    min_longitude = lonr - difference_longitude;
    max_longitude = lonr + difference_longitude;

    bounds[0] = rad_deg(min_latitude);
    bounds[1] = rad_deg(min_longitude);
    bounds[2] = rad_deg(max_latitude);
    bounds[3] = rad_deg(max_longitude);

    return true;
}
Beispiel #2
0
/* calculate distance using haversin great circle distance formula */
double distanceEarth(double lat1d, double lon1d, double lat2d, double lon2d) {
    double lat1r, lon1r, lat2r, lon2r, u, v;
    lat1r = deg_rad(lat1d);
    lon1r = deg_rad(lon1d);
    lat2r = deg_rad(lat2d);
    lon2r = deg_rad(lon2d);
    u = sin((lat2r - lat1r) / 2);
    v = sin((lon2r - lon1r) / 2);
    return 2.0 * EARTH_RADIUS_IN_METERS *
           asin(sqrt(u * u + cos(lat1r) * cos(lat2r) * v * v));
}
QPoint EmptyMapAdapter::coordinateToDisplay(const QPointF& coordinate) const
{
    qreal x = (coordinate.x()+180) * (numberOfTiles*mytilesize)/360.; // coord to pixel!
    qreal y = (1-(log(tan(PI/4+deg_rad(coordinate.y())/2)) /PI)) /2  * (numberOfTiles*mytilesize);

    return QPoint(int(x), int(y));
}
Beispiel #4
0
double	cosinus(int n)
{
	double	res;
	double	x;

	x = deg_rad(n);
	x += 1.57079632;
	if (x >  3.14159265)
		x -= 6.28318531;
	if (x < 0)
	{
		res = 1.27323954 * x + 0.405284735 * x * x;
		if (res < 0)
			res = .225 * (res *-res - res) + res;
		else
			res = .225 * (res * res - res) + res;
	}
	else
	{
		res = 1.27323954 * x - 0.405284735 * x * x;
		if (res < 0)
			res = .225 * (res *-res - res) + res;
		else
			res = .225 * (res * res - res) + res;
	}
	return (res);
}
Beispiel #5
0
double	sinus(int n)
{
	double	res;
	double	x;

	x = deg_rad(n);
	if (x < 0)
	{
		res = 1.27323954 * x + .405284735 * x * x;
		   
		if (res < 0)
			res = .225 * (res *-res - res) + res;
		else
		    res = .225 * (res * res - res) + res;
	}
	else
	{
		res = 1.27323954 * x - 0.405284735 * x * x;
			    
		if (res < 0)
			res = .225 * (res *-res - res) + res;
		else
		    res = .225 * (res * res - res) + res;
	}
	return (res);
}
Beispiel #6
0
double mercator_y(double lat) {
    lat = fmin(89.5, fmax(lat, -89.5));
    double phi = deg_rad(lat);
    double sinphi = sin(phi);
    double con = ECCENT * sinphi;
    con = pow((1.0 - con) / (1.0 + con), COM);
    double ts = tan(0.5 * (M_PI * 0.5 - phi)) / con;
    return 0 - R_MAJOR * log(ts);
}
Beispiel #7
0
double	tangente(int n)
{
	double	res;
	double	x;

	x = deg_rad(n);
	res = sinus(x) / cosinus(x);
	return (res);
}
QPoint TileMapAdapter::coordinateToDisplay(const QPointF& coordinate) const
{
// 	qDebug() << "numberOfTiles: " << numberOfTiles;

	double x = (coordinate.x()+180) * (numberOfTiles*tilesize)/360.;		// coord to pixel!
	double y = (1-(log(tan(PI/4+deg_rad(coordinate.y())/2)) /PI)) /2  * (numberOfTiles*tilesize);

	return QPoint(int(x), int(y));
	
}
Beispiel #9
0
static void		vars_init(t_env *e)
{
	if (e->check_x != 500)
		vars_init_loading(e);
	else
	{
		e->dirx = -1;
		e->diry = 0;
		e->planex = 0;
		e->planey = 0.66;
		e->angle = deg_rad(180);
	}
	e->rotspeed = 0.1;
	e->draw = 1;
	e->tid = 0;
	e->bol = 0;
	e->sprite_Distance = (double*)malloc(sizeof(double) * e->sprites_nb);
}
Beispiel #10
0
double mercator_x(double lon) { return R_MAJOR * deg_rad(lon); }