On Thursday, April 30, 2020 at 7:31:18 PM UTC-7, Martin Hauer wrote:
>
> I would like to convert Geo-coordinates with a click on a button in a 
> Tiddler.
> The coordinates should be converted from i.e. N 47° 04.624' to 47.077067° 
> and then a Google-Maps link should be created (<a href="
> http://maps.google.at/maps?q=47.077067+015.437033"; target="_blank"> 
> [img[in Google Maps anzeigen|GoogleMaps_Logo_36.gif]] </a>)
>

Field1 = N
> Field2 = 47
> Field3 = 04
> Field4 = 624
> Field5 = E
> Field6 = 015
> Field7 = 26
> Field8 = 222
>

The formula for converted from DMS (degrees,minutes,seconds) to DD (decimal 
degrees) is: *DD = D + M/60 + S/3600*

Note that in your example, you are specifying degrees=47 and minutes=4.624  
(using two fields to hold integer and decimal portions of the minutes 
value).

Thus, for D=47, M=4.624, we calculate: *DD = 47 + 4.624/60 = 47 + 0.077067*

To get this value using TW Math Filter operators, we can write:
{{{ [{!!field2}] [{!!field3}divide[60]] [{!!field4}divide[1000]divide[60]] 
+[sum[]multiply[1000000]round[]divide[1000000]] }}}
* get the value from field2
* get the value from field3 and then divide by 60
* get the value from field4 and then divide by 1000 to shift the decimal 
point to the left and then divide by 60
* add these values
* then, to round to 6 decimal places, multiply by 1000000, round to the 
nearest integer and then divide by 1000000

Thus, to get the latitude and longitude as variables, we would write:
<$vars latitude={{{ [{!!field2}] [{!!field3}divide[60]] 
[{!!field4}divide[1000]divide[60]] 
+[sum[]multiply[1000000]round[]divide[1000000]] }}}>
<$vars longitude={{{ [{!!field6}] [{!!field7}divide[60]] 
[{!!field8}divide[1000]divide[60]] 
+[sum[]multiply[1000000]round[]divide[1000000]] }}}>

and to construct the desired URL, we can use the title[] and addsuffix[] 
filters, like this:
<$vars url={{{ [title[http://maps.google.at/maps?q=]addsuffix<latitude>
addsuffix[+]addsuffix<longitude>] }}}>

Then, we can display the link this way:
<a href=<<url>> target="_blank"> [img[in Google Maps 
anzeigen|GoogleMaps_Logo_36.gif]] </a>

Putting it all together:
<$vars latitude={{{ [{!!field2}] [{!!field3}divide[60]] 
[{!!field4}divide[1000]divide[60]] 
+[sum[]multiply[1000000]round[]divide[1000000]] }}}>
<$vars longitude={{{ [{!!field6}] [{!!field7}divide[60]] 
[{!!field8}divide[1000]divide[60]] 
+[sum[]multiply[1000000]round[]divide[1000000]] }}}>
<$vars url={{{ [title[http://maps.google.at/maps?q=]addsuffix<latitude>
addsuffix[+]addsuffix<longitude>] }}}>
<a href=<<url>> target="_blank"> [img[in Google Maps 
anzeigen|GoogleMaps_Logo_36.gif]] </a>
</$vars>
</$vars>
</$vars>

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki - http://TiddlyTools.com/InsideTW



-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/bd062af5-ec14-4ef4-9dbb-5147fc3f9b4e%40googlegroups.com.

Reply via email to