mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
feat(tours): route paddle tours on the water, shaping points and auto-loaded regions
Paddle tours are planned on the water by TREK's own router: a water network per paddle region, built from the same Geofabrik extract as the obstacles and searched in a worker thread of the server (no sidecar). Rivers, canals and lakes (direct or along the shore), portages round weirs, locks by policy, whitewater by boat, gaps marked. Found portages and locks become points of their own; an unplannable leg says why and offers a way out. - Shaping points: a click on the line sets a point that steers the route without being a stop (hikes and paddle tours); recompute a single leg. - Lake style direct/shore, suggested from the wind forecast. - Regions load by themselves where a paddler plans (admin setting: automatic, on request, off; size cap and a daily count), with requests for the admins, a notification, and the load followed on the leg. - Portage from the last point, portages follow footways via the walking router (or stay straight), "put in here" on slipways and put-ins. - MCP plan_paddle_route with the REST route's rules.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { EntityRepositoryType, type Opt, PrimaryKeyProp, defineEntity, p } from '@mikro-orm/core';
|
||||
import { PaddleRegionRequestsRepository } from '../repositories/PaddleRegionRequests.repository';
|
||||
import { DbTimestampType } from '../types';
|
||||
|
||||
export class PaddleRegionRequests {
|
||||
[EntityRepositoryType]?: PaddleRegionRequestsRepository;
|
||||
[PrimaryKeyProp]?: 'region_id';
|
||||
region_id!: string;
|
||||
name!: string;
|
||||
reason!: TPaddleRegionRequestsReason;
|
||||
bytes?: number | null;
|
||||
requested_by?: string | null;
|
||||
requested_at!: string & Opt;
|
||||
declined_at?: string | null;
|
||||
}
|
||||
|
||||
export const PaddleRegionRequestsReason = {
|
||||
ASK: 'ask',
|
||||
TOO_LARGE: 'too_large',
|
||||
LIMIT: 'limit',
|
||||
} as const;
|
||||
|
||||
export type TPaddleRegionRequestsReason = (typeof PaddleRegionRequestsReason)[keyof typeof PaddleRegionRequestsReason];
|
||||
|
||||
export const PaddleRegionRequestsSchema = defineEntity({
|
||||
class: PaddleRegionRequests,
|
||||
repository: () => PaddleRegionRequestsRepository,
|
||||
properties: {
|
||||
region_id: p.text().primary(),
|
||||
name: p.text(),
|
||||
reason: p.enum(() => PaddleRegionRequestsReason),
|
||||
bytes: p.integer().nullable(),
|
||||
requested_by: p.text().nullable(),
|
||||
requested_at: p.type(DbTimestampType).defaultRaw(`CURRENT_TIMESTAMP`),
|
||||
declined_at: p.type(DbTimestampType).nullable(),
|
||||
},
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Collection, EntityRepositoryType, type Opt, defineEntity, p } from '@mikro-orm/core';
|
||||
import { Collection, EntityRepositoryType, type Opt, type Ref, defineEntity, p } from '@mikro-orm/core';
|
||||
import { PaddleRegionsRepository } from '../repositories/PaddleRegions.repository';
|
||||
import { DbTimestampType } from '../types';
|
||||
import { PaddleFeatures } from './PaddleFeatures.entity';
|
||||
import { PaddleWaterGraphs } from './PaddleWaterGraphs.entity';
|
||||
|
||||
export class PaddleRegions {
|
||||
[EntityRepositoryType]?: PaddleRegionsRepository;
|
||||
@@ -18,7 +19,9 @@ export class PaddleRegions {
|
||||
feature_count: number & Opt = 0;
|
||||
error?: string | null;
|
||||
created_at?: string | null;
|
||||
origin: TPaddleRegionsOrigin & Opt = PaddleRegionsOrigin.ADMIN;
|
||||
paddle_features_collection = new Collection<PaddleFeatures>(this);
|
||||
paddle_water_graphs: Ref<PaddleWaterGraphs> | null = null;
|
||||
}
|
||||
|
||||
export const PaddleRegionsStatus = {
|
||||
@@ -30,6 +33,13 @@ export const PaddleRegionsStatus = {
|
||||
|
||||
export type TPaddleRegionsStatus = (typeof PaddleRegionsStatus)[keyof typeof PaddleRegionsStatus];
|
||||
|
||||
export const PaddleRegionsOrigin = {
|
||||
ADMIN: 'admin',
|
||||
AUTO: 'auto',
|
||||
} as const;
|
||||
|
||||
export type TPaddleRegionsOrigin = (typeof PaddleRegionsOrigin)[keyof typeof PaddleRegionsOrigin];
|
||||
|
||||
export const PaddleRegionsSchema = defineEntity({
|
||||
class: PaddleRegions,
|
||||
repository: () => PaddleRegionsRepository,
|
||||
@@ -47,6 +57,8 @@ export const PaddleRegionsSchema = defineEntity({
|
||||
feature_count: p.integer().default(0),
|
||||
error: p.text().nullable(),
|
||||
created_at: p.type(DbTimestampType).nullable().defaultRaw(`CURRENT_TIMESTAMP`),
|
||||
origin: p.enum(() => PaddleRegionsOrigin).default('admin'),
|
||||
paddle_features_collection: () => p.oneToMany(PaddleFeatures).mappedBy('region').hidden(),
|
||||
paddle_water_graphs: () => p.oneToOne(PaddleWaterGraphs).ref().mappedBy('region').hidden(),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { EntityRepositoryType, PrimaryKeyProp, type Ref, defineEntity, p } from '@mikro-orm/core';
|
||||
import { PaddleWaterGraphsRepository } from '../repositories/PaddleWaterGraphs.repository';
|
||||
import { DbTimestampType } from '../types';
|
||||
import { PaddleRegions } from './PaddleRegions.entity';
|
||||
|
||||
export class PaddleWaterGraphs {
|
||||
[EntityRepositoryType]?: PaddleWaterGraphsRepository;
|
||||
[PrimaryKeyProp]?: 'region';
|
||||
region?: Ref<PaddleRegions> | null;
|
||||
region_id?: string | null;
|
||||
file!: string;
|
||||
rev!: string;
|
||||
bytes!: number;
|
||||
built_at!: string;
|
||||
stats!: string;
|
||||
min_lat!: number;
|
||||
min_lng!: number;
|
||||
max_lat!: number;
|
||||
max_lng!: number;
|
||||
}
|
||||
|
||||
export const PaddleWaterGraphsSchema = defineEntity({
|
||||
class: PaddleWaterGraphs,
|
||||
repository: () => PaddleWaterGraphsRepository,
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_paddle_water_graphs_box',
|
||||
properties: ['min_lat', 'max_lat', 'min_lng', 'max_lng'],
|
||||
},
|
||||
],
|
||||
uniques: [{ properties: ['region'] }],
|
||||
properties: {
|
||||
region: () => p.oneToOne(PaddleRegions).primary().ref().deleteRule('cascade').nullable().hidden(),
|
||||
region_id: p.text().nullable().persist(false),
|
||||
file: p.text(),
|
||||
rev: p.text(),
|
||||
bytes: p.integer(),
|
||||
built_at: p.type(DbTimestampType),
|
||||
stats: p.text(),
|
||||
min_lat: p.double(),
|
||||
min_lng: p.double(),
|
||||
max_lat: p.double(),
|
||||
max_lng: p.double(),
|
||||
},
|
||||
});
|
||||
@@ -13,12 +13,16 @@ export class TourWaypoints {
|
||||
sequence!: number;
|
||||
fixed_leg?: string | null;
|
||||
lock?: string | null;
|
||||
shaping: number & Opt = 0;
|
||||
}
|
||||
|
||||
export const TourWaypointsSchema = defineEntity({
|
||||
class: TourWaypoints,
|
||||
repository: () => TourWaypointsRepository,
|
||||
uniques: [{ properties: ['place', 'sequence'] }],
|
||||
checks: [
|
||||
{ name: 'tour_waypoints_shaping_check', expression: 'shaping IN (0, 1)' },
|
||||
],
|
||||
properties: {
|
||||
id: p.integer().primary(),
|
||||
place: () => p.manyToOne(Tours).ref().name('place_id').deleteRule('cascade').hidden(),
|
||||
@@ -29,5 +33,6 @@ export const TourWaypointsSchema = defineEntity({
|
||||
sequence: p.integer(),
|
||||
fixed_leg: p.text().nullable(),
|
||||
lock: p.text().nullable(),
|
||||
shaping: p.integer().default(0),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -33,6 +33,7 @@ export class Tours {
|
||||
paddle_speed_kmh?: number | null;
|
||||
portage_speed_kmh?: number | null;
|
||||
track_marks?: string | null;
|
||||
paddle_lake_style?: TToursPaddleLakeStyle | null;
|
||||
tourTypeRef!: Ref<TourTypes>;
|
||||
tour_obstacle_reviews_collection = new Collection<TourObstacleReviews>(this);
|
||||
tour_sources: Ref<TourSources> | null = null;
|
||||
@@ -63,6 +64,13 @@ export const ToursWaterContext = {
|
||||
|
||||
export type TToursWaterContext = (typeof ToursWaterContext)[keyof typeof ToursWaterContext];
|
||||
|
||||
export const ToursPaddleLakeStyle = {
|
||||
DIRECT: 'direct',
|
||||
SHORE: 'shore',
|
||||
} as const;
|
||||
|
||||
export type TToursPaddleLakeStyle = (typeof ToursPaddleLakeStyle)[keyof typeof ToursPaddleLakeStyle];
|
||||
|
||||
export const ToursSchema = defineEntity({
|
||||
class: Tours,
|
||||
repository: () => ToursRepository,
|
||||
@@ -98,6 +106,7 @@ export const ToursSchema = defineEntity({
|
||||
paddle_speed_kmh: p.double().nullable(),
|
||||
portage_speed_kmh: p.double().nullable(),
|
||||
track_marks: p.text().nullable(),
|
||||
paddle_lake_style: p.enum(() => ToursPaddleLakeStyle).nullable(),
|
||||
tourTypeRef: () => p.manyToOne(TourTypes).ref().joinColumn('tour_type').hidden().index('idx_tours_tour_type'),
|
||||
tour_obstacle_reviews_collection: () => p.oneToMany(TourObstacleReviews).mappedBy('place').hidden(),
|
||||
tour_sources: () => p.oneToOne(TourSources).ref().mappedBy('place').hidden(),
|
||||
|
||||
@@ -62,7 +62,9 @@ import { PackingTemplateCategoriesSchema } from './PackingTemplateCategories.ent
|
||||
import { PackingTemplateItemsSchema } from './PackingTemplateItems.entity';
|
||||
import { PackingTemplatesSchema } from './PackingTemplates.entity';
|
||||
import { PaddleFeaturesSchema } from './PaddleFeatures.entity';
|
||||
import { PaddleRegionRequestsSchema } from './PaddleRegionRequests.entity';
|
||||
import { PaddleRegionsSchema } from './PaddleRegions.entity';
|
||||
import { PaddleWaterGraphsSchema } from './PaddleWaterGraphs.entity';
|
||||
import { PasswordResetTokensSchema } from './PasswordResetTokens.entity';
|
||||
import { PhotoProviderFieldsSchema } from './PhotoProviderFields.entity';
|
||||
import { PhotoProvidersSchema } from './PhotoProviders.entity';
|
||||
@@ -204,7 +206,9 @@ export const ALL_ENTITIES: readonly EntitySchema[] = [
|
||||
PackingTemplateItemsSchema,
|
||||
PackingTemplatesSchema,
|
||||
PaddleFeaturesSchema,
|
||||
PaddleRegionRequestsSchema,
|
||||
PaddleRegionsSchema,
|
||||
PaddleWaterGraphsSchema,
|
||||
PasswordResetTokensSchema,
|
||||
PhotoProviderFieldsSchema,
|
||||
PhotoProvidersSchema,
|
||||
|
||||
Reference in New Issue
Block a user