         weightTotal (apply + weights)
         weightedValues (map #(/ (:value %) (+ 1 (:distance %))) values)
         weightedSum (apply + weightedValues)]
-    (.log js/console "wa" weightedSum weightTotal (/ weightedSum weightTotal))
+    ;(.log js/console "wa" weightedSum weightTotal (/ weightedSum weightTotal))
     (/ weightedSum weightTotal)))
+
+(defn alpha-blend [values]
+  (let [distances (map :distance values)
+        maxDistance (apply max distances)
+        fudgeFactor 700.0]
+    ;(.log js/console "ab" maxDistance)
+    (min 1.0 (/ 1.0 (/ maxDistance fudgeFactor)))))
 
 (defn temp-for-locations [boxWidth boxHeight]
   (let [locations (:locations @app-state)

                                             (Math/pow (- (-> node :location second) y) 2.0)))})

(defn draw-map [canvas mapImage]
  (set! (.-width canvas) (.-width mapImage))
  (set! (.-height canvas) (.-height mapImage))
  (let [context (.getContext canvas "2d")
        gridSize 2
        boxWidth (/ (.-width canvas) gridSize)
        boxHeight (/ (.-height canvas) gridSize)
        values (-> (:nodes @app-state) vals)
        temp (-> (temp-for-locations boxWidth boxHeight) seq)
        grid (apply merge (for
                           [x (range gridSize) y (range gridSize)]
                            {[x y] (weighted-average (map #(rangeValues % x y) temp))}))
        minTemp (apply min (vals grid))
        maxTemp (apply max (vals grid))]
    (.drawImage context mapImage 0 0)
    (.log js/console "max" minTemp maxTemp)
    (.fillRect context 0 0 boxWidth boxHeight)
    (set! (.-fillStyle context) "#ff0000")
    (set! (.-globalAlpha context) .5)
    (.log js/console context)
    (.fillRect context 100 100 10 10)))

(def canvas-dom (.getElementById js/document "map"))


      (fetch-events)
      (. timer (start))
      (swap! app-state assoc :timer timer)
      ;(events/listen timer goog.Timer/TICK fetch-events)
)))

(if (-> (:timer @app-state) nil? not)
  (.stop (:timer @app-state)))
