Building the Future of Maps
A ground-up engineering guide to creating a fully sovereign mapping infrastructure.
Digital Sovereignty
In the age of expensive APIs and data lock-ins, building your own map stack isn't just a technical choice—it's a declaration of Sovereignty. By orchestrating OpenStreetMap, PostGIS, and high-performance tile servers, we eliminate per-view costs and gain absolute control over every pixel.
في عصر واجهات برمجة التطبيقات المكلفة وتقييد البيانات، لا يعد بناء مجموعة أدوات الخرائط الخاصة بك مجرد خيار تقني، بل هو إعلان عن السيادة الرقمية. من خلال تنظيم OpenStreetMap وPostGIS وخوادم البلاطات عالية الأداء، نقوم بإلغاء تكاليف العرض لكل خريطة ونكتسب تحكماً مطلقاً في كل بكسل.
Phase 1: Raw Data Acquisition
Where does the world's map data come from? For this project, we rely on OpenStreetMap (OSM). We obtain high-quality, pre-extracted geographic fragments from Geofabrik.
Why Geofabrik?
Downloading the entire world is 1.6TB. Geofabrik allows us to target specific regions (like Jordan) in the `.osm.pbf` format—a highly compressed binary structure.
من أين تأتي بيانات خرائط العالم؟ في هذا المشروع، نعتمد على OpenStreetMap (OSM). نحصل على قطع جغرافية عالية الجودة ومستخرجة مسبقاً من Geofabrik.
لماذا Geofabrik؟
تحميل العالم بالكامل يزن 1.6 تيرابايت. يسمح لنا Geofabrik باستهداف مناطق معينة (مثل الأردن) بتنسيق `.osm.pbf` - وهو هيكل ثنائي مضغوط للغاية.
Source URL: http://download.geofabrik.de/asia/jordan-latest.osm.pbf
Phase 2: The Spatial Database
Standard databases store text and numbers. A mapping engine needs to store Geometry. We use **PostGIS**, an extension for PostgreSQL that adds support for geographic objects.
The "Why" of PostGIS
PostGIS allows us to perform spatial SQL queries. For example, finding all roads that intersect with a specific park, or calculating the area of a building block instantly.
قواعد البيانات العادية تخزن النصوص والأرقام. أما محرك الخرائط فيحتاج إلى تخزين الهندسة (Geometry). نحن نستخدم **PostGIS**، وهي إضافة لـ PostgreSQL تضيف دعماً للأجسام الجغرافية.
سبب استخدام PostGIS
يسمح لنا PostGIS بإجراء استعلامات SQL مكانية. على سبيل المثال، العثور على جميع الطرق التي تتقاطع مع حديقة معينة، أو حساب مساحة كتلة بناء بشكل فوري.
Phase 3: Data Transformation
To move data from a PBF file into PostGIS, we use osm2pgsql. This isn't just a copy-paste tool; it's a sophisticated translator.
لنقل البيانات من ملف PBF إلى PostGIS، نستخدم osm2pgsql. هذه ليست مجرد أداة نسخ ولصق؛ بل هي مترجم متطور.
osm2pgsql --create --slim --cache 1000 --database map_db --host db jordan-latest.osm.pbf
--create
Initializes a fresh schema. Wipe out old data and start clean.
(AR) لإنشاء مخطط (Schema) جديد تماماً ومسح البيانات القديمة.
--slim
Stores intermediate data on disk. Essential for keeping RAM usage low during complex imports.
(AR) لتخزين البيانات الوسيطة على القرص، مما يحافظ على استهلاك الذاكرة منخفضاً.
--cache
Allocates RAM (1GB here) to the tool. More cache means faster translation from PBF to SQL.
(AR) يخصص ذاكرة وصول عشوائي للأداة. ذاكرة أكبر تعني ترجمة أسرع للبيانات.
Phase 4: Vector Tile Serving
Mapping in 2026 relies on Vector Tiles. Instead of static pictures, we send mathematical geometry to the browser. We use Martin because it generates these tiles dynamically from PostGIS SQL tables.
تعتمد الخرائط في عام 2026 على بلاطات المتجهات (Vector Tiles). بدلاً من الصور الثابتة، نرسل أجزاء هندسية رياضية إلى المتصفح. نستخدم Martin لأنه ينشئ هذه البلاطات ديناميكياً من جداول SQL.
Phase 5: Pathfinding with GraphHopper
Maps are for travel. GraphHopper is our logistics brain. It reads the imported road network and applies Dijkstra-based algorithms to find the fastest path between any two points in Jordan.
الخرائط هي للسفر والتحرك. GraphHopper هو دماغ اللوجستيات الخاص بنا. يقرأ شبكة الطرق المستوردة ويطبق خوارزميات (Dijkstra) للعثور على أسرع مسار بين أي نقطتين في الأردن.
Phase 6: The Full-Stack Bridge
Last, we bridge it all. NestJS provides the secured API proxy, and React + MapLibre GL provides the high-performance visualization layer.
أخيراً، نجمع كل شيء. يوفر NestJS بوابة آمنة (API Proxy)، ويوفر React + MapLibre GL طبقة التصور المرئي عالية الأداء.