Skip to content

xristp/salamina-map-generator

Repository files navigation

Salamina Custom Map Generator | Γεννήτρια Χαρτών Σαλαμίνας

Python Shapely SVG


Overview | Σχετικά με το Project

[English]
A highly optimized, commercial-ready Python toolset for generating scalable vector graphics (SVG) maps of Salamina island, Greece. It seamlessly merges OpenStreetMap (OSM) base data with custom-defined GeoJSON areas to produce clean, fast-rendering maps ideal for web and print.

[Ελληνικά]
Ένα πλήρως βελτιστοποιημένο, επαγγελματικό εργαλείο σε Python για τη δημιουργία διανυσματικών χαρτών (SVG) της Σαλαμίνας. Ενώνει απρόσκοπτα τα βασικά δεδομένα του OpenStreetMap (OSM) με προσαρμοσμένες περιοχές GeoJSON, παράγοντας "καθαρούς" και γρήγορους χάρτες, ιδανικούς για το διαδίκτυο και για εκτύπωση.


Features | Δυνατότητες

  • High-Performance SVG Output: Uses advanced geometry simplification (Shapely.simplify) and optimized SVG path commands to keep file sizes incredibly small.

  • Smart Label Placement: Employs mathematical representative points (rather than simple centroids) to guarantee that location names always render inside their respective polygon boundaries, regardless of shape concavity.

  • Data Caching: Raw coordinates and OpenStreetMap XML/JSON data are cached locally to prevent API rate-limiting and ensure instant map generation.

  • Dual-Map Generators: Produces both a pure custom area map and a hybrid residential nodes map.

  • Υψηλής Απόδοσης Εξαγωγή SVG: Χρησιμοποιεί προηγμένη απλοποίηση γεωμετρίας και βελτιστοποιημένες εντολές SVG για να διατηρεί τα μεγέθη των αρχείων απίστευτα μικρά.

  • Έξυπνη Τοποθέτηση Ετικετών: Αξιοποιεί μαθηματικά "αντιπροσωπευτικά σημεία" για να εγγυηθεί ότι τα ονόματα των περιοχών εμφανίζονται πάντα μέσα στα όρια του πολυγώνου τους.

  • Αποθήκευση Δεδομένων (Caching): Τα ακατέργαστα δεδομένα του OpenStreetMap αποθηκεύονται τοπικά για άμεση δημιουργία χαρτών χωρίς καθυστερήσεις από το API.

  • Διπλή Γεννήτρια Χαρτών: Παράγει τόσο έναν χάρτη αποκλειστικά με τις προσαρμοσμένες περιοχές, όσο και έναν υβριδικό χάρτη οικισμών.


Project Structure | Δομή Κώδικα

The codebase follows a strict "Single Source of Truth" philosophy, completely free of clutter. (Ο κώδικας ακολουθεί μια αυστηρή δομή χωρίς περιττά αρχεία.)

salaminaa/
├── custom_areas/                     # Minified GeoJSON files for custom map regions
├── fetch_map.py                      # Fetches & caches OSM data via Overpass API
├── generate_custom_map.py            # Generates the primary custom area SVG map
├── generate_residential_map.py       # Generates the residential hybrid SVG map
├── salamina_outline.json             # Cached base island polygon boundary
├── salamina_map_data.json            # Cached OpenStreetMap points/nodes
├── salamina_custom_labeled.svg       # [OUTPUT] Primary Map
├── salamina_residential_labeled.svg  # [OUTPUT] Hybrid Map
└── requirements.txt                  # Python dependencies

Installation | Εγκατάσταση

[English]

  1. Ensure you have Python 3.8+ installed.
  2. Clone or download this repository.
  3. Install the required dependencies:
    pip install -r requirements.txt

[Ελληνικά]

  1. Βεβαιωθείτε ότι έχετε εγκαταστήσει την Python 3.8+.
  2. Κατεβάστε το αποθετήριο.
  3. Εγκαταστήστε τις απαραίτητες βιβλιοθήκες:
    pip install -r requirements.txt

Usage | Χρήση

[English]
To generate or update the maps, simply run the generation scripts. They will automatically read from custom_areas/ and update the SVG files in seconds.

[Ελληνικά]
Για να δημιουργήσετε ή να ενημερώσετε τους χάρτες, απλά "τρέξτε" τα scripts. Θα διαβάσουν αυτόματα τον φάκελο custom_areas/ και θα ανανεώσουν τα αρχεία SVG σε δευτερόλεπτα.

# Generate the Custom Map (salamina_custom_labeled.svg)
python generate_custom_map.py

# Generate the Residential Nodes Map (salamina_residential_labeled.svg)
python generate_residential_map.py

(Note: You only need to run python fetch_map.py if you wish to pull updated underlying map geometries directly from OpenStreetMap).


Adding Custom Areas | Προσθήκη Νέων Περιοχών

[English]

  1. Go to a GeoJSON drawing tool (e.g., geojson.io).
  2. Draw the polygon for your new area.
  3. Export and save it directly into the custom_areas/ directory.
  4. Important: The filename will dictate the label on the map (e.g., Αιάντειο.geojson becomes "Αιάντειο").
  5. Run python generate_custom_map.py.

[Ελληνικά]

  1. Χρησιμοποιήστε ένα εργαλείο σχεδίασης GeoJSON (π.χ., geojson.io).
  2. Σχεδιάστε το πολύγωνο για τη νέα περιοχή.
  3. Εξάγετε το αρχείο και αποθηκεύστε το απευθείας στον φάκελο custom_areas/.
  4. Σημαντικό: Το όνομα του αρχείου θα αποτελέσει την ετικέτα στον χάρτη (π.χ., το Αιάντειο.geojson θα εμφανιστεί ως "Αιάντειο").
  5. Τρέξτε την εντολή python generate_custom_map.py.

Maintenance Notes

  • The geometries are clipped precisely to the island's coastline via shapely boolean intersections (union_poly.intersection(island_boundary)).
  • Unwanted bounding boxes or bounding rectangles accidentally exported from GeoJSON editors are filtered out programmatically to avoid rendering artifacts.
  • minify_geojson.py is an internal concept used to compress JSON files to 6 decimal places, drastically reducing bloat.

About

A highly optimized Python toolset for generating commercial-ready vector (SVG) maps of Salamina, Greece, combining OpenStreetMap data with custom GeoJSON areas.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages