diff options
author | Gehad elrobey <gehadelrobey@gmail.com> | 2014-08-14 06:32:47 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-08-14 09:53:05 -0600 |
commit | 9015160199506f271f8758c9b284b1d56bae860b (patch) | |
tree | 9ce1c0ac781f04c8724135c5be64b12411c9b271 /save-html.c | |
parent | a03e7729547ccf635e0e023caa8bc3bad32bb0e2 (diff) | |
download | subsurface-9015160199506f271f8758c9b284b1d56bae860b.tar.gz |
HTML: Add coordinates to the HTML exports
- Export dive coordinates (if exist) to JSON file.
- Add dive coordinates to list view and detailed dive view.
- Add hyperlink that opens the dive location in a new tab viewed in
Google maps.
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-html.c')
-rw-r--r-- | save-html.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/save-html.c b/save-html.c index 1efc6b96a..0288d447c 100644 --- a/save-html.c +++ b/save-html.c @@ -122,6 +122,21 @@ void put_HTML_samples(struct membuffer *b, struct dive *dive) put_string(b, "],"); } +void put_HTML_coordinates(struct membuffer *b, struct dive *dive) +{ + degrees_t latitude = dive->latitude; + degrees_t longitude = dive->longitude; + + //don't put coordinates if in (0,0) + if (!latitude.udeg && !longitude.udeg) + return; + + put_string(b, "\"coordinates\":{"); + put_degrees(b, latitude, "\"lat\":\"", "\","); + put_degrees(b, longitude, "\"lon\":\"", "\","); + put_string(b, "},"); +} + void put_HTML_date(struct membuffer *b, struct dive *dive, const char *pre, const char *post) { struct tm tm; @@ -207,6 +222,7 @@ void write_one_dive(struct membuffer *b, struct dive *dive, const char *photos_d put_HTML_date(b, dive, "\"date\":\"", "\","); put_HTML_time(b, dive, "\"time\":\"", "\","); write_attribute(b, "location", dive->location); + put_HTML_coordinates(b, dive); put_format(b, "\"rating\":%d,", dive->rating); put_format(b, "\"visibility\":%d,", dive->visibility); put_format(b, "\"dive_duration\":\"%u:%02u min\",", @@ -390,7 +406,7 @@ void export_translation(const char *file_name) write_attribute(b, "Events", translate("gettextFromC", "Events")); write_attribute(b, "Name", translate("gettextFromC", "Name")); write_attribute(b, "Value", translate("gettextFromC", "Value")); - + write_attribute(b, "Coordinates", translate("gettextFromC", "Coordinates")); write_attribute(b, "Dive_Status", translate("gettextFromC", "Dive Status")); put_format(b, "}"); |