21 #include <grass/gis.h>
22 #include <grass/glocale.h>
23 #include <grass/gprojects.h>
43 while (list !=
NULL) {
48 dstruct->dx = list->
dx;
49 dstruct->dy = list->
dy;
50 dstruct->dz = list->
dz;
87 struct gpj_datum_transform_list *list, *old;
99 *params =
G_store(list->params);
101 while (list !=
NULL) {
174 char **datumname,
char **params)
192 G_asprintf(params,
"nadgrids=%s%s/%s", gisbase, GRIDDIR,
241 char buff[1024], answer[100];
244 struct gpj_datum_transform_list *list, *listhead, *old;
245 int transformcount, currenttransform;
249 if (
NULL == (Tmp_fd = fopen(Tmp_file,
"w"))) {
250 G_warning(_(
"Unable to open temporary file"));
253 fprintf(Tmp_fd,
"Number\tDetails\t\n---\n");
257 while (list !=
NULL) {
262 "%d\tUsed in %s\n\t(PROJ.4 Params %s)\n\t%s\n---\n",
263 list->count, list->where_used, list->params,
273 (
"\nNow select Datum Transformation Parameters\n"));
275 (
"Please think carefully about the area covered by your data\n"
276 "and the accuracy you require before making your selection.\n"));
278 (
"\nEnter 'list' to see the list of available Parameter sets\n"));
280 (
"Enter the corresponding number, or <RETURN> to cancel request\n"));
281 fprintf(stderr,
">");
282 }
while (!
G_gets(answer));
284 if (strlen(answer) == 0) {
289 if (strcmp(answer,
"list") == 0) {
292 pager =
getenv(
"GRASS_PAGER");
293 if (!pager || strlen(pager) == 0)
297 sprintf(buff,
"%s \"%s\" 1>&2", pager,
302 if ((sscanf(answer,
"%d", ¤ttransform) != 1) ||
303 currenttransform > transformcount ||
304 currenttransform < 1) {
308 fprintf(stderr, (
"\ninvalid transformation number\n"));
319 while (list !=
NULL) {
322 if (list->count == currenttransform)
337 (
"\nPlease specify datum transformation parameters in PROJ.4 syntax. Examples:\n"));
339 (
"\ttowgs84=dx,dy,dz\t(3-parameter transformation)\n"));
341 (
"\ttowgs84=dx,dy,dz,rx,ry,rz,m\t(7-parameter transformation)\n"));
343 (
"\tnadgrids=alaska\t(Tables-based grid-shifting transformation)\n"));
344 fprintf(stderr, _(
"Hit RETURN to cancel request\n"));
345 fprintf(stderr,
">");
346 }
while (!
G_gets(answer));
348 if (strlen(answer) == 0)
352 "Parameters to be used are:\n\"%s\"\nIs this correct?",
381 char file[GPATH_MAX];
384 struct gpj_datum_transform_list *current =
NULL, *outputlist =
NULL;
385 struct gpj_datum dstruct;
389 if (dstruct.dx < 99999 && dstruct.dy < 99999 && dstruct.dz < 99999) {
394 current = outputlist =
395 G_malloc(
sizeof(
struct gpj_datum_transform_list));
397 current = current->next =
398 G_malloc(
sizeof(
struct gpj_datum_transform_list));
399 G_asprintf(&(current->params),
"towgs84=%.3f,%.3f,%.3f", dstruct.dx,
400 dstruct.dy, dstruct.dz);
401 G_asprintf(&(current->where_used),
"whole %s region", inputname);
403 "Default 3-Parameter Transformation (May not be optimum for "
404 "older datums; use this only if no more appropriate options "
407 current->count = count;
408 current->next =
NULL;
414 sprintf(file,
"%s%s",
G_gisbase(), DATUMTRANSFORMTABLE);
416 fd = fopen(file,
"r");
418 G_warning(_(
"Unable to open datum table file <%s>"), file);
422 for (line = 1;
G_getl2(buf,
sizeof(buf), fd); line++) {
423 char name[100], params[1024], where_used[1024], comment[1024];
426 if (*buf ==
'\0' || *buf ==
'#')
429 if (sscanf(buf,
"%99s \"%1023[^\"]\" \"%1023[^\"]\" \"%1023[^\"]\"",
430 name, params, where_used, comment) != 4) {
431 G_warning(_(
"Error in datum table file <%s>, line %d"), file,
440 current = outputlist =
441 G_malloc(
sizeof(
struct gpj_datum_transform_list));
443 current = current->next =
444 G_malloc(
sizeof(
struct gpj_datum_transform_list));
445 current->params =
G_store(params);
446 current->where_used =
G_store(where_used);
447 current->comment =
G_store(comment);
449 current->count = count;
450 current->next =
NULL;
488 char file[GPATH_MAX];
496 fd = fopen(file,
"r");
498 G_warning(_(
"Unable to open datum table file <%s>"), file);
502 for (line = 1;
G_getl2(buf,
sizeof(buf), fd); line++) {
507 if (*buf ==
'\0' || *buf ==
'#')
510 if (sscanf(buf,
"%s \"%1023[^\"]\" %s dx=%lf dy=%lf dz=%lf",
511 name, descr, ellps, &dx, &dy, &dz) != 6) {
512 G_warning(_(
"Error in datum table file <%s>, line %d"), file,
518 current = outputlist = G_malloc(
sizeof(
struct datum_list));
546 G_free(dstruct->longname);
561 while (dstruct !=
NULL) {