Skip to content

Commit

Permalink
Fix issue #11
Browse files Browse the repository at this point in the history
Eliminate tool doesn't split non-contiguous HRU's
  • Loading branch information
lbross committed Oct 16, 2015
1 parent 7646a80 commit 985b70d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 15 deletions.
12 changes: 12 additions & 0 deletions src/BAGIS_ClassLibrary/ToolsModule.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,18 @@ Public Module ToolsModule
End If
End Function

Public Function BA_MultipartToSinglepart(ByVal inFeatures As String, ByVal outFeatureClass As String) As BA_ReturnCode
Dim tool As MultipartToSinglepart = New MultipartToSinglepart()
tool.in_features = inFeatures
tool.out_feature_class = outFeatureClass
'No snapRasterPath because not a spatial analyst tool
If Execute_Geoprocessing(tool, False, Nothing) = 1 Then
Return BA_ReturnCode.Success
Else
Return BA_ReturnCode.UnknownError
End If
End Function

End Module


28 changes: 21 additions & 7 deletions src/BAGIS_H/RefineHru/FrmEliminatePoly.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/BAGIS_H/RefineHru/FrmEliminatePoly.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
28 changes: 22 additions & 6 deletions src/BAGIS_H/RefineHru/FrmEliminatePoly.vb
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,27 @@ Public Class FrmEliminatePoly
tempm_featureName = m_featureName
End If

'eliminate polygons iteratively
response = BA_CopyFeatures(m_featurePath & "\" & m_featureName, hruOutputPath2 & "\" & tempm_featureName)
'if output layer is contiguous only and input layer was non-contig, explode multi-part polygons before proceeding
Dim parentHruName As LayerListItem = CType(LstSelectHruLayers.SelectedItem, LayerListItem) 'explicit cast
Dim aoi As Aoi = Nothing
Dim hruInputPath As String = BA_GetHruPath(m_aoi.FilePath, PublicPath.HruDirectory, parentHruName.Name)
If CkNonContiguous.Checked = False Then
aoi = BA_LoadHRUFromXml(hruInputPath)
For Each anHru In aoi.HruList
' We found the hru the user selected
If String.Compare(anHru.Name, parentHruName.Name) = 0 Then
'checking to see if input layer was non-contig
If anHru.AllowNonContiguousHru = True Then
' We need to explode the polygons before proceeding
Dim success As BA_ReturnCode = BA_MultipartToSinglepart(m_featurePath & "\" & m_featureName, hruOutputPath2 & "\" & tempm_featureName)
Else
response = BA_CopyFeatures(m_featurePath & "\" & m_featureName, hruOutputPath2 & "\" & tempm_featureName)
End If
End If
Next
Else
response = BA_CopyFeatures(m_featurePath & "\" & m_featureName, hruOutputPath2 & "\" & tempm_featureName)
End If
success2 = BA_AddShapeAreaToAttrib(hruOutputPath2 & "\" & tempm_featureName)
success2 = BA_GetDataStatistics(hruOutputPath2 & "\" & tempm_featureName, BA_FIELD_AREA_SQKM, statResults)
Dim maxiteration As Integer = 3
Expand Down Expand Up @@ -594,10 +613,7 @@ Public Class FrmEliminatePoly
End If
pHru.EliminateProcess = elimProcess

Dim parentHruName As LayerListItem = CType(LstSelectHruLayers.SelectedItem, LayerListItem) 'explicit cast

Dim hruInputPath As String = BA_GetHruPath(m_aoi.FilePath, PublicPath.HruDirectory, parentHruName.Name)
Dim aoi As Aoi = BA_LoadHRUFromXml(hruInputPath)
If aoi Is Nothing Then aoi = BA_LoadHRUFromXml(hruInputPath)
For Each parentHru As Hru In aoi.HruList
' We found the hru the user selected
If String.Compare(parentHru.Name, parentHruName.Name) = 0 Then
Expand Down

0 comments on commit 985b70d

Please sign in to comment.