PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwdoubles_to_latlon()

static char* lwdoubles_to_latlon ( double  lat,
double  lon,
const char *  format 
)
static

Definition at line 366 of file lwprint.c.

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

Referenced by lwpoint_to_latlon().

367 {
368  char * lat_text;
369  char * lon_text;
370  char * result;
371 
372  /* Normalize lat/lon to the normal (-90 to 90, -180 to 180) range. */
373  lwprint_normalize_latlon(&lat, &lon);
374  /* This is somewhat inefficient as the format is parsed twice. */
375  lat_text = lwdouble_to_dms(lat, "N", "S", format);
376  lon_text = lwdouble_to_dms(lon, "E", "W", format);
377 
378  /* lat + lon + a space between + the null terminator. */
379  result = (char*)lwalloc(strlen(lat_text) + strlen(lon_text) + 2);
380  sprintf(result, "%s %s", lat_text, lon_text);
381  lwfree(lat_text);
382  lwfree(lon_text);
383  return result;
384 }
void lwfree(void *mem)
Definition: lwutil.c:214
static void lwprint_normalize_latlon(double *lat, double *lon)
Definition: lwprint.c:14
static char * lwdouble_to_dms(double val, const char *pos_dir_symbol, const char *neg_dir_symbol, const char *format)
Definition: lwprint.c:56
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: