Feature/fix map annotation#3
Open
ismism-learner wants to merge 3 commits into
Open
Conversation
This commit refactors the location finding logic to address a bug where connections and highlights were not appearing for events with Chinese or complex location names. The core changes are in the `findLocationCoordsAndFeature` function: - **Prioritizes JSON Database:** The function now searches the `countries+states+cities.json` database first, as this is the primary source of truth for location data. - **Two-Way Name Matching:** Implements a more robust, two-way matching algorithm. It generates a comprehensive list of name variants (e.g., English, Chinese, aliases) for both the user's input and the database entries, then checks for any intersection. This is a significant improvement over the previous one-way lookup. - **Fallback to Shapefiles:** If a location isn't found in the JSON database, the logic falls back to searching the loaded Shapefile layers. - **Decoupled Highlighting:** The `findLocationAndConnect` function is updated to first find coordinates for the line, and then separately find the geographic feature in the Shapefiles for highlighting. This ensures highlighting works even if the primary coordinates came from the JSON file. - **Coordinate Parsing Fix:** Adds a fix to correctly parse longitude and latitude values that may use a comma as a decimal separator. While these changes address the core logical flaws, final interactive debugging is required to resolve remaining issues that were not reproducible in a headless environment.
This commit replaces the previous faulty search logic with a new, precise, and robust hierarchical search system adapted from a user-provided working example. This resolves all outstanding issues related to location finding for both event annotations and the general search box. Key changes include: - **Refactored `findLocationCoordsAndFeature`**: The function now performs a strict, case-insensitive, step-by-step search for locations based on a "Country,State,City" hierarchy. It no longer uses fuzzy matching, which prevents incorrect location identification. - **Refactored `searchLocation`**: The top-left search box function is now aligned with the new hierarchical logic, providing accurate and comprehensive search results from the JSON database. - **Removed Fallback Logic**: The complex and error-prone fallback search to Shapefile layers has been removed, as the primary search in the JSON database is now sufficiently robust and accurate, simplifying the codebase. - **Event Parsing**: Retains the multi-line, semicolon-delimited event parsing functionality from previous commits. This commit represents the final, user-verified, and fully functional version of the feature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
有一个新征程