Skip to content

Commit

Permalink
updated promoter for edited vbet outputs. 1.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgilbert committed Aug 3, 2017
1 parent 6a1ce7d commit d2a8248
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 12 deletions.
27 changes: 24 additions & 3 deletions Promoter.py
Expand Up @@ -5,7 +5,7 @@
# Author: Jordan Gilbert
#
# Created: 06/2017
# Latest Update: 06/20/2017
# Latest Update: 08/03/2017
# Copyright: (c) Jordan Gilbert 2017
# Licence: This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
# License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
Expand All @@ -15,9 +15,10 @@
import xml.dom.minidom as minidom
import string
import sys
import uuid


def main(projPath, type, realization):
def main(projPath, type, realization, vbetOut):
"""promote a selected realization within a project"""

filepath = projPath + "/project.rs.xml"
Expand Down Expand Up @@ -53,6 +54,25 @@ def main(projPath, type, realization):
if int(rznum) == int(realization):
rzs[x].set("promoted", "True")

# if promoting a vbet project, add in the edited output to the promoted realization
if vbetOut is not None:
analysesNode = rzs[x].find("Analyses")
if analysesNode is None:
analysesNode = ET.SubElement(rzs[x], "Analyses")
analysisNode = analysesNode.find("Analysis")
if analysisNode is None:
analysisNode = ET.SubElement(analysesNode, "Analysis")
outputsNode = analysisNode.find("Outputs")
if outputsNode is None:
outputsNode = ET.SubElement(analysisNode, "Outputs")

vectorNode = ET.SubElement(outputsNode, "Vector")
vectorNode.set("guid", str(uuid.uuid4()).upper())
nameNode = ET.SubElement(vectorNode, "Name")
nameNode.text = "Edited Valley Bottom"
pathNode = ET.SubElement(vectorNode, "Path")
pathNode.text = str(vbetOut[vbetOut.find("02_Analyses"):])

# rewrite the output xml
rough_string = ET.tostring(root, encoding='utf-8', method='xml')
reparsed = minidom.parseString(rough_string)
Expand All @@ -79,4 +99,5 @@ def main(projPath, type, realization):
main(
sys.argv[1],
sys.argv[2],
sys.argv[3])
sys.argv[3],
sys.argv[4])
Binary file modified Promoter.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions RCA.py
Expand Up @@ -312,7 +312,7 @@ def main(
newxml.addMeta("Watershed", hucName, newxml.project)

newxml.addRCARealization("RCA Realization 1", rid="RZ1", dateCreated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
productVersion="1.0.9", guid=getUUID())
productVersion="1.0.10", guid=getUUID())

newxml.addParameter("width_thresh", width_thresh, newxml.RCArealizations[0])

Expand Down Expand Up @@ -375,7 +375,7 @@ def main(
k += 1

exxml.addRCARealization("RCA Realization " + str(k), rid="RZ" + str(k),
dateCreated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), productVersion="1.0.9",
dateCreated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), productVersion="1.0.10",
guid=getUUID())

exxml.addParameter("width_thresh", width_thresh, exxml.RCArealizations[0])
Expand Down
Binary file modified RCA.pyc
Binary file not shown.
19 changes: 17 additions & 2 deletions RCAT.pyt
Expand Up @@ -1026,7 +1026,15 @@ class Promotertool(object):
parameterType="Required",
direction="Input")

return [param0, param1, param2]
param3 = arcpy.Parameter(
displayName="Edited VBET Output",
name="vbetOut",
datatype="DEFeatureClass",
parameterType="Optional",
direction="Input")
param3.filter.list = ["Polygon"]

return [param0, param1, param2, param3]

def isLicensed(self):
"""Set whether tool is licensed to execute."""
Expand All @@ -1036,6 +1044,12 @@ class Promotertool(object):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""

if parameters[1].value == "VBET":
parameters[3].enabled = True
else:
parameters[3].enabled = False

return

def updateMessages(self, parameters):
Expand All @@ -1048,5 +1062,6 @@ class Promotertool(object):
reload(Promoter)
Promoter.main(p[0].valueAsText,
p[1].valueAsText,
p[2].valueAsText)
p[2].valueAsText,
p[3].valueAsText)
return
2 changes: 1 addition & 1 deletion RCAT.pyt.xml
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xml:lang="en"><Esri><CreaDate>20151222</CreaDate><CreaTime>11013900</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><ModDate>20170612</ModDate><ModTime>135328</ModTime></Esri><toolbox name="RCAT" alias="Riparian Area Condition Assessments"><arcToolboxHelpPath>c:\program files (x86)\arcgis\desktop10.4\Help\gp</arcToolboxHelpPath><toolsets/></toolbox><dataIdInfo><idCitation><resTitle>RCAT</resTitle></idCitation></dataIdInfo><distInfo><distributor><distorFormat><formatName>ArcToolbox Toolbox</formatName></distorFormat></distributor></distInfo></metadata>
<metadata xml:lang="en"><Esri><CreaDate>20151222</CreaDate><CreaTime>11013900</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><ModDate>20170803</ModDate><ModTime>104055</ModTime></Esri><toolbox name="RCAT" alias="Riparian Area Condition Assessments"><arcToolboxHelpPath>c:\program files (x86)\arcgis\desktop10.4\Help\gp</arcToolboxHelpPath><toolsets/></toolbox><dataIdInfo><idCitation><resTitle>RCAT</resTitle></idCitation></dataIdInfo><distInfo><distributor><distorFormat><formatName>ArcToolbox Toolbox</formatName></distorFormat></distributor></distInfo></metadata>
4 changes: 2 additions & 2 deletions RVD.py
Expand Up @@ -609,7 +609,7 @@ def main(
newxml.addMeta("Watershed", hucName, newxml.project)

newxml.addRVDRealization("RVD Realization 1", rid="RZ1", dateCreated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
productVersion="1.0.9", guid=getUUID())
productVersion="1.0.10", guid=getUUID())

# add inputs and outputs to xml file
newxml.addProjectInput("Raster", "Existing Vegetation", evt[evt.find("01_Inputs"):], iid="EXVEG1", guid=getUUID())
Expand Down Expand Up @@ -666,7 +666,7 @@ def main(
k += 1

exxml.addRVDRealization("RVD Realization " + str(k), rid="RZ" + str(k),
dateCreated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), productVersion="1.0.9", guid=getUUID())
dateCreated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), productVersion="1.0.10", guid=getUUID())

inputs = exxml.root.find("Inputs")

Expand Down
Binary file modified RVD.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions VBET.py
Expand Up @@ -218,7 +218,7 @@ def main(
newxml.addMeta("Watershed", hucName, newxml.project)

newxml.addVBETRealization("VBET Realization 1", rid="RZ1", dateCreated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
productVersion="1.0.9", guid=getUUID())
productVersion="1.0.10", guid=getUUID())

newxml.addParameter("high_da", high_da_thresh, newxml.VBETrealizations[0])
newxml.addParameter("low_da", low_da_thresh, newxml.VBETrealizations[0])
Expand Down Expand Up @@ -278,7 +278,7 @@ def main(
k += 1

exxml.addVBETRealization("VBET Realization " + str(k), rid="RZ" + str(k), dateCreated=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
productVersion="1.0.9", guid=getUUID())
productVersion="1.0.10", guid=getUUID())

exxml.addParameter("high_da", high_da_thresh, exxml.VBETrealizations[0])
exxml.addParameter("low_da", low_da_thresh, exxml.VBETrealizations[0])
Expand Down
Binary file modified VBET.pyc
Binary file not shown.

0 comments on commit d2a8248

Please sign in to comment.