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

        :when (= freq 1)]            ;; this is the filter condition
   id))

;perform an aggregation of $geoNear (to get the document distances) and $geoIntersects at the same time
(defn catch-trottoirs [perp radius]
  (mc/aggregate db "t" [
     {
       "$geoNear" {
          :near {:type "Point" :coordinates (first perp)}
          :spherical true
          :maxDistance radius
          :distanceField "calculated_distance"
          :query { :geometry { "$geoIntersects" { "$geometry" (:geometry (perp-lineString perp)) } }}
      }}
  ]))

;; TESTS START with this segment
(def seg [[2.379831219812292 48.845304455299846] [2.378934357368756 48.8457372123706]])
(def seg [[2.364545590666204 48.870542444326375] [2.36458829896837 48.87056413432559]])

(defn drawPerps []
  (let [nearQuery { :geometry { $near
                             { "$geometry" {

  (: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)
