Riverscapes / RaveAddIn

RAVE AddIn for ArcGIS
http://rave.riverscapes.xyz/
GNU General Public License v3.0
1 stars 3 forks source link

View In Warehouse Feature #158

Closed philipbaileynar closed 2 years ago

philipbaileynar commented 2 years ago

I just used the "View in warehouse" feature within QRAVE, by right clicking on the project. It is insanely useful (kudos @MattReimer) and we should implement in ArcRAVE.

MattReimer commented 2 years ago

Behaviour

Not saying Arc needs to do EXACTLY the same stuff but for reference here's what the menu items look like in Q

Root project menu item Screen Shot 2021-10-25 at 2 04 27 PM Layer imported from another project Screen Shot 2021-10-25 at 2 04 04 PM

Couple of caveats:

  1. projects that have not been uploaded will not have the <Warehouse> element so you need to check for existence
  2. You need to hard-code the base url "warehouseUrl": "https://data.riverscapes.xyz/#"
  3. The URL will either be to the current project OR to the project this layer came from. This depends on whether '_rs_wh_id' and '_rs_wh_program' are in the layer's <MetaData

Here's the XML you're reading for the root node:

<?xml version="1.0"?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xml.riverscapes.xyz/Projects/XSD/V1/BRAT.xsd">
  <Name>BRAT for HUC 10190004</Name>
  <ProjectType>BRAT</ProjectType>
  <Warehouse>
    <Meta name="id">f20d6d07-6d2c-4188-bbf4-5d4405ddad4b</Meta>
    <Meta name="user">d6c0ff26-8550-4f80-b9ea-6cc1e70a1c4d</Meta>
    <Meta name="program">Anabranch</Meta>
    <Meta name="tags">TEST,OCT16,WEBRAVE</Meta>
  </Warehouse>

And here's the MEtadata you need for a derivative layer:

        <DEM guid="f2b8255b-656b-4bf0-a7fe-6e3300e91243" id="DEM">
          <Name>NED 10m DEM</Name>
          <Path>inputs/dem.tif</Path>
          <MetaData>
            <Meta name="_rs_wh_id">e84e1f3f-b3cc-4133-a348-ec0cdc7024c9</Meta>
            <Meta name="_rs_wh_program">Anabranch</Meta>
           <Meta name="_rs_OTHERSTUFF">...etc</Meta>
          </MetaData>
        </DEM>

FYI here's the python code that does this in case it helps:

    def get_warehouse_url(self, wh_meta: Dict[str, str]):

        if wh_meta is not None:
            # if this is not a derivative layer then you're looking for the <Warehouse> tag at the root of the <Project> node
            if 'program' in wh_meta and 'id' in wh_meta:
                return '/'.join([CONSTANTS['warehouseUrl'], wh_meta['program'][0], wh_meta['id'][0]])

            # If this is a derivative layer (like DEM) then the URL you need to build is not to THIS project but rather
            # to the parent project from which this program came. So a VBET project's DEM.tif link will be to the RSContext
            # project
            elif '_rs_wh_id' in wh_meta and '_rs_wh_program' in wh_meta:
                return '/'.join([CONSTANTS['warehouseUrl'], wh_meta['_rs_wh_program'][0], wh_meta['_rs_wh_id'][0]])

        return None
philipbaileynar commented 2 years ago

Fixed via last commit

MattReimer commented 2 years ago

@philipbaileynar I see the code for the project-level part of this but not for the layer-level part. Are we including that in ArcRave?

philipbaileynar commented 2 years ago

Was already implemented. Tested. Works.