PostGIS  2.1.10dev-r@@SVN_REVISION@@
static char* lwdoubles_to_latlon ( double  lat,
double  lon,
const char *  format 
)
static

Definition at line 364 of file lwprint.c.

References lwalloc(), lwdouble_to_dms(), lwfree(), lwprint_normalize_latlon(), and result.

Referenced by lwpoint_to_latlon().

365 {
366  char * lat_text;
367  char * lon_text;
368  char * result;
369 
370  /* Normalize lat/lon to the normal (-90 to 90, -180 to 180) range. */
371  lwprint_normalize_latlon(&lat, &lon);
372  /* This is somewhat inefficient as the format is parsed twice. */
373  lat_text = lwdouble_to_dms(lat, "N", "S", format);
374  lon_text = lwdouble_to_dms(lon, "E", "W", format);
375 
376  /* lat + lon + a space between + the null terminator. */
377  result = (char*)lwalloc(strlen(lat_text) + strlen(lon_text) + 2);
378  sprintf(result, "%s %s", lat_text, lon_text);
379  lwfree(lat_text);
380  lwfree(lon_text);
381  return result;
382 }
void lwfree(void *mem)
Definition: lwutil.c:190
char ** result
Definition: liblwgeom.h:218
static void lwprint_normalize_latlon(double *lat, double *lon)
Definition: lwprint.c:15
static char * lwdouble_to_dms(double val, const char *pos_dir_symbol, const char *neg_dir_symbol, const char *format)
Definition: lwprint.c:57
void * lwalloc(size_t size)
Definition: lwutil.c:175

Here is the call graph for this function:

Here is the caller graph for this function: