Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"permissions": {
"allow": [
"Bash(python create_map_poster.py:*)",
"Bash(source:*)",
"Bash(python:*)",
"Bash(sips -g pixelWidth -g pixelHeight:*)",
"mcp__filesystem__directory_tree",
"mcp__filesystem__list_directory_with_sizes"
]
}
}
62 changes: 52 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,46 @@
cache/*
# Python
*.py[cod]
*$py.class
*.so
*.egg
*.egg-info/
MANIFEST
.Python
.eggs/
.installed.cfg
pip-wheel-metadata/
share/python-wheels/
wheels/
sdist/
develop-eggs/
downloads/
eggs/
lib/
lib64/
parts/
var/
build/
dist/

# Virtual environments
env/
env.bak/
ENV/
.env/
.venv/
venv/
venv.bak/

# Build artifacts
*.egg-info/
dist/
build/
*.pyc
# Caches
__pycache__/
.pytest_cache/
.ipynb_checkpoints/
htmlcov/
.coverage
cache/*
.cache/*
temp/
tmp/

# IDE
.idea/
Expand All @@ -23,13 +52,26 @@ __pycache__/
# OS files
.DS_Store
Thumbs.db
.cache/*
*~

# Jupyter Notebooks
*.ipynb

# Logs
*.log

# Package manager
uv.lock

# Test outputs
test_venv/
htmlcov/
.coverage
.pytest_cache/

# Build artifacts
pyproject.toml.bak

# Generated Posters (keep directory structure but not the files)
posters/**/*.dxf
posters/**/*.png
posters/**/*.svg
# Keep the posters directory itself
!posters/.gitkeep
146 changes: 146 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Kanpur Map Project - Architecture Documentation

## System Architecture Diagram

This diagram visualizes the complete architecture and data flow of the Kanpur Map Project, a Python application that generates minimalist map posters using OpenStreetMap data.

```mermaid
graph TB
subgraph "Entry Points"
A[main.py<br/>Root CLI Wrapper] --> B[create_map_poster.py<br/>Core Application]
CLI[CLI Arguments<br/>city, country, theme,<br/>distance, dimensions] --> B
end

subgraph "Data Fetching Layer"
B --> C[get_coordinates]
C --> D[Nominatim API<br/>Geocoding Service]
D --> E[Latitude, Longitude]

E --> F[OSMnx Data Fetching]
F --> G[Street Network<br/>ox.graph_from_point]
F --> H[Water Features<br/>ox.features_from_point]
F --> I[Park/Green Spaces<br/>ox.features_from_point]
end

subgraph "Theme System"
J[themes/ Directory<br/>17 JSON Themes] --> K[load_theme]
K --> L[Theme Dictionary<br/>bg, text, water,<br/>parks, road colors]
end

subgraph "Rendering Pipeline"
M[create_poster<br/>Main Rendering Function]

G --> N[get_edge_colors_by_type<br/>Road Hierarchy Coloring]
G --> O[get_edge_widths_by_type<br/>Road Width Assignment]

L --> M
H --> M
I --> M
N --> M
O --> M

M --> P[Matplotlib Layers]

P --> P1[Layer 0: Background]
P --> P2[Layer 1: Water Polygons]
P --> P3[Layer 2: Parks Polygons]
P --> P4[Layer 3: Road Network]
P --> P5[Layer 10: Gradient Fades<br/>create_gradient_fade]
P --> P6[Layer 11: Typography<br/>City, Country, Coordinates]
end

subgraph "Road Hierarchy System"
R[OSM Highway Tags]
R --> R1[motorway<br/>Width: 1.2]
R --> R2[primary/trunk<br/>Width: 1.0]
R --> R3[secondary<br/>Width: 0.8]
R --> R4[tertiary<br/>Width: 0.6]
R --> R5[residential<br/>Width: 0.4]

R1 --> N
R2 --> N
R3 --> N
R4 --> N
R5 --> N
end

subgraph "Font Assets"
F1[fonts/Roboto-Bold.ttf]
F2[fonts/Roboto-Regular.ttf]
F3[fonts/Roboto-Light.ttf]
F1 --> P6
F2 --> P6
F3 --> P6
end

subgraph "Output"
P6 --> Q[plt.savefig<br/>300 DPI]
Q --> S[posters/ Directory<br/>{city}_{theme}_{timestamp}.png]
end

subgraph "Dependencies"
T1[osmnx 2.0.7<br/>OSM Data]
T2[matplotlib 3.10.8<br/>Visualization]
T3[geopandas 1.1.2<br/>Geospatial Data]
T4[geopy 2.4.1<br/>Geocoding]

T1 -.-> F
T2 -.-> M
T3 -.-> M
T4 -.-> C
end

style A fill:#e1f5ff
style B fill:#fff9c4
style M fill:#fff9c4
style S fill:#c8e6c9
style J fill:#f8bbd0
style D fill:#e1bee7
style F fill:#e1bee7
style P fill:#ffccbc
```

## Component Overview

### Entry Points
- **main.py**: Simple CLI wrapper that executes Kanpur-specific commands
- **CLI Arguments**: Accepts city, country, theme, distance, and dimension parameters

### Data Fetching Layer
- **Geocoding**: Uses Nominatim API to convert city names to coordinates
- **OSM Data**: Fetches street networks, water features, and parks via OSMnx

### Theme System
- 17 JSON-based themes define visual appearance
- Each theme controls colors for background, text, water, parks, and roads

### Rendering Pipeline
Six distinct layers rendered via matplotlib:
1. **Background**: Theme-based solid color
2. **Water Polygons**: Rivers, lakes, water bodies (z-order: 1)
3. **Park Polygons**: Green spaces, parks (z-order: 2)
4. **Road Network**: Hierarchical road rendering (z-order: 3)
5. **Gradient Fades**: Top/bottom fade effects (z-order: 10)
6. **Typography**: City name, country, coordinates (z-order: 11)

### Road Hierarchy
Five-tier classification based on OSM highway tags:
- **Motorway**: Width 1.2 (highways)
- **Primary/Trunk**: Width 1.0 (major roads)
- **Secondary**: Width 0.8 (secondary roads)
- **Tertiary**: Width 0.6 (local roads)
- **Residential**: Width 0.4 (neighborhood streets)

### Output
- Generated posters saved to `maptoposter/posters/`
- Format: `{city}_{theme}_{timestamp}.png`
- Resolution: 300 DPI
- Customizable dimensions

## Technology Stack
- **Python 3.12**
- **OSMnx**: OpenStreetMap data fetching
- **Matplotlib**: Map visualization
- **GeoPandas**: Geospatial operations
- **Geopy**: Geocoding services
- **NumPy, Pandas, Shapely, NetworkX**: Data processing
83 changes: 83 additions & 0 deletions COMMANDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Kanpur Map Project - Commands Used

This document contains all the commands used to set up the project and generate the Kanpur map.

## 1. Create Project Directory

```bash
# Create the main project directory
mkdir -p kanpur_map_project && cd kanpur_map_project
```

## 2. Create Virtual Environment

```bash
# Create a Python virtual environment
python3 -m venv venv
```

## 3. Clone the Repository

```bash
# Clone the maptoposter repository from GitHub
git clone https://github.com/originalankur/maptoposter.git
```

## 4. Install Dependencies

```bash
# Navigate to the cloned repository and install required packages
cd maptoposter

# Activate the virtual environment
source ../venv/bin/activate

# Install all dependencies from requirements.txt
pip install -r requirements.txt
```

## 5. Generate the Map

```bash
# Generate a map poster of Kanpur, India
# -c: City name
# -C: Country name
# -t: Theme (contrast_zones for urban density visualization)
# -d: Distance/radius in meters (18000m = 18km for large city coverage)
python create_map_poster.py -c "Kanpur" -C "India" -t contrast_zones -d 18000
```

## Output

The generated map is saved in:
```
maptoposter/posters/kanpur_contrast_zones_20260118_223911.png
```

## Additional Theme Options

You can generate maps with different themes by changing the `-t` parameter:

```bash
# List all available themes
python create_map_poster.py --list-themes

# Examples with different themes:
python create_map_poster.py -c "Kanpur" -C "India" -t noir -d 18000
python create_map_poster.py -c "Kanpur" -C "India" -t sunset -d 18000
python create_map_poster.py -c "Kanpur" -C "India" -t japanese_ink -d 18000
```

## Project Structure

```
kanpur_map_project/
├── venv/ # Virtual environment
├── maptoposter/ # Cloned repository
│ ├── create_map_poster.py # Main script
│ ├── requirements.txt # Dependencies
│ ├── themes/ # Theme JSON files
│ ├── fonts/ # Font files
│ └── posters/ # Generated map posters
└── COMMANDS.md # This file
```
Loading