Skip to content

Commit f1dc299

Browse files
committed
avoid unrelated changes
1 parent a1fc70e commit f1dc299

File tree

13 files changed

+55
-55
lines changed

13 files changed

+55
-55
lines changed

src/Converters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { GeocodingHit } from '@/api/graphhopper'
2-
import { Coordinate } from '@/utils'
2+
import { Coordinate } from '@/stores/QueryStore'
33

44
export function milliSecondsToText(ms: number) {
55
const hours = Math.floor(ms / 3600000)

src/NavBar.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import Dispatcher from '@/stores/Dispatcher'
33
import { ClearPoints, SelectMapLayer, SetBBox, SetQueryPoints, SetVehicleProfile } from '@/actions/Actions'
44
// import the window like this so that it can be mocked during testing
55
import { window } from '@/Window'
6-
import QueryStore, { QueryPoint, QueryPointType, QueryStoreState } from '@/stores/QueryStore'
6+
import QueryStore, { getBBoxFromCoord, QueryPoint, QueryPointType, QueryStoreState } from '@/stores/QueryStore'
77
import MapOptionsStore, { MapOptionsStoreState } from './stores/MapOptionsStore'
8-
import { getApi } from '@/api/Api'
8+
import { ApiImpl, getApi } from '@/api/Api'
99
import { AddressParseResult } from '@/pois/AddressParseResult'
10-
import { getBBoxFromCoord, getBBoxPoints } from '@/utils'
1110

1211
export default class NavBar {
1312
private readonly queryStore: QueryStore
@@ -159,7 +158,7 @@ export default class NavBar {
159158
const bbox =
160159
initializedPoints.length == 1
161160
? getBBoxFromCoord(initializedPoints[0].coordinate)
162-
: getBBoxPoints(initializedPoints.map(p => p.coordinate))
161+
: ApiImpl.getBBoxPoints(initializedPoints.map(p => p.coordinate))
163162
if (bbox) Dispatcher.dispatch(new SetBBox(bbox))
164163
return Dispatcher.dispatch(new SetQueryPoints(points))
165164
}

src/actions/Actions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Action } from '@/stores/Dispatcher'
2-
import { QueryPoint } from '@/stores/QueryStore'
2+
import { Coordinate, QueryPoint } from '@/stores/QueryStore'
33
import { ApiInfo, Bbox, Path, RoutingArgs, RoutingProfile, RoutingResult } from '@/api/graphhopper'
44
import { PathDetailsPoint } from '@/stores/PathDetailsStore'
55
import { POI } from '@/stores/POIsStore'
66
import { Settings } from '@/stores/SettingsStore'
7-
import { Coordinate } from '@/utils'
87

98
export class InfoReceived implements Action {
109
readonly result: ApiInfo

src/api/Api.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { LineString } from 'geojson'
1818
import { getTranslation, tr } from '@/translation/Translation'
1919
import * as config from 'config'
2020
import { POIQuery } from '@/pois/AddressParseResult'
21+
import { Coordinate } from '@/stores/QueryStore'
2122

2223
interface ApiProfile {
2324
name: string
@@ -455,4 +456,25 @@ export class ApiImpl implements Api {
455456
public static isTruck(profile: string) {
456457
return profile.includes('truck')
457458
}
459+
460+
public static getBBoxPoints(points: Coordinate[]): Bbox | null {
461+
const bbox: Bbox = points.reduce(
462+
(res: Bbox, c) => [
463+
Math.min(res[0], c.lng),
464+
Math.min(res[1], c.lat),
465+
Math.max(res[2], c.lng),
466+
Math.max(res[3], c.lat),
467+
],
468+
[180, 90, -180, -90] as Bbox
469+
)
470+
if (points.length == 1) {
471+
bbox[0] = bbox[0] - 0.001
472+
bbox[1] = bbox[1] - 0.001
473+
bbox[2] = bbox[2] + 0.001
474+
bbox[3] = bbox[3] + 0.001
475+
}
476+
477+
// return null if the bbox is not valid, e.g. if no url points were given at all
478+
return bbox[0] < bbox[2] && bbox[1] < bbox[3] ? bbox : null
479+
}
458480
}

src/map/findNextWayPoint.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { calcDist, Coordinate } from '@/utils'
1+
import { calcDist } from '@/utils'
2+
import { Coordinate } from '@/stores/QueryStore'
23

34
/**
45
* Finds the way-point that follows the part of a route that is closest to a given location

src/pois/AddressParseResult.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { hitToItem } from '@/Converters'
44
import { GeocodingHit, ReverseGeocodingHit } from '@/api/graphhopper'
55
import { tr, Translation } from '@/translation/Translation'
66
import { POI } from '@/stores/POIsStore'
7-
import { getBBoxPoints } from '@/utils'
7+
import { ApiImpl } from '@/api/Api'
88

99
export class AddressParseResult {
1010
location: string
@@ -144,7 +144,7 @@ export class AddressParseResult {
144144
address: res.secondText,
145145
} as POI
146146
})
147-
const bbox = getBBoxPoints(pois.map(p => p.coordinate))
147+
const bbox = ApiImpl.getBBoxPoints(pois.map(p => p.coordinate))
148148
if (bbox) {
149149
if (parseResult.location) Dispatcher.dispatch(new SetBBox(bbox))
150150
Dispatcher.dispatch(new SetPOIs(pois))

src/sidebar/CustomModelExamples.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CustomModel } from '@/utils'
1+
import { CustomModel } from '@/stores/QueryStore'
22

33
export const customModelExamples: { [key: string]: CustomModel } = {
44
default_example: {

src/sidebar/SettingsBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import OffIcon from '@/sidebar/toggle_off.svg'
88
import { useContext } from 'react'
99
import { SettingsContext } from '@/contexts/SettingsContext'
1010
import { RoutingProfile } from '@/api/graphhopper'
11-
import { ProfileGroupMap } from '@/stores/QueryStore'
1211
import * as config from 'config'
12+
import { ProfileGroupMap } from '@/utils'
1313

1414
export default function SettingsBox({ profile }: { profile: RoutingProfile }) {
1515
const settings = useContext(SettingsContext)

src/sidebar/search/routingProfiles/RoutingProfiles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import Chevron from './chevron.svg'
88
import { tr } from '@/translation/Translation'
99
import CustomModelBoxSVG from '@/sidebar/open_custom_model.svg'
1010
import { icons } from '@/sidebar/search/routingProfiles/profileIcons'
11-
import { ProfileGroupMap } from '@/stores/QueryStore'
1211
import * as config from 'config'
12+
import { ProfileGroupMap } from '@/utils'
1313

1414
export default function ({
1515
routingProfiles,

src/stores/QueryStore.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,20 @@ import {
1818
SetQueryPoints,
1919
SetVehicleProfile,
2020
} from '@/actions/Actions'
21-
import { RoutingArgs, RoutingProfile } from '@/api/graphhopper'
22-
import { calcDist, Coordinate, ProfileGroupMap } from '@/utils'
21+
import { Bbox, RoutingArgs, RoutingProfile } from '@/api/graphhopper'
22+
import { calcDist, ProfileGroupMap } from '@/utils'
2323
import config from 'config'
2424
import { customModel2prettyString, customModelExamples } from '@/sidebar/CustomModelExamples'
2525

26+
export interface Coordinate {
27+
lat: number
28+
lng: number
29+
}
30+
31+
export function getBBoxFromCoord(c: Coordinate, offset: number = 0.005): Bbox {
32+
return [c.lng - offset, c.lat - offset, c.lng + offset, c.lat + offset]
33+
}
34+
2635
export interface QueryStoreState {
2736
readonly profiles: RoutingProfile[]
2837
readonly lastProfiles: Record<string, string>
@@ -35,6 +44,13 @@ export interface QueryStoreState {
3544
readonly customModelStr: string
3645
}
3746

47+
export interface CustomModel {
48+
readonly speed?: object[]
49+
readonly priority?: object[]
50+
readonly distance_influence?: number
51+
readonly areas?: object
52+
}
53+
3854
export interface QueryPoint {
3955
readonly coordinate: Coordinate
4056
readonly queryText: string

0 commit comments

Comments
 (0)