PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ellipsoid_in()

Datum ellipsoid_in ( PG_FUNCTION_ARGS  )

Definition at line 81 of file lwgeom_spheroid.c.

References SPHEROID::a, SPHEROID::b, SPHEROID::e, SPHEROID::e_sq, ellipsoid_out(), SPHEROID::f, SPHEROID::name, and PG_FUNCTION_INFO_V1().

82 {
83  char *str = PG_GETARG_CSTRING(0);
84  SPHEROID *sphere = (SPHEROID *) palloc(sizeof(SPHEROID));
85  int nitems;
86  double rf;
87 
88  memset(sphere,0, sizeof(SPHEROID));
89 
90  if (strstr(str,"SPHEROID") != str )
91  {
92  elog(ERROR,"SPHEROID parser - doesn't start with SPHEROID");
93  pfree(sphere);
94  PG_RETURN_NULL();
95  }
96 
97  nitems = sscanf(str,"SPHEROID[\"%19[^\"]\",%lf,%lf]",
98  sphere->name, &sphere->a, &rf);
99 
100  if ( nitems==0)
101  nitems = sscanf(str,"SPHEROID(\"%19[^\"]\",%lf,%lf)",
102  sphere->name, &sphere->a, &rf);
103 
104  if (nitems != 3)
105  {
106  elog(ERROR,"SPHEROID parser - couldnt parse the spheroid");
107  pfree(sphere);
108  PG_RETURN_NULL();
109  }
110 
111  sphere->f = 1.0/rf;
112  sphere->b = sphere->a - (1.0/rf)*sphere->a;
113  sphere->e_sq = ((sphere->a*sphere->a) - (sphere->b*sphere->b)) /
114  (sphere->a*sphere->a);
115  sphere->e = sqrt(sphere->e_sq);
116 
117  PG_RETURN_POINTER(sphere);
118 
119 }
double b
Definition: liblwgeom.h:314
double f
Definition: liblwgeom.h:315
double e
Definition: liblwgeom.h:316
double e_sq
Definition: liblwgeom.h:317
double a
Definition: liblwgeom.h:313
char name[20]
Definition: liblwgeom.h:319
Here is the call graph for this function: