 
 
 
+;;; Utils ;;;;;;;;;;;
 
 (defn compute-perp [segment d]
   "Compute the middle-perpendicular of a segment seg of length d"

        perps (map (fn [lseg] [lseg (compute-perp lseg 20)]) filtered-segments)
        ;; check whether this perpendicular's first intersection is a bordure trottoir
        hits (mapcat (fn [[lseg perp]]
                       (let [first-caught (first (catch-trottoirs perp 60))
                             valid (= "BOR" (get-in first-caught [:properties :info]))]
                         (if valid [(compute-perp lseg (:calculated_distance first-caught))] [])))
                  perps)
        ]
    ;(json/write-str (map perp-lineString (map (fn [[lseg perp]] perp) perps)) :value-fn objectId-reader)))
    (json/write-str (map perp-lineString hits) :value-fn objectId-reader)))


;; Is it a trottoir ?
(contains? #{"BOR" "BTT"} (get-in (first caught) [:properties :info]))
; YEAH !!
(:calculated_distance (first caught))

















(comment
(defn getSample []
  (let [res (mc/find-maps db "v" nearQuery)]
    (json/write-str (nth res 2) :value-fn objectId-reader))
  ))

(defn sample []
  (str (json/write-str (perp-lineString (compute-perp seg 50))))
)


;; ROUTES

  (:import [com.mongodb MongoOptions ServerAddress]
    org.bson.types.ObjectId))

;;; DB ;;;;;;;;;;;
(def db (mg/get-db (mg/connect) "agreable"))
(defn objectId-reader [key value]
  (if (= key :_id)
