Skip to content

feat: support direct lat/lon input to bypass Nominatim geocoding - #233

Open
NieBangyan wants to merge 13 commits into
originalankur:mainfrom
NieBangyan:main
Open

NieBangyan wants to merge 13 commits into
originalankur:mainfrom
NieBangyan:main

Conversation

@NieBangyan

@NieBangyan NieBangyan commented Jun 25, 2026

Copy link
Copy Markdown

Summary

This PR introduces a new feature that allows users to generate map posters using direct latitude/longitude coordinates, bypassing the Nominatim geocoding service entirely.All existing functionality remains fully backward-compatible. The new arguments are optional, so users can still use the old --city/--country workflow without any changes.

Problem

The current implementation relies on Nominatim for geocoding, which can be:

  • Unreliable in certain regions (e.g., China, where the service often times out)
  • Rate-limited for bulk or frequent requests
  • Unavailable offline or in restricted network environments

This limits the tool's usability for users in affected regions and prevents generating posters for locations that Nominatim cannot resolve (e.g., unnamed villages or remote areas).

Solution

  • Added support for --lat and --long arguments to accept direct coordinates.
  • Geocoding bypass: If coordinates are provided, the script skips the Nominatim call entirely and uses them directly.
  • Intelligent fallback: Made --city and --country optional. If missing, the script defaults to using coordinates for the filename and "Unknown" for the country label.
  • Enhanced i18n: The new --display-city and --display-country arguments allow users to override the displayed names, which is especially useful for non-Latin scripts (e.g., Chinese, Korean).

Key Changes

  1. Modified argument validation in create_map_poster.py to allow --city/--country or --lat/--long.
  2. Conditional geocoding logic checks for coordinates first and bypasses get_coordinates() if they exist.
  3. Updated README with new usage examples, including CJK font support and pure coordinate-based generation.
  4. Added sample commands for Chengdu (China) and Seoul (South Korea) to demonstrate the new workflow.

Example Usage

# Using only coordinates (no city/country required)
python create_map_poster.py --lat 27.8940 --long 102.2640 -t warm_beige -d 15000 --display-city "凉山区域" --display-country "中国" --font-family "Noto Sans SC"

# Using coordinates with custom display names
python create_map_poster.py --lat 28.983234 --long 105.092062 -t midnight_blue -d 30000 --display-city "MY HOMETOWN" --display-country "China"

Tested with multiple coordinate pairs, including Chinese cities, and verified that both the new coordinate workflow and the original geocoding workflow work correctly

NieBangyan added 13 commits May 17, 2026 21:48
Updated README.md to include modifications for Chinese localization and network adaptability. Added usage examples and parameter descriptions for generating map posters with latitude and longitude.
Updated README to include modifications for improved functionality in China, emphasizing direct latitude/longitude input and localization features.
Updated README to reflect changes in functionality and usage instructions for generating map posters using latitude and longitude.
Updated the README to clarify changes made to the get_coordinates() function and argument validation.
Added information on map generation using city and country names.
Updated README to reflect new features and usage instructions for map generation.
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.

1 participant