78 #define PI 3.1415926535897931160E0
80 #define DEGREE (PI / 180.0)
81 #define RADIAN (180.0 / PI)
83 #define DATUM_INDEX_WGS84 101
84 #define DATUM_INDEX_UNKNOWN -1
86 static const double WGS84_semimajor_axis_meters =
88 static const double mercator_k0 = 0.9996;
89 static const double WGSinvf = 298.257223563;
91 void datumParams(
short datum,
double *a,
double *es);
96 extern "C" void toDMS(
double a,
char *bufp,
int bufplen);
97 extern "C" void toDMM(
double a,
char *bufp,
int bufplen);
98 extern "C" void todmm(
int flag,
double a,
char *bufp,
int bufplen);
100 extern "C" void toTM(
float lat,
float lon,
float lat0,
float lon0,
double *x,
102 extern "C" void fromTM(
double x,
double y,
double lat0,
double lon0,
103 double *lat,
double *lon);
105 extern "C" void toSM(
double lat,
double lon,
double lat0,
double lon0,
106 double *x,
double *y);
107 extern "C" double toSMcache_y30(
double lat0);
108 extern "C" void toSMcache(
double lat,
double lon,
double y30,
double lon0,
109 double *x,
double *y);
110 extern "C" void fromSM(
double x,
double y,
double lat0,
double lon0,
111 double *lat,
double *lon);
112 extern "C" void fromSMR(
double x,
double y,
double lat0,
double lon0,
113 double axis_meters,
double *lat,
double *lon);
115 extern "C" void toSM_ECC(
double lat,
double lon,
double lat0,
double lon0,
116 double *x,
double *y);
117 extern "C" void fromSM_ECC(
double x,
double y,
double lat0,
double lon0,
118 double *lat,
double *lon);
120 extern "C" void toPOLY(
double lat,
double lon,
double lat0,
double lon0,
121 double *x,
double *y);
122 extern "C" void fromPOLY(
double x,
double y,
double lat0,
double lon0,
123 double *lat,
double *lon);
125 extern "C" void cache_phi0(
double lat0,
double *sin_phi0,
double *cos_phi0);
127 extern "C" void toORTHO(
double lat,
double lon,
double sin_phi0,
128 double cos_phi0,
double lon0,
double *x,
double *y);
129 extern "C" void fromORTHO(
double x,
double y,
double lat0,
double lon0,
130 double *lat,
double *lon);
132 extern "C" double toPOLARcache_e(
double lat0);
133 extern "C" void toPOLAR(
double lat,
double lon,
double e,
double lat0,
134 double lon0,
double *x,
double *y);
135 extern "C" void fromPOLAR(
double x,
double y,
double lat0,
double lon0,
136 double *lat,
double *lon);
138 extern "C" void toSTEREO(
double lat,
double lon,
double sin_phi0,
139 double cos_phi0,
double lon0,
double *x,
double *y);
140 extern "C" void fromSTEREO(
double x,
double y,
double lat0,
double lon0,
141 double *lat,
double *lon);
143 extern "C" void toGNO(
double lat,
double lon,
double sin_phi0,
double cos_phi0,
144 double lon0,
double *x,
double *y);
145 extern "C" void fromGNO(
double x,
double y,
double lat0,
double lon0,
146 double *lat,
double *lon);
148 extern "C" void toEQUIRECT(
double lat,
double lon,
double lat0,
double lon0,
149 double *x,
double *y);
150 extern "C" void fromEQUIRECT(
double x,
double y,
double lat0,
double lon0,
151 double *lat,
double *lon);
154 extern "C" void ll_gc_ll(
double lat,
double lon,
double crs,
double dist,
155 double *dlat,
double *dlon);
156 extern "C" void ll_gc_ll_reverse(
double lat1,
double lon1,
double lat2,
157 double lon2,
double *bearing,
double *dist);
159 extern "C" void PositionBearingDistanceMercator(
double lat,
double lon,
160 double brg,
double dist,
161 double *dlat,
double *dlon);
162 extern "C" double DistGreatCircle(
double slat,
double slon,
double dlat,
164 extern "C" double DistLoxodrome(
double slat,
double slon,
double dlat,
167 extern "C" int GetDatumIndex(
const char *str);
168 extern "C" void MolodenskyTransform(
double lat,
double lon,
double *to_lat,
169 double *to_lon,
int from_datum_index,
172 extern "C" void DistanceBearingMercator(
double lat1,
double lon1,
double lat0,
173 double lon0,
double *brg,
double *dist);
175 extern "C" int Georef_Calculate_Coefficients(
struct GeoRef *cp,
int nlin_lon);
176 extern "C" int Georef_Calculate_Coefficients_Proj(
struct GeoRef *cp);
177 extern "C" double lat_gc_crosses_meridian(
double lat1,
double lon1,
double lat2,
178 double lon2,
double lon);
179 extern "C" double lat_rl_crosses_meridian(
double lat1,
double lon1,
double lat2,
180 double lon2,
double lon);
183 void toDMS(
double a,
char *bufp,
int bufplen);
184 void toDMM(
double a,
char *bufp,
int bufplen);
185 int GetDatumIndex(
const char *str);
186 void MolodenskyTransform(
double lat,
double lon,
double *to_lat,
double *to_lon,
187 int from_datum_index,
int to_datum_index);
188 double lat_gc_crosses_meridian(
double lat1,
double lon1,
double lat2,
189 double lon2,
double lon);
190 double lat_rl_crosses_meridian(
double lat1,
double lon1,
double lat2,
191 double lon2,
double lon);
227 typedef void(lm_evaluate_ftype)(
double *par,
int m_dat,
double *fvec,
228 void *data,
int *info);
230 void lm_evaluate_default(
double *par,
int m_dat,
double *fvec,
void *data,
234 typedef void(lm_print_ftype)(
int n_par,
double *par,
int m_dat,
double *fvec,
235 void *data,
int iflag,
int iter,
int nfev);
237 void lm_print_default(
int n_par,
double *par,
int m_dat,
double *fvec,
238 void *data,
int iflag,
int iter,
int nfev);
242 void lm_minimize(
int m_dat,
int n_par,
double *par, lm_evaluate_ftype *evaluate,
243 lm_print_ftype *printout,
void *data,
245 double lm_enorm(
int,
double *);
248 void lm_lmdif(
int m,
int n,
double *x,
double *fvec,
double ftol,
double xtol,
249 double gtol,
int maxfev,
double epsfcn,
double *diag,
int mode,
250 double factor,
int *info,
int *nfev,
double *fjac,
int *ipvt,
251 double *qtf,
double *wa1,
double *wa2,
double *wa3,
double *wa4,
252 lm_evaluate_ftype *evaluate, lm_print_ftype *printout,
256 extern const char *lm_infmsg[];
257 extern const char *lm_shortmsg[];
265 double (*user_func)(
double user_tx_point,
double user_ty_point,
int n_par,