 
 (save-deal 53.98193516 -6.41601562 "Dundalk shop" "Free coffee")
 
-(defn print-entity[entity]
+;; Calculate heading and distance given two GPS co-ordinates
+(defn heading-distance[gps-start gps-end]
+  (let [lat-start (:lat gps-start)
+        lon-start (:lon gps-start)
+        lat-end (:lat gps-end)
+        lon-end (:lon gps-end)
+        NS (if (< lat-start lat-end) :north :south)
+        EW (if (< lon-start lon-end) :east :west)
+        ]
+    (vector NS EW (gps/haversine gps-start gps-end))))
+
+(heading-distance {:lat 56.99134711 :lon -6.40017986}
+                  {:lat 54.99031266 :lon -4.40017986})
+
+
+
+(defn print-entity[start-lat start-lon entity]
   (let [location-ent (d/entity (d/db conn) (first entity))
         vendor-ent (first (:location/vendor location-ent))
         geocode (:location/geocode location-ent)

    (println end)
    (println (count res))
    (doseq[r res]
      (print-entity r))))

;(get-nearest-deals 53.98193516 -6.41601562 8)
(get-nearest-deals 53.99134711 -6.39824867 6)

(save-deal 53.99086773 -6.3988924  "End of grass"  "Deal 2")
(save-deal 53.99031266 -6.40017986 "Junction DublinRD" "Deal 3")
(save-deal 53.98908894 -6.39942884 "Hospital Junction" "Deal4")
(save-deal 53.99369399 -6.39780177 "Tom Bellew Avenue" "Small Shop")
(save-deal 53.99369399 -6.39516288 "Bellew Ave" "At round about")



(d/delete-database uri)

