Show Current Sun Position and Shadow of House (Generate SVG)


(Paul Hansen) #145

Can anyone give me a hint on how to get the inner circle highlighted in respect of where the sun is for someone in the southern hemisphere? Everything else looks good, but my wife just commented that the bright section of the inner circle wasn’t in the right place… now it’s all I can see and i’m not sure where to begin with the script.

The attached image was taken just before midday and the inner and outer markers look good.


(Vincent Regaud) #146

Hi @pahansen

These two lines:

svg = svg + self.generateArc(WIDTH/2,PRIMARY_COLOR,self.sunset_azimuth,self.sunrise_azimuth)
svg = svg + self.generateArc(WIDTH/2,LIGHT_COLOR,self.sunrise_azimuth,self.sunset_azimuth)

Change the first one the LIGHT_COLOR and the second one to PRIMARY_COLOR


(Gaël L'hopital) #148

Small evolution, if you happen to have moon age and want to display it directly :

Add a moon_age property :

		self.moon_azimuth = float(self.oh.getState('Astro_Moon_Azimuth').replace(" °",""))
		self.moon_elevation = float(self.oh.getState('Astro_Moon_Elevation').replace(" °",""))
		self.moon_age = self.oh.getState('Astro_Moon_Age')

Modification of the moon rendering :

# moon
moon = self.degreesToPoint(self.moon_azimuth, WIDTH / 2)
#svg = svg + '<circle cx="' + str(moon['x']) + '" cy="' + str(moon['y']) + '" r="' + str(MOON_RADIUS -1) + '" stroke="' + MOON_COLOR + '" stroke-width="0" fill="' + MOON_COLOR + '" />'
		
svg = svg + '<image x="' + str(moon['x']) + '" y="' + str(moon['y']) + '" width="' + str(MOON_RADIUS *2 ) + '" height="' + str(MOON_RADIUS *2) + '" xlink:href="/icon/moon?state=' + self.moon_age +'&amp;format=svg" />'
		svg = svg + '</svg>'

And here you are :
Capture%20d%E2%80%99%C3%A9cran%20du%202019-03-14%2009-17-50


(Andrew Pawelski) #149

Dumb question but is north up on the svg?


(Gaël L'hopital) #150

Yes, it should


(Vincent Regaud) #151

Yes, but you’ll have to make some code changes if you live in the southern hemisphere


(Andrew Pawelski) #152

And altitude in meters?


(Andrew Pawelski) #153

Ah I do I think there’s a post a bit up about that…


(Vincent Regaud) #154

Yes in meters