Index: /branches/eam_branches/ipp-20110213/Ohana/src/addstar/include/skycells.h
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/addstar/include/skycells.h	(revision 31091)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/addstar/include/skycells.h	(revision 31092)
@@ -69,4 +69,5 @@
 double CELLSIZE;
 int    LEVEL;
+char   PROJECTION_NUMBER[8];
 
 double CENTER_RA, CENTER_DEC;
Index: /branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/args_skycells.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/args_skycells.c	(revision 31091)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/args_skycells.c	(revision 31092)
@@ -93,4 +93,19 @@
       remove_argument (N, &argc, argv);
       OVERLAP_DEC  = atof (argv[N]);
+      remove_argument (N, &argc, argv);
+    }
+    PROJECTION_NUMBER[0] = 0;
+    if ((N = get_argument (argc, argv, "-projection-number"))) {
+      remove_argument (N, &argc, argv);
+      int projection_number = atoi(argv[N]);
+      // We store projection number as a string, but range check as a number
+      if (projection_number > 10000) {
+        fprintf (stderr, "maximum projection-number value is 10000\n");
+        help();
+      } else if (projection_number < 0) {
+        fprintf (stderr, "projection-number value must be > 0\n");
+        help();
+      }
+      strcpy(PROJECTION_NUMBER, argv[N]);
       remove_argument (N, &argc, argv);
     }
@@ -208,4 +223,5 @@
   fprintf (stderr, "  -nx Nx                      : subdivide skycell projection in x by Nx\n");
   fprintf (stderr, "  -ny Ny                      : subdivide skycell projection in y by Ny\n");
+  fprintf (stderr, "  -projection-number Np       : set projection-number (local mode only)\n");
   fprintf (stderr, "  -help                       : this list\n");
   fprintf (stderr, "  -h                          : this list\n\n");
Index: /branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/sky_tessalation.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/sky_tessalation.c	(revision 31091)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/addstar/src/sky_tessalation.c	(revision 31092)
@@ -208,4 +208,11 @@
   sky_rectangle_local (&rectangle);
   strcpy (rectangle.name, "skycell");
+
+  if (strlen(PROJECTION_NUMBER) > 0) {
+    // We store projection number as a string so one can pass in
+    // values like 00, 01, etc. 
+    strcat(rectangle.name, ".");
+    strcat(rectangle.name, PROJECTION_NUMBER);
+  }
 
   // subdivide each image (Nx x Ny subcells)
Index: /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/Makefile
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/Makefile	(revision 31091)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/Makefile	(revision 31092)
@@ -24,5 +24,6 @@
 $(SRC)/compare.$(ARCH).o 			$(SRC)/sort.$(ARCH).o      		\
 $(SRC)/count_neighbors.$(ARCH).o                $(SRC)/nextline.$(ARCH).o		\
-$(SRC)/nextword.$(ARCH).o			$(SRC)/gcompare.$(ARCH).o
+$(SRC)/nextword.$(ARCH).o			$(SRC)/gcompare.$(ARCH).o               \
+$(SRC)/gc_compare.$(ARCH).o
 
 $(GCOMPARE): $(INC)/gcompare.h
Index: /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/include/gcompare.h
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/include/gcompare.h	(revision 31091)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/include/gcompare.h	(revision 31092)
@@ -26,4 +26,5 @@
 data_type          input             PROTO((char *, int, int, int));
 match_type        *compare           PROTO((data_type, data_type, int *, double, double, double, double));
+match_type        *gc_compare        PROTO((data_type, data_type, int *, double, double, double, double));
 int                get_argument      PROTO((int, char **, char *));
 int                remove_argument   PROTO((int, int *, char **));
Index: /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/src/gc_compare.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/src/gc_compare.c	(revision 31092)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/src/gc_compare.c	(revision 31092)
@@ -0,0 +1,58 @@
+# include "gcompare.h"
+# define D_NMATCH 500;
+
+double gcdist (double r1, double d1, double r2, double d2) {
+  double num,den;
+  r1 *= M_PI / 180;
+  d1 *= M_PI / 180;
+  r2 *= M_PI / 180;
+  d2 *= M_PI / 180;
+
+  num = sqrt(pow((cos(d2) * sin(r2 - r1)),2) +
+	     pow((cos(d1) * sin(d2) -
+		  sin(d1) * cos(d2) * cos(r2 - r1)),2));
+  den = (sin(d1) * sin(d2) + cos(d1) * cos(d2) * cos(r2 - r1));
+  return(atan2(num,den) * (180 / M_PI));
+}
+  
+
+match_type *gc_compare (data_type data1, data_type data2, int *Nmatches, double radius, double DX, double DY, double noauto) {
+
+  int i, j, Nmatch, NMATCH;
+  double dR;
+  match_type *match;
+  fprintf (stderr, "using gc_compare\n");
+  fprintf (stderr, "%f  %f\n", DX, DY);
+  Nmatch = 0;
+  NMATCH = D_NMATCH;
+  ALLOCATE (match, match_type, NMATCH);
+
+  for (i = 0; i < data1.Nvalues ;i++) {
+    if (!(i % 100))
+      fprintf (stderr, ".");
+
+    for (j = 0; j < data2.Nvalues ; j++) {
+      dR = gcdist(data1.values[i].X,data1.values[i].Y,
+		  data2.values[j].X,data2.values[j].Y);
+/*       fprintf(stderr,"%g %g %g %g => %g\n", */
+/* 	      data1.values[i].X,data1.values[i].Y,data2.values[j].X,data2.values[j].Y, */
+/* 	      dR); */
+      if ((dR < radius) && ((noauto == 0) || (dR > noauto))) {
+	match [Nmatch].line1 = data1.values[i].line;
+	match [Nmatch].line2 = data2.values[j].line;
+	match [Nmatch].dX = data1.values[i].X - data2.values[j].X - DX;
+	match [Nmatch].dY = data1.values[i].Y - data2.values[j].Y - DY;
+	data1.values[i].match = TRUE;
+	data2.values[j].match = TRUE;
+	Nmatch ++;
+	if (Nmatch == NMATCH - 1) {
+	  NMATCH += D_NMATCH;
+	  REALLOCATE (match, match_type, NMATCH);
+	}
+      }
+    }
+  }
+  *Nmatches = Nmatch;
+  return (match);
+}
+
Index: /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/src/gcompare.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/src/gcompare.c	(revision 31091)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/gcompare/src/gcompare.c	(revision 31092)
@@ -6,5 +6,5 @@
   
   int Nskip1, Nskip2, Nmatches, N;
-  int X1, X2, Y1, Y2, deltas, match, nomatch1, nomatch2;
+  int X1, X2, Y1, Y2, deltas, match, nomatch1, nomatch2, greatcircle;
   data_type data1, data2;
   match_type *matches;
@@ -12,5 +12,5 @@
 
   DX = DY = Nskip1 = Nskip2 = 0;
-  noauto = match = nomatch1 = nomatch2 = deltas = FALSE;
+  noauto = match = nomatch1 = nomatch2 = deltas = greatcircle = FALSE;
 
   if (remove_argument(get_argument (argc, argv, "-d"), &argc, argv))
@@ -26,4 +26,6 @@
   if (remove_argument(get_argument (argc, argv, "-n2"), &argc, argv))
     nomatch2 = TRUE;
+  if (remove_argument(get_argument (argc, argv, "-C"), &argc, argv))
+    greatcircle = TRUE;
   if (!(match || deltas || nomatch1 || nomatch2)) {
     fprintf (stderr, "no output mode, use at least one of -d, -m, -n1, or -n2\n");
@@ -75,5 +77,11 @@
 
   fprintf (stderr, "noauto: %e\n", noauto);
-  matches = compare (data1, data2, &Nmatches, radius, DX, DY, noauto);
+  if (greatcircle) {
+    matches = gc_compare (data1, data2, &Nmatches, radius, DX, DY, noauto);
+  }
+  else {
+    matches = compare (data1, data2, &Nmatches, radius, DX, DY, noauto);
+  }
+
 
   output (data1, data2, matches, Nmatches, match, deltas, nomatch1, nomatch2);
@@ -90,4 +98,5 @@
   fprintf (stderr, "  -d      return delta coords\n");
   fprintf (stderr, "  -m      return matched lines\n");
+  fprintf (stderr, "  -C      uses great circle calculation\n");
   fprintf (stderr, "  -n1     return unmatched lines, file 1\n");
   fprintf (stderr, "  -n2     return unmatched lines, file 2\n");
Index: /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.astro/Makefile
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.astro/Makefile	(revision 31091)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.astro/Makefile	(revision 31092)
@@ -22,4 +22,5 @@
 $(SRC)/coords.$(ARCH).o	   \
 $(SRC)/cdot.$(ARCH).o		   \
+$(SRC)/cline.$(ARCH).o             \
 $(SRC)/cplot.$(ARCH).o		   \
 $(SRC)/csystem.$(ARCH).o	   \
Index: /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.astro/cline.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.astro/cline.c	(revision 31092)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.astro/cline.c	(revision 31092)
@@ -0,0 +1,33 @@
+# include "data.h"
+
+int cline (int argc, char **argv) {
+  
+  int kapa, status;
+  Graphdata graphmode;
+  float x[2], y[2];
+  double r[2], d[2];
+  
+  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
+
+  if (argc != 6) {
+    gprint (GP_ERR, "USAGE: cline <x> <y> to <x> <y>\n");
+    return (FALSE);
+  }
+  r[0] = atof(argv[1]);
+  d[0] = atof(argv[2]);
+  r[1] = atof(argv[4]);
+  d[1] = atof(argv[5]);
+
+  /* set point style and errorbar mode (these are NOT sticky) */
+  graphmode.style = 0;
+  graphmode.etype = 0;
+
+  status = fRD_to_XY (&x[0], &y[0], r[0], d[0], &graphmode.coords);
+  status = fRD_to_XY (&x[1], &y[1], r[1], d[1], &graphmode.coords);
+  
+  if (!KapaPrepPlot (kapa, 2, &graphmode)) return (FALSE);
+  KapaPlotVector (kapa, 2, x, "x");
+  KapaPlotVector (kapa, 2, y, "y");
+  
+  return (TRUE);
+}
Index: /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.astro/init.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.astro/init.c	(revision 31091)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.astro/init.c	(revision 31092)
@@ -6,4 +6,5 @@
 int coords                  PROTO((int, char **));
 int cdot                    PROTO((int, char **));
+int cline                   PROTO((int, char **));
 int cplot                   PROTO((int, char **));
 int csystem                 PROTO((int, char **));
@@ -53,4 +54,5 @@
   {1, "coords",      coords,       "load coordinates for buffer from file"},
   {1, "cdot",        cdot,         "plot point in sky coordinates"},
+  {1, "cline",       cline,        "plot line connecting two sky coordinates"},
   {1, "cplot",       cplot,        "plot vectors in sky coordinates"},
   {1, "csystem",     csystem,      "convert between coordinate systems"},
