Giter Club home page Giter Club logo

haversine-ts's People

Contributors

renovate[bot] avatar vgavara avatar

Watchers

 avatar

haversine-ts's Issues

Support calculation of a destination point given a source point, bearing and distance

Add Haversine class a new method for calculating the coordinates of a destination point given a source point, a bearing and a distance.

Add suitable unit tests and update the documentation accordingly.

Sample:

  /**
   * Calculates the coordinates of a point given an start point, a distance and
   * a bearing
   *
   * @param {DDPoint} startPoint - Start point, in decimal degrees coordinates.
   * @param {number} distance - Distance from the start point to the targetted
   *   point, using as unit of measure that set in the class constructor
   *   (metres, kilometres or miles).
   * @param {number} bearing Bearing to the targetted point, in degrees (0 to
   *   360, clockwise from North).
   */
  getPoint(startPoint: DDPoint, distance: number, bearing: number): DDPoint {
    if (distance < 0)
      throw new Error("Distance out of range: Must be equal of higher than 0");
    if (bearing < 0 || bearing >= 360)
      throw new Error("Bearing out of range: Must be between 0 and < 360");

    const startLatitude = toRadians(startPoint.latitude);
    const startLongitude = toRadians(startPoint.longitude);
    const angularDistance = distance / this.sphereRadius;

    const targetLatitude = Math.asin(
      Math.sin(startLatitude) * Math.cos(angularDistance) +
        Math.cos(startLatitude) * Math.sin(angularDistance) * Math.cos(bearing)
    );
    const targetLongitude =
      startLongitude +
      Math.atan2(
        Math.sin(bearing) * Math.sin(angularDistance) * Math.cos(startLatitude),
        Math.cos(angularDistance) -
          Math.sin(startLatitude) * Math.sin(targetLatitude)
      );

    return new DDPoint(targetLatitude, targetLongitude);
  }

Support finding the nearest/farthest point to a reference one

Add Haversine class a method to find the nearest/farthest point of a list of points to a given reference point:

havesine.getNearest(referencePoint: DDPoint, points: DDPoint[]) => DDPoint
havesine.getFarthest(referencePoint: DDPoint, points: DDPoint[]) => DDPoint

Create haversine class with basic features

Create a Haversine static class supporting the calculation of the distance between two points.
Also create the Point class addressed to hold a sphere point latitude and longitude.

Create repository base

Create the file set needed for developing a typescript library able to be uploaded to NPM as package. The library must contain:

  • Support to linter and prettier, including jsdoc-prettier, on commiting
  • Support to unit tests

Fix coordinates range check

Coordinates range check must be fixed to validate that latitude ranges from -90 to 90 instead of -180 to 180.

This fix must be performed in both DD and DMS point classes

Add support to GitHub PR workflow

Create a GitHub workflow to be run when a PR to master/stable branches was created.
The workflow must build the project and run the tests

Improve the README.md documentation structure

Perform these operations in README.md:

  • Add npm, release and license badges
  • Move the current heading information to a subsection called "About"
  • Keep the current "At a glance" section but convert it into subseciton
  • Create a subsection called "Installation"
  • Create a subsection called "Usage" describing in detail each class
  • Create a subsection called "Support" with a link to the repository issues
  • Create a subsection called "License" including a link to the MIT
  • Create a subsection called "Contact" with the repo owner email and a link to GitHub and LinkedIn.

Give support to NPM integration

Add required files, actions and secrets to allow an automatic deployment to NPM once a pull request was merged on branch stable and tagged.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency eslint to v8.57.0
  • Update dependency prettier to v3.3.1
  • Update dependency prettier-plugin-jsdoc to v1.3.0
  • Update dependency @typescript-eslint/eslint-plugin to v7
  • Update dependency chai to v5
  • Update dependency eslint to v9
  • Update dependency husky to v9
  • Update dependency sinon to v18
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/pull-request.yml
  • actions/checkout v4
  • actions/setup-node v3
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-node v3
npm
package.json
  • @types/chai ^4.3.4
  • @types/mocha ^10.0.0
  • @types/sinon ^10.0.13
  • @typescript-eslint/eslint-plugin ^6.0.0
  • chai ^4.3.7
  • eslint ^8.28.0
  • eslint-config-prettier ^8.5.0
  • eslint-plugin-prettier ^5.0.0
  • husky ^8.0.2
  • lint-staged ^13.0.4
  • mocha ^10.1.0
  • prettier ^3.0.0
  • prettier-plugin-jsdoc ^1.0.0
  • sinon ^16.0.0
  • ts-node ^10.9.1
  • tsconfig-paths ^4.1.0
  • typescript ^4.9.3

  • Check this box to trigger a request for Renovate to run again on this repository

Support searching points in a given radio

Add Haversine class a method (getInRange?) to find those points that are in a given distance range from a reference point:

havesine.getInRange(referencePoint: DDPoint, points: DDPoint[], distance: number) => DDPoint[]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.