Page 1 of 1

How does Cumulus work out the Phases of the Moon

Posted: Wed 20 Mar 2013 12:22 pm
by ellcheepo
Hi guy's

I have my own web site working
http://www.ellcheepoweather.webspace.vi ... /index.htm
It is still under development for the text and I intent to change some of the gauges to a different colour and so on.
But I am having issues with the Moon Phases as mine is staying on Waxing Gibbious.
I want to change it so that it follows the phases of the moon correctly. As you can see I have a new picture but I must be missing in my head or somewhere else the code that allows the moon to change phases.

Anyone got any idea's to help me out on this.

Re: How does Cumulus work out the Phases of the Moon

Posted: Wed 20 Mar 2013 12:40 pm
by steve
The Cumulus descriptions are based on the percentage age of the moon. It obtains the age from a third-party component, and it uses the following code to determine the phase (positive percentages are waxing and negative percentages are waning):

Code: Select all

  if (MoonPercent > 1) and (MoonPercent < 49) then
    MoonPhaseString := WaxingCrescent
  else if (MoonPercent >= 49) and (MoonPercent <= 51) then
    MoonPhaseString := FirstQuarter
  else if (MoonPercent > 51) and (MoonPercent < 99) then
    MoonPhaseString := WaxingGibbous
  else if (MoonPercent >= 99) or (MoonPercent <= -99) then
    MoonPhaseString := Fullmoon
  else if (MoonPercent < -51) and (MoonPercent > -99) then
    MoonPhaseString := WaningGibbous
  else if (MoonPercent <= -49) and (MoonPercent >= -51) then
    MoonPhaseString := LastQuarter
  else if (MoonPercent > -49) and (MoonPercent < -1) then
    MoonPhaseString := WaningCrescent
  else
    MoonPhaseString := Newmoon;
The current percentage is 57%, so the phase is "Waxing Gibbous". If you disagree with the phases that Cumulus generates, you can use the <#MoonPercent> web tag and generate your own. If you disagree with the percentage figure that Cumulus provides, you'll have to generate your own somehow.

Re: How does Cumulus work out the Phases of the Moon

Posted: Wed 20 Mar 2013 1:10 pm
by ellcheepo
Steve,

Thanks for that.
The issue I have is that the phase the moon is in, is not showing on my website in terms of say a half moon, the image is still showing the whole moon. I was wondering that because I have changed the moon image to a .gif and use one I wanted it has stopped the shading from working. I was wondering what part of your web app controlled that so I could check what I have missed.

Regards
Philip

Re: How does Cumulus work out the Phases of the Moon

Posted: Wed 20 Mar 2013 1:33 pm
by steve
The moon image that Cumulus makes available is just a 'grab' of the image on the main Cumulus screen. That image is generated by a third-party component.

If you want to use a different image, then you will also have to devise a way of displaying the correct image according to the current moon phase, e.g. by using a set of images and selecting the correct one based on the <#MoonPercent> web tag. Some people have done this; you might be able to find something with a search on the forum, or perhaps someone who has done it will reply with some pointers.