| 1 | | Advanced Concepts |
| | 1 | == Advanced Concepts |
| | 2 | |
| | 3 | Во оваа фаза од проектот, стандардниот релационен модел е надограден со просторни функционалности преку екстензијата PostGIS. Дополнително, за следење на возилата е имплементирана Lambda архитектура (Hot/Cold складирање) со 4D просторно-временски траектории (LineStringZM). |
| | 4 | |
| | 5 | 1. Иницијализација на PostGIS и конверзија во полигони (Geofencing) |
| | 6 | Првиот чекор вклучува овозможување на PostGIS екстензијата и мигрирање на постоечките координати во geometry објекти. Дополнителна промена е отфрлањето на обичните радиуси за зоните на компаниите. Наместо тоа, користејќи ја функцијата ST_Buffer, кружните области се конвертирани во прецизни полигони со што се овозможува вистинско дигитално надградување. Креирани се и GiST (Generalized Search Tree) индекси кои се потребни за брзо пребарување на просторни податоци. |
| | 7 | |
| | 8 | {{{ |
| | 9 | create extension if not exists postgis schema public; |
| | 10 | |
| | 11 | alter table driver add column location geometry(Point, 4326); |
| | 12 | |
| | 13 | update driver |
| | 14 | set location = st_setsrid(st_makepoint(longitude, latitude), 4326); |
| | 15 | |
| | 16 | alter table request add column start_location geometry(Point, 4326); |
| | 17 | |
| | 18 | alter table request add column end_location geometry(Point, 4326); |
| | 19 | |
| | 20 | update request |
| | 21 | set start_location = st_setsrid(st_makepoint(start_longitude, start_latitude), 4326); |
| | 22 | |
| | 23 | update request |
| | 24 | set end_location = st_setsrid(st_makepoint(end_longitude, end_latitude), 4326); |
| | 25 | |
| | 26 | alter table waypoints add column location geometry(Point, 4326); |
| | 27 | |
| | 28 | update waypoints |
| | 29 | set location = st_setsrid(st_makepoint(longitude, latitude), 4326); |
| | 30 | |
| | 31 | alter table location add column location geometry(Point, 4326); |
| | 32 | |
| | 33 | update location |
| | 34 | set location = st_setsrid(st_makepoint(longitude, latitude), 4326); |
| | 35 | |
| | 36 | alter table report add column location geometry(Point, 4326); |
| | 37 | |
| | 38 | update report |
| | 39 | set location = st_setsrid(st_makepoint(longitude, latitude), 4326); |
| | 40 | |
| | 41 | alter table area add column coverage_polygon geometry(Polygon, 4326); |
| | 42 | |
| | 43 | update area |
| | 44 | set coverage_polygon = ST_Buffer( |
| | 45 | ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography, |
| | 46 | radius |
| | 47 | )::geometry; |
| | 48 | |
| | 49 | create index idx_area_coverage_polygon on area using gist (coverage_polygon); |
| | 50 | |
| | 51 | }}} |