From 973e27b243ea7f12b6743894465c67a4a6a87eb2 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Sat, 6 Sep 2025 09:26:21 +0200 Subject: Move some other code here Signed-off-by: Carlos Maiolino --- C/HF/geo2json.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 C/HF/geo2json.c (limited to 'C/HF/geo2json.c') diff --git a/C/HF/geo2json.c b/C/HF/geo2json.c new file mode 100644 index 0000000..f1d3f8a --- /dev/null +++ b/C/HF/geo2json.c @@ -0,0 +1,31 @@ +#include + +int +main(void) +{ + float latitude; + float longitude; + char info[80]; + int started = 0; + + puts("data=["); + while (scanf("%f,%f,%79[^\n]",&longitude, &latitude, info) == 3) { + if (started) + printf(",\n"); + else + started = 1; + + if (longitude < -180 || longitude > 180 || + latitude < -90 || latitude > 90) { + fprintf(stderr, "Latitude must be between -90,90 and longitude -180,180\n"); + return 2; + } + + printf("{latitude: %f, longitude: %f, info: '%s'}", + latitude, longitude, info); + } + puts("\n]"); + return 0; +} + + -- cgit v1.2.3