Index: /trunk/Ohana/src/addstar/src/ReadStarsSDSS.c
===================================================================
--- /trunk/Ohana/src/addstar/src/ReadStarsSDSS.c	(revision 16936)
+++ /trunk/Ohana/src/addstar/src/ReadStarsSDSS.c	(revision 16937)
@@ -1,3 +1,5 @@
 # include "addstar.h"
+int SetSDSSFlags (Stars *star, unsigned int flags1, unsigned int flags2);
+
 # define NFILTER 5
 # define dCOS(A)   ((double) cos ((double)RAD_DEG*A))
@@ -150,5 +152,4 @@
       stars[N].extNsigma = 0.0;
       stars[N].detID     = N;
-      stars[N].flags     = flags[N] & 0x0000ffff; // XXX totally arbitrary bits
       stars[N].R         = ra[i] + dCOS(dec[i]) * offsetRa[N] / 3600.0;
       stars[N].D         = dec[i] + offsetDec[N] / 3600.0;
@@ -165,4 +166,6 @@
       stars[N].dt        = 53.907456; // is this 2048*clockRate ?
 
+      SetSDSSFlags (&stars[N], flags[N], flags2[N]);
+
       // longitude and latitude for SDSS:
       // Latitude 32° 46' 49.30" N, Longitude 105° 49' 13.50" W
@@ -284,2 +287,24 @@
   return TRUE;
 }
+
+int SetSDSSFlags (Stars *star, unsigned int flags1, unsigned int flags2) {
+
+  // XXX this is wrong, need to roll left to set the correct bit 
+  if (flags1 & 0x00000002) star[0].flags |= 0x0001; // BRIGHT            - 1  1
+  if (flags1 & 0x00000004) star[0].flags |= 0x0002; // EDGE              - 1  2
+  if (flags1 & 0x00000008) star[0].flags |= 0x0004; // BLENDED           - 1  3
+  if (flags1 & 0x00000010) star[0].flags |= 0x0008; // CHILD             - 1  4
+  if (flags1 & 0x00000020) star[0].flags |= 0x0010; // PEAKCENTER        - 1  5
+  if (flags1 & 0x00000040) star[0].flags |= 0x0020; // NODEBLEND         - 1  6
+  if (flags1 & 0x00040000) star[0].flags |= 0x0040; // SATUR             - 1 18
+  if (flags1 & 0x00080000) star[0].flags |= 0x0080; // NOTCHECKED        - 1 19
+  if (flags1 & 0x10000000) star[0].flags |= 0x0100; // BINNED1           - 1 28
+  if (flags1 & 0x20000000) star[0].flags |= 0x0200; // BINNED2           - 1 29
+  if (flags1 & 0x40000000) star[0].flags |= 0x0400; // BINNED4           - 1 30
+  if (flags2 & 0x00000040) star[0].flags |= 0x0800; // LOCAL_EDGE        - 2  7
+  if (flags2 & 0x00000800) star[0].flags |= 0x1000; // INTERP_CENTER     - 2 12
+  if (flags2 & 0x00002000) star[0].flags |= 0x2000; // DEBLEND_NOPEAK    - 2 14
+  if (flags2 & 0x02000000) star[0].flags |= 0x4000; // NOTCHECKED_CENTER - 2 26
+  return (TRUE);
+
+}
