Cloverage/ Kibit now working again
There was an - unterminated function in svg.clj, now removed.
This commit is contained in:
parent
c7469051f4
commit
e07dc7098c
|
@ -14,17 +14,6 @@
|
|||
<td class="with-number">Lines %</td>
|
||||
<td class="with-number">Total</td><td class="with-number">Blank</td><td class="with-number">Instrumented</td>
|
||||
</tr></thead>
|
||||
<tr>
|
||||
<td><a href="walkmap/core.clj.html">walkmap.core</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>
|
||||
<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">9</td><td class="with-number">1</td><td class="with-number">1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/edge.clj.html">walkmap.edge</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:98.31697054698458%;
|
||||
|
@ -38,95 +27,127 @@
|
|||
style="width:4.8076923076923075%;
|
||||
float:left;"> 5 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">189</td><td class="with-number">18</td><td class="with-number">104</td>
|
||||
<td class="with-number">175</td><td class="with-number">17</td><td class="with-number">104</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/geometry.clj.html">walkmap.geometry</a></td><td class="with-bar"><div class="covered"
|
||||
<td><a href="walkmap/id.clj.html">walkmap.id</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 62 </div></td>
|
||||
float:left;"> 3 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 10 </div></td>
|
||||
float:left;"> 2 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">17</td><td class="with-number">1</td><td class="with-number">10</td>
|
||||
<td class="with-number">8</td><td class="with-number">2</td><td class="with-number">2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/ocean.clj.html">walkmap.ocean</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:17.857142857142858%;
|
||||
float:left;"> 5 </div><div class="not-covered"
|
||||
style="width:82.14285714285714%;
|
||||
float:left;"> 23 </div></td>
|
||||
<td class="with-number">17.86 %</td>
|
||||
style="width:64.28571428571429%;
|
||||
float:left;"> 18 </div><div class="not-covered"
|
||||
style="width:35.714285714285715%;
|
||||
float:left;"> 10 </div></td>
|
||||
<td class="with-number">64.29 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:50.0%;
|
||||
float:left;"> 4 </div><div class="not-covered"
|
||||
style="width:50.0%;
|
||||
float:left;"> 4 </div></td>
|
||||
<td class="with-number">50.00 %</td>
|
||||
style="width:87.5%;
|
||||
float:left;"> 7 </div><div class="not-covered"
|
||||
style="width:12.5%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">87.50 %</td>
|
||||
<td class="with-number">24</td><td class="with-number">4</td><td class="with-number">8</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/path.clj.html">walkmap.path</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:3.5294117647058822%;
|
||||
float:left;"> 6 </div><div class="not-covered"
|
||||
style="width:96.47058823529412%;
|
||||
float:left;"> 164 </div></td>
|
||||
<td class="with-number">3.53 %</td>
|
||||
style="width:12.041884816753926%;
|
||||
float:left;"> 23 </div><div class="not-covered"
|
||||
style="width:87.95811518324608%;
|
||||
float:left;"> 168 </div></td>
|
||||
<td class="with-number">12.04 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:15.789473684210526%;
|
||||
float:left;"> 6 </div><div class="not-covered"
|
||||
style="width:84.21052631578948%;
|
||||
float:left;"> 32 </div></td>
|
||||
<td class="with-number">15.79 %</td>
|
||||
<td class="with-number">78</td><td class="with-number">7</td><td class="with-number">38</td>
|
||||
style="width:17.94871794871795%;
|
||||
float:left;"> 7 </div><div class="partial"
|
||||
style="width:2.5641025641025643%;
|
||||
float:left;"> 1 </div><div class="not-covered"
|
||||
style="width:79.48717948717949%;
|
||||
float:left;"> 31 </div></td>
|
||||
<td class="with-number">20.51 %</td>
|
||||
<td class="with-number">84</td><td class="with-number">7</td><td class="with-number">39</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/polygon.clj.html">walkmap.polygon</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:90.56603773584905%;
|
||||
float:left;"> 48 </div><div class="not-covered"
|
||||
style="width:9.433962264150944%;
|
||||
float:left;"> 5 </div></td>
|
||||
<td class="with-number">90.57 %</td>
|
||||
style="width:72.42647058823529%;
|
||||
float:left;"> 197 </div><div class="not-covered"
|
||||
style="width:27.573529411764707%;
|
||||
float:left;"> 75 </div></td>
|
||||
<td class="with-number">72.43 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:90.0%;
|
||||
float:left;"> 9 </div><div class="partial"
|
||||
style="width:64.0%;
|
||||
float:left;"> 32 </div><div class="partial"
|
||||
style="width:10.0%;
|
||||
float:left;"> 5 </div><div class="not-covered"
|
||||
style="width:26.0%;
|
||||
float:left;"> 13 </div></td>
|
||||
<td class="with-number">74.00 %</td>
|
||||
<td class="with-number">87</td><td class="with-number">8</td><td class="with-number">50</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/read_svg.clj.html">walkmap.read-svg</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:2.857142857142857%;
|
||||
float:left;"> 7 </div><div class="not-covered"
|
||||
style="width:97.14285714285714%;
|
||||
float:left;"> 238 </div></td>
|
||||
<td class="with-number">2.86 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:15.217391304347826%;
|
||||
float:left;"> 7 </div><div class="not-covered"
|
||||
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>
|
||||
</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>
|
||||
<td class="with-number">19</td><td class="with-number">3</td><td class="with-number">10</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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/stl.clj.html">walkmap.stl</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:56.777996070726914%;
|
||||
float:left;"> 289 </div><div class="not-covered"
|
||||
style="width:43.222003929273086%;
|
||||
float:left;"> 220 </div></td>
|
||||
<td class="with-number">56.78 %</td>
|
||||
style="width:49.07216494845361%;
|
||||
float:left;"> 238 </div><div class="not-covered"
|
||||
style="width:50.92783505154639%;
|
||||
float:left;"> 247 </div></td>
|
||||
<td class="with-number">49.07 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:44.0%;
|
||||
float:left;"> 44 </div><div class="partial"
|
||||
style="width:10.0%;
|
||||
style="width:40.56603773584906%;
|
||||
float:left;"> 43 </div><div class="partial"
|
||||
style="width:9.433962264150944%;
|
||||
float:left;"> 10 </div><div class="not-covered"
|
||||
style="width:46.0%;
|
||||
float:left;"> 46 </div></td>
|
||||
<td class="with-number">54.00 %</td>
|
||||
<td class="with-number">191</td><td class="with-number">14</td><td class="with-number">100</td>
|
||||
style="width:50.0%;
|
||||
float:left;"> 53 </div></td>
|
||||
<td class="with-number">50.00 %</td>
|
||||
<td class="with-number">206</td><td class="with-number">16</td><td class="with-number">106</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/superstructure.clj.html">walkmap.superstructure</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:2.5974025974025974%;
|
||||
float:left;"> 4 </div><div class="not-covered"
|
||||
style="width:97.40259740259741%;
|
||||
float:left;"> 150 </div></td>
|
||||
<td class="with-number">2.60 %</td>
|
||||
style="width:71.76781002638522%;
|
||||
float:left;"> 272 </div><div class="not-covered"
|
||||
style="width:28.232189973614776%;
|
||||
float:left;"> 107 </div></td>
|
||||
<td class="with-number">71.77 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:14.814814814814815%;
|
||||
float:left;"> 4 </div><div class="not-covered"
|
||||
style="width:85.18518518518519%;
|
||||
float:left;"> 23 </div></td>
|
||||
<td class="with-number">14.81 %</td>
|
||||
<td class="with-number">85</td><td class="with-number">9</td><td class="with-number">27</td>
|
||||
style="width:71.26436781609195%;
|
||||
float:left;"> 62 </div><div class="partial"
|
||||
style="width:3.4482758620689653%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:25.28735632183908%;
|
||||
float:left;"> 22 </div></td>
|
||||
<td class="with-number">74.71 %</td>
|
||||
<td class="with-number">183</td><td class="with-number">18</td><td class="with-number">87</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/svg.clj.html">walkmap.svg</a></td><td class="with-bar"><div class="covered"
|
||||
|
@ -141,56 +162,58 @@
|
|||
style="width:87.87878787878788%;
|
||||
float:left;"> 58 </div></td>
|
||||
<td class="with-number">12.12 %</td>
|
||||
<td class="with-number">108</td><td class="with-number">7</td><td class="with-number">66</td>
|
||||
<td class="with-number">110</td><td class="with-number">7</td><td class="with-number">66</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/tag.clj.html">walkmap.tag</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 137 </div></td>
|
||||
float:left;"> 181 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 36 </div></td>
|
||||
float:left;"> 34 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">65</td><td class="with-number">7</td><td class="with-number">36</td>
|
||||
<td class="with-number">68</td><td class="with-number">8</td><td class="with-number">34</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/utils.clj.html">walkmap.utils</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:7.894736842105263%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:92.10526315789474%;
|
||||
float:left;"> 35 </div></td>
|
||||
<td class="with-number">7.89 %</td>
|
||||
style="width:76.66666666666667%;
|
||||
float:left;"> 92 </div><div class="not-covered"
|
||||
style="width:23.333333333333332%;
|
||||
float:left;"> 28 </div></td>
|
||||
<td class="with-number">76.67 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:30.0%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:70.0%;
|
||||
float:left;"> 7 </div></td>
|
||||
<td class="with-number">30.00 %</td>
|
||||
<td class="with-number">23</td><td class="with-number">3</td><td class="with-number">10</td>
|
||||
style="width:80.0%;
|
||||
float:left;"> 16 </div><div class="partial"
|
||||
style="width:5.0%;
|
||||
float:left;"> 1 </div><div class="not-covered"
|
||||
style="width:15.0%;
|
||||
float:left;"> 3 </div></td>
|
||||
<td class="with-number">85.00 %</td>
|
||||
<td class="with-number">43</td><td class="with-number">4</td><td class="with-number">20</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="walkmap/vertex.clj.html">walkmap.vertex</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:78.08641975308642%;
|
||||
float:left;"> 253 </div><div class="not-covered"
|
||||
style="width:21.91358024691358%;
|
||||
float:left;"> 71 </div></td>
|
||||
<td class="with-number">78.09 %</td>
|
||||
style="width:66.52078774617068%;
|
||||
float:left;"> 304 </div><div class="not-covered"
|
||||
style="width:33.479212253829324%;
|
||||
float:left;"> 153 </div></td>
|
||||
<td class="with-number">66.52 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:70.0%;
|
||||
float:left;"> 42 </div><div class="partial"
|
||||
style="width:10.0%;
|
||||
float:left;"> 6 </div><div class="not-covered"
|
||||
style="width:20.0%;
|
||||
float:left;"> 12 </div></td>
|
||||
<td class="with-number">80.00 %</td>
|
||||
<td class="with-number">114</td><td class="with-number">11</td><td class="with-number">60</td>
|
||||
style="width:59.75609756097561%;
|
||||
float:left;"> 49 </div><div class="partial"
|
||||
style="width:10.975609756097562%;
|
||||
float:left;"> 9 </div><div class="not-covered"
|
||||
style="width:29.26829268292683%;
|
||||
float:left;"> 24 </div></td>
|
||||
<td class="with-number">70.73 %</td>
|
||||
<td class="with-number">148</td><td class="with-number">13</td><td class="with-number">82</td>
|
||||
</tr>
|
||||
<tr><td>Totals:</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">61.24 %</td>
|
||||
<td class="with-number">60.81 %</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">61.28 %</td>
|
||||
<td class="with-number">62.17 %</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
|
|
@ -20,556 +20,514 @@
|
|||
005 (:require [clojure.math.numeric-tower :as m]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [walkmap.polygon :refer [polygon?]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.vertex :refer [ensure2d ensure3d vertex vertex= vertex?]]))
|
||||
006 [walkmap.vertex :refer [ensure2d ensure3d vertex vertex= vertex?]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
008
|
||||
007
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
009 (defn edge
|
||||
008 (defn edge
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 "Return an edge between vertices `v1` and `v2`."
|
||||
009 "Return an edge between vertices `v1` and `v2`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [v1 v2]
|
||||
010 [v1 v2]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
012 (if
|
||||
011 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
013 (and (vertex? v1) (vertex? v2))
|
||||
012 (and (vertex? v1) (vertex? v2))
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
014 {:kind :edge :id (keyword (gensym "edge")) :start v1 :end v2}
|
||||
013 {:kind :edge :walkmap.id/id (keyword (gensym "edge")) :start v1 :end v2}
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
015 (throw (IllegalArgumentException. "Must be vertices."))))
|
||||
014 (throw (IllegalArgumentException. "Must be vertices."))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
016
|
||||
015
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
017 (defn edge?
|
||||
016 (defn edge?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 "True if `o` satisfies the conditions for a edge. An edge shall be a map
|
||||
017 "True if `o` satisfies the conditions for a edge. An edge shall be a map
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 having the keys `:start` and `:end`, such that the values of each of those
|
||||
018 having the keys `:start` and `:end`, such that the values of each of those
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 keys shall be a vertex."
|
||||
019 keys shall be a vertex."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 [o]
|
||||
020 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
022 (and
|
||||
021 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
023 (map? o)
|
||||
022 (map? o)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
024 (vertex? (:start o))
|
||||
023 (vertex? (:start o))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
025 (vertex? (:end o))))
|
||||
024 (vertex? (:end o))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
026
|
||||
025
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
027 (defn length
|
||||
026 (defn length
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 "Return the length of the edge `e`."
|
||||
027 "Return the length of the edge `e`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 [e]
|
||||
028 [e]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
030 (let [start (ensure3d (:start e))
|
||||
029 (let [start (ensure3d (:start e))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
031 end (ensure3d (:end e))]
|
||||
030 end (ensure3d (:end e))]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
032 (m/sqrt
|
||||
031 (m/sqrt
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
033 (reduce
|
||||
032 (reduce
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
034 +
|
||||
033 +
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
035 (map
|
||||
034 (map
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
036 #(m/expt (- (% end) (% start)) 2)
|
||||
035 #(m/expt (- (% end) (% start)) 2)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
037 [:x :y :z])))))
|
||||
036 [:x :y :z])))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
038
|
||||
037
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
039 (defn centre
|
||||
038 (defn centre
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 "Return the vertex that represents the centre of this `edge`."
|
||||
039 "Return the vertex that represents the centre of this `edge`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 [edge]
|
||||
040 [edge]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
042 (let [s (ensure3d (:start edge))
|
||||
041 (let [s (ensure3d (:start edge))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
043 e (ensure3d (:end edge))]
|
||||
042 e (ensure3d (:end edge))]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
044 (vertex
|
||||
043 (vertex
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
045 (+ (:x s) (/ (- (:x e) (:x s)) 2))
|
||||
044 (+ (:x s) (/ (- (:x e) (:x s)) 2))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
046 (+ (:y s) (/ (- (:y e) (:y s)) 2))
|
||||
045 (+ (:y s) (/ (- (:y e) (:y s)) 2))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
047 (+ (:z s) (/ (- (:z e) (:z s)) 2)))))
|
||||
046 (+ (:z s) (/ (- (:z e) (:z s)) 2)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
048
|
||||
047
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
049 (defn unit-vector
|
||||
048 (defn unit-vector
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 "Return an vertex parallel to `e` starting from the coordinate origin. Two
|
||||
049 "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">
|
||||
051 edges which are parallel will have the same unit vector."
|
||||
050 edges which are parallel will have the same unit vector."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 [e]
|
||||
051 [e]
|
||||
</span><br/>
|
||||
<span class="covered" title="14 out of 14 forms covered">
|
||||
053 (let [e' {:start (ensure3d (:start e)) :end (ensure3d (:end e))}
|
||||
052 (let [e' {:start (ensure3d (:start e)) :end (ensure3d (:end e))}
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
054 l (length e')]
|
||||
053 l (length e')]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
055 (reduce
|
||||
054 (reduce
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
056 merge
|
||||
055 merge
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
057 {}
|
||||
056 {}
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
058 (map
|
||||
057 (map
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
059 (fn [k]
|
||||
058 (fn [k]
|
||||
</span><br/>
|
||||
<span class="covered" title="17 out of 17 forms covered">
|
||||
060 {k (/ (- (k (:end e')) (k (:start e'))) l)})
|
||||
059 {k (/ (- (k (:end e')) (k (:start e'))) l)})
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
061 [:x :y :z]))))
|
||||
060 [:x :y :z]))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
062
|
||||
061
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
063 (defn parallel?
|
||||
062 (defn parallel?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 "True if all `edges` passed are parallel with one another."
|
||||
063 "True if all `edges` passed are parallel with one another."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 [& edges]
|
||||
064 [& edges]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
066 (let [uvs (map unit-vector edges)]
|
||||
065 (let [uvs (map unit-vector edges)]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
067 (every?
|
||||
066 (every?
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
068 #(vertex= % (first uvs))
|
||||
067 #(vertex= % (first uvs))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
069 (rest uvs))))
|
||||
068 (rest uvs))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
070
|
||||
069
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
071 (defn collinear?
|
||||
070 (defn collinear?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 "True if edges `e1` and `e2` are collinear with one another."
|
||||
071 "True if edges `e1` and `e2` are collinear with one another."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
073 [e1 e2]
|
||||
072 [e1 e2]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
074 (parallel?
|
||||
073 (parallel?
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
075 e1
|
||||
074 e1
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
076 e2
|
||||
075 e2
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
077 (if (vertex= (:start e1) (:start e2))
|
||||
076 (if (vertex= (:start e1) (:start e2))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
078 {:start (:start e1) :end (:end e2)}
|
||||
077 {:start (:start e1) :end (:end e2)}
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
079 {:start (:start e1) :end (:start e2)})))
|
||||
078 {:start (:start e1) :end (:start e2)})))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
080
|
||||
079
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
081 (defn collinear2d?
|
||||
080 (defn collinear2d?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 "True if the projections of edges `e1`, `e2` onto the x, y plane are
|
||||
081 "True if the projections of edges `e1`, `e2` onto the x, y plane are
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 collinear."
|
||||
082 collinear."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
084 [e1 e2]
|
||||
083 [e1 e2]
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
085 (collinear? {:start (ensure2d (:start e1)) :end (ensure2d (:end e1))}
|
||||
084 (collinear? {:start (ensure2d (:start e1)) :end (ensure2d (:end e1))}
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
086 {:start (ensure2d (:start e2)) :end (ensure2d (:end e2))}))
|
||||
085 {:start (ensure2d (:start e2)) :end (ensure2d (:end e2))}))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
087
|
||||
086
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
088 (defn minimaxd
|
||||
087 (defn minimaxd
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 "Apply function `f` to `coord` of the vertices at start and end of `edge`
|
||||
088 "Apply function `f` to `coord` of the vertices at start and end of `edge`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 and return the result. Intended use case is `f` = `min` or `max`, `coord`
|
||||
089 and return the result. Intended use case is `f` = `min` or `max`, `coord`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 is `:x`, `:y` or `:z`. No checks are made for sane arguments."
|
||||
090 is `:x`, `:y` or `:z`. No checks are made for sane arguments."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 [edge coord f]
|
||||
091 [edge coord f]
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
093 (apply f (list (coord (:start edge)) (coord (:end edge)))))
|
||||
092 (apply f (list (coord (:start edge)) (coord (:end edge)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
094
|
||||
093
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
095 (defn on?
|
||||
094 (defn on?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
096 "True if the vertex `v` is on the edge `e`."
|
||||
095 "True if the vertex `v` is on the edge `e`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
097 [e v]
|
||||
096 [e v]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
098 (let [p (ensure3d (:start e))
|
||||
097 (let [p (ensure3d (:start e))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
099 q (ensure3d v)
|
||||
098 q (ensure3d v)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
100 r (ensure3d (:end e))]
|
||||
099 r (ensure3d (:end e))]
|
||||
</span><br/>
|
||||
<span class="partial" title="20 out of 25 forms covered">
|
||||
101 (and
|
||||
100 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
102 (collinear? (edge p q) (edge q r))
|
||||
101 (collinear? (edge p q) (edge q r))
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
103 (<= (:x q) (max (:x p) (:x r)))
|
||||
102 (<= (:x q) (max (:x p) (:x r)))
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
104 (>= (:x q) (min (:x p) (:x r)))
|
||||
103 (>= (:x q) (min (:x p) (:x r)))
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
105 (<= (:y q) (max (:y p) (:y r)))
|
||||
104 (<= (:y q) (max (:y p) (:y r)))
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
106 (>= (:y q) (min (:y p) (:y r)))
|
||||
105 (>= (:y q) (min (:y p) (:y r)))
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
107 (<= (:z q) (max (:z p) (:z r)))
|
||||
106 (<= (:z q) (max (:z p) (:z r)))
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
108 (>= (:z q) (min (:z p) (:z r))))))
|
||||
107 (>= (:z q) (min (:z p) (:z r))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
109
|
||||
108
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
110 (defn on2d?
|
||||
109 (defn on2d?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
111 "True if vertex `v` is on edge `e` when projected onto the x, y plane."
|
||||
110 "True if vertex `v` is on edge `e` when projected onto the x, y plane."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
112 [e v]
|
||||
111 [e v]
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
113 (on? (edge (ensure2d (:start e)) (ensure2d (:end e))) v))
|
||||
112 (on? (edge (ensure2d (:start e)) (ensure2d (:end e))) v))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
114
|
||||
113
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
115 (defn overlaps2d?
|
||||
114 (defn overlaps2d?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
116 "True if the recangle in the x,y plane bisected by edge `e1` overlaps that
|
||||
115 "True if the recangle in the x,y plane bisected by edge `e1` overlaps that
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
117 bisected by edge `e2`. It is an error if either `e1` or `e2` is not an edge."
|
||||
116 bisected by edge `e2`. It is an error if either `e1` or `e2` is not an edge."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
118 [e1 e2]
|
||||
117 [e1 e2]
|
||||
</span><br/>
|
||||
<span class="partial" title="11 out of 12 forms covered">
|
||||
119 (when (and (edge? e1) (edge? e2))
|
||||
118 (when (and (edge? e1) (edge? e2))
|
||||
</span><br/>
|
||||
<span class="partial" title="11 out of 13 forms covered">
|
||||
120 (and
|
||||
119 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
121 (> (minimaxd e1 :x max) (minimaxd e2 :x min))
|
||||
120 (> (minimaxd e1 :x max) (minimaxd e2 :x min))
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
122 (< (minimaxd e1 :x min) (minimaxd e2 :x max))
|
||||
121 (< (minimaxd e1 :x min) (minimaxd e2 :x max))
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
123 (> (minimaxd e1 :y max) (minimaxd e2 :y min))
|
||||
122 (> (minimaxd e1 :y max) (minimaxd e2 :y min))
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
124 (< (minimaxd e1 :y min) (minimaxd e2 :y max)))))
|
||||
123 (< (minimaxd e1 :y min) (minimaxd e2 :y max)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
125
|
||||
124
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
125 (defn intersection2d
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
126 ;; Don't think I need this.
|
||||
126 "The probability of two lines intersecting in 3d space is low, and actually
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
127 ;; (defn orientation
|
||||
127 that is mostly not something we're interested in. We're interested in
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
128 ;; "Determine whether the ordered sequence of vertices `p`, `q` and `r` run
|
||||
128 intersection in the `x,y` plane. This function returns a vertex representing
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
129 ;; clockwise, collinear or anticlockwise in the x,y plane."
|
||||
129 a point vertically over the intersection of edges `e1`, `e2` in the `x,y`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
130 ;; [p q r]
|
||||
130 plane, whose `z` coordinate is
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
131
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
131 ;; (let [v (- (* (- (:y q) (:y p)) (- (:x r) (:x q)))
|
||||
132 * 0 if both edges are 2d (i.e. have missing or zero `z` coordinates);
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
132 ;; (* (- (:x q) (:x p)) (- (:y r) (:y q))))]
|
||||
133 * if one edge is 2d, then the point on the other edge over the intersection;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
133 ;; (cond
|
||||
134 * otherwise, the average of the z coordinates of the points on the two
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
134 ;; (zero? v) :collinear
|
||||
135 edges over the intersection.
|
||||
</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">
|
||||
135 ;; (pos? v) :clockwise
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
136 ;; :else
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
137 ;; :anticlockwise)))
|
||||
137 If no such intersection exists, `nil` is returned.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
138
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
139 (defn intersection2d
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
139 It is an error, and an exception will be thrown, if either `e1` or `e2` is
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
140 "The probability of two lines intersecting in 3d space is low, and actually
|
||||
140 not an edge."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
141 that is mostly not something we're interested in. We're interested in
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
142 intersection in the `x,y` plane. This function returns a vertex representing
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
143 a point vertically over the intersection of edges `e1`, `e2` in the `x,y`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
144 plane, whose `z` coordinate is
|
||||
</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 * 0 if both edges are 2d (i.e. have missing or zero `z` coordinates);
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
147 * if one edge is 2d, then the point on the other edge over the intersection;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
148 * otherwise, the average of the z coordinates of the points on the two
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
149 edges over the intersection.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
150
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
151 If no such intersection exists, `nil` is returned.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
152
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
153 It is an error, and an exception will be thrown, if either `e1` or `e2` is
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
154 not an edge."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
155 [e1 e2]
|
||||
141 [e1 e2]
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
156 (if (and (edge? e1) (edge? e2))
|
||||
142 (if (and (edge? e1) (edge? e2))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
157 (when
|
||||
143 (when
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
158 (overlaps2d? e1 e2) ;; relatively cheap check
|
||||
144 (overlaps2d? e1 e2) ;; relatively cheap check
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
159 (if
|
||||
145 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
160 (collinear2d? e1 e2)
|
||||
146 (collinear2d? e1 e2)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
161 ;; any point within the overlap will do, but we'll pick the end of e1
|
||||
147 ;; any point within the overlap will do, but we'll pick the end of e1
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
162 ;; which is on e2
|
||||
148 ;; which is on e2
|
||||
</span><br/>
|
||||
<span class="partial" title="10 out of 13 forms covered">
|
||||
163 (if (on2d? e2 (:start e1)) (:start e1) (:end e1))
|
||||
149 (if (on2d? e2 (:start e1)) (:start e1) (:end e1))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
164 ;; blatantly stolen from
|
||||
150 ;; blatantly stolen from
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
165 ;; https://gist.github.com/cassiel/3e725b49670356a9b936
|
||||
151 ;; https://gist.github.com/cassiel/3e725b49670356a9b936
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
166 (let [x1 (:x (:start e1))
|
||||
152 (let [x1 (:x (:start e1))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
167 x2 (:x (:end e1))
|
||||
153 x2 (:x (:end e1))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
168 x3 (:x (:start e2))
|
||||
154 x3 (:x (:start e2))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
169 x4 (:x (:end e2))
|
||||
155 x4 (:x (:end e2))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
170 y1 (:y (:start e1))
|
||||
156 y1 (:y (:start e1))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
171 y2 (:y (:end e1))
|
||||
157 y2 (:y (:end e1))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
172 y3 (:y (:start e2))
|
||||
158 y3 (:y (:start e2))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
173 y4 (:y (:end e2))
|
||||
159 y4 (:y (:end e2))
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
174 denom (- (* (- x1 x2) (- y3 y4))
|
||||
160 denom (- (* (- x1 x2) (- y3 y4))
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
175 (* (- y1 y2) (- x3 x4)))
|
||||
161 (* (- y1 y2) (- x3 x4)))
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
176 x1y2-y1x2 (- (* x1 y2) (* y1 x2))
|
||||
162 x1y2-y1x2 (- (* x1 y2) (* y1 x2))
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
177 x3y4-y3x4 (- (* x3 y4) (* y3 x4))
|
||||
163 x3y4-y3x4 (- (* x3 y4) (* y3 x4))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
178 px-num (- (* x1y2-y1x2 (- x3 x4))
|
||||
164 px-num (- (* x1y2-y1x2 (- x3 x4))
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
179 (* (- x1 x2) x3y4-y3x4))
|
||||
165 (* (- x1 x2) x3y4-y3x4))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
180 py-num (- (* x1y2-y1x2 (- y3 y4))
|
||||
166 py-num (- (* x1y2-y1x2 (- y3 y4))
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
181 (* (- y1 y2) x3y4-y3x4))
|
||||
167 (* (- y1 y2) x3y4-y3x4))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
182 result (when-not (zero? denom)
|
||||
168 result (when-not (zero? denom)
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
183 (vertex (/ px-num denom) (/ py-num denom)))]
|
||||
169 (vertex (/ px-num denom) (/ py-num denom)))]
|
||||
</span><br/>
|
||||
<span class="partial" title="19 out of 20 forms covered">
|
||||
184 (when (and result (on2d? e1 result) (on2d? e2 result)) result))))
|
||||
170 (when (and result (on2d? e1 result) (on2d? e2 result)) result))))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
185 (throw (IllegalArgumentException.
|
||||
171 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
186 (str
|
||||
172 (str
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
187 "Both `e1` and `e2` must be edges."
|
||||
173 "Both `e1` and `e2` must be edges."
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
188 (map #(or (:kind %) (type %)) [e1 e2]))))))
|
||||
174 (map #(or (:kind %) (type %)) [e1 e2]))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
189
|
||||
175
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
32
docs/cloverage/walkmap/id.clj.html
Normal file
32
docs/cloverage/walkmap/id.clj.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/id.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns walkmap.id
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "The namespace within which the privileged keyword `:walkmap.id/id` is defined.")
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
003
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
004 (def ^:const id
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 "The magic id key walkmap uses, to distinguish it from all other uses of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 the unprotected keyword."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 ::id)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
008
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -49,13 +49,13 @@
|
|||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 [facet]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
016 (every?
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
017 #(= % *sea-level*)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
018 (map :z (:vertices facet))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
|
|
|
@ -17,226 +17,244 @@
|
|||
004 feature, where such features specifically include watercourses."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 (:require [walkmap.edge :as e]
|
||||
005 (:require [clojure.string :as s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [walkmap.polygon :refer [polygon?]]
|
||||
006 [walkmap.edge :as e]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.vertex :refer [vertex?]]))
|
||||
007 [walkmap.polygon :refer [polygon?]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [walkmap.utils :refer [kind-type]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [walkmap.vertex :refer [vertex?]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
008
|
||||
010
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
009 (defn path?
|
||||
011 (defn path?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 "True if `o` satisfies the conditions for a path. A path shall be a map
|
||||
012 "True if `o` satisfies the conditions for a path. A path shall be a map
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 having the key `:vertices`, whose value shall be a sequence of vertices as
|
||||
013 having the key `:vertices`, whose value shall be a sequence of vertices as
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 defined in `walkmap.vertex`."
|
||||
014 defined in `walkmap.vertex`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 [o]
|
||||
015 [o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
014 (let
|
||||
016 (let
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
015 [v (:vertices o)]
|
||||
017 [v (:vertices o)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 22 forms covered">
|
||||
016 (and
|
||||
018 (and
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
017 (seq? v)
|
||||
019 (seq? v)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
018 (> (count v) 2)
|
||||
020 (> (count v) 2)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
019 (every? vertex? v)
|
||||
021 (every? vertex? v)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
020 (:id o)
|
||||
022 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
021 (or (nil? (:kind o)) (= (:kind o) :path)))))
|
||||
023 (or (nil? (:kind o)) (= (:kind o) :path)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
022
|
||||
024
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
023 (defn path
|
||||
025 (defn path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 "Return a path constructed from these `vertices`."
|
||||
026 "Return a path constructed from these `vertices`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 [& vertices]
|
||||
027 [& vertices]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
026 (if
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
027 (every? vertex? vertices)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
028 {:vertices vertices :id (keyword (gensym "path")) :kind :path}
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
029 (throw (IllegalArgumentException. "Each item on path must be a vertex."))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
030
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
031 (defn polygon->path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 "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">
|
||||
033 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">
|
||||
034 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">
|
||||
035 edge explicitly.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
036
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 If `o` is not a polygon, will throw an exception."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 [o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
039 (if
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
040 (polygon? o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 21 forms covered">
|
||||
041 (assoc (dissoc o :vertices) :kind :path :vertices (concat (:vertices o) (list (first (:vertices o)))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
042 (throw (IllegalArgumentException. "Not a polygon!"))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
043
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
044 (defn path->edges
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 "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">
|
||||
046 edges representing that path, polygon or sequence.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
047
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
048 Throws `IllegalArgumentException` if `o` is not a path, a polygon, or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
049 sequence of vertices."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 [o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
051 (cond
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
052 (seq? o)
|
||||
<span class="partial" title="6 out of 7 forms covered">
|
||||
028 (when-not (every? vertex? vertices)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
053 (when
|
||||
029 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
054 (and
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
030 (str
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
055 (vertex? (first o))
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 "Each item on path must be a vertex: "
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
032 (s/join " " (map kind-type (remove vertex? vertices)))))))
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
033 {:vertices vertices :walkmap.id/id (keyword (gensym "path")) :kind :path})
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
034
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
035 (defn polygon->path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 "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">
|
||||
037 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">
|
||||
038 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">
|
||||
039 edge explicitly.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
040
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 If `o` is not a polygon, will throw an exception."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 [o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
056 (vertex? (first (rest o))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
057 (cons
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 ;; 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">
|
||||
059 ;; constructed edge be tagged with the tags of the path?
|
||||
043 (when-not (polygon? o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
060 (e/edge (first o) (rest o))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
061 (path->edges (rest o))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
062 (path? o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
063 (path->edges (:vertices o))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 :else
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
065 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 "Not a path or sequence of vertices!"))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
067
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
068 (defn length
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 "Return the length of this path, in metres. **Note that**
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
070 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">
|
||||
071 path, which, except for absolutely straight paths, will be shorter;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 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">
|
||||
073 since paths will generally be rendered as spline curves."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
074 [path]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
075 (if
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
076 (path? path)
|
||||
044 (throw (IllegalArgumentException. (str "Not a polygon: " (kind-type o)))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
077 (reduce + (map e/length (path->edges path)))
|
||||
045 (assoc (dissoc o :vertices)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 :kind :path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 ;; `concat` rather than `conj` because order matters.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
048 :vertices (concat (:vertices o) (list (first (:vertices o))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
049
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
050 (defn path->edges
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
051 "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">
|
||||
052 edges representing that path, polygon or sequence.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
053
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 Throws `IllegalArgumentException` if `o` is not a path, a polygon, or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 sequence of vertices."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 [o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
078 (throw (IllegalArgumentException. "Not a path!"))))
|
||||
057 (cond
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
058 (seq? o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
059 (when
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
060 (and
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
061 (vertex? (first o))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
062 (vertex? (first (rest o))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
063 (cons
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
064 ;; 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">
|
||||
065 ;; constructed edge be tagged with the tags of the path?
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
066 (e/edge (first o) (rest o))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
067 (path->edges (rest o))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
068 (path? o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
069 (path->edges (:vertices o))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
070 :else
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
071 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 "Not a path or sequence of vertices!"))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
073
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
074 (defn length
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
075 "Return the length of this path, in metres. **Note that**
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
076 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">
|
||||
077 path, which, except for absolutely straight paths, will be shorter;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 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">
|
||||
079 since paths will generally be rendered as spline curves."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 [path]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
081 (if
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
082 (path? path)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
083 (reduce + (map e/length (path->edges path)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
084 (throw (IllegalArgumentException. "Not a path!"))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -11,55 +11,259 @@
|
|||
002 "Essentially the specification for things we shall consider to be polygons."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [walkmap.vertex :refer [vertex?]]))
|
||||
003 (:require [clojure.string :as s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 [walkmap.edge :as e]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [walkmap.tag :as t]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [walkmap.utils :refer [kind-type]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.vertex :refer [vertex vertex?]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
004
|
||||
008
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
005 (defn polygon?
|
||||
009 (defn polygon?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 "True if `o` satisfies the conditions for a polygon. A polygon shall be a
|
||||
010 "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">
|
||||
007 map which has a value for the key `:vertices`, where that value is a sequence
|
||||
011 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">
|
||||
008 of vertices."
|
||||
012 of vertices."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [o]
|
||||
013 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
010 (let
|
||||
014 (let
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
011 [v (:vertices o)]
|
||||
015 [v (:vertices o)]
|
||||
</span><br/>
|
||||
<span class="partial" title="17 out of 22 forms covered">
|
||||
012 (and
|
||||
016 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
013 (coll? v)
|
||||
017 (coll? v)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
014 (> (count v) 2)
|
||||
018 (> (count v) 2)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
015 (every? vertex? v)
|
||||
019 (every? vertex? v)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
016 (:id o)
|
||||
020 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
017 (or (nil? (:kind o)) (= (:kind o) :polygon)))))
|
||||
021 (or (nil? (:kind o)) (= (:kind o) :polygon)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
018
|
||||
022
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
023 (defn triangle?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 "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">
|
||||
025 polygon with exactly three vertices."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 [o]
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
027 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
028 (coll? o)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
029 (= (count (:vertices o)) 3)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
019
|
||||
030
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
031 (defn polygon
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 "Return a polygon constructed from these `vertices`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 [vertices]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
034 (when-not (every? vertex? vertices)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
035 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
036 (str
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 "Each item on vertices must be a vertex: "
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
038 (s/join " " (map kind-type (remove vertex? vertices)))))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
039 {:vertices vertices :walkmap.id/id (keyword (gensym "poly")) :kind :polygon})
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
040
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
041 (defn gradient
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 "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">
|
||||
043 unit vector representing the gradient across `triangle`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 [triangle]
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
045 (when-not (triangle? triangle)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
046 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
047 (s/join " " ["Must be a triangle:" (kind-type triangle)]))))
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
048 (let [order (sort #(max (:z %1) (:z %2)) (:vertices triangle))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
049 highest (first order)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
050 lowest (last order)]
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
051 (assoc triangle :gradient (e/unit-vector (e/edge lowest highest)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
052
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
053 (defn triangle-centre
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 "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">
|
||||
055 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">
|
||||
056 dimensions. This only works for triangles, so is here not in
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 `walkmap.polygon`. It is an error (although no exception is currently
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 thrown) if the object past is not a triangular polygon."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 [facet]
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
060 (when-not (triangle? facet)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
061 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
062 (s/join " " ["Must be a triangle:" (kind-type facet)]))))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
063 (let [vs (:vertices facet)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
064 v1 (first vs)
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
065 opposite (e/edge (nth vs 1) (nth vs 2))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
066 oc (e/centre opposite)]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
067 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
068 facet
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 :centre
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
070 (vertex
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
071 (+ (:x v1) (* (- (:x oc) (:x v1)) 2/3))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
072 (+ (:y v1) (* (- (:y oc) (:y v1)) 2/3))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
073 (+ (:z v1) (* (- (:z oc) (:z v1)) 2/3))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
074
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
075 (defn centre
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
076 [poly]
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
077 (when-not (polygon? poly)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
078 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
079 (s/join " " ["Must be a polygon:" (kind-type poly)]))))
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
080 (case (count (:vertices poly))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
081 3 (triangle-centre poly)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 ;; else
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
083 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
084 (UnsupportedOperationException.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
085 "The general case of centre for polygons is not yet implemented."))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
086
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
087
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
299
docs/cloverage/walkmap/read_svg.clj.html
Normal file
299
docs/cloverage/walkmap/read_svg.clj.html
Normal file
|
@ -0,0 +1,299 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/read_svg.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns walkmap.read-svg
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "Utility functions for scalable vector graphics (SVG) into walkmap
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 structures."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 (:require [clojure.data.zip :as dz]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [clojure.data.zip.xml :as zx]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [clojure.java.io :as io]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [clojure.string :as s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [clojure.xml :as x]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [clojure.zip :as z]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 [taoensso.timbre :as l]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [walkmap.path :refer [path]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 [walkmap.tag :refer [tag]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 [walkmap.utils :refer [kind-type truncate]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 [walkmap.vertex :refer [vertex vertex?]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
015
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
016 (defn upper-case?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 [s]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
018 (every? #(Character/isUpperCase %) s))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
019
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
020 (defn match->vertex
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 [match-vector x y]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
022 (when-not (empty? match-vector)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
023 (let [command (nth match-vector 1)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
024 xcoord (read-string (nth match-vector 2))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
025 ycoord (read-string (nth match-vector 3))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 ;; upper case command letters mean the coordinates that follow are
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 ;; absolute; lower case, relative.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
028 x' (if (upper-case? command) xcoord (+ x xcoord))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
029 y' (if (upper-case? command) ycoord (+ y ycoord))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
030 (case (s/lower-case command)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 20 forms covered">
|
||||
031 ("m" "l") {:vertex (vertex x' y') :x x' :y y'}
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 nil))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
033
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
034 (defn command-string->vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 "Return the destination of each successive line (`l`, `L`) and move (`m`, `M`)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 command in this string `s`, expected to be an SVG path command string."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 [s]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
038 (let [cmd-matcher ;; matches a 'command' in the string: a letter followed by
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 ;;spaces and numbers
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
040 (re-matcher #"[a-zA-Z][^a-zA-Z]*" s)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 seg-pattern ;; matches a command which initiates a move of the current
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 ;; position.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 #"([a-zA-Z]) +([-+]?[0-9]*\.?[0-9]+) +([-+]?[0-9]*\.?[0-9]+) +"]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
044 (loop [match (re-find cmd-matcher)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
045 result []
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 x 0
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 y 0]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
048 (if-not match
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
049 (filter vertex? result)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 18 forms covered">
|
||||
050 (let [m (match->vertex (re-find seg-pattern match) x y)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
051 (recur (re-find cmd-matcher) ;loop with 2 new arguments
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 (conj result (:vertex m))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 (or (:x m) x)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 (or (:y m) y)))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
055
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
056 (defn path-elt->path
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 "Given the SVG path element `elt`, return a walkmap path structure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 representing the line (`l`, `L`) and move (`m`, `M`) commands in
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 that path."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 [elt]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
061 (if (= (:tag elt) :path)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
062 (let [vs (command-string->vertices (-> elt :attrs :d))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
063 p (when-not (empty? vs) (apply path vs))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
064 (if (and p (-> elt :attrs :class))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 14 forms covered">
|
||||
065 (tag p (map keyword (s/split (-> elt :attrs :class) #" ")))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
066 p))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
067 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
068 (str "Must be an SVG `path` element: " elt)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
069
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
070 (defn progeny
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 "Return all the nodes in the XML structure below this `elt` which match
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 this `predicate`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
073 ;; the name `descendants` is bound in `clojure.core` for something quite
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
074 ;; different, and I chose not to rebind it.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
075 [elt predicate]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
076 (if
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
077 (apply predicate (list elt))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
078 (list elt)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
079 (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
080 concat
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
081 (remove
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
082 empty?
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
083 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
084 #(progeny % predicate)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
085 (:content elt))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
086
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
087 (defn read-svg
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 ;; I tried to get this working with all the clever zip stuff in
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 ;; `clojure.zip`, `clojure.data.zip`, and so on. It would probably have
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 ;; been more elegant, but it kept crashing out of heap space on even
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 ;; quite small XML files. So I've implemented my own solution.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 ([file-name]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
093 (read-svg file-name nil))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
094 ([file-name map-kind]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
095 (let [xml (x/parse (io/file file-name))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
096 paths (progeny xml #(= (:tag %) :path))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
097 (remove nil? (map path-elt->path paths)))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
62
docs/cloverage/walkmap/routing.clj.html
Normal file
62
docs/cloverage/walkmap/routing.clj.html
Normal file
|
@ -0,0 +1,62 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../coverage.css"/> <title> walkmap/routing.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns walkmap.routing
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
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]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 [walkmap.polygon :as q]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [walkmap.stl :as s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [walkmap.utils :as u]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.vertex :as v]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
008
|
||||
</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
|
||||
</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.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
011
|
||||
</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
|
||||
</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
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -23,559 +23,604 @@
|
|||
006 [org.clojars.smee.binary.core :as b]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [taoensso.timbre :as l :refer [info error spy]]
|
||||
007 [taoensso.timbre :as l]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [walkmap.edge :as e]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [walkmap.polygon :refer [polygon?]]
|
||||
009 [walkmap.ocean :as o]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 [walkmap.tag :refer [tag]]
|
||||
010 [walkmap.polygon :refer [centre gradient polygon?]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [walkmap.vertex :as v])
|
||||
011 [walkmap.superstructure :refer [store]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 (:import org.clojars.smee.binary.core.BinaryIO
|
||||
012 [walkmap.tag :refer [tag]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 java.io.DataInput))
|
||||
013 [walkmap.utils :as u]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 [walkmap.vertex :as v])
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 (:import org.clojars.smee.binary.core.BinaryIO
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 java.io.DataInput))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
014
|
||||
017
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
015 (defn stl?
|
||||
018 (defn stl?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 "True if `o` is recogniseable as an STL structure. An STL structure must
|
||||
019 "True if `o` is recogniseable as an STL structure. An STL structure must
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 have a key `:facets`, whose value must be a sequence of polygons; and
|
||||
020 have a key `:facets`, whose value must be a sequence of polygons; and
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 may have a key `:header` whose value should be a string, and/or a key
|
||||
021 may have a key `:header` whose value should be a string, and/or a key
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 `:count`, whose value should be a positive integer.
|
||||
022 `:count`, whose value should be a positive integer.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
020
|
||||
023
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 If `verify-count?` is passed and is not `false`, verify that the value of
|
||||
024 If `verify-count?` is passed and is not `false`, verify that the value of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 the `:count` header is equal to the number of facets."
|
||||
025 the `:count` header is equal to the number of facets."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ([o]
|
||||
026 ([o]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
024 (stl? o false))
|
||||
027 (stl? o false))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 ([o verify-count?]
|
||||
028 ([o verify-count?]
|
||||
</span><br/>
|
||||
<span class="partial" title="20 out of 26 forms covered">
|
||||
026 (and
|
||||
029 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
027 (map? o)
|
||||
030 (map? o)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
028 (:facets o)
|
||||
031 (:facets o)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
029 (every? polygon? (:facets o))
|
||||
032 (every? polygon? (:facets o))
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
030 (if (:header o) (string? (:header o)) true)
|
||||
033 (if (:header o) (string? (:header o)) true)
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
031 (if (:count o) (integer? (:count o)) true)
|
||||
034 (if (:count o) (integer? (:count o)) true)
|
||||
</span><br/>
|
||||
<span class="partial" title="14 out of 15 forms covered">
|
||||
032 (or (nil? (:kind o)) (= (:kind o) :stl))
|
||||
035 (or (nil? (:kind o)) (= (:kind o) :stl))
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 11 forms covered">
|
||||
033 (if verify-count? (= (:count o) (count (:facets o))) true))))
|
||||
036 (if verify-count? (= (:count o) (count (:facets o))) true))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
034
|
||||
037
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
035 (def vect
|
||||
038 (def vect
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 "A codec for vectors within a binary STL file."
|
||||
039 "A codec for vectors within a binary STL file."
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
037 (b/ordered-map
|
||||
040 (b/ordered-map
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 :x :float-le
|
||||
041 :x :float-le
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 :y :float-le
|
||||
042 :y :float-le
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 :z :float-le))
|
||||
043 :z :float-le))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
041
|
||||
044
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
042 (def facet
|
||||
045 (def facet
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 "A codec for a facet (triangle) within a binary STL file."
|
||||
046 "A codec for a facet (triangle) within a binary STL file."
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
044 (b/ordered-map
|
||||
047 (b/ordered-map
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
045 :normal vect
|
||||
048 :normal vect
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
046 :vertices [vect vect vect]
|
||||
049 :vertices [vect vect vect]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 :abc :ushort-le))
|
||||
050 :abc :ushort-le))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
048
|
||||
051
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
049 (def binary-stl
|
||||
052 (def binary-stl
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 "A codec for binary STL files"
|
||||
053 "A codec for binary STL files"
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
051 (b/ordered-map
|
||||
054 (b/ordered-map
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
052 :header (b/string "ISO-8859-1" :length 80) ;; for the time being we neither know nor care what's in this.
|
||||
055 :header (b/string "ISO-8859-1" :length 80) ;; for the time being we neither know nor care what's in this.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 :count :uint-le
|
||||
056 :count :uint-le
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
054 :facets (b/repeated facet)))
|
||||
057 :facets (b/repeated facet)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
055
|
||||
058
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
056 (defn centre
|
||||
059 (defn canonicalise
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 "Return a canonicalised `facet` (i.e. a triangular polygon) with an added
|
||||
060 "Objects read in from STL won't have all the keys/values we need them to have.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 key `:centre` whose value represents the centre of this facet in 3
|
||||
061 `o` may be a map (representing a facet or a vertex), or a sequence of such maps;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 dimensions. This only works for triangles, so is here not in
|
||||
062 if it isn't recognised it is at present just returned unchanged. `map-kind`, if
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 `walkmap.polygon`. It is an error (although no exception is currently
|
||||
063 passed, must be a keyword indicating the value represented by the `z` axis
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 thrown) if the object past is not a triangular polygon."
|
||||
064 (defaults to `:height`). It is an error, and an exception will be thrown, if
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 [facet]
|
||||
065 `map-kind` is not a keyword."
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
063 (let [vs (:vertices facet)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
064 v1 (first vs)
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
065 opposite (e/edge (nth vs 1) (nth vs 2))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
066 oc (e/centre opposite)]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
067 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
068 facet
|
||||
066 ([o] (canonicalise o :height))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 :centre
|
||||
067 ([o map-kind]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
070 (v/vertex
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
071 (+ (:x v1) (* (- (:x oc) (:x v1)) 2/3))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
072 (+ (:y v1) (* (- (:y oc) (:y v1)) 2/3))
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
073 (+ (:z v1) (* (- (:z oc) (:z v1)) 2/3))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
074
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
075 (defn canonicalise
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
068 (canonicalise o map-kind (v/vertex 1 1 1)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
076 "Objects read in from STL won't have all the keys/values we need them to have.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
077 `o` may be a map (representing a facet or a vertex), or a sequence of such maps;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 if it isn't recognised it is at present just returned unchanged. `map-kind`, if
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 passed, must be a keyword indicating the value represented by the `z` axis
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 (defaults to `:height`). It is an error, and an exception will be thrown, if
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
081 `map-kind` is not a keyword."
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
082 ([o] (canonicalise o :height))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 ([o map-kind]
|
||||
069 ([o map-kind scale-vertex]
|
||||
</span><br/>
|
||||
<span class="partial" title="2 out of 3 forms covered">
|
||||
084 (when-not
|
||||
070 (when-not
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
085 (keyword? map-kind)
|
||||
071 (keyword? map-kind)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
086 (throw (IllegalArgumentException.
|
||||
072 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 13 forms covered">
|
||||
087 (subs (str "Must be a keyword: " (or map-kind "nil")) 0 80))))
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
073 (u/truncate (str "Must be a keyword: " (or map-kind "nil")) 80))))
|
||||
</span><br/>
|
||||
<span class="partial" title="4 out of 5 forms covered">
|
||||
088 (cond
|
||||
074 (cond
|
||||
</span><br/>
|
||||
<span class="partial" title="19 out of 20 forms covered">
|
||||
089 (and (coll? o) (not (map? o))) (map #(canonicalise % map-kind) o)
|
||||
075 (and (coll? o) (not (map? o))) (map #(canonicalise % map-kind) o)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 ;; if it has :facets it's an STL structure, but it doesn't yet conform to `stl?`
|
||||
076 ;; if it has :facets it's an STL structure, but it doesn't yet conform to `stl?`
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
091 (:facets o) (assoc o
|
||||
077 (:facets o) (assoc o
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 :kind :stl
|
||||
078 :kind :stl
|
||||
</span><br/>
|
||||
<span class="partial" title="11 out of 12 forms covered">
|
||||
093 :id (or (:id o) (keyword (gensym "stl")))
|
||||
079 :walkmap.id/id (or (:walkmap.id/id o) (keyword (gensym "stl")))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
094 :facets (canonicalise (:facets o) map-kind))
|
||||
080 :facets (canonicalise (:facets o) map-kind))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 ;; if it has :vertices it's a polygon, but it doesn't yet conform to `polygon?`
|
||||
081 ;; if it has :vertices it's a polygon, but it may not yet conform to
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
096 (:vertices o) (centre
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 ;; `polygon?`
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
083 (:vertices o) (let [f (gradient
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
084 (centre
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
097 (tag
|
||||
085 (tag
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
098 (assoc o
|
||||
086 (assoc o
|
||||
</span><br/>
|
||||
<span class="partial" title="11 out of 12 forms covered">
|
||||
099 :id (or (:id o) (keyword (gensym "poly")))
|
||||
<span class="partial" title="4 out of 5 forms covered">
|
||||
087 :walkmap.id/id (or
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
088 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
089 (keyword (gensym "poly")))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
100 :kind :polygon
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
101 :vertices (canonicalise (:vertices o) map-kind))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
102 :facet map-kind))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
103 ;; if it has a value for :x it's a vertex, but it doesn't yet conform to `vertex?`
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
104 (:x o) (v/canonicalise o)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
105 ;; shouldn't happen
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
106 :else o)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
107
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
108 (defn decode-binary-stl
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
109 "Parse a binary STL file from this `filename` and return an STL structure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
110 representing its contents. `map-kind`, if passed, must be a keyword
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
111 indicating the value represented by the `z` axis (defaults to `:height`).
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
112 It is an error, and an exception will be thrown, if `map-kind` is not a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
113 keyword.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
114
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
115 **NOTE** that we've no way of verifying that the input file is binary STL
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
116 data, if it is not this will run but will return garbage."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
117 ([filename]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
118 (decode-binary-stl filename :height))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
119 ([filename map-kind]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
120 (when-not
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
121 (keyword? map-kind)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
122 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 13 forms covered">
|
||||
123 (subs (str "Must be a keyword: " (or map-kind "nil")) 0 80))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
124 (let [in (io/input-stream filename)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
125 (canonicalise (b/decode binary-stl in) map-kind))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
126
|
||||
090 :kind :polygon
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
127 (defn- vect->str [prefix v]
|
||||
091 :vertices (canonicalise
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
092 (:vertices o)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
093 map-kind))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
094 :facet map-kind)))]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
095 (if (o/ocean? f)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
096 (tag f :ocean :no-traversal)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
097 f))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
098 ;; if it has a value for :x it's a vertex, but it may not yet conform
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
099 ;; to `vertex?`; it should also be scaled using the scale-vertex, if any.
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
100 (:x o) (let [c (v/canonicalise o)]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
101 (if scale-vertex
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
102 (v/vertex* c scale-vertex)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
103 c))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
104 ;; shouldn't happen
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
105 :else o)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
106
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
107 (defn decode-binary-stl
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
108 "Parse a binary STL file from this `filename` and return an STL structure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
109 representing its contents. `map-kind`, if passed, must be a keyword
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
110 or sequence of keywords indicating the semantic value represented by the `z`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
111 axis (defaults to `:height`).
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
112
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
113 If `superstructure` is supplied and is a map, the generated STL structure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
114 will be stored in that superstructure, which will be returned.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
115
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
116 If `scale-vertex` is supplied, it must be a three dimensional vertex (i.e.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
117 the `:z` key must have a numeric value) representing the amount by which
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
118 each of the vertices read from the STL will be scaled.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
119
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
120 It is an error, and an exception will be thrown, if `map-kind` is not a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
121 keyword or sequence of keywords.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
122
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
123 **NOTE** that we've no way of verifying that the input file is binary STL
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
124 data, if it is not this will run but will return garbage."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
125 ([filename]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
126 (decode-binary-stl filename :height))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
127 ([filename map-kind]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
128 (when-not
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
129 (keyword? map-kind)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
130 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
131 (u/truncate (str "Must be a keyword: " (or map-kind "nil")) 80))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
132 (decode-binary-stl filename map-kind nil))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
133 ([filename mapkind superstucture]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
134 (decode-binary-stl filename mapkind superstucture (v/vertex 1 1 1)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
135 ([filename map-kind superstructure scale-vertex]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
136 (let [in (io/input-stream filename)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
137 stl (canonicalise (b/decode binary-stl in) map-kind scale-vertex)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
138 (if
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
139 (map? superstructure)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
140 (store stl superstructure)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
141 stl))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
142
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
143 (defn- vect->str [prefix v]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 16 forms covered">
|
||||
128 (str prefix " " (:x v) " " (:y v) " " (:z v) "\n"))
|
||||
144 (str prefix " " (:x v) " " (:y v) " " (:z v) "\n"))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
129
|
||||
145
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
130 (defn- facet2str [tri]
|
||||
146 (defn- facet2str [tri]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
131 (str
|
||||
147 (str
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
132 (vect->str "facet normal" (:normal tri))
|
||||
148 (vect->str "facet normal" (:normal tri))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
133 "outer loop\n"
|
||||
149 "outer loop\n"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
150 (s/join
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
134 (apply str
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
135 (map
|
||||
151 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
136 #(vect->str "vertex" %)
|
||||
152 #(vect->str "vertex" %)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
137 (:vertices tri)))
|
||||
153 (:vertices tri)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
138 "endloop\nendfacet\n"))
|
||||
154 "endloop\nendfacet\n"))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
139
|
||||
155
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
140 (defn stl->ascii
|
||||
156 (defn stl->ascii
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
141 "Return as a string an ASCII rendering of the `stl` structure."
|
||||
157 "Return as a string an ASCII rendering of the `stl` structure."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
142 ([stl]
|
||||
158 ([stl]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
143 (stl->ascii stl "unknown"))
|
||||
159 (stl->ascii stl "unknown"))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
144 ([stl solidname]
|
||||
160 ([stl solidname]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
145 (str
|
||||
161 (str
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
146 "solid "
|
||||
162 "solid "
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
147 solidname
|
||||
163 solidname
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
148 (s/trim (:header stl))
|
||||
164 (s/trim (:header stl))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
149 "\n"
|
||||
165 "\n"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
150 (apply
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
151 str
|
||||
166 (s/join
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
152 (map
|
||||
167 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
153 facet2str
|
||||
168 facet2str
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
154 (:facets stl)))
|
||||
169 (:facets stl)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
155 "endsolid "
|
||||
170 "endsolid "
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
156 solidname
|
||||
171 solidname
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
157 "\n")))
|
||||
172 "\n")))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
158
|
||||
173
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
159 (defn write-ascii-stl
|
||||
174 (defn write-ascii-stl
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
160 "Write an `stl` structure as read by `decode-binary-stl` to this
|
||||
175 "Write an `stl` structure as read by `decode-binary-stl` to this
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
161 `filename` as ASCII encoded STL."
|
||||
176 `filename` as ASCII encoded STL."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
162 ([filename stl]
|
||||
177 ([filename stl]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
163 (let [b (fs/base-name filename true)]
|
||||
178 (let [b (fs/base-name filename true)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
164 (write-ascii-stl
|
||||
179 (write-ascii-stl
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
165 filename stl
|
||||
180 filename stl
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 15 forms covered">
|
||||
166 (subs b 0 (or (s/index-of b ".") (count b))))))
|
||||
181 (subs b 0 (or (s/index-of b ".") (count b))))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
167 ([filename stl solidname]
|
||||
182 ([filename stl solidname]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 16 forms covered">
|
||||
168 (l/debug "Solid name is " solidname)
|
||||
183 (l/debug "Solid name is " solidname)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
169 (spit
|
||||
184 (spit
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
170 filename
|
||||
185 filename
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
171 (stl->ascii stl solidname))))
|
||||
186 (stl->ascii stl solidname))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
172
|
||||
187
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
173 (defn binary-stl-to-ascii
|
||||
188 (defn binary-stl-to-ascii
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
174 "Convert the binary STL file indicated by `in-filename`, and write it to
|
||||
189 "Convert the binary STL file indicated by `in-filename`, and write it to
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
175 `out-filename`, if specified; otherwise, to a file with the same basename
|
||||
190 `out-filename`, if specified; otherwise, to a file with the same basename
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
176 as `in-filename` but the extension `.ascii.stl`."
|
||||
191 as `in-filename` but the extension `.ascii.stl`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
177 ([in-filename]
|
||||
192 ([in-filename]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
178 (let [[_ ext] (fs/split-ext in-filename)]
|
||||
193 (let [[_ ext] (fs/split-ext in-filename)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
179 (binary-stl-to-ascii
|
||||
194 (binary-stl-to-ascii
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
180 in-filename
|
||||
195 in-filename
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
181 (str
|
||||
196 (str
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
182 (subs
|
||||
197 (subs
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
183 in-filename
|
||||
198 in-filename
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
184 0
|
||||
199 0
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
185 (or
|
||||
200 (or
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
186 (s/last-index-of in-filename ".")
|
||||
201 (s/last-index-of in-filename ".")
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
187 (count in-filename)))
|
||||
202 (count in-filename)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
188 ".ascii"
|
||||
203 ".ascii"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
189 ext))))
|
||||
204 ext))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
190 ([in-filename out-filename]
|
||||
205 ([in-filename out-filename]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
191 (write-ascii-stl out-filename (decode-binary-stl in-filename))))
|
||||
206 (write-ascii-stl out-filename (decode-binary-stl in-filename))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -11,253 +11,547 @@
|
|||
002 "single indexing structure for walkmap objects"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [walkmap.path :as p]
|
||||
003 (:require [clojure.walk :refer [postwalk]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 [walkmap.polygon :as q]
|
||||
004 [taoensso.timbre :as l]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [walkmap.stl :as s]
|
||||
005 [walkmap.path :as p]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [walkmap.utils :as u]
|
||||
006 [walkmap.polygon :as q]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.vertex :as v]))
|
||||
007 [walkmap.utils :as u]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [walkmap.vertex :as v]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
008
|
||||
009
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 ;; TODO: Think about reification/dereification. How can we cull a polygon, if
|
||||
010 ;; TODO: Think about reification/dereification. How can we cull a polygon, if
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 ;; some vertices still index it? I *think* that what's needed is that when
|
||||
011 ;; some vertices still index it? I *think* that what's needed is that when
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 ;; we store something in the superstructure, we replace all its vertices (and
|
||||
012 ;; we store something in the superstructure, we replace all its vertices (and
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 ;; other dependent structures, if any with their ids - as well as, obviously,
|
||||
013 ;; other dependent structures, if any with their ids - as well as, obviously,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 ;; adding/merging those vertices/dependent structures into the superstructure
|
||||
014 ;; adding/merging those vertices/dependent structures into the superstructure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 ;; as first class objects in themselves. That means, for each identified thing,
|
||||
015 ;; as first class objects in themselves. That means, for each identified thing,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 ;; the superstructure only contains one copy of it.
|
||||
016 ;; the superstructure only contains one copy of it.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 ;;
|
||||
017 ;;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 ;; The question then is, when we want to do things with those objects, do we
|
||||
018 ;; The question then is, when we want to do things with those objects, do we
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 ;; exteract a copy with its dependent structures fixed back up (reification),
|
||||
019 ;; exteract a copy with its dependent structures fixed back up (reification),
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 ;; or do we indirect through the superstructure every time we want to access
|
||||
020 ;; or do we indirect through the superstructure every time we want to access
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 ;; them? In a sense, the copy in the superstructure is the 'one true copy',
|
||||
021 ;; them? In a sense, the copy in the superstructure is the 'one true copy',
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 ;; but it may become very difficult then to have one true copy of the
|
||||
022 ;; but it may become very difficult then to have one true copy of the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 ;; superstructure - unless we replace the superstructure altogether with a
|
||||
023 ;; superstructure - unless we replace the superstructure altogether with a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 ;; database, which may be the Right Thing To Do.
|
||||
024 ;; database, which may be the Right Thing To Do.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
024
|
||||
025
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
026 (def vertex-index ::vertex-index)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
027
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
025 (defn index-vertex
|
||||
028 (defn vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 "Return a superstructure like `s` in which object `o` is indexed by vertex
|
||||
029 "If `o` is an object with vertices, return those vertices, else nil."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 `v`. It is an error (and an exception may be thrown) if
|
||||
030 [o]
|
||||
</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 1. `s` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 2. `o` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 3. `o` does not have a value for the key `:id`;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 4. `v` is not a vertex."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 [s o v]
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
031 (cond
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
034 (if-not (v/vertex? o)
|
||||
032 (v/vertex? o) (list o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
033 (q/polygon? o) (:vertices o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
034 (p/path? o) (:vertices o)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
035
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
036 (defn index-vertex
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 "Return a superstructure like `s` in which object `o` is indexed by vertex
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 `v`. It is an error (and an exception may be thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
039
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 1. `s` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 2. `o` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
042 3. `o` does not have a value for the key `:walkmap.id/id`;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 4. `v` is not a vertex."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 [s o v]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
045 (if-not (v/vertex? o)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
046 (if (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
047 (if (v/vertex? v)
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
048 (let [vi (or (::vertex-index s) {})
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
049 current (or (vi (:walkmap.id/id v)) {})]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 ;; deep-merge doesn't merge sets, only maps; so at this
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
051 ;; stage we need to build a map.
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
052 (assoc vi (:walkmap.id/id v) (assoc current (:walkmap.id/id o) (:walkmap.id/id v))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
035 (if (:id o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
036 (if (v/vertex? v)
|
||||
053 (throw (IllegalArgumentException. "Not a vertex: " v)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
037 (let [vi (or (:vertex-index s) {})
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
038 current (or (vi (:id v)) {})]
|
||||
054 (throw (IllegalArgumentException. (u/truncate (str "No `:walkmap.id/id` value: " o) 80))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 ;; deep-merge doesn't merge sets, only maps; so at this
|
||||
055 ;; it shouldn't actually be an error to try to index a vertex, but it
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 ;; stage we need to build a map.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 15 forms covered">
|
||||
041 (assoc vi (:id v) (assoc current (:id o) (:id v))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
042 (throw (IllegalArgumentException. "Not a vertex: " v)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
043 (throw (IllegalArgumentException. (subs (str "No `:id` value: " o) 0 80))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 ;; it shouldn't actually be an error to try to index a vertex, but it
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
045 ;; also isn't useful to do so, so I'd be inclined to ignore it.
|
||||
056 ;; also isn't useful to do so, so I'd be inclined to ignore it.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
046 (:vertex-index s)))
|
||||
057 (::vertex-index s)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
047
|
||||
058
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
048 (defn index-vertices
|
||||
059 (defn index-vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
049 "Return a superstructure like `s` in which object `o` is indexed by its
|
||||
060 "Return a superstructure like `s` in which object `o` is indexed by its
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 vertices. It is an error (and an exception may be thrown) if
|
||||
061 vertices. It is an error (and an exception may be thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
051
|
||||
062
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 1. `s` is not a map;
|
||||
063 1. `s` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 2. `o` is not a map;
|
||||
064 2. `o` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 3. `o` does not have a value for the key `:id`."
|
||||
065 3. `o` does not have a value for the key `:walkmap.id/id`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 [s o]
|
||||
066 [s o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
056 (assoc
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
067 (u/deep-merge
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
068 s
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
069 {::vertex-index
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
070 (reduce
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
071 u/deep-merge
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
072 {}
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
073 (map
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
074 #(index-vertex s o %)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
075 (:vertices o)))}))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
076
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
077 (defn in-retrieve
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 "Internal guts of `retrieve`, q.v. `x` can be anything; `s` must be a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 walkmap superstructure. TODO: recursive, quite likely to blow the fragile
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 Clojure stack. Probably better to do this with `walk`, but I don't yet
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
081 understand that."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 [x s]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
083 (cond
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
084 ;; if it's a keyword identifying something in s, retrieve that something.
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
085 (keyword? x) (if (s x)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
086 (in-retrieve (s x) s)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
087 x)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 ;; if it's a map, for every key which is not `:walkmap.id/id`, recurse.
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
089 (map? x) (let [v (reduce
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
090 (fn [m k]
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
091 (assoc m k (in-retrieve (x k) s)))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
092 {}
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
093 (keys (dissoc x :walkmap.id/id)))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
094 id (:walkmap.id/id x)]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 ;; if it has an id, bind it to that id in the returned value.
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
096 (if id
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
097 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
098 v
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
099 :walkmap.id/id
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
100 (:walkmap.id/id x))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
057 s
|
||||
101 v))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
102 (set? x) x ;; TODO: should I search in sets for objects when storing?
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
103 (coll? x) (map #(in-retrieve % s) x)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
104 :else x))
|
||||
</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 retrieve
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 :vertex-index
|
||||
107 "Retrieve the canonical representation of the object with this `id` from the
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
059 (reduce
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
108 superstructure `s`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
109 [id s]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
110 (in-retrieve (id s) s))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
111
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
112 (defn in-store-find-objects
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
113 "Return an id -> object map of every object within `o`. Internal to
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
114 `in-store`, q.v. Use at your own peril."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
115 ([o]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
116 (in-store-find-objects o {}))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
117 ([o s]
|
||||
</span><br/>
|
||||
<span class="covered" title="16 out of 16 forms covered">
|
||||
118 (l/debug "Finding objects in:" o)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
119 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
120 (set? o) s ;; TODO: should I search in sets for objects when storing?
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
121 (map? o) (if (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
122 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
123 (in-store-find-objects (vals o) s)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
124 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
125 o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
126 (in-store-find-objects (vals o) s))
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
127 (coll? o) (reduce merge s (map #(in-store-find-objects % s) o))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
128 :else s)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
129
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
130 (defn in-store-replace-with-keys
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
131 "Return a copy of `o` in which each reified walkmap object within `o` has
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
132 been replaced with the `:walkmap.id/id` of that object. Internal to
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
133 `in-store`, q.v. Use at your own peril."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
134 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
135 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
136 (postwalk #(or (:walkmap.id/id %) %) (dissoc o :walkmap.id/id))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
137 :walkmap.id/id
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
138 (:walkmap.id/id o)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
139
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
140 ;; (in-store-replace-with-keys (p/path (v/vertex 0 0 0) (v/vertex 0 1 2) (v/vertex 3 3 3)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
141 ;; (in-store-find-objects (p/path (v/vertex 0 0 0) (v/vertex 0 1 2) (v/vertex 3 3 3)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
142
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
143 (defn store
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
144 "Return a superstructure like `s` with object `o` added. If only one
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
145 argument is supplied it will be assumed to represent `o` and a new
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
146 superstructure will be returned.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
147
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
148 It is an error (and an exception may be thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
149
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
150 1. `s` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
151 2. `o` is not a recognisable walkmap object"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
152 ([o]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
153 (store o {}))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
154 ([o s]
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
155 (when-not (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
060 u/deep-merge
|
||||
156 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
157 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
061 (map
|
||||
158 (str "Not a walkmap object: no value for `:walkmap.id/id`: "
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
159 (u/kind-type o)))))
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
160 (when-not (map? s)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
161 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
162 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
163 (str "Superstructure must be a map: " (u/kind-type s)))))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
164 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
165 (u/deep-merge s (in-store-find-objects o) (index-vertices s o))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
166 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
167 (in-store-replace-with-keys o))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
168
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
169 (defn search-vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
170 "Search superstructure `s` for vertices within the box defined by vertices
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
171 `minv` and `maxv`. Every coordinate in `minv` must have a lower value than
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
172 the equivalent coordinate in `maxv`. If `d2?` is supplied and not false,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
173 search only in the x,y projection."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
174 ([s minv maxv]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
175 (search-vertices s minv maxv false))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
176 ([s minv maxv d2?]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
177 (let [minv' (if d2? (assoc minv :z Double/NEGATIVE_INFINITY) minv)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
178 maxv' (if d2? (assoc maxv :z Double/POSITIVE_INFINITY) maxv)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
179 (filter
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
062 #(index-vertex s o %)
|
||||
180 #(v/within-box? % minv maxv)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
063 (u/vertices o)))))
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
181 (filter #(= (:kind %) :vertex) (vals s))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
064
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
065 (defn add-to-superstructure
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 "Return a superstructure like `s` with object `o` added. If `o` is a collection,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 return a superstructure like `s` with each element of `o` added. If only one
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
068 argument is supplied it will be assumed to represent `o` and a new
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 superstructure will be returned.
|
||||
182
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
070
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 It is an error (and an exception may be thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
072
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
073 1. `s` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
074 2. `o` is not a map, or a sequence of maps."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
075 ([o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
076 (add-to-superstructure {} o))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
077 ([s o]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
078 (cond
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 18 forms covered">
|
||||
079 (map? o) (let [o' (if (:id o) o (assoc o :id (keyword (gensym "obj"))))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 10 forms covered">
|
||||
080 (index-vertices (assoc s (:id o') o') o'))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 14 forms covered">
|
||||
081 (coll? o) (reduce u/deep-merge (map #(add-to-superstructure s %) o))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
082 (nil? o) o
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
083 :else
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 13 forms covered">
|
||||
084 (throw (IllegalArgumentException. (str "Don't know how to index " (or (type o) "nil")))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
085
|
||||
183
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -17,316 +17,322 @@
|
|||
004 (SVG)."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 (:require [clojure.string :as s]
|
||||
005 (:require [clojure.java.io :as io]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [dali.io :as neatly-folded-clock]
|
||||
006 [clojure.string :as s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [hiccup.core :refer [html]]
|
||||
007 [clojure.xml :as x]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [taoensso.timbre :as l :refer [info error spy]]
|
||||
008 [dali.io :as neatly-folded-clock]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [walkmap.ocean :refer [cull-ocean-facets]]
|
||||
009 [hiccup.core :refer [html]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 [walkmap.polygon :refer [polygon?]]
|
||||
010 [taoensso.timbre :as l :refer [info error spy]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [walkmap.stl :refer [decode-binary-stl]]
|
||||
011 [walkmap.ocean :refer [cull-ocean-facets]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 [walkmap.vertex :refer [vertex?]]))
|
||||
012 [walkmap.polygon :refer [polygon?]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 [walkmap.stl :refer [decode-binary-stl]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 [walkmap.vertex :refer [vertex?]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
013
|
||||
015
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
014 (def ^:dynamic *preferred-svg-render*
|
||||
016 (def ^:dynamic *preferred-svg-render*
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 "Mainly for debugging dali; switch SVG renderer to use. Expected values:
|
||||
017 "Mainly for debugging dali; switch SVG renderer to use. Expected values:
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 `:dali`, `:hiccup`."
|
||||
018 `:dali`, `:hiccup`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 :dali)
|
||||
019 :dali)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
018
|
||||
020
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
019 (defn- facet->svg-poly
|
||||
021 (defn- facet->svg-poly
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 [facet]
|
||||
022 [facet]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
021 [:polygon
|
||||
023 [:polygon
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 20 forms covered">
|
||||
022 {:points (s/join " " (map #(str (:x %) "," (:y %)) (:vertices facet)))}])
|
||||
024 {:points (s/join " " (map #(str (:x %) "," (:y %)) (:vertices facet)))}])
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
023
|
||||
025
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
024 (defn- dali-facet->svg-poly
|
||||
026 (defn- dali-facet->svg-poly
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 [facet]
|
||||
027 [facet]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
026 (vec
|
||||
028 (vec
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
027 (cons
|
||||
029 (cons
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 :polygon
|
||||
030 :polygon
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 16 forms covered">
|
||||
029 (map #(vec (list (:x %) (:y %))) (:vertices facet)))))
|
||||
031 (map #(vec (list (:x %) (:y %))) (:vertices facet)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
030
|
||||
032
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
031 (defn dali-stl->svg
|
||||
033 (defn dali-stl->svg
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 "Format this `stl` as SVG for the `dali` renderer on a page with these
|
||||
034 "Format this `stl` as SVG for the `dali` renderer on a page with these
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 bounds."
|
||||
035 bounds."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 [stl minx maxx miny maxy]
|
||||
036 [stl minx maxx miny maxy]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
035 [:dali/page
|
||||
037 [:dali/page
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
036 {:xmlns "http://www.w3.org/2000/svg"
|
||||
038 {:xmlns "http://www.w3.org/2000/svg"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 :version "1.2"
|
||||
039 :version "1.2"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
038 :width (- maxx minx)
|
||||
040 :width (- maxx minx)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
039 :height (- maxy miny)
|
||||
041 :height (- maxy miny)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
040 :viewBox (s/join " " (map str [minx miny maxx maxy]))}
|
||||
042 :viewBox (s/join " " (map str [minx miny maxx maxy]))}
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
041 (vec
|
||||
043 (vec
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
042 (cons
|
||||
044 (cons
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
043 :g
|
||||
045 :g
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
044 (map
|
||||
046 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
045 dali-facet->svg-poly
|
||||
047 dali-facet->svg-poly
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
046 (:facets stl))))])
|
||||
048 (:facets stl))))])
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
047
|
||||
049
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
048 (defn hiccup-stl->svg
|
||||
050 (defn hiccup-stl->svg
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
049 "Format this `stl` as SVG for the `hiccup` renderer on a page with these
|
||||
051 "Format this `stl` as SVG for the `hiccup` renderer on a page with these
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
050 bounds."
|
||||
052 bounds."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
051 [stl minx maxx miny maxy]
|
||||
053 [stl minx maxx miny maxy]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
052 [:svg
|
||||
054 [:svg
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
053 {:xmlns "http://www.w3.org/2000/svg"
|
||||
055 {:xmlns "http://www.w3.org/2000/svg"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 :version "1.2"
|
||||
056 :version "1.2"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
055 :width (- maxx minx)
|
||||
057 :width (- maxx minx)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
056 :height (- maxy miny)
|
||||
058 :height (- maxy miny)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 11 forms covered">
|
||||
057 :viewBox (s/join " " (map str [minx miny maxx maxy]))}
|
||||
059 :viewBox (s/join " " (map str [minx miny maxx maxy]))}
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
058 (vec
|
||||
060 (vec
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
059 (cons
|
||||
061 (cons
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 :g
|
||||
062 :g
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
061 (map
|
||||
063 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
062 facet->svg-poly
|
||||
064 facet->svg-poly
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
063 (:facets stl))))])
|
||||
065 (:facets stl))))])
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
064
|
||||
066
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
065 (defn stl->svg
|
||||
067 (defn stl->svg
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 "Convert this in-memory `stl` structure, as read by `decode-binary-stl`, into
|
||||
068 "Convert this in-memory `stl` structure, as read by `decode-binary-stl`, into
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 an in-memory hiccup representation of SVG structure, and return it."
|
||||
069 an in-memory hiccup representation of SVG structure, and return it."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
068 [stl]
|
||||
070 [stl]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
069 (let [minx (reduce
|
||||
071 (let [minx (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
070 min
|
||||
072 min
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
071 (map
|
||||
073 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
072 #(reduce min (map :x (:vertices %)))
|
||||
074 #(reduce min (map :x (:vertices %)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
073 (:facets stl)))
|
||||
075 (:facets stl)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
074 maxx (reduce
|
||||
076 maxx (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
075 max
|
||||
077 max
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
076 (map
|
||||
078 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
077 #(reduce max (map :x (:vertices %)))
|
||||
079 #(reduce max (map :x (:vertices %)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
078 (:facets stl)))
|
||||
080 (:facets stl)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
079 miny (reduce
|
||||
081 miny (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
080 min
|
||||
082 min
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
081 (map
|
||||
083 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
082 #(reduce min (map :y (:vertices %)))
|
||||
084 #(reduce min (map :y (:vertices %)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
083 (:facets stl)))
|
||||
085 (:facets stl)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
084 maxy (reduce
|
||||
086 maxy (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
085 max
|
||||
087 max
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
086 (map
|
||||
088 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 9 forms covered">
|
||||
087 #(reduce max (map :y (:vertices %)))
|
||||
089 #(reduce max (map :y (:vertices %)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
088 (:facets stl)))]
|
||||
090 (:facets stl)))]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 17 forms covered">
|
||||
089 (l/info "Generating SVG for " *preferred-svg-render* " renderer")
|
||||
091 (l/info "Generating SVG for " *preferred-svg-render* " renderer")
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
090 (case *preferred-svg-render*
|
||||
092 (case *preferred-svg-render*
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
091 :hiccup (hiccup-stl->svg stl minx maxx miny maxy)
|
||||
093 :hiccup (hiccup-stl->svg stl minx maxx miny maxy)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
092 :dali (dali-stl->svg stl minx maxx miny maxy)
|
||||
094 :dali (dali-stl->svg stl minx maxx miny maxy)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
093 (throw (Exception. "Unexpected renderer value: " *preferred-svg-render*)))))
|
||||
095 (throw (Exception. "Unexpected renderer value: " *preferred-svg-render*)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
094
|
||||
096
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
095 (defn binary-stl-file->svg
|
||||
097 (defn binary-stl-file->svg
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
096 "Given only an `in-filename`, parse the indicated file, expected to be
|
||||
098 "Given only an `in-filename`, parse the indicated file, expected to be
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
097 binary STL, and return an equivalent SVG structure. Given both `in-filename`
|
||||
099 binary STL, and return an equivalent SVG structure. Given both `in-filename`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
098 and `out-filename`, as side-effect write the SVG to the indicated output file."
|
||||
100 and `out-filename`, as side-effect write the SVG to the indicated output file."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
099 ([in-filename]
|
||||
101 ([in-filename]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
100 (stl->svg (cull-ocean-facets (decode-binary-stl in-filename))))
|
||||
102 (stl->svg (cull-ocean-facets (decode-binary-stl in-filename))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
101 ([in-filename out-filename]
|
||||
103 ([in-filename out-filename]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
102 (let [s (binary-stl-file->svg in-filename)]
|
||||
104 (let [s (binary-stl-file->svg in-filename)]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 17 forms covered">
|
||||
103 (l/info "Emitting SVG with " *preferred-svg-render* " renderer")
|
||||
105 (l/info "Emitting SVG with " *preferred-svg-render* " renderer")
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
104 (case *preferred-svg-render*
|
||||
106 (case *preferred-svg-render*
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
105 :dali (neatly-folded-clock/render-svg s out-filename)
|
||||
107 :dali (neatly-folded-clock/render-svg s out-filename)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
106 :hiccup (spit out-filename (html s))
|
||||
108 :hiccup (spit out-filename (html s))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
107 (throw (Exception. "Unexpected renderer value: " *preferred-svg-render*)))
|
||||
109 (throw (Exception. "Unexpected renderer value: " *preferred-svg-render*)))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
108 s)))
|
||||
110 s)))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -17,187 +17,196 @@
|
|||
004 This is in an attempt to avoid name clashes with other uses of this key."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 (:require [clojure.set :refer [difference union]]))
|
||||
005 (:require [clojure.set :refer [difference union]]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [taoensso.timbre :as l]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
007 [walkmap.utils :refer [kind-type]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
006
|
||||
008
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
007 (defn tagged?
|
||||
009 (defn tagged?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 "True if this `object` is tagged with each of these `tags`. It is an error
|
||||
010 "True if this `object` is tagged with each of these `tags`. It is an error
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 (and an exception will be thrown) if
|
||||
011 (and an exception will be thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
010
|
||||
012
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 1. `object` is not a map;
|
||||
013 1. `object` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 2. any of `tags` is not a keyword."
|
||||
014 2. any of `tags` is not a keyword."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 [object & tags]
|
||||
015 [object & tags]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
014 (if
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
016 (when-not (map? object)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
015 (map? object)
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
017 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
016 (if
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
018 (str "Must be a map: " (kind-type object)))))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
017 (every? keyword? tags)
|
||||
019 (let [tags' (flatten tags)]
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
020 (when-not (every? keyword? tags')
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
021 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
022 (str "Must be keywords: " (map kind-type tags')))))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
018 (let [ot (::tags object)]
|
||||
023 (let [ot (::tags object)]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
019 (and
|
||||
024 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
020 (set? ot)
|
||||
025 (set? ot)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
021 (every? ot tags)))
|
||||
026 (every? ot tags')))))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
022 (throw (IllegalArgumentException.
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
027
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
023 (str "Must be keyword(s): " (map type tags)))))
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
028 (defn tag
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
024 (throw (IllegalArgumentException.
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 "Return an object like this `object` but with these `tags` added to its tags,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 if they are not already present. It is an error (and an exception will be
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
032
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 1. `object` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 2. any of `tags` is not a keyword or sequence of keywords.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
035
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 It's legal to include sequences of keywords in `tags`, so that users can do
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 useful things like `(tag obj (map keyword some-strings))`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
038 [object & tags]
|
||||
</span><br/>
|
||||
<span class="covered" title="20 out of 20 forms covered">
|
||||
039 (l/debug "Tagging" (kind-type object) "with" tags)
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
025 (str "Must be a map: " (type object))))))
|
||||
040 (when-not (map? object)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
026
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
041 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
027 (defn tag
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 "Return an object like this `object` but with these `tags` added to its tags,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 if they are not already present. It is an error (and an exception will be
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 thrown) if
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
031
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 1. `object` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 2. any of `tags` is not a keyword."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 [object & tags]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
035 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
036 (map? object)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
037 (if
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
042 (str "Must be a map: " (kind-type object)))))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
038 (every? keyword? tags)
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
039 (assoc object ::tags (union (set tags) (::tags object)))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
040 (throw (IllegalArgumentException.
|
||||
043 (let [tags' (flatten tags)]
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
041 (str "Must be keyword(s): " (map type tags)))))
|
||||
044 (when-not (every? keyword? tags')
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
042 (throw (IllegalArgumentException.
|
||||
045 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
043 (str "Must be a map: " (type object))))))
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
046 (str "Must be keywords: " (map kind-type tags')))))
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
047 (assoc object ::tags (union (set tags') (::tags object)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
044
|
||||
048
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
045 (defmacro tags
|
||||
049 (defmacro tags
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 "Return the tags of this object, if any."
|
||||
050 "Return the tags of this object, if any."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 [object]
|
||||
051 [object]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
048 `(::tags ~object))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
049
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
050 (defn untag
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
051 "Return an object like this `object` but with these `tags` removed from its
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 tags, if present. It is an error (and an exception will be thrown) if
|
||||
052 `(::tags ~object))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
053
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 1. `object` is not a map;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 2. any of `tags` is not a keyword."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 [object & tags]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
057 (if
|
||||
054 (defn untag
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
058 (map? object)
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 "Return an object like this `object` but with these `tags` removed from its
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
059 (if
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 tags, if present. It is an error (and an exception will be thrown) if
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
060 (every? keyword? tags)
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
057
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
061 (assoc object ::tags (difference (::tags object) (set tags)))
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 1. `object` is not a map;
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
062 (throw (IllegalArgumentException.
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 2. any of `tags` is not a keyword or sequence of keywords."
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
063 (str "Must be keywords: " (map type tags)))))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
064 (throw (IllegalArgumentException.
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 [object & tags]
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
065 (str "Must be a map: " (type object))))))
|
||||
061 (when-not (map? object)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
062 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
063 (str "Must be a map: " (kind-type object)))))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
064 (let [tags' (flatten tags)]
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
065 (when-not (every? keyword? tags')
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
066 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
067 (str "Must be keywords: " (map kind-type tags')))))
|
||||
</span><br/>
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
068 (assoc object ::tags (difference (::tags object) (set tags')))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -11,67 +11,127 @@
|
|||
002 "Miscellaneous utility functions."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [clojure.math.numeric-tower :as m]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 [walkmap.path :as p]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 [walkmap.polygon :as q]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 [walkmap.vertex :as v]))
|
||||
003 (:require [clojure.math.numeric-tower :as m]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
007
|
||||
004
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
008 (defn deep-merge
|
||||
005 (defn deep-merge
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 "Recursively merges maps. If vals are not maps, the last value wins."
|
||||
006 "Recursively merges maps. If vals are not maps, the last value wins."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 ;; TODO: not my implementation, not sure I entirely trust it.
|
||||
007 ;; TODO: not my implementation, not sure I entirely trust it.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [& vals]
|
||||
008 ;; TODO TODO: if we are to successfully merge walkmap objects, we must
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
012 (if (every? map? vals)
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 ;; return, on each object, the union of its tags if any.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
013 (apply merge-with deep-merge vals)
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 [& vals]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
014 (last vals)))
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
011 (if (every? map? vals)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
012 (apply merge-with deep-merge vals)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
013 (last vals)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
015
|
||||
014
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
016 (defn vertices
|
||||
015 (defn truncate
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 "If `o` is an object with vertices, return those vertices, else nil."
|
||||
016 "If string `s` is more than `n` characters long, return the first `n`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 [o]
|
||||
017 characters; otherwise, return `s`."
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
019 (cond
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 [s n]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
020 (v/vertex? o) (list o)
|
||||
<span class="not-covered" title="0 out of 21 forms covered">
|
||||
019 (if (and (string? s) (number? n) (> (count s) n))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
021 (q/polygon? o) (:vertices o)
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
020 (subs s 0 n)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
022 (p/path? o) (:vertices o)))
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
021 s))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
023
|
||||
022
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
023 (defn kind-type
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
024 "Identify the type of an `object`, e.g. for logging. If it has a `:kind` key,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
025 it's one of ours, and that's what we want. Otherwise, we want its type; but
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 the type of `nil` is `nil`, which doesn't get printed when assembling error
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 ,essages, so return \"nil\"."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 [object]
|
||||
</span><br/>
|
||||
<span class="partial" title="14 out of 15 forms covered">
|
||||
029 (or (:kind object) (type object) "nil"))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
030
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
031 (defn =ish
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 "True if numbers `n1`, `n2` are roughly equal; that is to say, equal to
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 within `tolerance` (defaults to one part in a million)."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 ([n1 n2]
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
035 (if (and (number? n1) (number? n2))
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
036 (let [m (m/abs (min n1 n2))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
037 t (if (zero? m) 0.000001 (* 0.000001 m))]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
038 (=ish n1 n2 t))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
039 (= n1 n2)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 ([n1 n2 tolerance]
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
041 (if (and (number? n1) (number? n2))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
042 (< (m/abs (- n1 n2)) tolerance)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
043 (= n1 n2))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -26,325 +26,427 @@
|
|||
007 [clojure.string :as s]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
008 [walkmap.geometry :refer [=ish]]))
|
||||
008 [taoensso.timbre :as l]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 [walkmap.utils :refer [=ish kind-type truncate]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
009
|
||||
010
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
010 (defn vertex-key
|
||||
011 (defn vertex-key
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 "Making sure we get the same key everytime we key a vertex with the same
|
||||
012 "Making sure we get the same key everytime we key a vertex with the same
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 coordinates. `o` must have numeric values for `:x`, `:y`, and optionally
|
||||
013 coordinates. `o` must have numeric values for `:x`, `:y`, and optionally
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 `:z`; it is an error and an exception will be thrown if `o` does not
|
||||
014 `:z`; it is an error and an exception will be thrown if `o` does not
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 conform to this specification.
|
||||
015 conform to this specification.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
015
|
||||
016
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 **Note:** these keys can be quite long. No apology is made: it is required
|
||||
017 **Note:** these keys can be quite long. No apology is made: it is required
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 that the same key can *never* refer to two different locations in space."
|
||||
018 that the same key can *never* refer to two different locations in space."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 [o]
|
||||
019 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
019 (keyword
|
||||
020 (keyword
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
020 (s/replace
|
||||
021 (s/replace
|
||||
</span><br/>
|
||||
<span class="partial" title="2 out of 3 forms covered">
|
||||
021 (cond
|
||||
022 (cond
|
||||
</span><br/>
|
||||
<span class="partial" title="15 out of 17 forms covered">
|
||||
022 (and (:x o) (:y o) (:z o))
|
||||
023 (and (:x o) (:y o) (:z o))
|
||||
</span><br/>
|
||||
<span class="covered" title="14 out of 14 forms covered">
|
||||
023 (str "vert_" (:x o) "_" (:y o) "_" (:z o))
|
||||
024 (str "vert_" (:x o) "_" (:y o) "_" (:z o))
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
024 (and (:x o) (:y o))
|
||||
025 (and (:x o) (:y o))
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
025 (str "vert_" (:x o) "_" (:y o))
|
||||
026 (str "vert_" (:x o) "_" (:y o))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
026 :else
|
||||
027 :else
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
027 (throw (IllegalArgumentException.
|
||||
028 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 13 forms covered">
|
||||
028 (subs (str "Not a vertex: " (or o "nil")) 0 80))))
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
029 (truncate (str "Not a vertex: " (or o "nil")) 80))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 "."
|
||||
030 "."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 "-")))
|
||||
031 "-")))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
031
|
||||
032
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
032 (defn vertex?
|
||||
033 (defn vertex?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 "True if `o` satisfies the conditions for a vertex. That is, essentially,
|
||||
034 "True if `o` satisfies the conditions for a vertex. That is, essentially,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 that it must rerpresent a two- or three- dimensional vector. A vertex is
|
||||
035 that it must rerpresent a two- or three- dimensional vector. A vertex is
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 shall be a map having at least the keys `:x` and `:y`, where the value of
|
||||
036 shall be a map having at least the keys `:x` and `:y`, where the value of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 those keys is a number. If the key `:z` is also present, its value must also
|
||||
037 those keys is a number. If the key `:z` is also present, its value must also
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
037 be a number.
|
||||
038 be a number.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
038
|
||||
039
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 The name `vector?` was not used as that would clash with a function of that
|
||||
040 The name `vector?` was not used as that would clash with a function of that
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 name in `clojure.core` whose semantics are entirely different."
|
||||
041 name in `clojure.core` whose semantics are entirely different."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
041 [o]
|
||||
042 [o]
|
||||
</span><br/>
|
||||
<span class="partial" title="23 out of 26 forms covered">
|
||||
042 (and
|
||||
043 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
043 (map? o)
|
||||
044 (map? o)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
044 (:id o)
|
||||
045 (:walkmap.id/id o)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
045 (number? (:x o))
|
||||
046 (number? (:x o))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
046 (number? (:y o))
|
||||
047 (number? (:y o))
|
||||
</span><br/>
|
||||
<span class="covered" title="14 out of 14 forms covered">
|
||||
047 (or (nil? (:z o)) (number? (:z o)))
|
||||
048 (or (nil? (:z o)) (number? (:z o)))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
048 (or (nil? (:kind o)) (= (:kind o) :vertex))))
|
||||
049 (or (nil? (:kind o)) (= (:kind o) :vertex))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
049
|
||||
050
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
050 (defn vertex=
|
||||
051 (defn vertex=
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
051 "True if vertices `v1`, `v2` represent the same vertex."
|
||||
052 "True if vertices `v1`, `v2` represent the same vertex."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 [v1 v2]
|
||||
053 [v1 v2]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
053 (every?
|
||||
054 (every?
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
054 #(=ish (% v1) (% v2))
|
||||
055 #(=ish (% v1) (% v2))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
055 [:x :y :z]))
|
||||
056 [:x :y :z]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
056
|
||||
057
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
057 (defn vertex
|
||||
058 (defn vertex*
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 "Make a vertex with this `x`, `y` and (if provided) `z` values. Returns a map
|
||||
059 "Return a vertex like `v1`, but with each of its coordinates multiplied
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
059 with those values, plus a unique `:id` value, and `:kind` set to `:vertex`.
|
||||
060 by the equivalent vertex in `v2`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
060 It's not necessary to use this function to create a vertex, but the `:id`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 must be present and must be unique."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 ([x y]
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
063 (let [v {:x x :y y :kind :vertex}]
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
064 (assoc v :id (vertex-key v))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
065 ([x y z]
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
066 (let [v (assoc (vertex x y) :z z)]
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
067 (assoc v :id (vertex-key v)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
068
|
||||
061 [v1 v2]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
069 (defn canonicalise
|
||||
062 (if
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
063 (and (vertex? v1) (vertex? v2))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
064 (let [f (fn [v1 v2 coord]
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
065 (* (or (coord v1) 0)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
070 "If `o` is a map with numeric values for `:x`, `:y` and optionally `:z`,
|
||||
066 ;; one here is deliberate!
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 upgrade it to something we will recognise as a vertex."
|
||||
<span class="partial" title="7 out of 8 forms covered">
|
||||
067 (or (coord v2) 1)))]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
073 (if
|
||||
</span><br/>
|
||||
<span class="partial" title="13 out of 17 forms covered">
|
||||
074 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
075 (map? o)
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
068 (assoc v1 :x (f v1 v2 :x)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
076 (number? (:x o))
|
||||
069 :y (f v1 v2 :y)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
077 (number? (:y o))
|
||||
070 :z (f v1 v2 :z)))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
078 (or (nil? (:z o)) (number? (:z o))))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
079 (assoc o :kind :vertex :id (vertex-key o))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
080 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
081 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
082 (subs
|
||||
<span class="not-covered" title="0 out of 15 forms covered">
|
||||
071 (do (l/warn
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
083 (str "Not a proto-vertex: must have numeric `:x` and `:y`: "
|
||||
072 (s/join
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
073 " "
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
074 ["in `vertex-multiply`, both must be vectors. v1:" v1 "v2:" v2]))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
075 v1)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
076
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
077 (defn vertex
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
078 "Make a vertex with this `x`, `y` and (if provided) `z` values. Returns a map
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 with those values, plus a unique `:walkmap.id/id` value, and `:kind` set to `:vertex`.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 It's not necessary to use this function to create a vertex, but the `:walkmap.id/id`
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
081 must be present and must be unique."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 ([x y]
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
083 (let [v {:x x :y y :kind :vertex}]
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
084 (assoc v :walkmap.id/id (vertex-key v))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
085 ([x y z]
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
086 (let [v (assoc (vertex x y) :z z)]
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
087 (assoc v :walkmap.id/id (vertex-key v)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
088
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
089 (defn canonicalise
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 "If `o` is a map with numeric values for `:x`, `:y` and optionally `:z`,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 upgrade it to something we will recognise as a vertex."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
093 (if
|
||||
</span><br/>
|
||||
<span class="partial" title="13 out of 17 forms covered">
|
||||
094 (and
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
095 (map? o)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
096 (number? (:x o))
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
097 (number? (:y o))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
098 (or (nil? (:z o)) (number? (:z o))))
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
099 (assoc o :kind :vertex :walkmap.id/id (vertex-key o))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
100 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
101 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
102 (truncate
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
103 (str "Not a proto-vertex: must have numeric `:x` and `:y`: "
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 6 forms covered">
|
||||
084 (or o "nil"))
|
||||
104 (or o "nil"))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
085 0 80)))))
|
||||
105 80)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
086
|
||||
106
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
087 (def ensure3d
|
||||
107 (def ensure3d
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
088 "Given a vertex `o`, if `o` has a `:z` value, just return `o`; otherwise
|
||||
108 "Given a vertex `o`, if `o` has a `:z` value, just return `o`; otherwise
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
089 return a vertex like `o` but having thie `dflt` value as the value of its
|
||||
109 return a vertex like `o` but having thie `dflt` value as the value of its
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
090 `:z` key, or zero as the value of its `:z` key if `dflt` is not specified.
|
||||
110 `:z` key, or zero as the value of its `:z` key if `dflt` is not specified.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
091
|
||||
111
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
092 If `o` is not a vertex, throws an exception."
|
||||
112 If `o` is not a vertex, throws an exception."
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
093 (memoize
|
||||
113 (memoize
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
094 (fn
|
||||
114 (fn
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
095 ([o]
|
||||
115 ([o]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
096 (ensure3d o 0.0))
|
||||
116 (ensure3d o 0.0))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
097 ([o dflt]
|
||||
117 ([o dflt]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
098 (cond
|
||||
118 (cond
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
099 (not (vertex? o)) (throw
|
||||
119 (not (vertex? o)) (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
100 (IllegalArgumentException.
|
||||
120 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 13 forms covered">
|
||||
101 (subs (str "Not a vertex: " (or o "nil")) 0 80)))
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
121 (truncate (str "Not a vertex: " (or o "nil")) 80)))
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
102 (:z o) o
|
||||
122 (:z o) o
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
103 :else (assoc o :z dflt))))))
|
||||
123 :else (assoc o :z dflt))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
104
|
||||
124
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
105 (def ensure2d
|
||||
125 (def ensure2d
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
106 "If `o` is a vertex, set its `:z` value to zero; else throw an exception."
|
||||
126 "If `o` is a vertex, set its `:z` value to zero; else throw an exception."
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
107 (memoize
|
||||
127 (memoize
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
108 (fn [o]
|
||||
128 (fn [o]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
109 (if
|
||||
129 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
110 (vertex? o)
|
||||
130 (vertex? o)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
111 (assoc o :z 0.0)
|
||||
131 (assoc o :z 0.0)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
112 (throw
|
||||
132 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
113 (IllegalArgumentException.
|
||||
133 (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 13 forms covered">
|
||||
114 (subs (str "Not a vertex: " (or o "nil")) 0 80)))))))
|
||||
<span class="not-covered" title="0 out of 12 forms covered">
|
||||
134 (truncate (str "Not a vertex: " (or o "nil")) 80)))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
135
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
136 (defn within-box?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
137 "True if `target` is within the box defined by `minv` and `maxv`. All
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
138 arguments must be vertices; additionally, both `minv` and `maxv` must
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
139 have `:z` coordinates."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
140 [target minv maxv]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 20 forms covered">
|
||||
141 (when-not (and (vertex? target) (vertex? minv) (vertex? maxv))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
142 (throw (IllegalArgumentException.
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
143 (s/join " " ["Arguments to `within-box?` must be vertices:"
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 7 forms covered">
|
||||
144 (map kind-type [target minv maxv])]))))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
145 (every?
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
146 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 16 forms covered">
|
||||
147 #(< (% minv) (or (% target) 0) (% maxv))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
148 [:x :y :z])))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -31,5 +31,5 @@
|
|||
["uberjar"]
|
||||
["change" "version" "leiningen.release/bump-version"]
|
||||
["vcs" "commit"]]
|
||||
:repl-options {:init-ns walkmap.core}
|
||||
:repl-options {:init-ns walkmap.superstructure}
|
||||
:url "https://simon-brooke.github.io/walkmap/")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(ns walkmap.core
|
||||
(ns walkmap.routing
|
||||
"Finding optimal routes to traverse a map."
|
||||
(:require [walkmap.path :as p]
|
||||
[walkmap.polygon :as q]
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
[org.clojars.smee.binary.core :as b]
|
||||
[taoensso.timbre :as l]
|
||||
[walkmap.edge :as e]
|
||||
[walkmap.ocean :as o]
|
||||
[walkmap.polygon :refer [centre gradient polygon?]]
|
||||
[walkmap.superstructure :refer [store]]
|
||||
[walkmap.tag :refer [tag]]
|
||||
|
|
|
@ -108,9 +108,3 @@
|
|||
:hiccup (spit out-filename (html s))
|
||||
(throw (Exception. "Unexpected renderer value: " *preferred-svg-render*)))
|
||||
s)))
|
||||
|
||||
|
||||
(defn read-svg
|
||||
([file-name]
|
||||
(read-svg file-name nil))
|
||||
([file-name map-kind]
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
(:require [clojure.math.numeric-tower :as m]
|
||||
[clojure.string :as s]
|
||||
[taoensso.timbre :as l]
|
||||
[walkmap.geometry :refer [=ish]]
|
||||
[walkmap.utils :refer [kind-type truncate]]))
|
||||
[walkmap.utils :refer [=ish kind-type truncate]]))
|
||||
|
||||
(defn vertex-key
|
||||
"Making sure we get the same key everytime we key a vertex with the same
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
(ns walkmap.core-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[walkmap.core :refer :all]))
|
||||
|
||||
;; (deftest a-test
|
||||
;; (testing "FIXME, I fail."
|
||||
;; (is (= 0 1))))
|
|
@ -1,6 +1,6 @@
|
|||
(ns walkmap.geometry-test
|
||||
(ns walkmap.utils-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[walkmap.geometry :refer :all]))
|
||||
[walkmap.utils :refer :all]))
|
||||
|
||||
(deftest =ish-tests
|
||||
(testing "Rough equality"
|
Loading…
Reference in a new issue