        n
        (recur tail distance (+ k head) (inc n)))))
 
-(def coordinates (reverse (decode-polyline (polyline))))
-
-(def meters-away 200)
-
-(def pairs (partition 2 1 coordinates))
-
-(def segments (map (fn [[a b]] (haversine a b)) pairs))
-
-(def back-segment (take-segments segments meters-away))
-
-(def front-segment (dec back-segment))
-
-(def back-distance (reduce + (take back-segment segments)))
-
-(def front-distance (reduce + (take front-segment segments)))
-
-(def back-coordinate (nth coordinates back-segment))
-
-(def front-coordinate (nth coordinates front-segment))
-
-(def distance-to-front-segment (- back-distance meters-away))
-
-(def target-to-front-segment (- meters-away front-distance))
-
-;;(pprint coordinates)
-
+(defn target-coordinates [src dst meters-away]
+  (let [coordinates (reverse (decode-polyline (polyline src dst)))
+        pairs (partition 2 1 coordinates)
+        segments (map (fn [[a b]] (haversine a b)) pairs)
+        back-segment (take-segments segments meters-away)
+        front-segment (dec back-segment)
+        front-distance (reduce + (take front-segment segments))
+        back-coordinate (nth coordinates back-segment)   
+        front-coordinate (nth coordinates front-segment)
+        front-to-target (- meters-away front-distance)]
+    (interpolate-coordinates front-coordinate back-coordinate front-to-target meters-away)))
 
 (defroutes routes
   (POST "/rush-hour/api/triangulate/edn" {:keys [body]}
         (let [{:keys [src dst]} (read-string (slurp body))]
-          (pr-str {}))))
+          (pr-str {:coordinates (interpolate-coordinates)}))))
 
 (def app (wrap-params #'routes))
 

  (:import [polyline PolylineDecoder]
           [polyline Location]))

(defn polyline []
  (let [body (:body (client/get "http://maps.googleapis.com/maps/api/directions/json"
                                {:query-params {:origin "Intersection of Main Street and Stephenson Street, Duryea, PA"
                                                :destination "Intersection of Main Street and Phoenix Street, Duryea, PA"
                                                :sensor false}}))]
    (-> (parse-string body true) :routes first :overview_polyline :points)))


        a (+ (* (Math/sin (/ dlat 2)) (Math/sin (/ dlat 2)))
             (* (Math/sin (/ dlon 2)) (Math/sin (/ dlon 2))
                (Math/cos lat1) (Math/cos lat2)))]
    (* radius-of-earth 2 (Math/asin (Math/sqrt a)))))

(defn interpolate-coordinates [a b c d]
  (let [lat1 (:lat a)
