Skip to content

Commit

Permalink
Merge pull request IDEMSInternational#9291 from N-thony/reogrid_shape…
Browse files Browse the repository at this point in the history
…file

Improved the display of shapefile data
  • Loading branch information
Patowhiz authored Dec 18, 2024
2 parents 95db4f7 + 492e7af commit c1c4ed4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
12 changes: 12 additions & 0 deletions instat/UserControls/DataGrid/ReoGrid/ucrDataViewReoGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ Public Class ucrDataViewReoGrid
Dim strData As String = dataFrame.DisplayedData(i, j)
If strData IsNot Nothing AndAlso grdData.CurrentWorksheet.ColumnHeaders.Item(j).Text.Contains("(LT)") Then
strData = GetTransformedLTColumnContents(strData)
ElseIf strData IsNot Nothing AndAlso grdData.CurrentWorksheet.ColumnHeaders.Item(j).Text.Contains("(G)") Then
strData = ShortenString(strData)
grdData.CurrentWorksheet.GetCell(row:=i, col:=j).IsReadOnly = True
End If
grdData.CurrentWorksheet(row:=i, col:=j) = strData
Next
Expand All @@ -111,6 +114,15 @@ Public Class ucrDataViewReoGrid
grdData.CurrentWorksheet.RowHeaderWidth = TextRenderer.MeasureText(strLongestRowHeaderText, Me.Font).Width
End Sub

Private Function ShortenString(strText As String) As String
Dim maxLength As Integer = 30
If strText.Length > maxLength Then
' Trim the string to the specified length and add ellipsis
Return strText.Substring(0, maxLength) & "..."
End If
Return strText
End Function

''' <summary>
''' Transforms contents of LT column(s) that have structured R-like data into a more readable and user-friendly format that is consistent with R Viewer.
''' For example, content like list(Birmingham = list(IATA = c("BHM", NA, NA, NA), Hartford = list(IATA = "BDL", ICAO = "KBDL"))
Expand Down
14 changes: 12 additions & 2 deletions instat/static/InstatObject/R/data_object_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,12 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne
}
if(self$column_selection_applied()) self$remove_current_column_selection()
# Need to use private$data here because changing names of data field
names(private$data)[names(curr_data) == curr_col_name] <- new_col_name
if(any(c("sfc", "sfc_MULTIPOLYGON") %in% class(private$data[[curr_col_name]]))){
# Update the geometry column reference
sf::st_geometry(private$data) <- new_col_name
}
names(private$data)[names(private$data) == curr_col_name] <- new_col_name

self$append_to_variables_metadata(new_col_name, name_label, new_col_name)
# TODO decide if we need to do these 2 lines
self$append_to_changes(list(Renamed_col, curr_col_name, new_col_name))
Expand All @@ -976,7 +981,12 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne
curr_col_names[cols_changed_index] <- new_col_names
if(any(duplicated(curr_col_names))) stop("Cannot rename columns. Column names must be unique.")
if(self$column_selection_applied()) self$remove_current_column_selection()
if(any(c("sfc", "sfc_MULTIPOLYGON") %in% class(private$dataprivate$data)[cols_changed_index])){
# Update the geometry column reference
sf::st_geometry(private$data) <- new_col_names
}
names(private$data)[cols_changed_index] <- new_col_names

for (i in seq_along(cols_changed_index)) {
self$append_to_variables_metadata(new_col_names[i], name_label, new_col_names[i])
}
Expand All @@ -996,11 +1006,11 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne
if (missing(.fn)) stop(.fn, "is missing with no default.")
curr_col_names <- names(curr_data)
private$data <- curr_data |>

dplyr::rename_with(
.fn = .fn,
.cols = {{ .cols }}, ...
)

if(self$column_selection_applied()) self$remove_current_column_selection()
new_col_names <- names(private$data)
if (!all(new_col_names %in% curr_col_names)) {
Expand Down

0 comments on commit c1c4ed4

Please sign in to comment.