]> Pileus Git - grits/blobdiff - src/gis-util.c
Document GisOpenGL
[grits] / src / gis-util.c
index c2af66dd9da6cdba1fac20cec7efc96df916c49a..c25b57c4ed0116902b7a06457d60a76011ab401c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
+ * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,7 +20,6 @@
 
 #include "gis-util.h"
 
-
 /******************
  * Global helpers *
  ******************/
@@ -66,3 +65,16 @@ gdouble distd(gdouble *a, gdouble *b)
                    (a[1]-b[1])*(a[1]-b[1]) +
                    (a[2]-b[2])*(a[2]-b[2]));
 }
+
+gdouble lon_avg(gdouble a, gdouble b)
+{
+       gdouble diff = ABS(a-b);
+       gdouble avg  = (a+b)/2;
+       if (diff > 180) {
+               if (avg >= 0)
+                       avg -= 180;
+               else
+                       avg += 180;
+       }
+       return avg;
+}