Enormous progress on routing, but not there yet.
All existing unit tests still pass, but new code is not instrumented yet.
This commit is contained in:
parent
777b8bc077
commit
99a6c6824a
24 changed files with 2050 additions and 1103 deletions
|
|
@ -16,18 +16,18 @@
|
|||
</tr></thead>
|
||||
<tr>
|
||||
<td><a href="walkmap/edge.clj.html">walkmap.edge</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:98.32167832167832%;
|
||||
float:left;"> 703 </div><div class="not-covered"
|
||||
style="width:1.6783216783216783%;
|
||||
style="width:98.37177747625509%;
|
||||
float:left;"> 725 </div><div class="not-covered"
|
||||
style="width:1.6282225237449117%;
|
||||
float:left;"> 12 </div></td>
|
||||
<td class="with-number">98.32 %</td>
|
||||
<td class="with-number">98.37 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:95.23809523809524%;
|
||||
float:left;"> 100 </div><div class="partial"
|
||||
style="width:4.761904761904762%;
|
||||
style="width:95.32710280373831%;
|
||||
float:left;"> 102 </div><div class="partial"
|
||||
style="width:4.672897196261682%;
|
||||
float:left;"> 5 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">177</td><td class="with-number">17</td><td class="with-number">105</td>
|
||||
<td class="with-number">177</td><td class="with-number">17</td><td class="with-number">107</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/id.clj.html">walkmap.id</a></td><td class="with-bar"><div class="covered"
|
||||
|
|
@ -42,18 +42,18 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/microworld.clj.html">walkmap.microworld</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:1.7647058823529411%;
|
||||
style="width:1.5957446808510638%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:98.23529411764706%;
|
||||
float:left;"> 167 </div></td>
|
||||
<td class="with-number">1.76 %</td>
|
||||
style="width:98.40425531914893%;
|
||||
float:left;"> 185 </div></td>
|
||||
<td class="with-number">1.60 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:7.5%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:92.5%;
|
||||
float:left;"> 37 </div></td>
|
||||
<td class="with-number">7.50 %</td>
|
||||
<td class="with-number">97</td><td class="with-number">11</td><td class="with-number">40</td>
|
||||
<td class="with-number">75</td><td class="with-number">6</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"
|
||||
|
|
@ -68,37 +68,35 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/path.clj.html">walkmap.path</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:93.98496240601504%;
|
||||
float:left;"> 250 </div><div class="not-covered"
|
||||
style="width:6.015037593984962%;
|
||||
style="width:93.9622641509434%;
|
||||
float:left;"> 249 </div><div class="not-covered"
|
||||
style="width:6.037735849056604%;
|
||||
float:left;"> 16 </div></td>
|
||||
<td class="with-number">93.98 %</td>
|
||||
<td class="with-number">93.96 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
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.6315789473684212%;
|
||||
float:left;"> 1 </div></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>
|
||||
style="width:88.88888888888889%;
|
||||
float:left;"> 32 </div><div class="partial"
|
||||
style="width:11.11111111111111%;
|
||||
float:left;"> 4 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">93</td><td class="with-number">9</td><td class="with-number">36</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/polygon.clj.html">walkmap.polygon</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:66.40471512770138%;
|
||||
float:left;"> 338 </div><div class="not-covered"
|
||||
style="width:33.59528487229863%;
|
||||
float:left;"> 171 </div></td>
|
||||
<td class="with-number">66.40 %</td>
|
||||
style="width:50.87976539589443%;
|
||||
float:left;"> 347 </div><div class="not-covered"
|
||||
style="width:49.12023460410557%;
|
||||
float:left;"> 335 </div></td>
|
||||
<td class="with-number">50.88 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:71.42857142857143%;
|
||||
float:left;"> 45 </div><div class="partial"
|
||||
style="width:9.523809523809524%;
|
||||
float:left;"> 6 </div><div class="not-covered"
|
||||
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>
|
||||
style="width:61.333333333333336%;
|
||||
float:left;"> 46 </div><div class="partial"
|
||||
style="width:9.333333333333334%;
|
||||
float:left;"> 7 </div><div class="not-covered"
|
||||
style="width:29.333333333333332%;
|
||||
float:left;"> 22 </div></td>
|
||||
<td class="with-number">70.67 %</td>
|
||||
<td class="with-number">155</td><td class="with-number">14</td><td class="with-number">75</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/read_svg.clj.html">walkmap.read-svg</a></td><td class="with-bar"><div class="covered"
|
||||
|
|
@ -113,18 +111,24 @@
|
|||
style="width:84.78260869565217%;
|
||||
float:left;"> 39 </div></td>
|
||||
<td class="with-number">15.22 %</td>
|
||||
<td class="with-number">97</td><td class="with-number">6</td><td class="with-number">46</td>
|
||||
<td class="with-number">100</td><td class="with-number">8</td><td class="with-number">46</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/routing.clj.html">walkmap.routing</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
style="width:5.678233438485805%;
|
||||
float:left;"> 18 </div><div class="not-covered"
|
||||
style="width:94.3217665615142%;
|
||||
float:left;"> 299 </div></td>
|
||||
<td class="with-number">5.68 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">18</td><td class="with-number">2</td><td class="with-number">1</td>
|
||||
style="width:17.56756756756757%;
|
||||
float:left;"> 13 </div><div class="partial"
|
||||
style="width:2.7027027027027026%;
|
||||
float:left;"> 2 </div><div class="not-covered"
|
||||
style="width:79.72972972972973%;
|
||||
float:left;"> 59 </div></td>
|
||||
<td class="with-number">20.27 %</td>
|
||||
<td class="with-number">201</td><td class="with-number">21</td><td class="with-number">74</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/stl.clj.html">walkmap.stl</a></td><td class="with-bar"><div class="covered"
|
||||
|
|
@ -145,20 +149,20 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/superstructure.clj.html">walkmap.superstructure</a></td><td class="with-bar"><div class="covered"
|
||||
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>
|
||||
style="width:44.61538461538461%;
|
||||
float:left;"> 261 </div><div class="not-covered"
|
||||
style="width:55.38461538461539%;
|
||||
float:left;"> 324 </div></td>
|
||||
<td class="with-number">44.62 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:56.88073394495413%;
|
||||
float:left;"> 62 </div><div class="partial"
|
||||
style="width:3.669724770642202%;
|
||||
style="width:48.507462686567166%;
|
||||
float:left;"> 65 </div><div class="partial"
|
||||
style="width:2.985074626865672%;
|
||||
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>
|
||||
style="width:48.507462686567166%;
|
||||
float:left;"> 65 </div></td>
|
||||
<td class="with-number">51.49 %</td>
|
||||
<td class="with-number">272</td><td class="with-number">22</td><td class="with-number">134</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/svg.clj.html">walkmap.svg</a></td><td class="with-bar"><div class="covered"
|
||||
|
|
@ -188,20 +192,20 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/utils.clj.html">walkmap.utils</a></td><td class="with-bar"><div class="covered"
|
||||
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>
|
||||
style="width:96.31043256997455%;
|
||||
float:left;"> 757 </div><div class="not-covered"
|
||||
style="width:3.6895674300254453%;
|
||||
float:left;"> 29 </div></td>
|
||||
<td class="with-number">96.31 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:85.71428571428571%;
|
||||
float:left;"> 36 </div><div class="partial"
|
||||
style="width:2.380952380952381%;
|
||||
style="width:80.43478260869566%;
|
||||
float:left;"> 37 </div><div class="partial"
|
||||
style="width:2.1739130434782608%;
|
||||
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>
|
||||
style="width:17.391304347826086%;
|
||||
float:left;"> 8 </div></td>
|
||||
<td class="with-number">82.61 %</td>
|
||||
<td class="with-number">119</td><td class="with-number">10</td><td class="with-number">46</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/vertex.clj.html">walkmap.vertex</a></td><td class="with-bar"><div class="covered"
|
||||
|
|
@ -222,9 +226,9 @@
|
|||
</tr>
|
||||
<tr><td>Totals:</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">69.99 %</td>
|
||||
<td class="with-number">62.51 %</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">65.94 %</td>
|
||||
<td class="with-number">59.55 %</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
006 [walkmap.utils :as u]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.vertex :refer [canonicalise ensure2d ensure3d vertex vertex= vertex?]]))
|
||||
007 [walkmap.vertex :refer [canonicalise check-vertex ensure2d ensure3d vertex vertex= vertex?]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
008
|
||||
|
|
@ -37,17 +37,17 @@
|
|||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [v1 v2]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
012 (if
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
012 {:kind :edge
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
013 (and (vertex? v1) (vertex? v2))
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
013 :walkmap.id/id (keyword (gensym "edge"))
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
014 {:kind :edge :walkmap.id/id (keyword (gensym "edge")) :start v1 :end v2}
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
014 :start (check-vertex v1)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
015 (throw (IllegalArgumentException. "Must be vertices."))))
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
015 :end (check-vertex v2)})
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
016
|
||||
|
|
@ -145,7 +145,7 @@
|
|||
<span class="covered" title="16 out of 16 forms covered">
|
||||
047 (+ (:z s) (/ (- (:z e) (:z s)) 2)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
<span class="blank" title="4 out of 4 forms covered">
|
||||
048
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
|
|
@ -154,7 +154,7 @@
|
|||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 "Return an vertex parallel to `e` starting from the coordinate origin. Two
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
051 edges which are parallel will have the same unit vector."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
|
|
|
|||
|
|
@ -26,274 +26,208 @@
|
|||
007 [clojure.string :as s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [mw-cli.core :refer [process]]
|
||||
008 [taoensso.timbre :as l]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [mw-engine.core :refer [run-world]]
|
||||
009 [walkmap.edge :as e]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 [mw-engine.heightmap :as h]
|
||||
010 [walkmap.polygon :as p :only [rectangle]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [mw-engine.drainage :as d]
|
||||
011 [walkmap.superstructure :refer [store]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 [mw-parser.bulk :as parser]
|
||||
012 [walkmap.tag :as t :only [tag]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 [taoensso.timbre :as l]
|
||||
013 [walkmap.vertex :as v :only [check-vertex vertex vertex?]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 [walkmap.edge :as e]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 [walkmap.polygon :as p :only [check-polygon polygon? rectangle]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 [walkmap.superstructure :refer [store]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 [walkmap.tag :as t :only [tag tags]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 [walkmap.utils :as u :only [check-kind-type check-kind-type-seq kind-type truncate]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 [walkmap.vertex :as v :only [vertex vertex?]]))
|
||||
014 [walkmap.utils :as u :only [truncate]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
020
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 ;; (def settlement-rules (parser/compile-file "resources/rules/settlement_rules.txt"))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
022
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ;; (def w0 (h/apply-heightmap "../the-great-game/resources/maps/heightmap.png"))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 ;; (def w1 (d/rain-world (d/flood-hollows w0)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 ;; (def w2 (drainage/flow-world-nr w1))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
026
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 ;; (def w3 (run-world w2 nil settlement-rules 100))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
028
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 ;; (with-open [w (clojure.java.io/writer "settlement_1.edn")]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 ;; (binding [*out* w]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 ;; (pr
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 ;; (run-world w0 nil settlement-rules 100))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
033
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 ;; (process
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 ;; (h/apply-heightmap "resources/small_hill.png")
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 ;; (parser/compile-file "resources/rules/settlement_rules.txt")
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 ;; 100
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 ;; "small_hill.edn"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 ;; "small_hill.html")
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
040
|
||||
015
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
041 (defn cell->polygon
|
||||
016 (defn cell->polygon
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 ([cell]
|
||||
017 "From this MicroWorld `cell`, construct a walkmap polygon (specifically,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 a rectangle. If `scale-vector` passed and is a vertex, scale all the vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 in the cell by that vector."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 ([cell]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
043 (cell->polygon cell (v/vertex 1 1 1)))
|
||||
021 (cell->polygon cell (v/vertex 1 1 1)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 ([cell scale-vector]
|
||||
022 ([cell scale-vector]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
045 (t/tag
|
||||
023 (t/tag
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
046 (assoc
|
||||
024 (assoc
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
047 (merge
|
||||
025 (merge
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
048 cell
|
||||
026 cell
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
049 (let [w (* (:x cell) (:x scale-vector))
|
||||
<span class="not-covered" title="0 out of 24 forms covered">
|
||||
027 (let [w (* (:x cell) (:x (v/check-vertex scale-vector)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
050 s (* (:y cell) (:y scale-vector))
|
||||
028 s (* (:y cell) (:y scale-vector))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
051 e (+ w (:x scale-vector))
|
||||
029 e (+ w (:x scale-vector))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
052 n (+ s (:y scale-vector))
|
||||
030 n (+ s (:y scale-vector))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
053 z (* (:altitude cell) (:z scale-vector))]
|
||||
031 z (* (:altitude cell) (:z scale-vector))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
054 (p/rectangle
|
||||
032 (p/rectangle
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
055 (v/vertex s w z)
|
||||
033 (v/vertex s w z)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
056 (v/vertex n e z))))
|
||||
034 (v/vertex n e z))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 :walkmap.id/id
|
||||
035 :walkmap.id/id
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
058 (keyword (gensym "mw-cell")))
|
||||
036 (keyword (gensym "mw-cell")))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
059 (:state cell))))
|
||||
037 (:state cell))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
060
|
||||
038
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
061 (defn load-microworld-edn
|
||||
039 (defn load-microworld-edn
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 "While it would be possible to call MicroWorld functions directly from
|
||||
040 "While it would be possible to call MicroWorld functions directly from
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
063 Walkmap, the fact is that running MicroWorld is so phenomenally
|
||||
041 Walkmap, the fact is that running MicroWorld is so phenomenally
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 compute-heavy that it's much more sensible to do it in batch mode. So the
|
||||
042 compute-heavy that it's much more sensible to do it in batch mode. So the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 better plan is to be able to pull the output from MicroWorld - as an EDN
|
||||
043 better plan is to be able to pull the output from MicroWorld - as an EDN
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 structure - into a walkmap superstructure."
|
||||
044 structure - into a walkmap superstructure."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 ([filename]
|
||||
045 ([filename]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
068 (load-microworld-edn filename :mw))
|
||||
046 (load-microworld-edn filename :mw))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 ([filename map-kind]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
070 (when-not
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
071 (keyword? map-kind)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
072 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
073 (u/truncate
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
074 (str "Must be a keyword: " (or map-kind "nil")) 80))))
|
||||
047 ([filename map-kind]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
075 (load-microworld-edn filename map-kind nil))
|
||||
048 (when-not
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
049 (keyword? map-kind)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
050 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
051 (u/truncate
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
052 (str "Must be a keyword: " (or map-kind "nil")) 80))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
053 (load-microworld-edn filename map-kind nil))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
076 ([filename mapkind superstucture]
|
||||
054 ([filename mapkind superstucture]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
077 (load-microworld-edn filename mapkind superstucture (v/vertex 1 1 1)))
|
||||
055 (load-microworld-edn filename mapkind superstucture (v/vertex 1 1 1)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 ([filename map-kind superstructure scale-vertex]
|
||||
056 ([filename map-kind superstructure scale-vertex]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
079 (let [mw (try
|
||||
057 (let [mw (try
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
080 (with-open [r (io/reader filename)]
|
||||
058 (with-open [r (io/reader filename)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
081 (edn/read (java.io.PushbackReader. r)))
|
||||
059 (edn/read (java.io.PushbackReader. r)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 (catch RuntimeException e
|
||||
060 (catch RuntimeException e
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 15 forms covered">
|
||||
083 (l/error "Error parsing edn file '%s': %s\n"
|
||||
061 (l/error "Error parsing edn file '%s': %s\n"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
084 filename (.getMessage e))))
|
||||
062 filename (.getMessage e))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
085 polys (reduce
|
||||
063 polys (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
086 concat
|
||||
064 concat
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
087 (map (fn [row] (map cell->polygon row)) mw))]
|
||||
065 (map (fn [row] (map cell->polygon row)) mw))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
088 (if (map? superstructure)
|
||||
066 (if (map? superstructure)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
089 (reduce
|
||||
067 (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
090 #(store %2 %1)
|
||||
068 #(store %2 %1)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
091 superstructure
|
||||
069 superstructure
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
092 polys)
|
||||
070 polys)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
093 polys))))
|
||||
071 polys))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
094
|
||||
072
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
095
|
||||
073
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
096
|
||||
074
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
097
|
||||
075
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
009 [walkmap.utils :refer [check-kind-type check-kind-type-seq kind-type]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 [walkmap.vertex :refer [vertex?]]))
|
||||
010 [walkmap.vertex :refer [check-vertices vertex?]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
011
|
||||
|
|
@ -88,203 +88,200 @@
|
|||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 [& vertices]
|
||||
</span><br/>
|
||||
<span class="covered" title="26 out of 26 forms covered">
|
||||
029 (check-kind-type-seq vertices vertex? :vertex)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
030 (if
|
||||
029 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
031 (> (count vertices) 1)
|
||||
<span class="covered" title="30 out of 30 forms covered">
|
||||
030 (> (count (check-vertices vertices)) 1)
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
032 {:vertices vertices :walkmap.id/id (keyword (gensym "path")) :kind :path}
|
||||
031 {:vertices vertices :walkmap.id/id (keyword (gensym "path")) :kind :path}
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
033 (throw (IllegalArgumentException. "Path must have more than one vertex."))))
|
||||
032 (throw (IllegalArgumentException. "Path must have more than one vertex."))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
034
|
||||
033
|
||||
</span><br/>
|
||||
<span class="covered" title="22 out of 22 forms covered">
|
||||
035 (defmacro check-path
|
||||
034 (defmacro check-path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 "If `o` is not a path, throw an `IllegalArgumentException` with an
|
||||
035 "If `o` is not a path, throw an `IllegalArgumentException` with an
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
036 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 from the calling function."
|
||||
037 from the calling function."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 [o]
|
||||
038 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
040 `(check-kind-type ~o path? :path))
|
||||
039 `(check-kind-type ~o path? :path))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
041
|
||||
040
|
||||
</span><br/>
|
||||
<span class="covered" title="21 out of 21 forms covered">
|
||||
042 (defmacro check-paths
|
||||
041 (defmacro check-paths
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 "If `o` is not a sequence of paths, throw an `IllegalArgumentException` with an
|
||||
042 "If `o` is not a sequence of paths, throw an `IllegalArgumentException` with an
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
043 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 from the calling function."
|
||||
044 from the calling function."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 [o]
|
||||
045 [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 2 forms covered">
|
||||
048
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
049 (defn polygon->path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 "If `o` is a polygon, return an equivalent path. What's different about
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
051 a path is that in polygons there is an implicit edge between the first
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 vertex and the last. In paths, there isn't, so we need to add that
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 edge explicitly.
|
||||
046 `(check-kind-type-seq ~o path? :path))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
054
|
||||
047
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 3 forms covered">
|
||||
048 (defn polygon->path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 If `o` is not a polygon, will throw an exception."
|
||||
049 "If `o` is a polygon, return an equivalent path. What's different about
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 [o]
|
||||
050 a path is that in polygons there is an implicit edge between the first
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 ;; this is breaking, but I have NO IDEA why!
|
||||
051 vertex and the last. In paths, there isn't, so we need to add that
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 ;; (check-polygon o polygon? :polygon)
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
059 (assoc (dissoc o :vertices)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 :kind :path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 ;; `concat` rather than `conj` because order matters.
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
062 :vertices (concat (:vertices o) (list (first (:vertices o))))))
|
||||
052 edge explicitly.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
063
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
064 (defn path->edges
|
||||
053
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 "if `o` is a path, a polygon, or a sequence of vertices, return a sequence of
|
||||
054 If `o` is not a polygon, will throw an exception."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 edges representing that path, polygon or sequence.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
067
|
||||
055 [o]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
068 Throws `IllegalArgumentException` if `o` is not a path, a polygon, or
|
||||
056 ;; this is breaking, but I have NO IDEA why!
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 sequence of vertices."
|
||||
</span><br/>
|
||||
<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="14 out of 14 forms covered">
|
||||
072 (seq? o) (when
|
||||
</span><br/>
|
||||
<span class="partial" title="4 out of 5 forms covered">
|
||||
073 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
074 (vertex? (first o))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
075 (vertex? (first (rest o))))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
076 (cons
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
077 ;; TODO: think about: when constructing an edge from a path, should the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 ;; constructed edge be tagged with the tags of the path?
|
||||
057 ;; (check-polygon o polygon? :polygon)
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
079 (e/edge (first o) (first (rest o)))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
080 (path->edges (rest o))))
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
081 (path? o) (path->edges (:vertices o))
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
082 (polygon? o) (path->edges (polygon->path o))
|
||||
058 (assoc (dissoc o :vertices)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 :else
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
084 (throw (IllegalArgumentException.
|
||||
059 :kind :path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
085 "Not a path or sequence of vertices!"))))
|
||||
060 ;; `concat` rather than `conj` because order matters.
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
061 :vertices (concat (:vertices o) (list (first (:vertices o))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
086
|
||||
062
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
087 (defn length
|
||||
063 (defn path->edges
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 "Return the length of this path, in metres. **Note that**
|
||||
064 "if `o` is a path, a polygon, or a sequence of vertices, return a sequence of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 1. This is not the same as the distance from the start to the end of the
|
||||
065 edges representing that path, polygon or sequence.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
066
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 path, which, except for absolutely straight paths, will be shorter;
|
||||
067 Throws `IllegalArgumentException` if `o` is not a path, a polygon, or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 2. It is not even quite the same as the length of the path *as rendered*,
|
||||
068 sequence of vertices."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 since paths will generally be rendered as spline curves."
|
||||
069 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
070 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
071 (seq? o) (when
|
||||
</span><br/>
|
||||
<span class="partial" title="13 out of 14 forms covered">
|
||||
072 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
073 (vertex? (first o))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
074 (vertex? (first (rest o))))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
075 (cons
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
093 [path]
|
||||
076 ;; TODO: think about: when constructing an edge from a path, should the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
077 ;; constructed edge be tagged with the tags of the path?
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
078 (e/edge (first o) (first (rest o)))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
079 (path->edges (rest o))))
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
080 (path? o) (path->edges (:vertices o))
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
081 (polygon? o) (path->edges (polygon->path o))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 :else
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
083 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
084 "Not a path or sequence of vertices!"))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
085
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
086 (defn length
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
087 "Return the length of this path, in metres. **Note that**
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 1. This is not the same as the distance from the start to the end of the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 path, which, except for absolutely straight paths, will be shorter;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 2. It is not even quite the same as the length of the path *as rendered*,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 since paths will generally be rendered as spline curves."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 [path]
|
||||
</span><br/>
|
||||
<span class="partial" title="14 out of 24 forms covered">
|
||||
094 (reduce + (map e/length (path->edges (check-path path)))))
|
||||
093 (reduce + (map e/length (path->edges (check-path path)))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -20,364 +20,454 @@
|
|||
005 [walkmap.tag :as t]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [walkmap.utils :refer [check-kind-type check-kind-type-seq kind-type]]
|
||||
006 [walkmap.utils :refer [check-kind-type
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.vertex :refer [check-vertex check-vertices vertex vertex?]]))
|
||||
007 check-kind-type-seq
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 kind-type
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 not-yet-implemented]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 [walkmap.vertex :refer [check-vertex check-vertices vertex vertex?]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
008
|
||||
011
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
009 (defn polygon?
|
||||
012 (defn polygon?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 "True if `o` satisfies the conditions for a polygon. A polygon shall be a
|
||||
013 "True if `o` satisfies the conditions for a polygon. A polygon shall be a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 map which has a value for the key `:vertices`, where that value is a sequence
|
||||
014 map which has a value for the key `:vertices`, where that value is a sequence
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 of vertices."
|
||||
015 of vertices."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 [o]
|
||||
016 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
014 (let
|
||||
017 (let
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
015 [v (:vertices o)]
|
||||
018 [v (:vertices o)]
|
||||
</span><br/>
|
||||
<span class="partial" title="18 out of 22 forms covered">
|
||||
016 (and
|
||||
019 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
017 (coll? v)
|
||||
020 (coll? v)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
018 (> (count v) 2)
|
||||
021 (> (count v) 2)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
019 (every? vertex? v)
|
||||
022 (every? vertex? v)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
020 (:walkmap.id/id o)
|
||||
023 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
021 (or (nil? (:kind o)) (= (:kind o) :polygon)))))
|
||||
024 (or (nil? (:kind o)) (= (:kind o) :polygon)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
022
|
||||
025
|
||||
</span><br/>
|
||||
<span class="covered" title="22 out of 22 forms covered">
|
||||
023 (defmacro check-polygon
|
||||
026 (defmacro check-polygon
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 "If `o` is not a polygon, throw an `IllegalArgumentException` with an
|
||||
027 "If `o` is not a polygon, throw an `IllegalArgumentException` with an
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
028 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 from the calling function."
|
||||
029 from the calling function."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 [o]
|
||||
030 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
028 `(check-kind-type ~o polygon? :polygon))
|
||||
031 `(check-kind-type ~o polygon? :polygon))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
029
|
||||
032
|
||||
</span><br/>
|
||||
<span class="covered" title="21 out of 21 forms covered">
|
||||
030 (defmacro check-polygons
|
||||
033 (defmacro check-polygons
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 "If `o` is not a sequence of polygons, throw an `IllegalArgumentException` with an
|
||||
034 "If `o` is not a sequence of polygons, throw an `IllegalArgumentException` with an
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
035 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 from the calling function."
|
||||
036 from the calling function."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 [o]
|
||||
037 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
035 `(check-kind-type-seq ~o polygon? :polygon))
|
||||
038 `(check-kind-type-seq ~o polygon? :polygon))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
036
|
||||
039
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
037 (defn triangle?
|
||||
040 (defn triangle?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 "True if `o` satisfies the conditions for a triangle. A triangle shall be a
|
||||
041 "True if `o` satisfies the conditions for a triangle. A triangle shall be a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 polygon with exactly three vertices."
|
||||
042 polygon with exactly three vertices."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 [o]
|
||||
043 [o]
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
041 (and
|
||||
044 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
042 (coll? o)
|
||||
045 (coll? o)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
043 (= (count (:vertices o)) 3)))
|
||||
046 (= (count (:vertices o)) 3)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
044
|
||||
047
|
||||
</span><br/>
|
||||
<span class="covered" title="23 out of 23 forms covered">
|
||||
045 (defmacro check-triangle
|
||||
<span class="partial" title="25 out of 33 forms covered">
|
||||
048 (defmacro check-triangle
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 "If `o` is not a triangle, throw an `IllegalArgumentException` with an
|
||||
049 "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
|
||||
050 appropriate message; otherwise, returns `o`. Macro, so exception is thrown
|
||||
</span><br/>
|
||||
<span class="partial" title="2 out of 10 forms covered">
|
||||
048 from the calling function."
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
051 from the calling function."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
049 [o]
|
||||
052 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
050 `(check-kind-type ~o triangle? :triangle))
|
||||
053 `(check-kind-type ~o triangle? :triangle))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 2 forms covered">
|
||||
051
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
054
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
052 (defn polygon
|
||||
055 (defn polygon
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 "Return a polygon constructed from these `vertices`."
|
||||
056 "Return a polygon constructed from these `vertices`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 [& vertices]
|
||||
057 [& vertices]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
055 (if
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
058 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
056 (> (count vertices) 2)
|
||||
059 (> (count vertices) 2)
|
||||
</span><br/>
|
||||
<span class="covered" title="30 out of 30 forms covered">
|
||||
057 {:vertices (check-vertices vertices)
|
||||
060 {:vertices (check-vertices vertices)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
058 :walkmap.id/id (keyword (gensym "poly"))
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
061 :walkmap.id/id (keyword (gensym "poly"))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 :kind :polygon}
|
||||
062 :kind :polygon}
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
060 (throw (IllegalArgumentException.
|
||||
063 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 "A polygon must have at least 3 vertices."))))
|
||||
064 "A polygon must have at least 3 vertices."))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
062
|
||||
065
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
063 (defn rectangle
|
||||
066 (defn rectangle
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 "Return a rectangle, with edges aligned east-west and north-south, whose
|
||||
067 "Return a rectangle, with edges aligned east-west and north-south, whose
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 south-west corner is the vertex `vsw` and whose north-east corner is the
|
||||
068 south-west corner is the vertex `vsw` and whose north-east corner is the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 vertex `vne`."
|
||||
069 vertex `vne`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 [vsw vne]
|
||||
070 [vsw vne]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
068 ;; we can actually create any rectangle in the xy plane based on two opposite
|
||||
071 ;; we can actually create any rectangle in the xy plane based on two opposite
|
||||
</span><br/>
|
||||
<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 class="covered" title="9 out of 9 forms covered">
|
||||
072 ;; corners, but the maths are a bit to advanced for me today. TODO: do it!
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 21 forms covered">
|
||||
070 (let [vnw (vertex (:x (check-vertex vsw))
|
||||
073 (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="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">
|
||||
073 vse (vertex (:x vne)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
074 (:y vsw)
|
||||
074 (:y (check-vertex vne))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 20 forms covered">
|
||||
075 (/ (reduce + (map #(or (:z %) 0) [vsw vne])) 2))]
|
||||
075 (/ (reduce + (map #(or (:z %) 0) [vsw vne])) 2))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
076 vse (vertex (:x vne)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
076 (t/tag
|
||||
077 (:y vsw)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
077 (assoc
|
||||
<span class="not-covered" title="0 out of 20 forms covered">
|
||||
078 (/ (reduce + (map #(or (:z %) 0) [vsw vne])) 2))
|
||||
</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">
|
||||
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))
|
||||
079 height-order (sort-by :z [vsw vne])]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
082 (:z vse)))
|
||||
080 (t/tag
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
081 (assoc
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
082 (polygon vsw vnw vne vse)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 :rectangle)))
|
||||
083 :gradient
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
084
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
084 (e/unit-vector (e/edge (first height-order) (last height-order)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
085 ;; (rectangle (vertex 1 2 3) (vertex 7 9 4))
|
||||
085 :centre
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 18 forms covered">
|
||||
086 (vertex (+ (:x vsw) (/ (- (:x vne) (:x vsw)) 2))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 16 forms covered">
|
||||
087 (+ (:x vsw) (/ (- (:y vne) (:y vsw)) 2))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
088 (:z vse)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 :rectangle)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
086
|
||||
090
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 ;; (rectangle (vertex 1 2 3) (vertex 7 9 4))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
092
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
087 (defn gradient
|
||||
093 (defn gradient
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 "Return a polygon like `triangle` but with a key `:gradient` whose value is a
|
||||
094 "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">
|
||||
089 unit vector representing the gradient across `triangle`."
|
||||
095 unit vector representing the gradient across `triangle`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 [triangle]
|
||||
096 [triangle]
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
091 (let [order (sort #(max (:z %1) (:z %2))
|
||||
097 (let [order (sort #(max (:z %1) (:z %2))
|
||||
</span><br/>
|
||||
<span class="partial" title="8 out of 18 forms covered">
|
||||
092 (:vertices (check-triangle triangle)))
|
||||
098 (:vertices (check-triangle triangle)))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
093 highest (first order)
|
||||
099 highest (first order)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
094 lowest (last order)]
|
||||
100 lowest (last order)]
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
095 (assoc triangle :gradient (e/unit-vector (e/edge lowest highest)))))
|
||||
101 (assoc triangle :gradient (e/unit-vector (e/edge lowest highest)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
096
|
||||
102
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
097 (defn triangle-centre
|
||||
103 (defn triangle-centre
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
098 "Return a canonicalised `facet` (i.e. a triangular polygon) with an added
|
||||
104 "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">
|
||||
099 key `:centre` whose value represents the centre of this facet in 3
|
||||
105 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">
|
||||
100 dimensions. This only works for triangles, so is here not in
|
||||
106 dimensions. This only works for triangles, so is here not in
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
101 `walkmap.polygon`. It is an error (although no exception is currently
|
||||
107 `walkmap.polygon`. It is an error (although no exception is currently
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
102 thrown) if the object past is not a triangular polygon."
|
||||
108 thrown) if the object past is not a triangular polygon."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
103 [facet]
|
||||
109 [facet]
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 19 forms covered">
|
||||
104 (let [vs (:vertices (check-triangle facet))
|
||||
110 (let [vs (:vertices (check-triangle facet))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
105 v1 (first vs)
|
||||
111 v1 (first vs)
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
106 opposite (e/edge (nth vs 1) (nth vs 2))
|
||||
112 opposite (e/edge (nth vs 1) (nth vs 2))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
107 oc (e/centre opposite)]
|
||||
113 oc (e/centre opposite)]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
108 (assoc
|
||||
114 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
109 facet
|
||||
115 facet
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
110 :centre
|
||||
116 :centre
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
111 (vertex
|
||||
117 (vertex
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
112 (+ (:x v1) (* (- (:x oc) (:x v1)) 2/3))
|
||||
118 (+ (:x v1) (* (- (:x oc) (:x v1)) 2/3))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
113 (+ (:y v1) (* (- (:y oc) (:y v1)) 2/3))
|
||||
119 (+ (:y v1) (* (- (:y oc) (:y v1)) 2/3))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
114 (+ (:z v1) (* (- (:z oc) (:z v1)) 2/3))))))
|
||||
120 (+ (:z v1) (* (- (:z oc) (:z v1)) 2/3))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
115
|
||||
121
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
116 (defn centre
|
||||
122 (defn centre
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
117 [poly]
|
||||
123 [poly]
|
||||
</span><br/>
|
||||
<span class="covered" title="22 out of 22 forms covered">
|
||||
118 (case (count (:vertices (check-polygon poly)))
|
||||
124 (case (count (:vertices (check-polygon poly)))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
119 3 (triangle-centre poly)
|
||||
125 3 (triangle-centre poly)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
120 ;; else
|
||||
126 ;; else
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
121 (throw
|
||||
127 (throw
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
122 (UnsupportedOperationException.
|
||||
128 (UnsupportedOperationException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
123 "The general case of centre for polygons is not yet implemented."))))
|
||||
129 "The general case of centre for polygons is not yet implemented."))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
124
|
||||
130
|
||||
</span><br/>
|
||||
<span class="partial" title="4 out of 16 forms covered">
|
||||
131 (defmacro on2dtriangle?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
132 "Is the projection of this `vertex` on the x, y plane within the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
133 projection of this triangle on that plane?"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
134 [vertex poly]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
135 `(not-yet-implemented "on2d? for triangles."))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
125
|
||||
136
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
137 (defn on2drectangle?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
138 "Is the projection of this `vertex` on the x, y plane within the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
139 projection of this rectangle on that plane?"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
140 [vertex rectangle]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
141 (let [xo (sort-by :x (:vertices rectangle))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
142 yo (sort-by :x (:vertices rectangle))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
143 (and
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 15 forms covered">
|
||||
144 (< (:x (first xo)) (:x vertex) (:x (last xo)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 14 forms covered">
|
||||
145 (< (:y (first yo)) (:y vertex) (:y (last yo))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
146
|
||||
</span><br/>
|
||||
<span class="partial" title="4 out of 86 forms covered">
|
||||
147 (defmacro on2d?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
148 "Is the projection of this `vertex` on the x, y plane within the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
149 projection of this polygon `poly` on that plane?"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
150 [vertex poly]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
151 `(cond
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
152 (rectangle? ~poly) (on2drectangle? ~vertex ~poly)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
153 (triangle? ~poly) (on2dtriangle? ~vertex ~poly)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
154 :else
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
155 (not-yet-implemented "general case of on2d? for polygons.")))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -295,5 +295,14 @@
|
|||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
097 (remove nil? (map path-elt->path paths)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
098
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
099 ;; (read-svg "resources/iom/manual_roads.svg")
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
100
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -11,52 +11,601 @@
|
|||
002 "Finding optimal routes to traverse a map."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [walkmap.path :as p]
|
||||
003 (:require [clojure.math.numeric-tower :as m :only [expt]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 [walkmap.polygon :as q]
|
||||
004 [clojure.set :refer [intersection]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [walkmap.stl :as s]
|
||||
005 [walkmap.edge :as e]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [walkmap.utils :as u]
|
||||
006 [walkmap.path :as p]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.vertex :as v]))
|
||||
007 [walkmap.polygon :as q]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [walkmap.superstructure :as s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [walkmap.tag :as t]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 [walkmap.utils :as u]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [walkmap.vertex :as v]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
008
|
||||
012
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 ;; Breadth first search is a good algorithm for terrain in which all steps have
|
||||
013 ;; Breadth first search is a good algorithm for terrain in which all steps have
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 ;; equal, but in our world (like the real world), they don't.
|
||||
014 ;; equal, but in our world (like the real world), they don't.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
011
|
||||
015
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 ;; Reading list:
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 ;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 ;; https://en.wikipedia.org/wiki/A*_search_algorithm
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 ;; https://www.redblobgames.com/pathfinding/a-star/introduction.html
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 ;; https://faculty.nps.edu/ncrowe/opmpaper2.htm
|
||||
016 ;; Reading list:
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 ;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 ;; See https://simon-brooke.github.io/the-great-game/codox/Pathmaking.html
|
||||
018 ;; https://en.wikipedia.org/wiki/A*_search_algorithm
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 ;; https://www.redblobgames.com/pathfinding/a-star/introduction.html
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 ;; https://faculty.nps.edu/ncrowe/opmpaper2.htm
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 ;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 ;; See https://simon-brooke.github.io/the-great-game/codox/Pathmaking.html
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
023
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
024 (def ^:dynamic *gradient-exponent*
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 "The exponent to be applied to `(inc (:z (unit-vector from to)))`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 of a path segment to calculate the gradient-related part of the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 cost of traversal. Dynamic, because we will want to tune this."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 2)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
029
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
030 (def ^:dynamic *traversals-exponent*
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 "The (expected to be negative) exponent to be applied to the number
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 of traversals of a path to compute the road bonus. Paths more travelled by
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 should have larger bonuses, but not dramatically so - so the increase in
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
034 bonus needs to scale significantly less than linearly with the number
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 of traversals. Dynamic, because we will want to tune this."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 -2)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
037
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
038 (defn traversable?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 "True if this object can be considered as part of the walkmap."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 [object]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
041 (and
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
042 (or
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
043 (and
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
044 (q/polygon? object)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
045 (:centre object))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
046 (p/path? object))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
047 (not (t/tagged? object :no-traversal))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 2 forms covered">
|
||||
048
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
049 (declare traversal-cost)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
050
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
051 (defn vertices-traversal-cost
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 [vertices s]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
053 (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
054 +
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
055 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
056 #(traversal-cost %1 %2 s)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 25 forms covered">
|
||||
057 (v/check-vertices vertices)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
058 (rest vertices))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
059
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
060 (defn path-traversal-cost
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 [path s]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 21 forms covered">
|
||||
062 (vertices-traversal-cost (:vertices (p/check-path path)) s))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
063
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 2 forms covered">
|
||||
064 (defn barriers-crossed
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 "Search superstructure `s` and return a sequence of barriers, if any, which
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 obstruct traversal from vertex `from` to vertex `to`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 [from to s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
068 ;; TODO: implement
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 '())
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
070
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 2 forms covered">
|
||||
071 (defn crossing-penalty
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
072 "TODO: should return the cost of crossing this `barrier`, initially mainly
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
073 a watercourse, on the axis from vertex `from` to vertex `to`. in the context
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
074 of superstructure `s`. If there's a bridge, ferry or other crossing mechanism
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
075 in `s` at the intersection of the vertex and the barrier, then the penalty
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
076 should be substantially less than it would otherwise be."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
077 [barrier from to s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 ;; TODO: implement
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 0)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
080
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
081 (defn gradient-cost
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 "Compute the per-unit-distance cost of traversing this `edge`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 [edge]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
084 (let [g (:z (e/unit-vector edge))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
085 (if (pos? g)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
086 (m/expt (inc g) *gradient-exponent*)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
087 1)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
088
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 ;; (gradient-cost (e/edge (v/vertex 0 0 0) (v/vertex 0 1 0)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 ;; (gradient-cost (e/edge (v/vertex 0 0 0) (v/vertex 0 2 0)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 ;; (gradient-cost (e/edge (v/vertex 0 0 0) (v/vertex 0 1 1)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 ;; (gradient-cost (e/edge (v/vertex 0 0 0) (v/vertex 0 2 1)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
093 ;; (gradient-cost (e/edge (v/vertex 0 0 0) (v/vertex 0 1 0.0001)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
094
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
095 (defn best-road
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
096 "Find the best traversable path which links the vertices `from` and `to`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
097 in this superstructure `s`, or nil if there are none."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
098 [from to s]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
099 (let [f (fn [v] (set (s/touching v p/path? s)))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
100 (first
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
101 (sort-by
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
102 ;;; I... chose the path more travelled by.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
103 #(or (:traversals %) 0)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
104 (filter traversable? (intersection (f from) (f to)))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
105
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
106 (defn road-bonus
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
107 "Calculate the road bonus of the edge represented by the vertices `from`,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
108 `to`, in the context of the superstructure `s`. Obviously there only is
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
109 such a bonus if there actually is an existing thoroughfare to use. Road
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
110 bonuses scale with some fractional exponent of the number of traversals
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
111 which have been made of the road segment in question."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
112 [from to s]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
113 (let [best (best-road from to s)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
114 (when (:traversals best)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
115 (m/expt (:traversals best) *traversals-exponent*))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
116
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
117 (defn traversal-cost
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
118 "Return the traversal cost of the edge represented by the vertices `from`,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
119 `to`, in the context of the superstructure `s`. It is legitimate to pass
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
120 `nil` as the `to` argument, in which case the result will be zero, in order
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
121 to allow `reduce` to be used to compute total path costs."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
122 [from to s]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
123 (if (nil? to)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
124 0
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
125 (let [edge (e/edge from to)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
126 distance (e/length edge)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
127 (/
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
128 (+
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
129 (* distance
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
130 (gradient-cost edge))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
131 (reduce +
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
132 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
133 #(crossing-penalty [% from to s])
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
134 (barriers-crossed from to s))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
135 (or (road-bonus from to s) 1)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
136
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
137 ;; (def p '({:x 1.40625, :y 0, :kind :vertex, :walkmap.id/id :vert_1-40625_0}
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
138 ;; {:x 1.40625, :y -10.703125, :kind :vertex, :walkmap.id/id :vert_1-40625_-10-703125}
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
139 ;; {:x 7.578125, :y -10.703125, :kind :vertex, :walkmap.id/id :vert_7-578125_-10-703125}
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
140 ;; {:x 7.578125, :y 0, :kind :vertex, :walkmap.id/id :vert_7-578125_0}
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
141 ;; {:x 2.171875, :y -0.765625, :kind :vertex, :walkmap.id/id :vert_2-171875_-0-765625}
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
142 ;; {:x 6.8125, :y -0.765625, :kind :vertex, :walkmap.id/id :vert_6-8125_-0-765625}))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
143 ;; (v/check-vertices p)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
144 ;; (def p' (p/path p))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
145
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
146 ;; (traversal-cost (first p) (nth p 1) {})
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
147 ;; (vertices-traversal-cost p {})
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
148 ;; (path-traversal-cost (p/path p))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
149
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
150 (defn extend-frontier
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
151 "Return a sequence like `frontier` with all of these `candidates` which are
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
152 not already members either of `frontier` or of `rejects` appended."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
153 ([frontier candidates]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
154 (extend-frontier frontier candidates nil))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
155 ([frontier candidates rejects]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
156 (if
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
157 (empty? frontier)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
158 candidates
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
159 (let [fs (set (concat frontier rejects))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
160 (concat frontier (remove fs candidates))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
161
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
162 ;; (extend-frontier '(1 2 3 4 5) '(7 3 6 2 9 8) '(6 8))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
163 ;; (extend-frontier '(1 2 3 4 5) '(7 3 6 2 9 8))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
164 ;; (extend-frontier '(1 2 3 4 5) '())
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
165 ;; (extend-frontier '(1 2 3 4 5) nil)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
166 ;; (extend-frontier nil '(1 2 3 4 5))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
167
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
168 (defn route
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
169 ;; NOT YET GOOD ENOUGH! Simple breadth first, and although it will
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
170 ;; reach the goal
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
171 ([from to s search-radius]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
172 (loop [f from
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
173 t to
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
174 frontier (extend-frontier
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
175 nil
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
176 (s/neighbour-ids
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
177 (s/nearest s from :centre search-radius)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
178 traversable?
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
179 s))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
180 visited nil
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
181 track nil]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
182 (let [here (s/retrieve (first frontier) s)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
183 (cond
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
184 (< (e/length (e/edge (:centre here)) to) search-radius)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
185 ;; close enough
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
186 (apply p/path (cons (:centre here) track))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
187 (empty? (rest frontier))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
188 ;; failed
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
189 nil
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
190 :else
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
191 (recur
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
192 f
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
193 t
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
194 (extend-frontier
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
195 (rest frontier)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
196 (s/neighbour-ids here traversable? s)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
197 visited)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
198 (cons here visited)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
199 ;; this is going to be wrong, and I need to think about how to fix.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
200 (cons here track)))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
201
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -343,5 +343,23 @@
|
|||
<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/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
114
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
115 (defn not-yet-implemented
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
116 [message]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
117 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
118 (UnsupportedOperationException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
119 (str "Not yet implemented: " message))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue