PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwdoubles_to_latlon()

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

Definition at line 408 of file lwprint.c.

409{
410 char * lat_text;
411 char * lon_text;
412 char * result;
413 size_t sz;
414
415 /* Normalize lat/lon to the normal (-90 to 90, -180 to 180) range. */
416 lwprint_normalize_latlon(&lat, &lon);
417 /* This is somewhat inefficient as the format is parsed twice. */
418 lat_text = lwdouble_to_dms(lat, "N", "S", format);
419 lon_text = lwdouble_to_dms(lon, "E", "W", format);
420
421 /* lat + lon + a space between + the null terminator. */
422 sz = strlen(lat_text) + strlen(lon_text) + 2;
423 result = (char*)lwalloc(sz);
424 snprintf(result, sz, "%s %s", lat_text, lon_text);
425 lwfree(lat_text);
426 lwfree(lon_text);
427 return result;
428}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:248
static char * lwdouble_to_dms(double val, const char *pos_dir_symbol, const char *neg_dir_symbol, const char *format)
Definition lwprint.c:79
static void lwprint_normalize_latlon(double *lat, double *lon)
Definition lwprint.c:37

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

Referenced by lwpoint_to_latlon().

Here is the call graph for this function:
Here is the caller graph for this function: