Пример #1
0
	void
geod_set(int argc, char **argv) {
	paralist *start = 0, *curr;
	double es;
	char *name;
	int i;

    /* put arguments into internal linked list */
	if (argc <= 0)
		emess(1, "no arguments in initialization list");
	start = curr = pj_mkparam(argv[0]);
	for (i = 1; i < argc; ++i) {
		curr->next = pj_mkparam(argv[i]);
		curr = curr->next;
	}
	/* set elliptical parameters */
	if (pj_ell_set(pj_get_default_ctx(),start, &geod_a, &es)) emess(1,"ellipse setup failure");
	/* set units */
	if ((name = pj_param(NULL,start, "sunits").s) != NULL) {
		char *s;
                struct PJ_UNITS *unit_list = pj_get_units_ref();
		for (i = 0; (s = unit_list[i].id) && strcmp(name, s) ; ++i) ;
		if (!s)
			emess(1,"%s unknown unit conversion id", name);
		fr_meter = 1. / (to_meter = atof(unit_list[i].to_meter));
	} else
		to_meter = fr_meter = 1.;
	geod_f = es/(1 + sqrt(1 - es));
	geod_ini();
	/* check if line or arc mode */
	if (pj_param(NULL,start, "tlat_1").i) {
		double del_S;
#undef f
		phi1 = pj_param(NULL,start, "rlat_1").f;
		lam1 = pj_param(NULL,start, "rlon_1").f;
		if (pj_param(NULL,start, "tlat_2").i) {
			phi2 = pj_param(NULL,start, "rlat_2").f;
			lam2 = pj_param(NULL,start, "rlon_2").f;
			geod_inv();
			geod_pre();
		} else if ((geod_S = pj_param(NULL,start, "dS").f) != 0.) {
			al12 = pj_param(NULL,start, "rA").f;
			geod_pre();
			geod_for();
		} else emess(1,"incomplete geodesic/arc info");
		if ((n_alpha = pj_param(NULL,start, "in_A").i) > 0) {
			if (!(del_alpha = pj_param(NULL,start, "rdel_A").f))
				emess(1,"del azimuth == 0");
		} else if ((del_S = fabs(pj_param(NULL,start, "ddel_S").f)) != 0.) {
			n_S = (int)(geod_S / del_S + .5);
		} else if ((n_S = pj_param(NULL,start, "in_S").i) <= 0)
			emess(1,"no interval divisor selected");
	}
	/* free up linked list */
	for ( ; start; start = curr) {
		curr = start->next;
		pj_dalloc(start);
	}
}
Пример #2
0
	static void
do_arc(void) {
	double az;

	printLL(phi2, lam2); putchar('\n');
	for (az = al12; n_alpha--; ) {
		al12 = az = adjlon(az + del_alpha);
		geod_pre();
		geod_for();
		printLL(phi2, lam2); putchar('\n');
	}
}
Пример #3
0
	static void	/* generate intermediate geodesic coordinates */
do_geod(void) {
	double phil, laml, del_S;

	phil = phi2;
	laml = lam2;
	printLL(phi1, lam1); putchar('\n');
	for ( geod_S = del_S = geod_S / n_S; --n_S; geod_S += del_S) {
		geod_for();
		printLL(phi2, lam2); putchar('\n');
	}
	printLL(phil, laml); putchar('\n');
}
void ll_gc_ll(double lat, double lon, double brg, double dist, double *dlat, double *dlon)
{
    /*      Setup the static parameters  */
    phi1 = lat * DEGREE;            /* Initial Position  */
    lam1 = lon * DEGREE;
    al12 = brg * DEGREE;            /* Forward azimuth */
    geod_S = dist * 1852.0;         /* Distance        */

    geod_pre();
    geod_for();

    *dlat = phi2 / DEGREE;
    *dlon = lam2 / DEGREE;
}
Пример #5
0
void geod_set(int argc, char **argv)
{
    paralist *start = 0, *curr = NULL;	/* added NULL */
    double es;
    char *name;
    int i;

/*
 * put arguments into internal linked list 
 */
    if (argc <= 0)
	emess(1, "no arguments in initialization list");
    for (i = 0; i < argc; ++i)
	if (i)
	    curr = curr->next = pj_mkparam(argv[i]);
	else
	    start = curr = pj_mkparam(argv[i]);
/*
 * set elliptical parameters 
 */
    if (pj_ell_set(start, &geod_a, &es))
	emess(1, "ellipse setup failure");
/*
 * set units 
 */
    if ((name = pj_param(start, "sunits").s)) {	/* added parentheses */
	char *s;

	for (i = 0; (s = pj_units[i].id) && strcmp(name, s); ++i);
	if (!s)
	    emess(1, "%s unknown unit conversion id", name);
	fr_meter = 1. / (to_meter = atof(pj_units[i].to_meter));
    } else
	to_meter = fr_meter = 1.;
    if ((ellipse = es != 0.)) {	/* added parentheses */
	onef = sqrt(1. - es);
	geod_f = 1 - onef;
	f2 = geod_f / 2;
	f4 = geod_f / 4;
	f64 = geod_f * geod_f / 64;
    } else {
	onef = 1.;
	geod_f = f2 = f4 = f64 = 0.;
    }
/*
 * check if line or arc mode 
 */
    if (pj_param(start, "tlat_1").i) {
	double del_S;
#undef f
	phi1 = pj_param(start, "rlat_1").f;
	lam1 = pj_param(start, "rlon_1").f;
	if (pj_param(start, "tlat_2").i) {
	    phi2 = pj_param(start, "rlat_2").f;
	    lam2 = pj_param(start, "rlon_2").f;
	    geod_inv();
	    geod_pre();
	} else if ((geod_S = pj_param(start, "dS").f)) {	/* added
								 * parentheses 
								 */
	    al12 = pj_param(start, "rA").f;
	    geod_pre();
	    geod_for();
	} else
	    emess(1, "incomplete geodesic/arc info");
	if ((n_alpha = pj_param(start, "in_A").i) > 0) {
	    if (!(del_alpha = pj_param(start, "rdel_A").f))
		emess(1, "del azimuth == 0");
	} else if ((del_S = fabs(pj_param(start, "ddel_S").f))) {	/* added 
									 * parentheses 
									 */
	    n_S = geod_S / del_S + .5;
	} else if ((n_S = pj_param(start, "in_S").i) <= 0)
	    emess(1, "no interval divisor selected");
    }
/*
 * free up linked list 
 */
    for (; start; start = curr) {
	curr = start->next;
	pj_dalloc(start);
    }
}
Пример #6
0
GEODESIC_T *
GEOD_init(int argc, char **argv, GEODESIC_T *GEODESIC)
{
  paralist *start = 0, *curr = 0;
	double es;
	char *name;
	int i;


    if(0 == GEODESIC)
    {
       GEODESIC = malloc(sizeof(GEODESIC_T));
    }
    memset(GEODESIC, 0, sizeof(GEODESIC_T));

    /* put arguments into internal linked list */
	if (argc <= 0)
		emess(1, "no arguments in initialization list");
	for (i = 0; i < argc; ++i)
		if (i)
			curr = curr->next = pj_mkparam(argv[i]);
		else
			start = curr = pj_mkparam(argv[i]);
	/* set elliptical parameters */
	if (pj_ell_set(start, &GEODESIC->A, &es)) emess(1,"ellipse setup failure");
	/* set units */
	if ((name = pj_param(start, "sunits").s)) {
		char *s;
                struct PJ_UNITS *unit_list = pj_get_units_ref();
		for (i = 0; (s = unit_list[i].id) && strcmp(name, s) ; ++i) ;
		if (!s)
			emess(1,"%s unknown unit conversion id", name);
		GEODESIC->FR_METER = 1. / (GEODESIC->TO_METER = atof(unit_list[i].to_meter));
	} else
		GEODESIC->TO_METER = GEODESIC->FR_METER = 1.;
	if ((GEODESIC->ELLIPSE = (es != 0.))) {
		GEODESIC->ONEF = sqrt(1. - es);
		GEODESIC->FLAT = 1 - GEODESIC->ONEF;
		GEODESIC->FLAT2 = GEODESIC->FLAT/2;
		GEODESIC->FLAT4 = GEODESIC->FLAT/4;
		GEODESIC->FLAT64 = GEODESIC->FLAT*GEODESIC->FLAT/64;
	} else {
		GEODESIC->ONEF = 1.;
		GEODESIC->FLAT = GEODESIC->FLAT2 = GEODESIC->FLAT4 = GEODESIC->FLAT64 = 0.;
	}
	/* check if line or arc mode */
	if (pj_param(start, "tlat_1").i) {
		double del_S;
#undef f

    GEODESIC->p1.u = pj_param(start, "rlat_1").f;
		GEODESIC->p1.v = pj_param(start, "rlon_1").f;
		if (pj_param(start, "tlat_2").i) {
			GEODESIC->p2.u = pj_param(start, "rlat_2").f;
			GEODESIC->p2.v = pj_param(start, "rlon_2").f;
			geod_inv(GEODESIC);
			geod_pre(GEODESIC);
		} else if ((GEODESIC->DIST = pj_param(start, "dS").f)) {
			GEODESIC->ALPHA12 = pj_param(start, "rA").f;
			geod_pre(GEODESIC);
			geod_for(GEODESIC);
		} else emess(1,"incomplete geodesic/arc info");
		if ((GEODESIC->n_alpha = pj_param(start, "in_A").i) > 0) {
			if (!(GEODESIC->del_alpha = pj_param(start, "rdel_A").f))
				emess(1,"del azimuth == 0");
		} else if ((del_S = fabs(pj_param(start, "ddel_S").f))) {
			GEODESIC->n_S = GEODESIC->DIST / del_S + .5;
		} else if ((GEODESIC->n_S = pj_param(start, "in_S").i) <= 0)
			emess(1,"no interval divisor selected");
	}
	/* free up linked list */
	for ( ; start; start = curr) {
		curr = start->next;
		pj_dalloc(start);
	}
  return GEODESIC;
}
Пример #7
0
	static void	/* file processing function */
process(FILE *fid) {
	char line[MAXLINE+3], *s;

	for (;;) {
		++emess_dat.File_line;
		if (!(s = fgets(line, MAXLINE, fid)))
			break;
		if (!strchr(s, '\n')) { /* overlong line */
			int c;
			strcat(s, "\n");
			/* gobble up to newline */
			while ((c = fgetc(fid)) != EOF && c != '\n') ;
		}
		if (*s == tag) {
			fputs(line, stdout);
			continue;
		}
		phi1 = dmstor(s, &s);
		lam1 = dmstor(s, &s);
		if (inverse) {
			phi2 = dmstor(s, &s);
			lam2 = dmstor(s, &s);
			geod_inv();
		} else {
			al12 = dmstor(s, &s);
			geod_S = strtod(s, &s) * to_meter;
			geod_pre();
			geod_for();
		}
		if (!*s && (s > line)) --s; /* assumed we gobbled \n */
		if (pos_azi) {
			if (al12 < 0.) al12 += M_TWOPI;
			if (al21 < 0.) al21 += M_TWOPI;
		}
		if (fullout) {
			printLL(phi1, lam1); TAB;
			printLL(phi2, lam2); TAB;
			if (oform) {
				(void)printf(oform, al12 * RAD_TO_DEG); TAB;
				(void)printf(oform, al21 * RAD_TO_DEG); TAB;
				(void)printf(osform, geod_S * fr_meter);
			}  else {
				(void)fputs(rtodms(pline, al12, 0, 0), stdout); TAB;
				(void)fputs(rtodms(pline, al21, 0, 0), stdout); TAB;
				(void)printf(osform, geod_S * fr_meter);
			}
		} else if (inverse)
			if (oform) {
				(void)printf(oform, al12 * RAD_TO_DEG); TAB;
				(void)printf(oform, al21 * RAD_TO_DEG); TAB;
				(void)printf(osform, geod_S * fr_meter);
			} else {
				(void)fputs(rtodms(pline, al12, 0, 0), stdout); TAB;
				(void)fputs(rtodms(pline, al21, 0, 0), stdout); TAB;
				(void)printf(osform, geod_S * fr_meter);
			}
		else {
			printLL(phi2, lam2); TAB;
			if (oform)
				(void)printf(oform, al21 * RAD_TO_DEG);
			else
				(void)fputs(rtodms(pline, al21, 0, 0), stdout);
		}
		(void)fputs(s, stdout);
	}
}