diff --git a/src/pages/Trip/index.tsx b/src/pages/Trip/index.tsx
index 9bf7fb9..ed416c8 100644
--- a/src/pages/Trip/index.tsx
+++ b/src/pages/Trip/index.tsx
@@ -12,7 +12,6 @@ import MainTripBody from './components/MainTripBody';
import TripCancleOrFinishedButton from './components/TripCancelOrFinishButton';
const DetailTrip = () => {
const intl = useIntl();
- const [responsive, setResponsive] = useState(false);
const [showAlarmList, setShowAlarmList] = useState(true);
const [isLoading, setIsLoading] = useState(false);
const [alarmList, setAlarmList] = useState
([]);
diff --git a/src/services/controller/DeviceController.ts b/src/services/controller/DeviceController.ts
index 957206c..b33608f 100644
--- a/src/services/controller/DeviceController.ts
+++ b/src/services/controller/DeviceController.ts
@@ -3,11 +3,12 @@ import {
API_GET_GPS,
API_PATH_ENTITIES,
API_PATH_SHIP_INFO,
+ API_PATH_SHIP_TRACK_POINTS,
API_SOS,
} from '@/constants';
import { request } from '@umijs/max';
-function transformEntityResponse(
+export function transformEntityResponse(
raw: API.EntityResponse,
): API.TransformedEntity {
return {
@@ -19,7 +20,7 @@ function transformEntityResponse(
};
}
-export async function getEntities(): Promise {
+export async function queryEntities(): Promise {
const rawList = await request(API_PATH_ENTITIES);
return rawList.map(transformEntityResponse);
}
@@ -52,3 +53,7 @@ export async function sendSosMessage(message: string) {
},
});
}
+
+export async function queryShipTrackPoints() {
+ return await request(API_PATH_SHIP_TRACK_POINTS);
+}
\ No newline at end of file
diff --git a/src/services/controller/MapController.ts b/src/services/controller/MapController.ts
index ee0c601..e5e12e9 100644
--- a/src/services/controller/MapController.ts
+++ b/src/services/controller/MapController.ts
@@ -1,4 +1,4 @@
-import { API_GET_ALL_LAYER, API_GET_LAYER_INFO } from '@/constants';
+import { API_GET_ALL_BANZONES, API_GET_ALL_LAYER, API_GET_LAYER_INFO } from '@/constants';
import { request } from '@umijs/max';
export async function getLayer(name: string) {
@@ -8,3 +8,7 @@ export async function getLayer(name: string) {
export async function getAllLayer() {
return request(API_GET_ALL_LAYER);
}
+
+export async function queryBanzones() {
+ return request(API_GET_ALL_BANZONES);
+}
\ No newline at end of file
diff --git a/src/services/controller/typings.d.ts b/src/services/controller/typings.d.ts
index b47ccd3..e6bc058 100644
--- a/src/services/controller/typings.d.ts
+++ b/src/services/controller/typings.d.ts
@@ -124,6 +124,14 @@ declare namespace API {
fishing: boolean;
}
+ interface ShipTrackPoint {
+ time: number;
+ lon: number;
+ lat: number;
+ s: number;
+ h: number;
+ }
+
// Trips
interface FishingGear {
name: string;
@@ -328,4 +336,36 @@ declare namespace API {
evtid?: string;
content?: string;
}
+
+ // Banzone
+ export interface Zone {
+ id?: string;
+ name?: string;
+ type?: number;
+ conditions?: Condition[];
+ enabled?: boolean;
+ updated_at?: Date;
+ geom?: Geom;
+ }
+
+ export interface Condition {
+ max?: number;
+ min?: number;
+ type?: Type;
+ to?: number;
+ from?: number;
+ }
+
+ export enum Type {
+ LengthLimit = 'length_limit',
+ MonthRange = 'month_range',
+ }
+
+ export interface Geom {
+ geom_type?: number;
+ geom_poly?: string;
+ geom_lines?: string;
+ geom_point?: string;
+ geom_radius?: number;
+ }
}
diff --git a/src/utils/geomUtils.ts b/src/utils/geomUtils.ts
new file mode 100644
index 0000000..a092d28
--- /dev/null
+++ b/src/utils/geomUtils.ts
@@ -0,0 +1,76 @@
+export const convertWKTPointToLatLng = (wktString: string) => {
+ if (
+ !wktString ||
+ typeof wktString !== 'string' ||
+ !wktString.startsWith('POINT')
+ ) {
+ return null;
+ }
+
+ const matched = wktString.match(/POINT\s*\(([-\d.]+)\s+([-\d.]+)\)/);
+ if (!matched) return null;
+
+ const lng = parseFloat(matched[1]);
+ const lat = parseFloat(matched[2]);
+
+ return [lng, lat]; // [longitude, latitude]
+};
+export const convertWKTLineStringToLatLngArray = (wktString: string) => {
+ if (
+ !wktString ||
+ typeof wktString !== 'string' ||
+ !wktString.startsWith('LINESTRING')
+ ) {
+ return [];
+ }
+
+ const matched = wktString.match(/LINESTRING\s*\((.*)\)/);
+ if (!matched) return [];
+
+ const coordinates = matched[1].split(',').map((coordStr) => {
+ const [x, y] = coordStr.trim().split(' ').map(Number);
+ return [x, y]; // [lng, lat]
+ });
+
+ return coordinates;
+};
+
+export const convertWKTtoLatLngString = (wktString: string) => {
+ if (
+ !wktString ||
+ typeof wktString !== 'string' ||
+ !wktString.startsWith('MULTIPOLYGON')
+ ) {
+ return [];
+ }
+
+ const matched = wktString.match(/MULTIPOLYGON\s*\(\(\((.*)\)\)\)/);
+ if (!matched) return [];
+
+ const polygons = matched[1]
+ .split(')),((') // chia các polygon
+ .map((polygonStr) =>
+ polygonStr
+ .trim()
+ .split(',')
+ .map((coordStr) => {
+ const [x, y] = coordStr.trim().split(' ').map(Number);
+ return [x, y];
+ }),
+ );
+
+ return polygons;
+};
+
+export const getBanzoneNameByType = (type: number) => {
+ switch (type) {
+ case 1:
+ return 'Cấm đánh bắt';
+ case 2:
+ return 'Cấm di chuyển';
+ case 3:
+ return 'Vùng an toàn';
+ default:
+ return 'Chưa có';
+ }
+};