Skip to content

Commit

Permalink
Deploying to gh-pages from @ e435503 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
svamaa committed Feb 8, 2024
1 parent 80c3f45 commit 000a2c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ <h1>Source code for pyramid_oereb.contrib.data_sources.standard.sources.plr</h1>
<span class="kn">import</span> <span class="nn">importlib</span>

<span class="kn">from</span> <span class="nn">geoalchemy2.shape</span> <span class="kn">import</span> <span class="n">to_shape</span><span class="p">,</span> <span class="n">from_shape</span>
<span class="kn">from</span> <span class="nn">geoalchemy2.functions</span> <span class="kn">import</span> <span class="n">ST_DWithin</span><span class="p">,</span> <span class="n">ST_Intersects</span>
<span class="kn">from</span> <span class="nn">shapely.geometry</span> <span class="kn">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">LineString</span><span class="p">,</span> <span class="n">Polygon</span><span class="p">,</span> <span class="n">MultiPoint</span><span class="p">,</span> <span class="n">MultiLineString</span><span class="p">,</span> <span class="n">MultiPolygon</span><span class="p">,</span> \
<span class="n">GeometryCollection</span>
<span class="kn">from</span> <span class="nn">sqlalchemy</span> <span class="kn">import</span> <span class="n">text</span><span class="p">,</span> <span class="n">or_</span>
Expand Down Expand Up @@ -638,7 +639,7 @@ <h1>Source code for pyramid_oereb.contrib.data_sources.standard.sources.plr</h1>
<span class="p">]</span>
<span class="n">clause_blocks</span> <span class="o">=</span> <span class="p">[</span>
<span class="n">text</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;ST_Intersects(</span><span class="si">{</span><span class="n">extract</span><span class="si">}</span><span class="s1">, </span><span class="si">{</span><span class="n">geometry_string</span><span class="si">}</span><span class="s1">)&#39;</span><span class="p">)</span> <span class="k">if</span> <span class="n">tolerance</span> <span class="ow">is</span> <span class="kc">None</span>
<span class="k">else</span> <span class="n">text</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;ST_Distance(</span><span class="si">{</span><span class="n">extract</span><span class="si">}</span><span class="s1">, </span><span class="si">{</span><span class="n">geometry_string</span><span class="si">}</span><span class="s1">) &lt; </span><span class="si">{</span><span class="n">tolerance</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="k">else</span> <span class="n">text</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;ST_DWithin(</span><span class="si">{</span><span class="n">extract</span><span class="si">}</span><span class="s1">, </span><span class="si">{</span><span class="n">geometry_string</span><span class="si">}</span><span class="s1">, </span><span class="si">{</span><span class="n">tolerance</span><span class="si">}</span><span class="s1">)&#39;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">extract</span><span class="p">,</span> <span class="n">tolerance</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">([</span><span class="n">extract_point</span><span class="p">,</span> <span class="n">extract_line</span><span class="p">,</span> <span class="n">extract_polygon</span><span class="p">],</span> <span class="n">tolerance_extracts</span><span class="p">)</span>
<span class="p">]</span>
<span class="k">return</span> <span class="n">or_</span><span class="p">(</span><span class="o">*</span><span class="n">clause_blocks</span><span class="p">)</span></div>
Expand Down Expand Up @@ -678,17 +679,28 @@ <h1>Source code for pyramid_oereb.contrib.data_sources.standard.sources.plr</h1>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># The PLR is not problematic at all cause we do not have a collection type here</span>
<span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tolerances</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="s1">&#39;ALL&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tolerances</span><span class="p">):</span>
<span class="n">query</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="o">.</span><span class="n">geom</span><span class="o">.</span><span class="n">ST_Distance</span><span class="p">(</span>
<span class="n">from_shape</span><span class="p">(</span><span class="n">geometry_to_check</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="n">Config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;srid&#39;</span><span class="p">))</span>
<span class="p">)</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tolerances</span><span class="p">[</span><span class="s1">&#39;ALL&#39;</span><span class="p">])</span>
<span class="n">query</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
<span class="n">ST_DWithin</span><span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="o">.</span><span class="n">geom</span><span class="p">,</span>
<span class="n">from_shape</span><span class="p">(</span><span class="n">geometry_to_check</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="n">Config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;srid&#39;</span><span class="p">)),</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_tolerances</span><span class="p">[</span><span class="s1">&#39;ALL&#39;</span><span class="p">]</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="k">elif</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tolerances</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">geometry_to_check</span><span class="o">.</span><span class="n">geom_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tolerances</span><span class="p">):</span>
<span class="n">query</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="o">.</span><span class="n">geom</span><span class="o">.</span><span class="n">ST_Distance</span><span class="p">(</span>
<span class="n">from_shape</span><span class="p">(</span><span class="n">geometry_to_check</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="n">Config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;srid&#39;</span><span class="p">))</span>
<span class="p">)</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tolerances</span><span class="p">[</span><span class="n">geometry_to_check</span><span class="o">.</span><span class="n">geom_type</span><span class="p">])</span>
<span class="n">query</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
<span class="n">ST_DWithin</span><span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="o">.</span><span class="n">geom</span><span class="p">,</span>
<span class="n">from_shape</span><span class="p">(</span><span class="n">geometry_to_check</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="n">Config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;srid&#39;</span><span class="p">)),</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_tolerances</span><span class="p">[</span><span class="n">geometry_to_check</span><span class="o">.</span><span class="n">geom_type</span><span class="p">]</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">query</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="o">.</span><span class="n">geom</span><span class="o">.</span><span class="n">ST_Intersects</span><span class="p">(</span>
<span class="n">from_shape</span><span class="p">(</span><span class="n">geometry_to_check</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="n">Config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;srid&#39;</span><span class="p">))</span>
<span class="p">))</span>
<span class="n">query</span> <span class="o">=</span> <span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
<span class="n">ST_Intersects</span><span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_model_</span><span class="o">.</span><span class="n">geom</span><span class="p">,</span>
<span class="n">from_shape</span><span class="p">(</span><span class="n">geometry_to_check</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="n">Config</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;srid&#39;</span><span class="p">))</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">query</span></div>


Expand Down

0 comments on commit 000a2c2

Please sign in to comment.