Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitelist - gather coordinates for one to many routing #155

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export enum Direction {
Backward
}

export type oneToManyResult = {
export type OneToManyResult = {
duration: number;
distance: number;
};
Expand All @@ -155,7 +155,7 @@ export const oneToMany = async (
one: Coordinates,
many: Coordinates[],
direction: Direction
): Promise<oneToManyResult[]> => {
): Promise<OneToManyResult[]> => {
const dir = direction == Direction.Forward ? 'Forward' : 'Backward';
const response = await fetch('https://europe.motis-project.de/', {
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bookingApiParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { BusStop } from './busStop';
import type { Capacities } from './capacities';
import type { Coordinates } from './location';

export type BookingRequestParameters = {
export type CheckBookingValidityParameters = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type CheckBookingValidityParameters = {
export type WhiteListRequest = {

Man kann dann BlackListRequest als Alias von Whitelist Request definieren.

Terminologie für Anfragen = ...Request
Terminologie für Antworten = ...Response (ggf. hier wieder Typalias BlacklistResponse = WhitelistResponse falls zutreffend

userChosen: Coordinates;
busStops: BusStop[];
startFixed: boolean;
Expand Down
22 changes: 22 additions & 0 deletions src/lib/compositionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@ import type { Capacities } from './capacities';
import type { Interval } from './interval';
import type { Coordinates } from './location';

export type Company = {
id: number;
coordinates: Coordinates;
vehicles: Vehicle[];
zoneId: number;
};

export type Vehicle = {
id: number;
capacities: Capacities;
tours: Tour[];
events: Event[];
availabilities: Interval[];
lastEventBefore: Event | undefined;
firstEventAfter: Event | undefined;
};

export type Tour = {
arrival: Date;
departure: Date;
};

export type Event = {
capacities: Capacities;
is_pickup: boolean;
Expand Down
48 changes: 24 additions & 24 deletions src/routes/api/blacklisting/blacklisting.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BookingRequestParameters } from '$lib/bookingApiParameters';
import type { CheckBookingValidityParameters } from '$lib/bookingApiParameters';
import { Coordinates } from '$lib/location';
import { describe, it, expect, beforeEach } from 'vitest';
import { getViableBusStops } from './viableBusStops';
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('blacklisting test', () => {
await setAvailability(taxi, dateInXMinutes(0), dateInXMinutes(90));
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(90));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -58,7 +58,7 @@ describe('blacklisting test', () => {

await setAvailability(taxi, dateInXMinutes(0), dateInXMinutes(90));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -75,7 +75,7 @@ describe('blacklisting test', () => {

await setTour(taxi, dateInXMinutes(0), dateInXMinutes(90));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -91,7 +91,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [
{ times: [dateInXMinutes(50), dateInXMinutes(10)], coordinates: inNiesky },
Expand All @@ -110,7 +110,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -126,7 +126,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inZittau }],
startFixed: true,
Expand All @@ -142,7 +142,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inZittau,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -158,7 +158,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -174,7 +174,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -190,7 +190,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -206,7 +206,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -219,7 +219,7 @@ describe('blacklisting test', () => {
it('blacklisting fail, no vehicle', async () => {
await addCompany(Zone.NIESKY);

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -230,7 +230,7 @@ describe('blacklisting test', () => {
});

it('blacklisting fail, no company', async () => {
const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -244,7 +244,7 @@ describe('blacklisting test', () => {
const capacities: Capacities = { passengers: 3, bikes: 3, wheelchairs: 3, luggage: 3 };
const company = await addCompany(Zone.NIESKY);
await addTaxi(company, capacities);
const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -260,7 +260,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [
{ times: [dateInXMinutes(50)], coordinates: inZittau },
Expand All @@ -281,7 +281,7 @@ describe('blacklisting test', () => {
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [dateInXMinutes(1000), dateInXMinutes(50)], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -294,7 +294,7 @@ describe('blacklisting test', () => {
});

it('blacklisting, no busStops', async () => {
const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [],
startFixed: true,
Expand All @@ -309,7 +309,7 @@ describe('blacklisting test', () => {
const company = await addCompany(Zone.NIESKY);
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));
const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [
{ times: [], coordinates: inNiesky },
Expand All @@ -329,7 +329,7 @@ describe('blacklisting test', () => {
const company = await addCompany(Zone.NIESKY);
const taxi = await addTaxi(company, capacities);
await setTour(taxi, dateInXMinutes(0), dateInXMinutes(900));
const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [{ times: [], coordinates: inNiesky }],
startFixed: true,
Expand All @@ -346,7 +346,7 @@ describe('blacklisting test', () => {

await setAvailability(taxi, dateInXMinutes(0), dateInXMinutes(90));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [
{
Expand All @@ -368,7 +368,7 @@ describe('blacklisting test', () => {

await setAvailability(taxi, dateInXMinutes(0), dateInXMinutes(90));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [
{
Expand All @@ -390,7 +390,7 @@ describe('blacklisting test', () => {

await setAvailability(taxi, dateInXMinutes(0), dateInXMinutes(90));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [
{ times: [dateInXMinutesYMs(0, -MAX_PASSENGER_WAITING_TIME_PICKUP)], coordinates: inNiesky }
Expand All @@ -409,7 +409,7 @@ describe('blacklisting test', () => {

await setAvailability(taxi, dateInXMinutes(0), dateInXMinutes(90));

const r: BookingRequestParameters = {
const r: CheckBookingValidityParameters = {
userChosen: inNiesky,
busStops: [
{
Expand Down
Loading