From aab7763835c67d1570d07b4e7751d5b253f93cbc Mon Sep 17 00:00:00 2001 From: Hamza Date: Mon, 30 Mar 2026 09:44:40 +0200 Subject: [PATCH] Update Pipline --- Pipline.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Pipline.md b/Pipline.md index 1130fd8..527a8bd 100644 --- a/Pipline.md +++ b/Pipline.md @@ -18,13 +18,13 @@ M --> N[Render in Leaflet] ``` # Why C/C++ -What we're building here is a **GPS Trajectory Reconstruction and Stop-Detection Engine**, engines demand high performance code, it's a critical thing. We could've choose a different approach we could've decided to use Python and call Sklearn library to use **DBSCAN**, then use **OSRM** as **REST API** service, or a different approach integrate **DBSCAN** into TrizDistribution using **Java** then use API calls for **OSRM**. +What we are building is a GPS Trajectory Reconstruction and Stop-Detection Engine, so performance matters. We could use Python with libraries such as Scikit-learn for DBSCAN and call OSRM as a REST service, or use Java for the clustering logic and still call OSRM over HTTP. -The Python approach one seems good, we don't need to implement **DBSCAN** ourselves, well imagine install with your current project an entire additional python interpreter to call an entire library like Skitlearn just for a sake of one algorithm, it's too much resources for a simple thing. Also because we didn't implement the algorithm ourselves we lose control over the implementation, so if you want to implement **T-DBSCAN**, Adaptive eps or any variants, you will either need to use to ask **Sklearn** to implement it for us or we will need to understand how Sklearn is implemented and do it ourselves. +The Python approach is convenient because we do not need to implement DBSCAN ourselves. However, it adds an extra runtime dependency and gives us less control over the implementation. If we need custom behavior such as T-DBSCAN, adaptive eps, or other variants, we may eventually need to reimplement or deeply modify the algorithm anyway. -The Java approach seems good, but Java is not fast of language also due to everything is an object in Java it will cause the engine to run in slower speeds and the existence of Garbage Collector will make us loose performance, also if we want further optimizations like SIMD Java is not going to help, also we want from our engine to be separated from the project so we use the engine in other projects. +The Java approach is also reasonable, but for this engine we want fine-grained control over performance, memory usage, and low-level optimizations such as SIMD and multithreading. We also want the engine to be deployable as a standalone executable and reusable across projects without requiring a JVM or interpreter on the target system. -Using **C/C++** will help us to ingrate **OSRM** easily as of it's built in **C++**, also our engine will take the form of an executable, which makes it portable. Using language like Java/Python will require the system to have JDK or JRE in case of Java, or Interpreter in case of Python, which unnecessary bloat. +Using C/C++ fits this design well because OSRM itself is built in C++, integration is straightforward, and the resulting engine is portable and self-contained. # DBSCAN Clustering (Stop Detection) @@ -123,7 +123,8 @@ Handling gaps is very simple, we take last point from PATH_1, then we take first # Rendering ### Polyline -A polyline in GPS/Maps is a compact way of encoding a series of latitude/longitude points (a path or route) into a short string. It widely used to efficiently transmit route data. +A polyline in GPS and mapping systems is a compact way to encode a sequence of latitude/longitude points into a short string. It is commonly used to reduce payload size and transmit route geometry efficiently. + Normally, a route looks like this: ```json [ @@ -150,10 +151,13 @@ The algorithm: In JS we use `@mapbox/polyline` library: ```js const polyline = require('@mapbox/polyline'); -const encoded = '}_p~F~ps|U_ulLnnqC_mqNvxq`@'; -const decoded = polyline.decode(encoded); -// Render it in leaflet. -L.polyline(decoded); + +const encoded = '}_p~F~ps|U_ulLnnqC_mqNvxq`@'; +// decoded is an array of [lat, lng] pairs +const decoded = polyline.decode(encoded); + +// render it to leaflet map. +L.polyline(decoded).addTo(map); ``` Or you can decode it manuly