It is currently May 1st, 2024, 3:14 am

[Help] Map(X,Y) coords from City(Lon,Lat)

Get help with creating, editing & fixing problems with skins
User avatar
Nebbishatudub
Posts: 26
Joined: January 28th, 2011, 4:57 am
Location: Washington, DC

[Help] Map(X,Y) coords from City(Lon,Lat)

Post by Nebbishatudub »

What I'm trying to do:
I'm trying to use a variation on Enigma's World Skin to also show the city-in-question's location on the map.

What I've done & Givens
1) I've changed the weather-xml from yahoo.com's to weather.com's (personal preference)
2) The Sections [MeasureLon] and [MeasureLat] return the correct Longitude and Latitude coordinates
- these are substrings 11 and 10 respectively
3) I have created two CALC sections to convert the Longitude and Latitude to the corresponding pixel that point should be at on the map. These are titled [ConvertLon] and [ConvertLat] respectively.
4) These two sections do in fact give the appropriate x,y coordinates on the map that I'm using which I've tested using this:

Code: Select all

[TestConversions]
Meter=STRING
MeasureName=ConvertLon
MeasureName2=ConvertLat
Text="%1, %2"
FontColor=255,255,255,255
The problem
The problem that I'm having is then being able to use those sections as X,Y coordinates in another section. Something like this:

Code: Select all

[CityLocation]
Meter=IMAGE
X=ConvertLon
Y=ConvertLat
H=1
W=1
SolidColor=255,0,0,255
However, all I get is a red pixel at the upper-left corner of the map (0,0). Any help?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Help] Map(X,Y) coords from City(Lon,Lat)

Post by jsmorley »

[CityLocation]
Meter=IMAGE
SolidColor=255,0,0,255
H=1
W=1
X=[ConvertLon]
Y=[ConvertLat]
DynamicVariables=1

http://rainmeter.net/cms/Tips-MeasureAsVariable

Extra credit - Worth 2 points on the final exam:

If your calculations are not ending up as an integer, you might want to use Round(restofformula) on your calc measures to get a tad more precision. Meters will ignore fractions of a pixel when setting the X and Y, so if the calc ends up as 300.612 you are going to be a bit more accurate with 301 than you are with 300. It's never going to make more than a pixel's worth of difference, but hey...

Or you could do the Round function right on the meter like this:

X=(Round([ConvertLon]))
Y=(Round([ConvertLat]))
User avatar
Nebbishatudub
Posts: 26
Joined: January 28th, 2011, 4:57 am
Location: Washington, DC

Re: [Help] Map(X,Y) coords from City(Lon,Lat)

Post by Nebbishatudub »

Ahh sweet victory!

The Conversions had in fact been rounded, it was the DynamicVariable setting that I'd neglected!

I somehow missed the entire "Tips and Tricks" guide... this is going to be so much fun!