PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ellipsoid_in()

Datum ellipsoid_in ( PG_FUNCTION_ARGS  )

Definition at line 80 of file lwgeom_spheroid.c.

81{
82 char *str = PG_GETARG_CSTRING(0);
83 SPHEROID *sphere = (SPHEROID *) palloc(sizeof(SPHEROID));
84 int nitems;
85 double rf;
86
87 memset(sphere,0, sizeof(SPHEROID));
88
89 if (strstr(str,"SPHEROID") != str )
90 {
91 elog(ERROR,"SPHEROID parser - doesn't start with SPHEROID");
92 pfree(sphere);
93 PG_RETURN_NULL();
94 }
95
96 nitems = sscanf(str,"SPHEROID[\"%19[^\"]\",%lf,%lf]",
97 sphere->name, &sphere->a, &rf);
98
99 if (nitems != 3)
100 nitems = sscanf(str,"SPHEROID(\"%19[^\"]\",%lf,%lf)",
101 sphere->name, &sphere->a, &rf);
102
103 if (nitems != 3)
104 {
105 elog(ERROR,"SPHEROID parser - couldn't parse the spheroid");
106 pfree(sphere);
107 PG_RETURN_NULL();
108 }
109
110 sphere->f = 1.0/rf;
111 sphere->b = sphere->a - (1.0/rf)*sphere->a;
112 sphere->e_sq = ((sphere->a*sphere->a) - (sphere->b*sphere->b)) /
113 (sphere->a*sphere->a);
114 sphere->e = sqrt(sphere->e_sq);
115
116 PG_RETURN_POINTER(sphere);
117
118}
#define str(s)
double e_sq
Definition liblwgeom.h:379
double e
Definition liblwgeom.h:378
double a
Definition liblwgeom.h:375
double b
Definition liblwgeom.h:376
double f
Definition liblwgeom.h:377
char name[20]
Definition liblwgeom.h:381

References SPHEROID::a, SPHEROID::b, SPHEROID::e, SPHEROID::e_sq, SPHEROID::f, SPHEROID::name, and str.