npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@twpayne/xcscore

v1.0.3

Published

Cross country league scoring for paragliding

Downloads

90

Readme

xcscore

Cross country league flight scoring for paragliding.

Introduction

xcscore computes the highest scoring flight from an array of coords according to the World XContest and Swiss Cross Country Cup rules. It is designed for use in XC flight planning software like XC Planner. It uses crude brute force algorithms that support only a small number of coordinates and is not suitable for scoring flights from GPS tracklogs.

API overview

xcscore exports two functions:

  • scoreWorldXContest for scoring flights according to the World XContest rules.
  • scoreCHCrossCountryCup for scoring flights according to the Swiss Cross Country Cup rules.

Each function takes a single object as an argument with two properties:

  • coords: an array of coordinates.
  • distKMFunc: a function that returns the distance in kilometers between two coordinates.

Each function returns a single object describing the highest scoring flight found with five properties:

  • flightType: the type of the flight, e.g. "openDist", "flatTri", or "faiTri". For a full list of flight types see the documentation.
  • dist: the scoring distance of the flight.
  • multiplier: the scoring multiplier for the type of flight.
  • score: the score of the flight. Note that this is not necessarily equal to the product of dist and multiplier due to rounding rules.
  • coords: the coordinates of the start, up to three turnpoints, and end of the scoring part of the flight.

If no scoring flight can be found (e.g. because there are fewer than two input coords) then the returned object will have flightType "none", dist, multiplier, and score 0, and coords [].

For a full description of the API, consult the documentation in the dist/docs directory.

Performance

xcscore uses simple brute force algorithms for implementation simplicity and minimal code size. CPU usage increases with O(N^5) and memory usage with O(N^2) so xscore is heavily CPU bound.

The package includes benchmarks to measure performance, the results of which depend heavily on the CPU. As a rough guide, 25 coords is fine on any machine (scored in approximately less than 2ms on a single core of a 2014-era MacBook Pro), whereas 50 coords is a reasonable upper limit (taking 60ms on the same machine).

More sophisticated algorithms are used for scoring real GPS tracklogs with tens of thousands of points. Contact the author for details.

Use with popular JavaScript mapping libraries

xcscore is independent of the coordinate format and the function to compute the distance between two coordinates. As such, it can be used with any mapping library.

Google Maps JavaScript API

coords can be an array of google.maps.LatLngs and you can use the following function as distKMFunc:

function distKM(latLng1, latLng2) {
    return google.maps.geometry.spherical.computeDistanceBetween(latLng1, latLng2, 6371);
}

LeafletJS

coords can be an array of LatLngs and you can use the following function as distKMFunc:

function distKM(latLng1, latLng2) {
    return latLng1.distanceTo(latLng2)/1000;
}

License

MIT