Index: /trunk/FACT++/src/smartfact.cc
===================================================================
--- /trunk/FACT++/src/smartfact.cc	(revision 14301)
+++ /trunk/FACT++/src/smartfact.cc	(revision 14302)
@@ -1897,4 +1897,58 @@
         return make_pair(alt, make_pair(maxjd, maxjd>jd+jd0&&maxjd<jd+jd1?max:0));
     }
+
+    pair<vector<float>, pair<Time, float>> GetLightCondition(ln_equ_posn *src, ln_lnlat_posn *observer, double jd)
+    {
+        jd = floor(jd);
+
+        const double jd0 = fmod(fSun.fSetAstronomical.JD(),  1);
+        const double jd1 = fmod(fSun.fRiseAstronomical.JD(), 1);
+
+        ln_equ_posn  moon;
+
+        double max   = -1;
+        double maxjd =  0;
+
+        int cnt = 0;
+
+        vector<float> alt;
+        for (double h=0; h<1; h+=1./(24*12))
+        {
+            double lc = -1;
+
+            if (h>jd0 && h<jd1)
+            {
+                const double disk = ln_get_lunar_disk(jd+h);
+                ln_get_lunar_equ_coords(jd+h, &moon);
+
+                ln_hrz_posn hrz;
+                ln_get_hrz_from_equ(&moon, observer, jd+h, &hrz);
+
+                Moon m;
+                m.ra  = moon.ra;
+                m.dec = moon.dec;
+
+                const double angle = m.Angle(src->ra, src->dec);
+
+                lc = angle*hrz.alt*disk*M_PI*M_PI/180/180;
+
+                alt.push_back(lc);
+            }
+
+            if (lc>max)
+            {
+                max   = lc;
+                maxjd = jd+h;
+            }
+
+            if (h>jd0 && h<jd1 && lc>0)
+                cnt++;
+        }
+
+        if (max<=15 || cnt==0)
+            return make_pair(vector<float>(), make_pair(Time(), 0));
+
+        return make_pair(alt, make_pair(maxjd, maxjd>jd+jd0&&maxjd<jd+jd1?max:0));
+    }
 #endif
 
@@ -1957,10 +2011,12 @@
         }
 
-        ostringstream out2, out3;
+        ostringstream out2, out3, out4;
         out2 << setprecision(3);
         out2 << now.JavaDate() << '\n';
         out3 << now.JavaDate() << '\n';
+        out4 << now.JavaDate() << '\n';
 
         map<Time, pair<string, float>> culmination;
+        map<Time, pair<string, float>> lightcond;
         vector<vector<float>> alt;
 
@@ -1987,4 +2043,5 @@
             out2 << HTML::kWhite << '\t';
             out3 << HTML::kWhite << '\t';
+            out4 << HTML::kWhite << '\t';
 
             for (vector<mysqlpp::Row>::const_iterator v=res.begin(); v<res.end(); v++)
@@ -2006,4 +2063,11 @@
                     alt.push_back(vis.first);
                     culmination[vis.second.first] = make_pair(name, vis.second.second);
+                }
+
+                const pair<vector<float>, pair<Time, float>> lc = GetLightCondition(&pos, &observer, now.JD());
+                if (lc.first.size()>0)
+                {
+                    alt.push_back(lc.first);
+                    lightcond[lc.second.first] = make_pair(name, lc.second.second);
                 }
 
@@ -2046,4 +2110,13 @@
             }
 
+            for (auto it=lightcond.begin(); it!=lightcond.end(); it++)
+            {
+                if (it!=lightcond.begin())
+                    out4 << ", ";
+                out4 << "<B>" << it->second.first << "</B>";
+                if (it->second.second>0)
+                    out4 << " [" << nearbyint(90-it->second.second) << "&deg;]";
+            }
+
             ostringstream title;
             title << "Alt ";
@@ -2057,4 +2130,5 @@
             out2 << '\n';
             out3 << '\n';
+            out4 << '\n';
             out  << HTML::kWhite << '\t' << Time()-now << '\n';
             out2 << HTML::kWhite << '\t' << Time()-now << '\n';
@@ -2069,4 +2143,5 @@
             out2 << HTML::kWhite << '\t' << "ERROR  - "+string(e.what()) << '\n';
             out3 << HTML::kWhite << '\t' << "ERROR  - "+string(e.what()) << '\n';
+            out4 << HTML::kWhite << '\t' << "ERROR  - "+string(e.what()) << '\n';
         }
 #endif
@@ -2075,4 +2150,5 @@
         ofstream(fPath+"/source-list.data") << out2.str();
         ofstream(fPath+"/visibility.data") << out3.str();
+        ofstream(fPath+"/light-condition.data") << out4.str();
     }
 
@@ -2793,5 +2869,5 @@
         ("pixel-map-file",  var<string>("FACTmapV5a.txt"),     "Pixel mapping file. Used here to get the default reference voltage")
         ("path",            var<string>("www/smartfact/data"), "Output path for the data-files")
-        ("source-database", var<string>(), "Database link as in\n\tuser:password@server[:port]/database.")
+        ("source-database", var<string>(""), "Database link as in\n\tuser:password@server[:port]/database.")
         ("client",          po_bool(false), "For a standalone client choose this option.")
         ;
