Solid start made on routing.
This commit is contained in:
parent
9687e57666
commit
777b8bc077
29 changed files with 684 additions and 444 deletions
|
|
@ -53,7 +53,7 @@
|
|||
style="width:92.5%;
|
||||
float:left;"> 37 </div></td>
|
||||
<td class="with-number">7.50 %</td>
|
||||
<td class="with-number">95</td><td class="with-number">8</td><td class="with-number">40</td>
|
||||
<td class="with-number">97</td><td class="with-number">11</td><td class="with-number">40</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/ocean.clj.html">walkmap.ocean</a></td><td class="with-bar"><div class="covered"
|
||||
|
|
@ -74,31 +74,31 @@
|
|||
float:left;"> 16 </div></td>
|
||||
<td class="with-number">93.98 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:89.74358974358974%;
|
||||
float:left;"> 35 </div><div class="partial"
|
||||
style="width:7.6923076923076925%;
|
||||
style="width:89.47368421052632%;
|
||||
float:left;"> 34 </div><div class="partial"
|
||||
style="width:7.894736842105263%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:2.5641025641025643%;
|
||||
style="width:2.6315789473684212%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">97.44 %</td>
|
||||
<td class="with-number">94</td><td class="with-number">9</td><td class="with-number">39</td>
|
||||
<td class="with-number">97.37 %</td>
|
||||
<td class="with-number">94</td><td class="with-number">9</td><td class="with-number">38</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/polygon.clj.html">walkmap.polygon</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:72.0682302771855%;
|
||||
style="width:66.40471512770138%;
|
||||
float:left;"> 338 </div><div class="not-covered"
|
||||
style="width:27.931769722814497%;
|
||||
float:left;"> 131 </div></td>
|
||||
<td class="with-number">72.07 %</td>
|
||||
style="width:33.59528487229863%;
|
||||
float:left;"> 171 </div></td>
|
||||
<td class="with-number">66.40 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:77.58620689655173%;
|
||||
style="width:71.42857142857143%;
|
||||
float:left;"> 45 </div><div class="partial"
|
||||
style="width:10.344827586206897%;
|
||||
style="width:9.523809523809524%;
|
||||
float:left;"> 6 </div><div class="not-covered"
|
||||
style="width:12.068965517241379%;
|
||||
float:left;"> 7 </div></td>
|
||||
<td class="with-number">87.93 %</td>
|
||||
<td class="with-number">118</td><td class="with-number">13</td><td class="with-number">58</td>
|
||||
style="width:19.047619047619047%;
|
||||
float:left;"> 12 </div></td>
|
||||
<td class="with-number">80.95 %</td>
|
||||
<td class="with-number">125</td><td class="with-number">13</td><td class="with-number">63</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/read_svg.clj.html">walkmap.read-svg</a></td><td class="with-bar"><div class="covered"
|
||||
|
|
@ -145,20 +145,20 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/superstructure.clj.html">walkmap.superstructure</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:70.6043956043956%;
|
||||
float:left;"> 257 </div><div class="not-covered"
|
||||
style="width:29.395604395604394%;
|
||||
float:left;"> 107 </div></td>
|
||||
<td class="with-number">70.60 %</td>
|
||||
style="width:53.41614906832298%;
|
||||
float:left;"> 258 </div><div class="not-covered"
|
||||
style="width:46.58385093167702%;
|
||||
float:left;"> 225 </div></td>
|
||||
<td class="with-number">53.42 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:71.26436781609195%;
|
||||
style="width:56.88073394495413%;
|
||||
float:left;"> 62 </div><div class="partial"
|
||||
style="width:3.4482758620689653%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:25.28735632183908%;
|
||||
float:left;"> 22 </div></td>
|
||||
<td class="with-number">74.71 %</td>
|
||||
<td class="with-number">183</td><td class="with-number">18</td><td class="with-number">87</td>
|
||||
style="width:3.669724770642202%;
|
||||
float:left;"> 4 </div><div class="not-covered"
|
||||
style="width:39.44954128440367%;
|
||||
float:left;"> 43 </div></td>
|
||||
<td class="with-number">60.55 %</td>
|
||||
<td class="with-number">221</td><td class="with-number">19</td><td class="with-number">109</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/svg.clj.html">walkmap.svg</a></td><td class="with-bar"><div class="covered"
|
||||
|
|
@ -188,18 +188,20 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/utils.clj.html">walkmap.utils</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:99.86772486772487%;
|
||||
float:left;"> 755 </div><div class="not-covered"
|
||||
style="width:0.13227513227513227%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">99.87 %</td>
|
||||
style="width:97.04749679075738%;
|
||||
float:left;"> 756 </div><div class="not-covered"
|
||||
style="width:2.952503209242619%;
|
||||
float:left;"> 23 </div></td>
|
||||
<td class="with-number">97.05 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:97.22222222222223%;
|
||||
float:left;"> 35 </div><div class="partial"
|
||||
style="width:2.7777777777777777%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">101</td><td class="with-number">9</td><td class="with-number">36</td>
|
||||
style="width:85.71428571428571%;
|
||||
float:left;"> 36 </div><div class="partial"
|
||||
style="width:2.380952380952381%;
|
||||
float:left;"> 1 </div><div class="not-covered"
|
||||
style="width:11.904761904761905%;
|
||||
float:left;"> 5 </div></td>
|
||||
<td class="with-number">88.10 %</td>
|
||||
<td class="with-number">113</td><td class="with-number">9</td><td class="with-number">42</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/vertex.clj.html">walkmap.vertex</a></td><td class="with-bar"><div class="covered"
|
||||
|
|
@ -220,9 +222,9 @@
|
|||
</tr>
|
||||
<tr><td>Totals:</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">72.81 %</td>
|
||||
<td class="with-number">69.99 %</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">68.80 %</td>
|
||||
<td class="with-number">65.94 %</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -286,8 +286,14 @@
|
|||
<span class="blank" title="0 out of 0 forms covered">
|
||||
094
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 ;; (load-microworld-edn "../MicroWorld/mw-cli/isle_of_man.edn" nil {})
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
095
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
096
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
097
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -139,13 +139,13 @@
|
|||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 from the calling function."
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
047 `(check-kind-type-seq ~o path? :path))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
<span class="blank" title="0 out of 2 forms covered">
|
||||
048
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
|
|
@ -211,13 +211,13 @@
|
|||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 sequence of vertices."
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
070 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
071 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
<span class="covered" title="14 out of 14 forms covered">
|
||||
072 (seq? o) (when
|
||||
</span><br/>
|
||||
<span class="partial" title="4 out of 5 forms covered">
|
||||
|
|
|
|||
|
|
@ -139,13 +139,13 @@
|
|||
<span class="covered" title="23 out of 23 forms covered">
|
||||
045 (defmacro check-triangle
|
||||
</span><br/>
|
||||
<span class="partial" title="2 out of 10 forms covered">
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 "If `o` is not a triangle, throw an `IllegalArgumentException` with an
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
<span class="partial" title="2 out of 10 forms covered">
|
||||
048 from the calling function."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
|
|
@ -211,13 +211,13 @@
|
|||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 ;; corners, but the maths are a bit to advanced for me today. TODO: do it!
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 30 forms covered">
|
||||
<span class="not-covered" title="0 out of 21 forms covered">
|
||||
070 (let [vnw (vertex (:x (check-vertex vsw))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 18 forms covered">
|
||||
071 (:y (check-vertex vne))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 20 forms covered">
|
||||
<span class="partial" title="9 out of 29 forms covered">
|
||||
072 (/ (reduce + (map #(or (:z %) 0) [vsw vne])) 2))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
|
|
@ -229,134 +229,155 @@
|
|||
<span class="not-covered" title="0 out of 20 forms covered">
|
||||
075 (/ (reduce + (map #(or (:z %) 0) [vsw vne])) 2))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
076 (t/tag (polygon vsw vnw vne vse) :rectangle)))
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
076 (t/tag
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
077
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
077 (assoc
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
078 (polygon vsw vnw vne vse)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 ;; (rectangle (vertex 1 2 3) (vertex 7 9 4))
|
||||
079 :centre
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 18 forms covered">
|
||||
080 (vertex (+ (:x vsw) (/ (- (:x vne) (:x vsw)) 2))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 16 forms covered">
|
||||
081 (+ (:x vsw) (/ (- (:y vne) (:y vsw)) 2))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
082 (:z vse)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 :rectangle)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
079
|
||||
084
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
085 ;; (rectangle (vertex 1 2 3) (vertex 7 9 4))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
086
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
080 (defn gradient
|
||||
087 (defn gradient
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
081 "Return a polygon like `triangle` but with a key `:gradient` whose value is a
|
||||
088 "Return a polygon like `triangle` but with a key `:gradient` whose value is a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 unit vector representing the gradient across `triangle`."
|
||||
089 unit vector representing the gradient across `triangle`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 [triangle]
|
||||
090 [triangle]
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
084 (let [order (sort #(max (:z %1) (:z %2))
|
||||
091 (let [order (sort #(max (:z %1) (:z %2))
|
||||
</span><br/>
|
||||
<span class="partial" title="8 out of 18 forms covered">
|
||||
085 (:vertices (check-triangle triangle)))
|
||||
092 (:vertices (check-triangle triangle)))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
086 highest (first order)
|
||||
093 highest (first order)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
087 lowest (last order)]
|
||||
094 lowest (last order)]
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
088 (assoc triangle :gradient (e/unit-vector (e/edge lowest highest)))))
|
||||
095 (assoc triangle :gradient (e/unit-vector (e/edge lowest highest)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
089
|
||||
096
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
090 (defn triangle-centre
|
||||
097 (defn triangle-centre
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 "Return a canonicalised `facet` (i.e. a triangular polygon) with an added
|
||||
098 "Return a canonicalised `facet` (i.e. a triangular polygon) with an added
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 key `:centre` whose value represents the centre of this facet in 3
|
||||
099 key `:centre` whose value represents the centre of this facet in 3
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
093 dimensions. This only works for triangles, so is here not in
|
||||
100 dimensions. This only works for triangles, so is here not in
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
094 `walkmap.polygon`. It is an error (although no exception is currently
|
||||
101 `walkmap.polygon`. It is an error (although no exception is currently
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 thrown) if the object past is not a triangular polygon."
|
||||
102 thrown) if the object past is not a triangular polygon."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
096 [facet]
|
||||
103 [facet]
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 19 forms covered">
|
||||
097 (let [vs (:vertices (check-triangle facet))
|
||||
104 (let [vs (:vertices (check-triangle facet))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
098 v1 (first vs)
|
||||
105 v1 (first vs)
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
099 opposite (e/edge (nth vs 1) (nth vs 2))
|
||||
106 opposite (e/edge (nth vs 1) (nth vs 2))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
100 oc (e/centre opposite)]
|
||||
107 oc (e/centre opposite)]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
101 (assoc
|
||||
108 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
102 facet
|
||||
109 facet
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
103 :centre
|
||||
110 :centre
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
104 (vertex
|
||||
111 (vertex
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
105 (+ (:x v1) (* (- (:x oc) (:x v1)) 2/3))
|
||||
112 (+ (:x v1) (* (- (:x oc) (:x v1)) 2/3))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
106 (+ (:y v1) (* (- (:y oc) (:y v1)) 2/3))
|
||||
113 (+ (:y v1) (* (- (:y oc) (:y v1)) 2/3))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
107 (+ (:z v1) (* (- (:z oc) (:z v1)) 2/3))))))
|
||||
114 (+ (:z v1) (* (- (:z oc) (:z v1)) 2/3))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
108
|
||||
115
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
109 (defn centre
|
||||
116 (defn centre
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
110 [poly]
|
||||
117 [poly]
|
||||
</span><br/>
|
||||
<span class="covered" title="22 out of 22 forms covered">
|
||||
111 (case (count (:vertices (check-polygon poly)))
|
||||
118 (case (count (:vertices (check-polygon poly)))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
112 3 (triangle-centre poly)
|
||||
119 3 (triangle-centre poly)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
113 ;; else
|
||||
120 ;; else
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
114 (throw
|
||||
121 (throw
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
115 (UnsupportedOperationException.
|
||||
122 (UnsupportedOperationException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
116 "The general case of centre for polygons is not yet implemented."))))
|
||||
123 "The general case of centre for polygons is not yet implemented."))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
117
|
||||
124
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
118
|
||||
125
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -17,541 +17,655 @@
|
|||
004 [taoensso.timbre :as l]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [walkmap.path :as p]
|
||||
005 [walkmap.edge :refer [edge length]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [walkmap.polygon :as q]
|
||||
006 [walkmap.path :as p]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.utils :as u]
|
||||
007 [walkmap.polygon :as q]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [walkmap.vertex :as v]))
|
||||
008 [walkmap.utils :as u]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [walkmap.vertex :as v]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
009
|
||||
010
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 ;; TODO: Think about reification/dereification. How can we cull a polygon, if
|
||||
011 ;; TODO: Think about reification/dereification. How can we cull a polygon, if
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 ;; some vertices still index it? I *think* that what's needed is that when
|
||||
012 ;; some vertices still index it? I *think* that what's needed is that when
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 ;; we store something in the superstructure, we replace all its vertices (and
|
||||
013 ;; we store something in the superstructure, we replace all its vertices (and
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 ;; other dependent structures, if any with their ids - as well as, obviously,
|
||||
014 ;; other dependent structures, if any with their ids - as well as, obviously,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 ;; adding/merging those vertices/dependent structures into the superstructure
|
||||
015 ;; adding/merging those vertices/dependent structures into the superstructure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 ;; as first class objects in themselves. That means, for each identified thing,
|
||||
016 ;; as first class objects in themselves. That means, for each identified thing,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 ;; the superstructure only contains one copy of it.
|
||||
017 ;; the superstructure only contains one copy of it.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 ;;
|
||||
018 ;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 ;; The question then is, when we want to do things with those objects, do we
|
||||
019 ;; The question then is, when we want to do things with those objects, do we
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 ;; exteract a copy with its dependent structures fixed back up (reification),
|
||||
020 ;; exteract a copy with its dependent structures fixed back up (reification),
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 ;; or do we indirect through the superstructure every time we want to access
|
||||
021 ;; or do we indirect through the superstructure every time we want to access
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 ;; them? In a sense, the copy in the superstructure is the 'one true copy',
|
||||
022 ;; them? In a sense, the copy in the superstructure is the 'one true copy',
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 ;; but it may become very difficult then to have one true copy of the
|
||||
023 ;; but it may become very difficult then to have one true copy of the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ;; superstructure - unless we replace the superstructure altogether with a
|
||||
024 ;; superstructure - unless we replace the superstructure altogether with a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 ;; database, which may be the Right Thing To Do.
|
||||
025 ;; database, which may be the Right Thing To Do.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
025
|
||||
026
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
026 (def vertex-index ::vertex-index)
|
||||
027 (def vertex-index ::vertex-index)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
027
|
||||
028
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
028 (defn vertices
|
||||
029 (defn vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 "If `o` is an object with vertices, return those vertices, else nil."
|
||||
030 "If `o` is an object with vertices, return those vertices, else nil."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 [o]
|
||||
031 [o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
031 (cond
|
||||
032 (cond
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
032 (v/vertex? o) (list o)
|
||||
033 (v/vertex? o) (list o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
033 (q/polygon? o) (:vertices o)
|
||||
034 (q/polygon? o) (:vertices o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
034 (p/path? o) (:vertices o)))
|
||||
035 (p/path? o) (:vertices o)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
035
|
||||
036
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
036 (defn index-vertex
|
||||
037 (defn index-vertex
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 "Return a superstructure like `s` in which object `o` is indexed by vertex
|
||||
038 "Return a superstructure like `s` in which object `o` is indexed by vertex
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 `v`. It is an error (and an exception may be thrown) if
|
||||
039 `v`. It is an error (and an exception may be thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
039
|
||||
040
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 1. `s` is not a map;
|
||||
041 1. `s` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 2. `o` is not a map;
|
||||
042 2. `o` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 3. `o` does not have a value for the key `:walkmap.id/id`;
|
||||
043 3. `o` does not have a value for the key `:walkmap.id/id`;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 4. `v` is not a vertex."
|
||||
044 4. `v` is not a vertex."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 [s o v]
|
||||
045 [s o v]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
045 (if-not (v/vertex? o)
|
||||
046 (if-not (v/vertex? o)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
046 (if (:walkmap.id/id o)
|
||||
047 (if (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
047 (if (v/vertex? v)
|
||||
<span class="partial" title="4 out of 6 forms covered">
|
||||
048 (if (v/vertex? v)
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
048 (let [vi (or (::vertex-index s) {})
|
||||
049 (let [vi (or (::vertex-index s) {})
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
049 current (or (vi (:walkmap.id/id v)) {})]
|
||||
050 current (or (vi (:walkmap.id/id v)) {})]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
051 ;; deep-merge doesn't merge sets, only maps; so at this
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 ;; deep-merge doesn't merge sets, only maps; so at this
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
051 ;; stage we need to build a map.
|
||||
052 ;; stage we need to build a map.
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
052 (assoc vi (:walkmap.id/id v) (assoc current (:walkmap.id/id o) (:walkmap.id/id v))))
|
||||
053 (assoc vi (:walkmap.id/id v) (assoc current (:walkmap.id/id o) (:walkmap.id/id v))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
053 (throw (IllegalArgumentException. "Not a vertex: " v)))
|
||||
054 (throw (IllegalArgumentException. "Not a vertex: " v)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
054 (throw (IllegalArgumentException. (u/truncate (str "No `:walkmap.id/id` value: " o) 80))))
|
||||
055 (throw (IllegalArgumentException. (u/truncate (str "No `:walkmap.id/id` value: " o) 80))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 ;; it shouldn't actually be an error to try to index a vertex, but it
|
||||
056 ;; it shouldn't actually be an error to try to index a vertex, but it
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 ;; also isn't useful to do so, so I'd be inclined to ignore it.
|
||||
057 ;; also isn't useful to do so, so I'd be inclined to ignore it.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
057 (::vertex-index s)))
|
||||
058 (::vertex-index s)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
058
|
||||
059
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
059 (defn index-vertices
|
||||
060 (defn index-vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 "Return a superstructure like `s` in which object `o` is indexed by its
|
||||
061 "Return a superstructure like `s` in which object `o` is indexed by its
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 vertices. It is an error (and an exception may be thrown) if
|
||||
062 vertices. It is an error (and an exception may be thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
062
|
||||
063
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
063 1. `s` is not a map;
|
||||
064 1. `s` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 2. `o` is not a map;
|
||||
065 2. `o` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 3. `o` does not have a value for the key `:walkmap.id/id`."
|
||||
066 3. `o` does not have a value for the key `:walkmap.id/id`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 [s o]
|
||||
067 [s o]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
067 (u/deep-merge
|
||||
068 (u/deep-merge
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
068 s
|
||||
069 s
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
069 {::vertex-index
|
||||
070 {::vertex-index
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
070 (reduce
|
||||
071 (reduce
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
071 u/deep-merge
|
||||
072 u/deep-merge
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
072 {}
|
||||
073 {}
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
073 (map
|
||||
074 (map
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
074 #(index-vertex s o %)
|
||||
075 #(index-vertex s o %)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
075 (:vertices o)))}))
|
||||
076 (:vertices o)))}))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
076
|
||||
077
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
077 (defn in-retrieve
|
||||
078 (defn in-retrieve
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 "Internal guts of `retrieve`, q.v. `x` can be anything; `s` must be a
|
||||
079 "Internal guts of `retrieve`, q.v. `x` can be anything; `s` must be a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 walkmap superstructure. TODO: recursive, quite likely to blow the fragile
|
||||
080 walkmap superstructure. TODO: recursive, quite likely to blow the fragile
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 Clojure stack. Probably better to do this with `walk`, but I don't yet
|
||||
081 Clojure stack. Probably better to do this with `walk`, but I don't yet
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
081 understand that."
|
||||
082 understand that."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 [x s]
|
||||
083 [x s]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
083 (cond
|
||||
084 (cond
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
084 ;; if it's a keyword identifying something in s, retrieve that something.
|
||||
085 ;; if it's a keyword identifying something in s, retrieve that something.
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
085 (keyword? x) (if (s x)
|
||||
086 (keyword? x) (if (s x)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
086 (in-retrieve (s x) s)
|
||||
087 (in-retrieve (s x) s)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
087 x)
|
||||
088 x)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 ;; if it's a map, for every key which is not `:walkmap.id/id`, recurse.
|
||||
089 ;; if it's a map, for every key which is not `:walkmap.id/id`, recurse.
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
089 (map? x) (let [v (reduce
|
||||
090 (map? x) (let [v (reduce
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
090 (fn [m k]
|
||||
091 (fn [m k]
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
091 (assoc m k (in-retrieve (x k) s)))
|
||||
092 (assoc m k (in-retrieve (x k) s)))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
092 {}
|
||||
093 {}
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
093 (keys (dissoc x :walkmap.id/id)))
|
||||
094 (keys (dissoc x :walkmap.id/id)))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
094 id (:walkmap.id/id x)]
|
||||
095 id (:walkmap.id/id x)]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 ;; if it has an id, bind it to that id in the returned value.
|
||||
096 ;; if it has an id, bind it to that id in the returned value.
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
096 (if id
|
||||
097 (if id
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
097 (assoc
|
||||
098 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
098 v
|
||||
099 v
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
099 :walkmap.id/id
|
||||
100 :walkmap.id/id
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
100 (:walkmap.id/id x))
|
||||
101 (:walkmap.id/id x))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
101 v))
|
||||
102 v))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
102 (set? x) x ;; TODO: should I search in sets for objects when storing?
|
||||
103 (set? x) x ;; TODO: should I search in sets for objects when storing?
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
103 (coll? x) (map #(in-retrieve % s) x)
|
||||
104 (coll? x) (map #(in-retrieve % s) x)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
104 :else x))
|
||||
105 :else x))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
105
|
||||
106
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
106 (defn retrieve
|
||||
107 (defn retrieve
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
107 "Retrieve the canonical representation of the object with this `id` from the
|
||||
108 "Retrieve the canonical representation of the object with this `id` from the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
108 superstructure `s`."
|
||||
109 superstructure `s`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
109 [id s]
|
||||
110 [id s]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
110 (in-retrieve (id s) s))
|
||||
111 (in-retrieve (id s) s))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
111
|
||||
112
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
112 (defn in-store-find-objects
|
||||
113 (defn in-store-find-objects
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
113 "Return an id -> object map of every object within `o`. Internal to
|
||||
114 "Return an id -> object map of every object within `o`. Internal to
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
114 `in-store`, q.v. Use at your own peril."
|
||||
115 `in-store`, q.v. Use at your own peril."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
115 ([o]
|
||||
116 ([o]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
116 (in-store-find-objects o {}))
|
||||
117 (in-store-find-objects o {}))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
117 ([o s]
|
||||
118 ([o s]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
118 (l/debug "Finding objects in:" o)
|
||||
119 (l/debug "Finding objects in:" o)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
119 (cond
|
||||
120 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
120 (set? o) s ;; TODO: should I search in sets for objects when storing?
|
||||
121 (set? o) s ;; TODO: should I search in sets for objects when storing?
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
121 (map? o) (if (:walkmap.id/id o)
|
||||
122 (map? o) (if (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
122 (assoc
|
||||
123 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
123 (in-store-find-objects (vals o) s)
|
||||
124 (in-store-find-objects (vals o) s)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
124 (:walkmap.id/id o)
|
||||
125 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
125 o)
|
||||
126 o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
126 (in-store-find-objects (vals o) s))
|
||||
127 (in-store-find-objects (vals o) s))
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
127 (coll? o) (reduce merge s (map #(in-store-find-objects % s) o))
|
||||
128 (coll? o) (reduce merge s (map #(in-store-find-objects % s) o))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
128 :else s)))
|
||||
129 :else s)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
129
|
||||
130
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
130 (defn in-store-replace-with-keys
|
||||
131 (defn in-store-replace-with-keys
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
131 "Return a copy of `o` in which each reified walkmap object within `o` has
|
||||
132 "Return a copy of `o` in which each reified walkmap object within `o` has
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
132 been replaced with the `:walkmap.id/id` of that object. Internal to
|
||||
133 been replaced with the `:walkmap.id/id` of that object. Internal to
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
133 `in-store`, q.v. Use at your own peril."
|
||||
134 `in-store`, q.v. Use at your own peril."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
134 [o]
|
||||
135 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
135 (assoc
|
||||
136 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
136 (postwalk #(or (:walkmap.id/id %) %) (dissoc o :walkmap.id/id))
|
||||
137 (postwalk #(or (:walkmap.id/id %) %) (dissoc o :walkmap.id/id))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
137 :walkmap.id/id
|
||||
138 :walkmap.id/id
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
138 (:walkmap.id/id o)))
|
||||
139 (:walkmap.id/id o)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
139
|
||||
140
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
140 ;; (in-store-replace-with-keys (p/path (v/vertex 0 0 0) (v/vertex 0 1 2) (v/vertex 3 3 3)))
|
||||
141 ;; (in-store-replace-with-keys (p/path (v/vertex 0 0 0) (v/vertex 0 1 2) (v/vertex 3 3 3)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
141 ;; (in-store-find-objects (p/path (v/vertex 0 0 0) (v/vertex 0 1 2) (v/vertex 3 3 3)))
|
||||
142 ;; (in-store-find-objects (p/path (v/vertex 0 0 0) (v/vertex 0 1 2) (v/vertex 3 3 3)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
142
|
||||
143
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
143 (defn store
|
||||
144 (defn store
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
144 "Return a superstructure like `s` with object `o` added. If only one
|
||||
145 "Return a superstructure like `s` with object `o` added. If only one
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
145 argument is supplied it will be assumed to represent `o` and a new
|
||||
146 argument is supplied it will be assumed to represent `o` and a new
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
146 superstructure will be returned.
|
||||
147 superstructure will be returned.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
147
|
||||
148
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
148 It is an error (and an exception may be thrown) if
|
||||
149 It is an error (and an exception may be thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
149
|
||||
150
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
150 1. `s` is not a map;
|
||||
151 1. `s` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
151 2. `o` is not a recognisable walkmap object"
|
||||
152 2. `o` is not a recognisable walkmap object"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
152 ([o]
|
||||
153 ([o]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
153 (store o {}))
|
||||
154 (store o {}))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
154 ([o s]
|
||||
155 ([o s]
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
155 (when-not (:walkmap.id/id o)
|
||||
156 (when-not (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
156 (throw
|
||||
157 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
157 (IllegalArgumentException.
|
||||
158 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
158 (str "Not a walkmap object: no value for `:walkmap.id/id`: "
|
||||
159 (str "Not a walkmap object: no value for `:walkmap.id/id`: "
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
159 (u/kind-type o)))))
|
||||
160 (u/kind-type o)))))
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
160 (when-not (map? s)
|
||||
161 (when-not (map? s)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
161 (throw
|
||||
162 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
162 (IllegalArgumentException.
|
||||
163 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
163 (str "Superstructure must be a map: " (u/kind-type s)))))
|
||||
164 (str "Superstructure must be a map: " (u/kind-type s)))))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
164 (assoc
|
||||
165 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
165 (u/deep-merge s (in-store-find-objects o) (index-vertices s o))
|
||||
166 (u/deep-merge s (in-store-find-objects o) (index-vertices s o))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
166 (:walkmap.id/id o)
|
||||
167 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
167 (in-store-replace-with-keys o))))
|
||||
168 (in-store-replace-with-keys o))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
168
|
||||
169
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
169 (defn search-vertices
|
||||
170 (defn search-vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
170 "Search superstructure `s` for vertices within the box defined by vertices
|
||||
171 "Search superstructure `s` for vertices within the box defined by vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
171 `minv` and `maxv`. Every coordinate in `minv` must have a lower value than
|
||||
172 `minv` and `maxv`. Every coordinate in `minv` must have a lower value than
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
172 the equivalent coordinate in `maxv`. If `d2?` is supplied and not false,
|
||||
173 the equivalent coordinate in `maxv`. If `d2?` is supplied and not false,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
173 search only in the x,y projection."
|
||||
174 search only in the x,y projection."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
174 ([s minv maxv]
|
||||
175 ([s minv maxv]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
175 (search-vertices s minv maxv false))
|
||||
176 (search-vertices s minv maxv false))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
176 ([s minv maxv d2?]
|
||||
177 ([s minv maxv d2?]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
177 (let [minv' (if d2? (assoc minv :z Double/NEGATIVE_INFINITY) minv)
|
||||
178 (let [minv' (if d2? (assoc minv :z Double/NEGATIVE_INFINITY) minv)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
178 maxv' (if d2? (assoc maxv :z Double/POSITIVE_INFINITY) maxv)]
|
||||
179 maxv' (if d2? (assoc maxv :z Double/POSITIVE_INFINITY) maxv)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
179 (filter
|
||||
180 (filter
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
180 #(v/within-box? % minv maxv)
|
||||
181 #(v/within-box? % minv maxv)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
181 (filter #(= (:kind %) :vertex) (vals s))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
182
|
||||
182 (filter #(= (:kind %) :vertex) (vals s))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
183
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
184 (defn find-nearest
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
185 "Search superstructure `s` for the nearest object matching `filter-fn` to
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
186 the `target` vertex. Searches only with `radius` (slight misnomer, area
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
187 actually searched is a cube). Returns one object, or `nil` if no matching
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
188 object found.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
189
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
190 WARNING: currently only returns objects which have a defined `:centre`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
191 (but most of the significant objects we have do)."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
192 [s target filter-fn radius]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
193 (let [minv (v/vertex
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 21 forms covered">
|
||||
194 (- (:x (v/check-vertex target)) radius)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 17 forms covered">
|
||||
195 (- (:y target) radius) (- (or (:z target) 0) radius))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
196 maxv (v/vertex
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
197 (+ (:x target) 0.5) (+ (:y target) 0.5)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
198 (+ (or (:z target) 0) 0.5))]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
199 ;; filter those objects with the filter function, then sort that list
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
200 ;; by the edge distance from the target to the `:centre` of the object
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
201 ;; and take the first
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
202 (first
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
203 (sort-by
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
204 #(length (edge target (:centre %)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
205 (filter
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
206 :centre
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
207 (map #(retrieve % s)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
208 ;; for each vertex id in vids, get the objects associated with that id
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
209 ;; in the vertex index as a single flat list
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
210 (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
211 concat
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
212 (remove
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
213 nil?
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
214 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
215 #(-> s ::vertex-index % keys)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
216 ;; get all the vertex ids within radius of the target
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
217 (set
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
218 (map
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
219 :walkmap.id/id
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
220 (search-vertices s minv maxv))))))))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
221
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -11,301 +11,337 @@
|
|||
002 "Miscellaneous utility functions."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [clojure.math.numeric-tower :as m]
|
||||
003 (:require [clojure.edn :as edn :only [read]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 [clojure.string :as s]))
|
||||
004 [clojure.java.io :as io]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [clojure.math.numeric-tower :as m]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [clojure.string :as s]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
005
|
||||
007
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
006 (defn deep-merge
|
||||
008 (defn deep-merge
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 "Recursively merges maps. If vals are not maps, the last value wins."
|
||||
009 "Recursively merges maps. If vals are not maps, the last value wins."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 ;; TODO: not my implementation, not sure I entirely trust it.
|
||||
010 ;; TODO: not my implementation, not sure I entirely trust it.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 ;; TODO TODO: if we are to successfully merge walkmap objects, we must
|
||||
011 ;; TODO TODO: if we are to successfully merge walkmap objects, we must
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 ;; return, on each object, the union of its tags if any.
|
||||
012 ;; return, on each object, the union of its tags if any.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [& vals]
|
||||
013 [& vals]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
012 (if (every? map? vals)
|
||||
014 (if (every? map? vals)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
013 (apply merge-with deep-merge vals)
|
||||
015 (apply merge-with deep-merge vals)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
014 (last vals)))
|
||||
016 (last vals)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
015
|
||||
017
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
016 (defn truncate
|
||||
018 (defn truncate
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 "If string `s` is more than `n` characters long, return the first `n`
|
||||
019 "If string `s` is more than `n` characters long, return the first `n`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 characters; otherwise, return `s`."
|
||||
020 characters; otherwise, return `s`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 [s n]
|
||||
021 [s n]
|
||||
</span><br/>
|
||||
<span class="partial" title="20 out of 21 forms covered">
|
||||
020 (if (and (string? s) (number? n) (> (count s) n))
|
||||
022 (if (and (string? s) (number? n) (> (count s) n))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
021 (subs s 0 n)
|
||||
023 (subs s 0 n)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
022 s))
|
||||
024 s))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
023
|
||||
025
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
024 (defn kind-type
|
||||
026 (defn kind-type
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 "Identify the type of an `object`, e.g. for logging. If it has a `:kind` key,
|
||||
027 "Identify the type of an `object`, e.g. for logging. If it has a `:kind` key,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 it's one of ours, and that's what we want. Otherwise, we want its type; but
|
||||
028 it's one of ours, and that's what we want. Otherwise, we want its type; but
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 the type of `nil` is `nil`, which doesn't get printed when assembling error
|
||||
029 the type of `nil` is `nil`, which doesn't get printed when assembling error
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 ,essages, so return \"nil\"."
|
||||
030 ,essages, so return \"nil\"."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 [object]
|
||||
031 [object]
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
030 (or (:kind object) (type object) "nil"))
|
||||
032 (or (:kind object) (type object) "nil"))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
031
|
||||
033
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
032 (defn =ish
|
||||
034 (defn =ish
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 "True if numbers `n1`, `n2` are roughly equal; that is to say, equal to
|
||||
035 "True if numbers `n1`, `n2` are roughly equal; that is to say, equal to
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 within `tolerance` (defaults to one part in one hundred thousand)."
|
||||
036 within `tolerance` (defaults to one part in one hundred thousand)."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 ([n1 n2]
|
||||
037 ([n1 n2]
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
036 (if (and (number? n1) (number? n2))
|
||||
038 (if (and (number? n1) (number? n2))
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
037 (let [m (m/abs (min n1 n2))
|
||||
039 (let [m (m/abs (min n1 n2))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
038 t (if (zero? m) 0.00001 (* 0.00001 m))]
|
||||
040 t (if (zero? m) 0.00001 (* 0.00001 m))]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
039 (=ish n1 n2 t))
|
||||
041 (=ish n1 n2 t))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
040 (= n1 n2)))
|
||||
042 (= n1 n2)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 ([n1 n2 tolerance]
|
||||
043 ([n1 n2 tolerance]
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
042 (if (and (number? n1) (number? n2))
|
||||
044 (if (and (number? n1) (number? n2))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
043 (< (m/abs (- n1 n2)) tolerance)
|
||||
045 (< (m/abs (- n1 n2)) tolerance)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
044 (= n1 n2))))
|
||||
046 (= n1 n2))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
045
|
||||
047
|
||||
</span><br/>
|
||||
<span class="covered" title="198 out of 198 forms covered">
|
||||
046 (defmacro check-kind-type
|
||||
048 (defmacro check-kind-type
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 "If `object` is not of kind-type `expected`, throws an
|
||||
049 "If `object` is not of kind-type `expected`, throws an
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
048 IllegalArgumentException with an appropriate message; otherwise, returns
|
||||
050 IllegalArgumentException with an appropriate message; otherwise, returns
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
049 `object`. If `checkfn` is supplied, it should be a function which tests
|
||||
051 `object`. If `checkfn` is supplied, it should be a function which tests
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 whether the object is of the expected kind-type.
|
||||
052 whether the object is of the expected kind-type.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
051
|
||||
053
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 Macro, so that the exception is thrown from the calling function."
|
||||
054 Macro, so that the exception is thrown from the calling function."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 ([object expected]
|
||||
055 ([object expected]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
054 `(if-not (= (kind-type ~object) ~expected)
|
||||
056 `(if-not (= (kind-type ~object) ~expected)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 (throw
|
||||
057 (throw
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 (IllegalArgumentException.
|
||||
058 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 (s/join
|
||||
059 (s/join
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 " "
|
||||
060 " "
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
059 ["Expected" ~expected "but found" (kind-type ~object)])))
|
||||
061 ["Expected" ~expected "but found" (kind-type ~object)])))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
060 ~object))
|
||||
062 ~object))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 ([object checkfn expected]
|
||||
063 ([object checkfn expected]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
062 `(if-not (~checkfn ~object)
|
||||
064 `(if-not (~checkfn ~object)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
063 (throw
|
||||
065 (throw
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 (IllegalArgumentException.
|
||||
066 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 (s/join
|
||||
067 (s/join
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 " "
|
||||
068 " "
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
067 ["Expected" ~expected "but found" (kind-type ~object)])))
|
||||
069 ["Expected" ~expected "but found" (kind-type ~object)])))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
068 ~object)))
|
||||
070 ~object)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
069
|
||||
071
|
||||
</span><br/>
|
||||
<span class="covered" title="416 out of 416 forms covered">
|
||||
070 (defmacro check-kind-type-seq
|
||||
072 (defmacro check-kind-type-seq
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 "If some item on sequence `s` is not of the `expected` kind-type, throws an
|
||||
073 "If some item on sequence `s` is not of the `expected` kind-type, throws an
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 IllegalArgumentException with an appropriate message; otherwise, returns
|
||||
074 IllegalArgumentException with an appropriate message; otherwise, returns
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
073 `object`. If `checkfn` is supplied, it should be a function which tests
|
||||
075 `object`. If `checkfn` is supplied, it should be a function which tests
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
074 whether the object is of the expected kind-type.
|
||||
076 whether the object is of the expected kind-type.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
075
|
||||
077
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
076 Macro, so that the exception is thrown from the calling function."
|
||||
078 Macro, so that the exception is thrown from the calling function."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
077 ([s expected]
|
||||
079 ([s expected]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
078 `(if-not (every? #(= (kind-type %) ~expected) ~s)
|
||||
080 `(if-not (every? #(= (kind-type %) ~expected) ~s)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 (throw
|
||||
081 (throw
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 (IllegalArgumentException.
|
||||
082 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
081 (s/join
|
||||
083 (s/join
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 " "
|
||||
084 " "
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 ["Expected sequence of"
|
||||
085 ["Expected sequence of"
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
084 ~expected
|
||||
086 ~expected
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
085 "but found ("
|
||||
087 "but found ("
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
086 (s/join ", " (remove #(= ~expected %) (map kind-type ~s)))
|
||||
088 (s/join ", " (remove #(= ~expected %) (map kind-type ~s)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
087 ")"])))
|
||||
089 ")"])))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
088 ~s))
|
||||
090 ~s))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 ([s checkfn expected]
|
||||
091 ([s checkfn expected]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
090 `(if-not (every? #(~checkfn %) ~s)
|
||||
092 `(if-not (every? #(~checkfn %) ~s)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 (throw
|
||||
093 (throw
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 (IllegalArgumentException.
|
||||
094 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
093 (s/join
|
||||
095 (s/join
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
094 " "
|
||||
096 " "
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 ["Expected sequence of"
|
||||
097 ["Expected sequence of"
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
096 ~expected
|
||||
098 ~expected
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
097 "but found ("
|
||||
099 "but found ("
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
098 (s/join ", " (remove #(= ~expected %) (map kind-type ~s)))
|
||||
100 (s/join ", " (remove #(= ~expected %) (map kind-type ~s)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
099 ")"])))
|
||||
101 ")"])))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
100 ~s)))
|
||||
102 ~s)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
101
|
||||
103
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
104 (defn load-edn
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
105 "Load edn from an io/reader source (filename or io/resource)."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
106 [source]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
107 (try
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
108 (with-open [r (io/reader source)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
109 (edn/read (java.io.PushbackReader. r)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
110 (catch java.io.IOException e
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
111 (printf "Couldn't open '%s': %s\n" source (.getMessage e)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
112 (catch RuntimeException e
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
113 (printf "Error parsing edn file '%s': %s\n" source (.getMessage e)))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -139,13 +139,13 @@
|
|||
<span class="covered" title="3 out of 3 forms covered">
|
||||
045 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="partial" title="11 out of 17 forms covered">
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
046 (number? (:x o))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
047 (number? (:y o))
|
||||
</span><br/>
|
||||
<span class="covered" title="14 out of 14 forms covered">
|
||||
<span class="partial" title="20 out of 26 forms covered">
|
||||
048 (or (nil? (:z o)) (number? (:z o)))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
|
|
@ -211,13 +211,13 @@
|
|||
<span class="covered" title="16 out of 16 forms covered">
|
||||
069 (check-vertex v2)
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
070 (every?
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
071 #(=ish (% v1) (% v2))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
072 [:x :y :z]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue