This is the documentation of version 1.0.0-rc.4. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Function getCurvyStretchSections

    • Finds the curvy stretches of a route: where curves follow one another closely, such as a mountain pass or a winding country road.

      Parameters

      Returns CurvyStretchSectionProps[]

      The curvy stretches, in order along the route.

      • calculateRoute fills sections.curvyStretch when its sectionTypes names curvyStretch, with these thresholds from its curveDetection.curvyStretch. Call this for others, or over curves you found with your own getCurveSections thresholds.
      • A curve at a maneuver ends a stretch, as CurvyStretchSectionProps sets out.
      • A stretch's curveCount over its lengthInMeters says how winding it is: the hairpins of a mountain pass come one every 200 m or so. Rank the stretches by it to seek out the best roads, or to tell which route stays clear of them. Its hairpinCount says how many of them are hairpins, as isHairpin tells them.
      • Its curvinessScore adds up its curves' scores, so a longer stretch scores more. Roadcurvature.com, which scores roads the same way, lists them from 300 and calls those over 1000 very twisty.
      const routes = await calculateRoute({ locations, costModel: { routeType: 'thrilling' }, guidance: { type: 'coded' } });
      const passes = getCurvyStretchSections(routes.features[0], { minCurveCount: 5 });
      passes.forEach((pass) => console.log(`${pass.curveCount} curves in ${formatDistance(pass.lengthInMeters)}`));

      // The most rewarding stretch to ride
      const best = passes.toSorted((first, second) => second.curvinessScore - first.curvinessScore)[0];