sunrise/set

Discussion in 'Questions (Windows Mobile)' started by wm.chatman, Mar 27, 2009.

  1. wm.chatman

    wm.chatman Well-Known Member Licensed User

    Hello folks

    I am in need for sunrise/set code. Can i get just a little help on this matter?
    Found some code in vb6 for this, cant use it with Basic4PPC.:(
    sunrise=lblSR/sunset=lblSS

    Sincerely

    WmC

    PC: Laptop CoreDUo, Windows XP SP2 E
    PPC:hp5550"ARM"/Windows CE 4.2
    Bayern, Germany
     
  2. specci48

    specci48 Well-Known Member Licensed User

  3. wm.chatman

    wm.chatman Well-Known Member Licensed User

    :)Hi specci48

    Thanks for your help. Iwill ckeck this out.

    Regards,
    WmC

    PC: Laptop CoreDUo, Windows XP SP2 E
    PPC:hp5555"ARM"/Windows CE 4.2
    Bayern/Germany
     
  4. derez

    derez Expert Licensed User

  5. derez

    derez Expert Licensed User

    Sun Rise and Set

    Hi
    I have translated the code I found to a small B4ppc program, for the sun rise and set only.
    Comments inside show how to make it work with GPS time instead of system time.
    It has not been tested thoroughly !!!

    Edit:
    updated, the calculation should be done with GPS time or Greenwich time, then the delta hours due to time zone are added at the end of calculation.

    edit:
    To use with gps.dll, replace the beginning with this :
    Code:
    ttmp = gps.UTCDate
    stryear = 
    "20" & SubString(ttmp,4,2)
    strmonth = SubString(ttmp,
    2,2)
    strday = SubString(ttmp,
    0,2)
     

    Attached Files:

    • Sun.sbp
      File size:
      4.2 KB
      Views:
      94
    Last edited: Mar 30, 2009
  6. wm.chatman

    wm.chatman Well-Known Member Licensed User

    :)Hi Mr.Derez
    darn it, you are lightning!

    Fantastic, I'd like to thank you very very much for all the help so far!!! It is truly appreciated. Also I sincerely appreciate the time and effort of everyone who responded to my questions.

    Problem:
    I have tested the proramm using system time. The calculations are: SR=0538h/SS=1806h.
    With the Newspaper we get here in Bayern, Germany I took a look at SR/SS. It gives the
    SR=0657h/SS=1945h. Difference: SR=0119h/SS=0139h.

    Edit:
    With Update Sun:
    Now the calculations are SR=0642h/SS=1911h. Difference: SR=0015h/SS=0034h. Sure is getting close.
    How can I correct the Difference?

    To all: Happy Easter Holidays!:sign0089:
    Mr. Derez did you get my private msg?

    P.S. I am thinking about getting a Smartphone/looking at MDA Pro=WM5.
    (Scratching head on this).

    Regards,
    WmC

    PC: Laptop CoreDUo, Windows XP SP2 E
    PPC:hp5555"ARM"/Windows CE 4.2
    Bayern/Germany
     
    Last edited: Mar 30, 2009
  7. derez

    derez Expert Licensed User

    If you change the lat and long which are defined in the program start ,to the coordinates of your home, you'll probably get a closer result....
    Can you please write down your coordinates so that i can check too ?

    Does anybody know a link to the moon rise and set calculation in VB or C ? I found one in basic and it does take a long time to convert it...:sign0085: ALFCEN ?
     
    Last edited: Mar 30, 2009
  8. wm.chatman

    wm.chatman Well-Known Member Licensed User

    :)Mr. Derez

    here the info you requested:
    Germany: Longitude: 10° 58' 0" East Latitude: 50° 9' 0" North

    Regards,
    WmC

    PC: Laptop CoreDUo, Windows XP SP2 E
    PPC:hp5555"ARM"/Windows CE 4.2
    Bayern/Germany
     
  9. wm.chatman

    wm.chatman Well-Known Member Licensed User

    I changed the lat/lon but still not getting the correct data.
    Also replaced code as is in #5 (permalink). Now we get Error Dialog!
    cant copy paste img, but it states:

    Error compiling program.
    Error description: gps is not a known control or object.
    Occurred on line: 22
    ttmp=gps.UTCDate

    Regards,
    WmC

    PC: Laptop CoreDUo, Windows XP SP2 E
    PPC:hp5555"ARM"/Windows CE 4.2
    Bayern/Germany
     
    Last edited: Mar 30, 2009
  10. derez

    derez Expert Licensed User

    When I changed to your coordinates I got 06:57 and 19:43 ! also important to input the time zone difference.

    As for the gps error - you should add GPS.dll library, make an object named GPS etc. as you may find in the help for GPS library. At the moment the sun program does not include the gps environment. You can copy it and add it to another program, like GPS4PPC for example.
     
  11. wm.chatman

    wm.chatman Well-Known Member Licensed User

    ok. added GPS.dll and new object GPS. Now the sun.sbp is going hay-wire.

    :)Could you update sun.sbp?

    Edit:
    Happy Easter Bunnies!!!
    no need to update sun.sbp Mr.Derez. We are also getting the correct Input now.
    delta_hour = 2 ' should be provided by the gps program

    'coordinates of my home: Longitude: 10° 58' 0" East Latitude: 50° 9' 0" North
    '(GMT+01:00)Amsterdam,Berlin,Bern,Rome,Stockholm,Vienna
    latlong.lat = 50.9
    latlong.long = 10.58

    Now have to work on including gps environment.

    Edit:still does not function correct. Tryd Changing input in the txt boxes D, M, Y. Bad thing.
    also the system time does not show the correct update, with the D, M Y.

    edit: Oh I am sorry, think it does work. I got to get some sleep.

    Best Regards,
    WmC

    PC: Laptop CoreDUo, Windows XP SP2 E
    PPC:hp5555"ARM"/Windows CE 4.2
    Bayern/Germany
     
    Last edited: Mar 31, 2009
  12. derez

    derez Expert Licensed User

    when you change coordinates from DMS to decimal it goes:
    10° 58' 0" = 10 + 58/60 + 0/3600 = 10.9667
    50° 9' 0" = 50 + 9/60 + 0/3600 = 50.15
     
  13. agraham

    agraham Expert Licensed User

    I'm afraid that I'm getting some very strange results :confused: Try setting the date to 1st May 2009, I get a -ve sunrise time! Other dates give me the sun rising before it sets, try the 1st December 2009.
     
  14. derez

    derez Expert Licensed User

    Agraham
    You are right, but I said I haven't tested it thoroughly...
    I also found this problem and corrected it (took the min and max of the hours for rise and set).
    to correct the minus I added 24 hours to the sum before the mod(24) so it is always positive now.

    And the real good news - I translated the moon rise and set algorithm from old basic, and it works !
    Let me just test it a little and arrange the code before i post it.:)
     
  15. wm.chatman

    wm.chatman Well-Known Member Licensed User

    Halleluiah...:sign0060::sign0060::sign0060:

    Also Changing Time Zone diff: does not show any effect.

    Best Regards,
    WmC

    PC: Laptop CoreDUo, Windows XP SP2 E
    PPC:hp5555"ARM"/Windows CE 4.2
    Bayern/Germany
     
  16. derez

    derez Expert Licensed User

    Can anybody translate this line for me ?:confused:

    i = (xtra > 0.0 ? Math.floor(xtra) : Math.ceil(xtra - 1.0));

    Thanks
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    These conversions are a little bit tricky.
    You could use this code:
    Code:
    i = Int(xtra)
        
    If xtra <= 0 AND xtra = i Then i = i - 1
     
  18. derez

    derez Expert Licensed User

    Thank you Erel, but I found a better algorithm, see in "Share your creation"
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice