PostGIS  2.2.7dev-r@@SVN_REVISION@@
projPJ lwproj_from_string ( const char *  txt)

Get a projection from a string representation.

Eg: "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"

Definition at line 160 of file liblwgeom/lwgeom_transform.c.

References lwalloc(), and lwfree().

Referenced by gml_reproject_pa(), and transform_geom().

161 {
162  int t;
163  char *params[1024]; /* one for each parameter */
164  char *loc;
165  char *str;
166  size_t slen;
167  projPJ result;
168 
169 
170  if (str1 == NULL) return NULL;
171 
172  slen = strlen(str1);
173 
174  if (slen == 0) return NULL;
175 
176  str = lwalloc(slen+1);
177  strcpy(str, str1);
178 
179  /*
180  * first we split the string into a bunch of smaller strings,
181  * based on the " " separator
182  */
183 
184  params[0] = str; /* 1st param, we'll null terminate at the " " soon */
185 
186  loc = str;
187  t = 1;
188  while ((loc != NULL) && (*loc != 0) )
189  {
190  loc = strchr(loc, ' ');
191  if (loc != NULL)
192  {
193  *loc = 0; /* null terminate */
194  params[t] = loc+1;
195  loc++; /* next char */
196  t++; /*next param */
197  }
198  }
199 
200  if (!(result=pj_init(t, params)))
201  {
202  lwfree(str);
203  return NULL;
204  }
205  lwfree(str);
206  return result;
207 }
void lwfree(void *mem)
Definition: lwutil.c:214
void * lwalloc(size_t size)
Definition: lwutil.c:199

Here is the call graph for this function:

Here is the caller graph for this function: