Zakladni verze planovace

This commit is contained in:
Michal Kváček
2024-04-15 18:13:22 +02:00
parent 338ec13db2
commit cee979fec8
15 changed files with 672 additions and 304 deletions
+24 -8
View File
@@ -1,20 +1,36 @@
import gql from "graphql-tag";
export const FRAGMENT_FLIGHT_PLAN_MARKER = gql`
fragment flightPlanMarker on FlightPlanMarker {
name
position
type
gpsLatitude
gpsLongitude
}
`
export const FRAGMENT_FLIGHT_PLAN_FULL_INFO = gql`
fragment flightPlanFullInfo on FlightPlan {
id
name
markers {
name
position
type
gpsLatitude
gpsLongitude
track {
bearing
distance
from {
...flightPlanMarker
}
to {
...flightPlanMarker
}
}
}`;
}
${FRAGMENT_FLIGHT_PLAN_MARKER}
`;
export const FRAGMENT_FLIGHT_PLAN_LIST_INFO = gql`
fragment flightPlanListInfo on FlightPlanListInfo {
fragment flightPlanListInfo on FlightPlan {
id
name
}
+46
View File
@@ -0,0 +1,46 @@
export const useBasicVectorOperations = () => {
const vectorSize = (a) => {
return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2));
}
const vector = (pointA, pointB) => {
return [pointA.gpsLatitude - pointB.gpsLatitude, pointA.gpsLongitude - pointB.gpsLongitude];
}
const vectorDistance = (pointA, pointB) => {
console.log("pointA", pointA, "pointB", pointB);
const u = [pointA.gpsLatitude, pointA.gpsLongitude];
const v = [pointB.gpsLatitude, pointB.gpsLongitude];
// const v = vector(pointB);
return Math.sqrt(
Math.pow(u[0] - v[0], 2) + Math.pow(u[1] - v[1], 2)
);
}
return {vector, vectorSize, vectorDistance}
}
export const useVectorUtities = () => {
function isPointInPolygon(clickPoint, polygonCoords) {
let count = 0;
const x = clickPoint.lng, y = clickPoint.lat;
for (let i = 0; i < polygonCoords.length; i++) {
const iNext = (i + 1) % polygonCoords.length;
const xi = polygonCoords[i].lng, yi = polygonCoords[i].lat;
const xiNext = polygonCoords[iNext].lng, yiNext = polygonCoords[iNext].lat;
const test = ((yi > y) !== (yiNext > y)) && (x < (xiNext - xi) * (y - yi) / (yiNext - yi) + xi);
if (test) count++;
}
return count % 2 === 1; // Lichý počet průsečíků = bod uvnitř
}
return {isPointInPolygon}
}
+3 -3
View File
@@ -2,7 +2,7 @@ import gql from "graphql-tag";
import {FRAGMENT_FLIGHT_PLAN_FULL_INFO} from "src/graphql/fragments/flightPlan";
export const CREATE_FLIGHT_PLAN = gql`
mutation createFlight_Plan($input: CreateFlightPlanInput!) {
mutation createFlightPlan($input: CreateFlightPlanInput!) {
createFlightPlan(input: $input) {
...flightPlanFullInfo
}
@@ -13,8 +13,8 @@ export const CREATE_FLIGHT_PLAN = gql`
export const EDIT_FLIGHT_PLAN = gql`
mutation editFlightPlan($id: Int!, $input: EditFlightPlanInput!) {
editFlight_Plan(id: $id, input: $input) {
...flight_planFullInfo
editFlightPlan(id: $id, input: $input) {
...flightPlanFullInfo
}
}
${FRAGMENT_FLIGHT_PLAN_FULL_INFO}
+11 -1
View File
@@ -1,5 +1,5 @@
import gql from "graphql-tag";
import {FRAGMENT_FLIGHT_PLAN_LIST_INFO} from "src/graphql/fragments/flightPlan";
import {FRAGMENT_FLIGHT_PLAN_FULL_INFO, FRAGMENT_FLIGHT_PLAN_LIST_INFO} from "src/graphql/fragments/flightPlan";
export const FLIGHT_PLANS_LIST = gql`
query flightPlansList {
@@ -10,3 +10,13 @@ query flightPlansList {
${FRAGMENT_FLIGHT_PLAN_LIST_INFO}
`;
export const FLIGHT_PLAN_DETAIL = gql`
query flightPlansDetail($id: Int!) {
flightPlan(id: $id) {
...flightPlanFullInfo
}
}
${FRAGMENT_FLIGHT_PLAN_FULL_INFO}
`;