Skip to content

Commit

Permalink
Merge pull request #143 from HSLdevcom/development
Browse files Browse the repository at this point in the history
Enable construction profile for routes valid in the future
  • Loading branch information
jhanninen authored Dec 5, 2023
2 parents f518b4b + 34abb63 commit 56a9353
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/geometryMatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const ROUTE_TYPE_PROFILES = {
TRAMBUS: "trambus",
};

const CONSTRUCTION_PROFILE_SUFFIX = "-with-construction";

export const runGeometryMatcher = async (schema = SCHEMA) => {
const startTime = process.hrtime();

Expand Down Expand Up @@ -42,13 +44,18 @@ export const runGeometryMatcher = async (schema = SCHEMA) => {
routeType = "TRAMBUS";
}

const profile = ROUTE_TYPE_PROFILES[routeType];
let profile = ROUTE_TYPE_PROFILES[routeType]

let geometry;
let confidence;
let fittedDataResult;

if (profile) {

// Use construction profile if route is not yet in use (dateBegin is in the future)
if (new Date(shape.properties.date_begin) > new Date()) {
profile += CONSTRUCTION_PROFILE_SUFFIX;
}
// Request fitted geometry from map matcher for the profile
fittedDataResult = await fetch(`${MAP_MATCHER_URL}match/${profile}`, {
method: "POST",
Expand Down

0 comments on commit 56a9353

Please sign in to comment.