Skip to content

Commit

Permalink
Deploying to gh-pages from @ b917447 🚀
Browse files Browse the repository at this point in the history
svamaa committed Oct 17, 2024
1 parent 10bf7ab commit 6932498
Showing 7 changed files with 69 additions and 25 deletions.
Binary file modified .doctrees/contrib/data_sources/standard/sources.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -736,32 +736,67 @@ <h1>Source code for pyramid_oereb.contrib.data_sources.standard.sources.plr</h1>
<span class="p">)</span><span class="o">.</span><span class="n">all</span><span class="p">()</span></div>


<div class="viewcode-block" id="DatabaseSource.get_legend_entries_from_db">
<a class="viewcode-back" href="../../../../../../contrib/data_sources/standard/sources.html#pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.get_legend_entries_from_db">[docs]</a>
<span class="k">def</span> <span class="nf">get_legend_entries_from_db</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">session</span><span class="p">,</span> <span class="n">legend_entry_ids</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Retrieves the legend entries for a list of id-values.</span>

<span class="sd"> Args:</span>
<span class="sd"> session (sqlalchemy.orm.Session): The requested clean session instance ready for use</span>
<span class="sd"> legend_entry_ids (list): list of the egend entry ids</span>

<span class="sd"> Returns:</span>
<span class="sd"> list: the query result represented as a list.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">return</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">legend_entry_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">legend_entry_model</span><span class="o">.</span><span class="n">id</span><span class="o">.</span><span class="n">in_</span><span class="p">(</span><span class="n">legend_entry_ids</span><span class="p">))</span><span class="o">.</span><span class="n">all</span><span class="p">()</span></div>


<div class="viewcode-block" id="DatabaseSource.collect_legend_entries_by_bbox">
<a class="viewcode-back" href="../../../../../../contrib/data_sources/standard/sources.html#pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.collect_legend_entries_by_bbox">[docs]</a>
<span class="k">def</span> <span class="nf">collect_legend_entries_by_bbox</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">session</span><span class="p">,</span> <span class="n">bbox</span><span class="p">,</span> <span class="n">law_status</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">collect_legend_entries_by_bbox</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">session</span><span class="p">,</span> <span class="n">bbox</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Extracts all legend entries in the topic which have spatial relation with the passed bounding box of</span>
<span class="sd"> visible extent.</span>

<span class="sd"> Args:</span>
<span class="sd"> session (sqlalchemy.orm.Session): The requested clean session instance ready for use</span>
<span class="sd"> bbox (shapely.geometry.base.BaseGeometry): The bbox to search the records.</span>
<span class="sd"> law_status (str): String of the law status for which the legend entries should be queried.</span>

<span class="sd"> Returns:</span>
<span class="sd"> list: The result of the related geometries unique by the public law restriction id and law status</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">distinct_legend_entry_ids</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># Select the legend entries of all plr within bbox</span>
<span class="n">geometries</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">handle_collection</span><span class="p">(</span><span class="n">session</span><span class="p">,</span> <span class="n">bbox</span><span class="p">)</span><span class="o">.</span><span class="n">options</span><span class="p">(</span>
<span class="n">selectinload</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">Geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="p">)</span>
<span class="p">)</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>

<span class="c1"># Compile a list of unique legend entry ids for each law status</span>
<span class="n">legend_entry_ids</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
<span class="k">for</span> <span class="n">geometry</span> <span class="ow">in</span> <span class="n">geometries</span><span class="p">:</span>
<span class="k">if</span> <span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">legend_entry_id</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">distinct_legend_entry_ids</span> \
<span class="ow">and</span> <span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">law_status</span> <span class="o">==</span> <span class="n">law_status</span><span class="p">:</span>
<span class="n">distinct_legend_entry_ids</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">legend_entry_id</span><span class="p">)</span>
<span class="k">return</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">legend_entry_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">legend_entry_model</span><span class="o">.</span><span class="n">id</span><span class="o">.</span><span class="n">in_</span><span class="p">((</span><span class="n">distinct_legend_entry_ids</span><span class="p">)))</span><span class="o">.</span><span class="n">all</span><span class="p">()</span></div>
<span class="k">if</span> <span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">law_status</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">legend_entry_ids</span><span class="p">:</span>
<span class="n">legend_entry_ids</span><span class="p">[</span><span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">law_status</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
<span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">legend_entry_id</span>
<span class="p">}</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">legend_entry_ids</span><span class="p">[</span><span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">law_status</span><span class="p">]</span><span class="o">.</span><span class="n">add</span><span class="p">(</span>
<span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">legend_entry_id</span>
<span class="p">)</span>

<span class="c1"># Retrieve legend entries</span>
<span class="n">legend_entries_from_db</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">law_status</span> <span class="ow">in</span> <span class="n">legend_entry_ids</span><span class="p">:</span>
<span class="n">legend_entries_from_db</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
<span class="p">[</span>
<span class="bp">self</span><span class="o">.</span><span class="n">get_legend_entries_from_db</span><span class="p">(</span><span class="n">session</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">legend_entry_ids</span><span class="p">[</span><span class="n">law_status</span><span class="p">])),</span>
<span class="n">law_status</span>
<span class="p">]</span>
<span class="p">)</span>

<span class="k">return</span> <span class="n">legend_entries_from_db</span></div>


<div class="viewcode-block" id="DatabaseSource.read">
@@ -801,20 +836,8 @@ <h1>Source code for pyramid_oereb.contrib.data_sources.standard.sources.plr</h1>
<span class="c1"># We found spatially related elements. This means we need to extract the actual plr</span>
<span class="c1"># information related to the found geometries.</span>

<span class="n">law_status_of_geometry</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># get distinct values of law_status for all geometries found</span>
<span class="k">for</span> <span class="n">geometry</span> <span class="ow">in</span> <span class="n">geometry_results</span><span class="p">:</span>
<span class="k">if</span> <span class="p">(</span><span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">law_status</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">law_status_of_geometry</span><span class="p">):</span>
<span class="n">law_status_of_geometry</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">geometry</span><span class="o">.</span><span class="n">public_law_restriction</span><span class="o">.</span><span class="n">law_status</span><span class="p">)</span>

<span class="n">legend_entries_from_db</span> <span class="o">=</span> <span class="p">[]</span>
<span class="c1"># get legend_entries per law_status</span>
<span class="k">for</span> <span class="n">law_status</span> <span class="ow">in</span> <span class="n">law_status_of_geometry</span><span class="p">:</span>
<span class="n">legend_entry_with_law_status</span> <span class="o">=</span> <span class="p">[</span>
<span class="bp">self</span><span class="o">.</span><span class="n">collect_legend_entries_by_bbox</span><span class="p">(</span><span class="n">session</span><span class="p">,</span> <span class="n">bbox</span><span class="p">,</span> <span class="n">law_status</span><span class="p">),</span>
<span class="n">law_status</span>
<span class="p">]</span>
<span class="n">legend_entries_from_db</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">legend_entry_with_law_status</span><span class="p">)</span>
<span class="n">legend_entries_from_db</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">collect_legend_entries_by_bbox</span><span class="p">(</span><span class="n">session</span><span class="p">,</span> <span class="n">bbox</span><span class="p">)</span>

<span class="bp">self</span><span class="o">.</span><span class="n">records</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">geometry_result</span> <span class="ow">in</span> <span class="n">geometry_results</span><span class="p">:</span>
23 changes: 21 additions & 2 deletions contrib/data_sources/standard/sources.html
Original file line number Diff line number Diff line change
@@ -601,15 +601,14 @@

<dl class="py method">
<dt class="sig sig-object py" id="pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.collect_legend_entries_by_bbox">
<span class="sig-name descname"><span class="pre">collect_legend_entries_by_bbox</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">session</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bbox</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">law_status</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/pyramid_oereb/contrib/data_sources/standard/sources/plr.html#DatabaseSource.collect_legend_entries_by_bbox"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.collect_legend_entries_by_bbox" title="Link to this definition"></a></dt>
<span class="sig-name descname"><span class="pre">collect_legend_entries_by_bbox</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">session</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bbox</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/pyramid_oereb/contrib/data_sources/standard/sources/plr.html#DatabaseSource.collect_legend_entries_by_bbox"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.collect_legend_entries_by_bbox" title="Link to this definition"></a></dt>
<dd><p>Extracts all legend entries in the topic which have spatial relation with the passed bounding box of
visible extent.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>session</strong> (<em>sqlalchemy.orm.Session</em>) – The requested clean session instance ready for use</p></li>
<li><p><strong>bbox</strong> (<em>shapely.geometry.base.BaseGeometry</em>) – The bbox to search the records.</p></li>
<li><p><strong>law_status</strong> (<em>str</em>) – String of the law status for which the legend entries should be queried.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
@@ -820,6 +819,26 @@
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.get_legend_entries_from_db">
<span class="sig-name descname"><span class="pre">get_legend_entries_from_db</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">session</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legend_entry_ids</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/pyramid_oereb/contrib/data_sources/standard/sources/plr.html#DatabaseSource.get_legend_entries_from_db"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.get_legend_entries_from_db" title="Link to this definition"></a></dt>
<dd><p>Retrieves the legend entries for a list of id-values.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>session</strong> (<em>sqlalchemy.orm.Session</em>) – The requested clean session instance ready for use</p></li>
<li><p><strong>legend_entry_ids</strong> (<em>list</em>) – list of the egend entry ids</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>the query result represented as a list.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>list</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.handle_collection">
<span class="sig-name descname"><span class="pre">handle_collection</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">session</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">geometry_to_check</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/pyramid_oereb/contrib/data_sources/standard/sources/plr.html#DatabaseSource.handle_collection"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.handle_collection" title="Link to this definition"></a></dt>
4 changes: 3 additions & 1 deletion genindex.html
Original file line number Diff line number Diff line change
@@ -696,10 +696,12 @@ <h2 id="G">G</h2>
<li><a href="core/records.html#pyramid_oereb.core.records.image.ImageRecord.get_extension">get_extension() (pyramid_oereb.core.records.image.ImageRecord static method)</a>
</li>
<li><a href="core/records.html#pyramid_oereb.core.records.view_service.ViewServiceRecord.get_full_wms_url">get_full_wms_url() (pyramid_oereb.core.records.view_service.ViewServiceRecord method)</a>
</li>
<li><a href="contrib/data_sources/standard/models.html#pyramid_oereb.contrib.data_sources.standard.models.get_geometry">get_geometry() (in module pyramid_oereb.contrib.data_sources.standard.models)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="contrib/data_sources/standard/models.html#pyramid_oereb.contrib.data_sources.standard.models.get_geometry">get_geometry() (in module pyramid_oereb.contrib.data_sources.standard.models)</a>
<li><a href="contrib/data_sources/standard/sources.html#pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource.get_legend_entries_from_db">get_legend_entries_from_db() (pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource method)</a>
</li>
<li><a href="contrib/data_sources/standard/models.html#pyramid_oereb.contrib.data_sources.standard.models.get_legend_entry">get_legend_entry() (in module pyramid_oereb.contrib.data_sources.standard.models)</a>
</li>
Binary file modified objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 6932498

Please sign in to comment.