Skip to content

Cosmetic Improvements Made on the Check Station Locations Dialog#10249

Open
MeSophie wants to merge 5 commits intoIDEMSInternational:masterfrom
MeSophie:LocationPointissue10238
Open

Cosmetic Improvements Made on the Check Station Locations Dialog#10249
MeSophie wants to merge 5 commits intoIDEMSInternational:masterfrom
MeSophie:LocationPointissue10238

Conversation

@MeSophie
Copy link
Contributor

@MeSophie MeSophie commented Mar 3, 2026

Fixes #10238

@rdstern @lilyclements @Ag-Derek @berylwaswa
I made some change on Climatic>Check Data > Check Location Dialog
Please have a look.

I will create another PR on data base to change Location(Optional): to just Location:
@rdstern Here is what I notice with the the first Location receiver it create an intersection with the second Location receiver as we can see on the code

NAME <- data_book$get_columns_from_data(data_name="stations", col_names="NAME", force_as_data_frame=FALSE, use_current_filter=TRUE, drop_unused_filter_levels=FALSE)
NAME_2 <- data_book$get_columns_from_data(data_name="gadm41_BFA_2", col_names="NAME_2", force_as_data_frame=FALSE, use_current_filter=TRUE, drop_unused_filter_levels=FALSE)
stations <- data_book$get_data_frame(data_name="stations", use_current_filter=TRUE, drop_unused_filter_levels=FALSE)
points <- sf::st_as_sf(x=stations, coords=c("long", "lat"), crs=4326, na.fail=FALSE)
gadm41_BFA_2 <- data_book$get_data_frame(data_name="gadm41_BFA_2", use_current_filter=TRUE, drop_unused_filter_levels=FALSE)
intersection <- as.integer(x=sf::st_intersects(x=points$geometry, y=gadm41_BFA_2))
location2 <- NAME == NAME_2[intersection]
data_book$add_columns_to_data(data_name="stations", col_name="location2", col_data=location2, use_col_name_as_prefix=FALSE, before=FALSE)
image

Developer Testing Checklist

  • Runs without errors
  • OK disabled when dialog is incomplete or invalid
  • OK enabled only when required inputs are valid
  • Reset returns dialog to its default/sensible state
  • Invalid inputs are handled cleanly (e.g. negative, too-large, empty, impossible combos)
  • Running twice with different settings behaves consistently (e.g., open → run → close → reopen → change options checked → run again)
  • All AI/bot comments addressed (fixed, intentionally ignored with explanation, or queried)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on improving the user experience and functionality of the 'Check Station Locations' dialog. It includes a minor cosmetic change to a label for clarity and introduces an auto-fill mechanism for key input fields (longitude, latitude, and geometry). These changes aim to streamline the process of selecting spatial data by automatically suggesting relevant columns, reducing manual input and potential errors.

Highlights

  • UI Text Simplification: The 'Location (Optional):' label in the 'Check Station Locations' dialog has been simplified to 'Location:' for improved clarity.
  • Dialog Layout Adjustment: The width of the base control (ucrBase) in the dialog's designer file was slightly increased to accommodate layout changes.
  • Automated Field Population: New functionality has been introduced to automatically populate longitude, latitude, and geometry receiver fields based on recognized column names from selected data frames, streamlining user input.
  • Enhanced Input Validation: The logic for enabling the 'OK' button has been refined, simplifying the conditions for valid input and improving user feedback.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • instat/dlgLocatingPointsInShapeFile.Designer.vb
    • Changed the text of lblShapeFilePolygon from "Location (Optional):" to "Location:".
    • Adjusted the Size property of ucrBase from (405, 52) to (408, 52).
  • instat/dlgLocatingPointsInShapeFile.vb
    • Added Imports RDotNet and Imports System.Text.RegularExpressions for new functionality.
    • Declared new private member variables: bisFilling (Boolean), lstLongReceivers, lstLatReceivers, lstGeometryReceivers (Lists of ucrReceiverSingle), clsGetDataFrame (RFunction), and lstRecognisedTypes (List of KeyValuePair).
    • Modified InitiliseDialog to define recognized column names for longitude, latitude, and geometry, and to add specific receivers to their respective lists.
    • Removed SetDataType("numeric") from ucrReceiverLongitude and ucrReceiverLatitude, and added Tag properties ("lon", "lat", "geometry") to these and ucrReceiverGeometry for auto-filling.
    • Initialized clsGetDataFrame with the R command for get_data_frame.
    • Updated the TestOKEnabled method to simplify the condition for enabling the OK button, specifically removing the check for ucrReceiverStationFilePolygon being empty when ucrReceiverShapeFilePolygon is not.
    • Implemented a new private method AutoFillReceivers to handle the automatic population of receiver controls based on recognized column names.
    • Added event handlers (ControlValueChanged, DataFrameChanged) for ucrSelectorStationFile, ucrReceiverLatitude, ucrReceiverLongitude, ucrSelectorShapeFile, and ucrReceiverGeometry to trigger the AutoFillReceivers logic.
    • Introduced a GetRecognisedValues function to retrieve a list of recognized column names based on a variable tag.
Activity
  • MeSophie created this pull request to address issue Cosmetic improvements to the Check Station Locations dialog #10238.
  • MeSophie provided a detailed description, including a developer testing checklist.
  • MeSophie shared an image demonstrating the UI changes.
  • MeSophie indicated plans for a follow-up PR to change database entries related to 'Location'.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces cosmetic improvements and a new auto-fill feature for the 'Check Station Locations' dialog. While these changes enhance user experience, a critical security vulnerability exists where untrusted data from loaded datasets (data frame and column names) is used to construct R commands without proper sanitization. This could lead to arbitrary R code execution. It is crucial to implement proper escaping for all strings embedded in R commands. The review also focuses on improving the auto-fill logic's readability and performance, and cleaning up dead code.

For Each lviTempVariable As ListViewItem In ucrSelector.lstAvailableVariable.Items
For Each strValue As String In lstRecognisedValues
If Regex.Replace(lviTempVariable.Text.ToLower(), "[^\w]", String.Empty).Equals(strValue) Then
ucrTempReceiver.Add(lviTempVariable.Text, dataFrameName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The AutoFillReceivers method is vulnerable to arbitrary R code execution. Untrusted data frame and column names from the loaded dataset are used to construct R commands without proper sanitization. A malicious dataset could exploit this by crafting names (e.g., containing "); system("...) to execute arbitrary R code. It is crucial to sanitize or escape all data frame and column names (e.g., replacing " with \") before they are used in R command construction. Additionally, for improved readability, consider simplifying this method by replacing the bFound flag and nested loops with a more concise LINQ query using FirstOrDefault to clarify the intent of finding the first matching variable. This might require adding Imports System.Linq.

clsGetDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame")

clsConcFunction.SetRCommand("c")
'clsRemoveFunc.SetRCommand("rm")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out line appears to be dead code. It should be removed to improve code clarity.

Comment on lines +305 to +315
Private Function GetRecognisedValues(strVariable As String) As List(Of String)
Dim lstValues As New List(Of String)

For Each kvpTemp As KeyValuePair(Of String, List(Of String)) In lstRecognisedTypes
If kvpTemp.Key = strVariable Then
lstValues = kvpTemp.Value
Exit For
End If
Next
Return lstValues
End Function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved performance and code clarity, consider using a Dictionary(Of String, List(Of String)) for lstRecognisedTypes instead of a List(Of KeyValuePair(...)). A dictionary provides faster lookups (O(1) on average vs O(n)).

This would require changing the declaration at line 38 to:

Private lstRecognisedTypes As New Dictionary(Of String, List(Of String))

And the initialization at lines 59-63 to:

lstRecognisedTypes.Add("lon", New List(Of String) From {"lon", "long", "LONGITUDE", "lont", "longitude"})
lstRecognisedTypes.Add("lat", New List(Of String) From {"lat", "latitude"})
lstRecognisedTypes.Add("geometry", New List(Of String) From {"geometry"})

Then, this function can be simplified as suggested.

    Private Function GetRecognisedValues(strVariable As String) As List(Of String)
        If lstRecognisedTypes.ContainsKey(strVariable) Then
            Return lstRecognisedTypes(strVariable)
        End If
        Return New List(Of String)()
    End Function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is resolved.

@rdstern
Copy link
Collaborator

rdstern commented Mar 11, 2026

@AmsaleEjigu can you test this pull request from @MeSophie please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cosmetic improvements to the Check Station Locations dialog

2 participants