Riverscapes / QRAVEPlugin

QGIS Plugin for viewing Riverscapes projects
GNU General Public License v3.0
0 stars 0 forks source link

Layers cannot have the same name #66

Open MattReimer opened 2 years ago

MattReimer commented 2 years ago

Sometimes we have a case like this in the business logic:

<Children>
  <Node label="Existing Dam Capacity" xpath="Geopackage/Layers/Vector[@id='BRAT_RESULTS']" type="line" symbology="oCC_EX_filtered" id="ex_capacity" filter="&quot;ReachCode&quot;=46006 OR &quot;ReachCode&quot; = 33600 OR &quot;ReachCode&quot; = 55800 " />  
  <Node label="Existing Dam Size" xpath="Geopackage/Layers/Vector[@id='BRAT_RESULTS']" type="line" symbology="mCC_EX_CT_filtered" filter="&quot;ReachCode&quot;=46006 OR &quot;ReachCode&quot; = 33600 OR &quot;ReachCode&quot; = 55800 " />
  <Node label="Historic Dam Capacity" xpath="Geopackage/Layers/Vector[@id='BRAT_RESULTS']" type="line" symbology="oCC_HPE_filtered" id ="his_capacity" filter="&quot;ReachCode&quot;=46006 OR &quot;ReachCode&quot; = 55800 " />
  <Node label="Historic Dam Size" xpath="Geopackage/Layers/Vector[@id='BRAT_RESULTS']" type="line" symbology="mCC_HPE_CT_filtered" filter="&quot;ReachCode&quot;=46006 OR &quot;ReachCode&quot; = 55800 " />
  <Node label="Capacity for Entire Network (overestimate including non-perennial) ">
    <Children>
      <Node label="Existing Dam Capacity" xpath="Geopackage/Layers/Vector[@id='BRAT_RESULTS']" type="line" symbology="oCC_EX"  />
      <Node label="Existing Dam Size" xpath="Geopackage/Layers/Vector[@id='BRAT_RESULTS']" type="line" symbology="mCC_EX_CT"  />
      <Node label="Historic Dam Capacity" xpath="Geopackage/Layers/Vector[@id='BRAT_RESULTS']" type="line" symbology="oCC_HPE" />
      <Node label="Historic Dam Size" xpath="Geopackage/Layers/Vector[@id='BRAT_RESULTS']" type="line" symbology="mCC_HPE_CT"  />
    </Children>
  </Node>
</Children>

In such cases QRave will simply refuse to load the second layer.

It seems like we're name matching the layers when we add them to the map so we should really do something more to make sure we have uniqueness.

For now we'll just tell people not to do this (looking at you @joewheaton)

For the BRAT case I've added " (All)" to the end of each layer name. It's an imperfect fix but it buys us time to solve this on our own schedule for the next version.

joewheaton commented 2 years ago

@MattReimer I just checked some projects in WebRAVE and QRAVE and these "temporary" fixes are forcing the desired behavior for the end-user. I like what you're saying here about this not being the ideal final solution, but for our short term problems, this is great.

Thanks!

joewheaton commented 2 years ago

I thought I posted this, but apparently I did not: https://github.com/Riverscapes/RiverscapesXML/pull/375#issuecomment-964343723

MattReimer commented 2 years ago

This may have a similar solution to ArcRave projects with the same name. https://github.com/Riverscapes/RaveAddIn/issues/175

philipbaileynar commented 2 years ago

FWIW QRiS will never experience this problem because it tags each map layer with the in-memory QRiS object with which it is associated. This allows recursion to then find the map layer by comparing each layer's tag with the same in-memory object. Names are never checked.

The downside of this memory-based matching is that I don't think that we can use QGZ files with QRiS because the QRiS memory addresses will not only change between sessions, but I'm not even sure if QGIS will repopulate these in-memory objects on reload.