From 6d14ed40bf45583ab4e8601d14100f645bb711a1 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 9 Feb 2010 17:45:26 +0000 Subject: [PATCH] examples: GoogleMaps removed dependency on Geom git-svn-id: svn://ultimatepp.org/upp/trunk@2040 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- examples/GoogleMaps/GoogleMaps.cpp | 26 ++++++++++++++++++++++---- examples/GoogleMaps/GoogleMaps.h | 2 ++ examples/GoogleMaps/GoogleMaps.upp | 6 ++++-- examples/GoogleMaps/init | 2 +- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/examples/GoogleMaps/GoogleMaps.cpp b/examples/GoogleMaps/GoogleMaps.cpp index 5173fa9bf..ac892003c 100644 --- a/examples/GoogleMaps/GoogleMaps.cpp +++ b/examples/GoogleMaps/GoogleMaps.cpp @@ -1,9 +1,5 @@ #include "GoogleMaps.h" -#include -#include -#include - using namespace Upp; #define LLOG(x) // LOG(x) @@ -98,6 +94,28 @@ Pointf ScanGPS(const char *s) return r; } +String FormatDegree(double d, int decimals) +{ + if(IsNull(d)) + return Null; + d = modulo(d + 180, 360) - 180; + char sign = (d < 0 ? '-' : '+'); + if(d < 0) d = -d; + int deg = ffloor(d); + String cd = ToCharset(CHARSET_DEFAULT, "%c%d°", CHARSET_UTF8); + if(decimals <= -2) + return NFormat(cd, sign, deg); + d = (d - deg) * 60; + int min = ffloor(d); + if(decimals <= -1) + return NFormat(cd + " %02d\'", sign, deg, min); + d = (d - min) * 60; + String sec = FormatDoubleFix(d, decimals); + if(!IsDigit(sec[1])) + sec.Insert(0, '0'); + return NFormat(cd + " %02d\' %s\"", sign, deg, min, sec); +} + String FormatGPSX(double x) { return IsNull(x) ? String() : FormatDegree(x, 2) + (x < 0 ? "W" : "E"); diff --git a/examples/GoogleMaps/GoogleMaps.h b/examples/GoogleMaps/GoogleMaps.h index 4b3168591..202474d9d 100644 --- a/examples/GoogleMaps/GoogleMaps.h +++ b/examples/GoogleMaps/GoogleMaps.h @@ -2,6 +2,8 @@ #define _GoogleMaps_GoogleMaps_h #include +#include + using namespace Upp; diff --git a/examples/GoogleMaps/GoogleMaps.upp b/examples/GoogleMaps/GoogleMaps.upp index 98ccffb8a..d769a55e2 100644 --- a/examples/GoogleMaps/GoogleMaps.upp +++ b/examples/GoogleMaps/GoogleMaps.upp @@ -1,6 +1,8 @@ +description "Example using GoogleMaps static API to display the map of given location\377"; + uses - Geom\Coords, - CtrlLib; + CtrlLib, + Web; file GoogleMaps.h, diff --git a/examples/GoogleMaps/init b/examples/GoogleMaps/init index 727abc36b..08a8a31b1 100644 --- a/examples/GoogleMaps/init +++ b/examples/GoogleMaps/init @@ -1,5 +1,5 @@ #ifndef _GoogleMaps_icpp_init_stub #define _GoogleMaps_icpp_init_stub -#include "Geom\Coords/init" #include "CtrlLib/init" +#include "Web/init" #endif