Plan 9 from Bell Labs’s /usr/web/sources/contrib/tristan/root/sys/src/cmd/geo/proj/ell.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>

#include "project.h"

static struct {
	double a, x;
	char *name, *description;
} ell_list[] = {	/* list stolen from PROJ.4 */
	6378137.0,	1/298.257223563,	"wgs84",		"WGS 84",
	6377563.396,	6356256.910,		"airy",		"Airy 1830",
	6377104.43,	1/300.0,			"andrae",		"Andrae 1876 (Den., Iclnd.)",
	6378137.0,	1/298.25,			"apl4.9",		"Appl. Physics. 1965",
	6378160.0,	1/298.25,			"aust_sa",		"Australian Natl & S. Amer. 1969",
	6377397.155,	1/299.1528128,	"bessel",		"Bessel 1841",
	6377483.865,	1/299.1528128,	"bess_nam",	"Bessel 1841 (Namibia)",
	6378206.4,	6356583.8,		"clrk66",		"Clarke 1866",
	6378249.145,	1/293.4663,		"clrk80",		"Clarke 1880 mod.",
	6375738.7,	1/334.29,			"cpm",		"Comm. des Poids et Mesures 1799",
	6376428.0,	1/311.5,			"delmbr",		"Delambre 1810 (Belgium)",
	6378136.05,	1/298.2566,		"engelis",		"Engelis 1985",
	6377276.345,	1/300.8017,		"evrst30",		"Everest 1830",
	6377304.063,	1/300.8017,		"evrst48",		"Everest 1948",
	6377301.243,	1/300.8017,		"evrst56",		"Everest 1956",
	6377295.664,	1/300.8017,		"evrst69",		"Everest 1969",
	6377298.556,	1/300.8017,		"evrstss",		"Everest (Sabah & Sarawak)",
	6378166.0,	1/298.3,			"fschr60",		"Fischer (Mercury Datum) 1960",
	6378155.0,	1/298.3,			"fschr60m",	"Modified Fischer 1960",
	6378150.0,	1/298.3,			"fschr68",		"Fischer 1968",
	6378160.0,	1/298.2471674270,	"grs67",		"GRS 67 (IUGG 1967)",
	6378137.0,	1/298.257222101,	"grs80",		"GRS 1980(IUGG 1980)",
	6378200.0,	1/298.3,			"helmert",		"Helmert 1906",
	6378270.0,	1/297.0,			"hough",		"Hough",
	6378140.0,	1/298.257,		"iau76",		"IAU 1976",
	6378388.0,	1/297.0,			"intl",		"International 1909 (Hayford)",
	6378163.0,	1/298.24,			"kaula",		"Kaula 1961",
	6378245.0,	1/298.3,			"krass",		"Krassovsky 1942",
	6378139.0,	1/298.257,		"lerch",		"Lerch 1979",
	6378137.0,	1/298.257,		"merit",		"MERIT 1983",
	6377340.189,	6356034.446,		"mod_airy",	"Modified Airy",
	6397300.0,	1/191.0,			"mprts",		"Maupertius 1738",
	6378157.5,	6356772.2,		"new_intl",	"New International 1967",
	6378145.0,	1/298.25,			"nwl9d",		"Naval Weapons Lab. 1965",
	6376523.0,	6355863.0,		"plessis",		"Plessis 1817 (France)",
	6378155.0,	6356773.3205,		"seasia",		"Southeast Asia",
	6378136.0,	1/298.257,		"sgs85",		"Soviet Geodetic System 85",
	6376896.0,	6355834.8467,		"walbeck",	"Walbeck",
	6378165.0,	1/298.3,			"wgs60",		"WGS 60",
	6378145.0,	1/298.25,			"wgs66",		"WGS 66",
	6378135.0,	1/298.26,			"wgs72", 		"WGS 72",
};

static void
calc_ell(struct elliptic *ell) {
	if(!ell->f)
		ell->f = 1. - ell->b/ell->a;
	if(!ell->b)
		ell->b = (1 - ell->f)*ell->a;
	ell->e⁲ = ell->f*(2. - ell->f);
	ell->E⁲ = ell->e⁲/(1. - ell->e⁲);
	if(!ell_en_init(ell))
		exits("en_init");
}

int
get_ell(struct elliptic *ell, char *name) {
	int i, m;

	if(name==nil) return 0;

	m = sizeof(ell_list)/sizeof(*ell_list);
	for(i=0; i < m; i++)
		if(!strcmp(name, ell_list[i].name)) break;
	if(i==m) return 0;

	ell->a = ell_list[i].a;
	if(ell_list[i].x > 1){
		ell->b = ell_list[i].x;
		ell->f = 0;
	}else{
		ell->f = ell_list[i].x;
		ell->b = 0;
	}
	calc_ell(ell);
	return 1;
}

void
list_ell(void){
	int i, m;

	print("Valid Ellipsoids:\n");
	m=sizeof(ell_list)/sizeof(*ell_list);
	for(i=0;i<m;i++)
		print("	%s	%s\n", ell_list[i].name, ell_list[i].description);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].