Definition at line 80 of file lwgeom_spheroid.c.
81{
82 char *
str = PG_GETARG_CSTRING(0);
84 int nitems;
85 double rf;
86
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
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}
References SPHEROID::a, SPHEROID::b, SPHEROID::e, SPHEROID::e_sq, SPHEROID::f, SPHEROID::name, and str.