160 |
|
|
161 |
void pos2lpos(bounds_t *bounds, pos_t *pos, lpos_t *lpos) { |
void pos2lpos(bounds_t *bounds, pos_t *pos, lpos_t *lpos) { |
162 |
lpos->x = POS_EQ_RADIUS * DEG2RAD(pos->lon); |
lpos->x = POS_EQ_RADIUS * DEG2RAD(pos->lon); |
163 |
|
#ifdef USE_FLOAT |
164 |
|
lpos->y = POS_EQ_RADIUS * logf(tanf(M_PI/4 + DEG2RAD(pos->lat)/2)); |
165 |
|
#else |
166 |
lpos->y = POS_EQ_RADIUS * log(tan(M_PI/4 + DEG2RAD(pos->lat)/2)); |
lpos->y = POS_EQ_RADIUS * log(tan(M_PI/4 + DEG2RAD(pos->lat)/2)); |
167 |
|
#endif |
168 |
lpos->x = ( lpos->x - bounds->center.x) * bounds->scale; |
lpos->x = ( lpos->x - bounds->center.x) * bounds->scale; |
169 |
lpos->y = (-lpos->y + bounds->center.y) * bounds->scale; |
lpos->y = (-lpos->y + bounds->center.y) * bounds->scale; |
170 |
} |
} |
172 |
/* the maps center is special as it isn't offset (by itself) */ |
/* the maps center is special as it isn't offset (by itself) */ |
173 |
void pos2lpos_center(pos_t *pos, lpos_t *lpos) { |
void pos2lpos_center(pos_t *pos, lpos_t *lpos) { |
174 |
lpos->x = POS_EQ_RADIUS * DEG2RAD(pos->lon); |
lpos->x = POS_EQ_RADIUS * DEG2RAD(pos->lon); |
175 |
|
#ifdef USE_FLOAT |
176 |
|
lpos->y = POS_EQ_RADIUS * logf(tanf(M_PI/4 + DEG2RAD(pos->lat)/2)); |
177 |
|
#else |
178 |
lpos->y = POS_EQ_RADIUS * log(tan(M_PI/4 + DEG2RAD(pos->lat)/2)); |
lpos->y = POS_EQ_RADIUS * log(tan(M_PI/4 + DEG2RAD(pos->lat)/2)); |
179 |
|
#endif |
180 |
} |
} |
181 |
|
|
182 |
void lpos2pos(bounds_t *bounds, lpos_t *lpos, pos_t *pos) { |
void lpos2pos(bounds_t *bounds, lpos_t *lpos, pos_t *pos) { |
186 |
tmp.y = (-tmp.y/bounds->scale) + bounds->center.y; |
tmp.y = (-tmp.y/bounds->scale) + bounds->center.y; |
187 |
|
|
188 |
pos->lon = RAD2DEG(tmp.x / POS_EQ_RADIUS); |
pos->lon = RAD2DEG(tmp.x / POS_EQ_RADIUS); |
189 |
|
#ifdef USE_FLOAT |
190 |
|
pos->lat = RAD2DEG(2 * atanf(expf(tmp.y/POS_EQ_RADIUS)) - M_PI/2); |
191 |
|
#else |
192 |
pos->lat = RAD2DEG(2 * atan(exp(tmp.y/POS_EQ_RADIUS)) - M_PI/2); |
pos->lat = RAD2DEG(2 * atan(exp(tmp.y/POS_EQ_RADIUS)) - M_PI/2); |
193 |
|
#endif |
194 |
} |
} |
195 |
|
|
196 |
void pos_dist_str(char *str, int len, pos_float_t dist, gboolean is_mil) { |
void pos_dist_str(char *str, int len, pos_float_t dist, gboolean is_mil) { |