Organic Maps
repository·master·Indexed 12 days ago
https://github.com/organicmaps/organicmapsA privacy-first, open-source offline maps and GPS application powered by OpenStreetMap data. Designed for travelers, hikers, and cyclists, it provides offline navigation, contour lines, and track import/export without ads or tracking. The project includes developer documentation for building from source, configuring ICU, and using third-party libraries like Libtess2, Open Location Code, and succinct.
What's inside Organic Maps
- airmaps is a tool for building maps using Apache Airflow. It manages the orchestration of map-building processes through Directed Acyclic Graphs (DAGs).
Overview of Libtess2
masterLibtess2 is a refactored version of the original GLU libtess polygon tesselator and triangulator. It is designed to provide high-quality polygon processing with a significantly improved interface and memory allocation scheme compared to the original GLU implementation.
Key improvements include:
- Performance: Uses a bucketed memory allocator that can improve speed by 15x to 50x depending on the data.
- Memory Management: The API allows users to provide their own allocator or configure the library to run on a predefined chunk of memory to avoid frequent small allocations.
- API Design: The interface is designed to loosely resemble the OpenGL vertex array API, using getter functions to access processed data.
- Output Versatility: The library can output contours, polygons, and connected polygons. The output can also be fed back into the library as input for subsequent runs (e.g., calculating a union of contours before triangulation).
Overview of the Issues Database tool
masterThe Issues Database is a local JSONL mirror of issues from theorganicmaps/organicmapsrepository. It is designed for triage tasks such as detecting duplicate reports, finding already-closed issues, or browsing historical context without repeatedly hitting the GitHub API.Overview of the webcolors library
masterThe
webcolorslibrary provides tools for working with color names and color codes defined by HTML and CSS specifications. It supports conversions between six-digit hexadecimal, three-digit hexadecimal, integerrgb()triplets, and percentagergb()triplets.Supported Formats:
- Six-digit hexadecimal (e.g.,
#0099cc) - Three-digit hexadecimal (e.g.,
#09c) - Integer
rgb()triplets (e.g.,(0, 153, 204)) - Percentage
rgb()triplets (e.g.,(0%, 60%, 80%)) - Predefined color names (e.g.,
white,AliceBlue)
Limitations:
- Does not support
hsl()triplets. - Does not support opacity/alpha-channel information (
rgba()orhsla()). - For HSL conversions, use the Python standard library's
colorsysmodule.
- Six-digit hexadecimal (e.g.,
Understand the Organic Maps directory structure
masterThe Organic Maps repository is organized into several key functional areas: platform-specific UI code, application data, map feature classification, styling assets, translation strings, build tools, and the C++ core engine. Use this overview to locate specific logic or assets for development or customization.Manage application data and map assets
masterThe
data/directory contains the essential files required for the application to function, including map files, styles, and metadata. Key files include:borders/: Polygons describing country borders.countries.json: Map files hierarchy and checksums.countries_meta.txt: Country/region languages and driving sides.hierarchy.txt: Countries/map regions hierarchy, languages, and Wikidata IDs.faq.html: FAQ text for the Help screen.copyright.html: Attributions for 3rd-party libraries, data, icons, and fonts.
Understand the Binary Format and Memory Layout
masterThe JSON is converted into a compact binary format during maps generation. This format is optimized for minimal memory usage and fast UTC $\leftrightarrow$ local conversions.
Logical Binary Structure:
Timezone Header (28 bits $\rightarrow$ 4 bytes):
format_version: 3 bitsgeneration_year_offset: 6 bitsbase_offset: 7 bitsdst_delta: 8 bitstransition_count: 4 bits
Transition Entry (20 bits $\rightarrow$ 3 bytes):
day_delta: 9 bits (days since previous transition)minute_of_day: 11 bits (0–1439)
Comparison: While a full
zoneinfodatabase can be 20–50 KB per timezone, this binary format typically uses only 3–25 bytes per timezone.Kotlin coding standards and detekt rules
masterWhen writing Kotlin, follow these specific rules enforced by the project:
- Naming Conventions: Hungarian notation (using an
mprefix) is forbidden for private properties.- Use
_camelCasefor backing fields. - Use
camelCasefor regular properties.
- Use
- Formatting: Formatting is handled by
ktlint, notdetekt. There is no overlap between the two tools.
- Naming Conventions: Hungarian notation (using an
Configure map features and classification
masterMap feature logic and OSM (OpenStreetMap) mapping are handled via several files:
mapcss-mapping.csv: Maps OSM tags to Organic Maps (OM) types.replaced_tags.txt: Defines how similar OSM tags are merged.mixed_tags.txt: Identifies high-popularity pedestrian streets.editor.config: Configuration for the built-in OSM data editor (defines editable POIs and attributes).config.xsd: XML schema foreditor.config.
Note:
classificator.txtandtypes.txtare automatically generated files representing the hierarchical list of OM types.Understand the C++ Core architecture
masterThe core engine is written in C++ and is organized into several functional modules:
ge0/: The external API of the application.map/: Application business logic and scene management.routing/: In-app routing engine.search/: Ranking and searching classes.indexer/: Processor for map files, classificator, and styles.drape/: The core graphics library.platform/: Platform abstraction (file paths, HTTP, location services).storage/: Map reading functions.geometry/: Geometry primitives.shaders/: Rendering shaders.routing_common/: Shared routing logic.transit/: Experimental GTFS-based public transport support.
Manage strings and translations
masterLocalization is handled through various string files and generated JSON files:
strings/: Primary translation files.categories.txt,categories_cuisines.txt,categories_brands.txt,countries_names.txt: Categorized strings.countries_synonyms.csv: Alternative country names.synonyms.txt: Country/region abbreviations and short names.languages.txt: Native language names.
Automatically generated localization files:
countries-strings/: JSON files for country and map region names.sound-strings/: JSON files for Text-To-Speech.
Understand the libtess2 tesselation algorithm phases
masterThe libtess2 algorithm is a 2D tesselation process that operates on projected 3D data. It follows these five distinct phases:
- Find the polygon normal $N$: Computes a normal vector for the input polygon.
- Project vertices: Projects the 3D vertex data onto a 2D plane. To maintain numerical accuracy, the algorithm projects onto a plane perpendicular to the coordinate axis whose dot product with $N$ is largest.
- Line Sweep: Uses a line-sweep algorithm to partition the plane into $x$-monotone regions. An $x$-monotone region is one where any vertical line intersects it in at most one interval.
- Triangulate: Triangulates the resulting $x$-monotone regions.
- Group: Groups the triangles into strips and fans using a greedy approach.
Note that triangulation is only performed after the line sweep is complete to ensure that vertex merging (caused by numerical errors or degeneracies) is fully accounted for.