Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor out _calculateAngle method #260

Closed
6 tasks
sashadev-sky opened this issue May 15, 2019 · 8 comments
Closed
6 tasks

Refactor out _calculateAngle method #260

sashadev-sky opened this issue May 15, 2019 · 8 comments

Comments

@sashadev-sky
Copy link
Member

First Time?

This is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

We know that the process of creating a pull request is the biggest barrier for new contributors. This issue is for you 💝

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

🤔 What you will need to know.

Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.

The problem

We rewrite the same function, _calculateAngle in a few of our files for each new "handle" class to have. Instead, we can define this function on L.EditHandle, the common class the other handle classes extend, and it will be available to all of them.

Solution

Where to find the relevant lines of code:

Delete the _calculateAngle function from the following files:

/* Takes two latlngs and calculates the angle between them. */
_calculateAngle: function(latlngA, latlngB) {
var map = this._handled._map,
centerPoint = map.latLngToLayerPoint(this._handled.getCenter()),
formerPoint = map.latLngToLayerPoint(latlngA),
newPoint = map.latLngToLayerPoint(latlngB),
initialAngle = Math.atan2(centerPoint.y - formerPoint.y, centerPoint.x - formerPoint.x),
newAngle = Math.atan2(centerPoint.y - newPoint.y, centerPoint.x - newPoint.x);
return newAngle - initialAngle;
},

/* Takes two latlngs and calculates the angle between them. */
_calculateAngle: function(latlngA, latlngB) {
var map = this._handled._map,
centerPoint = map.latLngToLayerPoint(this._handled.getCenter()),
formerPoint = map.latLngToLayerPoint(latlngA),
newPoint = map.latLngToLayerPoint(latlngB),
initialAngle = Math.atan2(centerPoint.y - formerPoint.y, centerPoint.x - formerPoint.x),
newAngle = Math.atan2(centerPoint.y - newPoint.y, centerPoint.x - newPoint.x);
return newAngle - initialAngle;
},

/* Takes two latlngs and calculates the angle between them. */
_calculateAngle: function(latlngA, latlngB) {
var map = this._handled._map,
centerPoint = map.latLngToLayerPoint(this._handled.getCenter()),
formerPoint = map.latLngToLayerPoint(latlngA),
newPoint = map.latLngToLayerPoint(latlngB),
initialAngle = Math.atan2(centerPoint.y - formerPoint.y, centerPoint.x - formerPoint.x),
newAngle = Math.atan2(centerPoint.y - newPoint.y, centerPoint.x - newPoint.x);
return newAngle - initialAngle;
},

  1. Then, copy it into src/edit/EditHandle.js (you can add it as the last function defined on the L.EditHandle class).

Thanks!!

Step by Step

  • Claim this issue with a comment here, below, and ask any clarifying questions you need
  • Fork the repository and set it up locally following the main repo README instructions https://github.com/publiclab/Leaflet.DistortableImage
  • Create a new feature branch with a unique name descriptive to the issue
  • Try to fix the issue following the steps above, but even before you're done, you can:
    commit your changes to your branch and start a pull request (see contributing to Public Lab software) but mark it as "in progress" if you have questions or if you haven't finished
  • Reference this issue in your pull request body
  • Once you submit your pull request, if there's an additional checklist provided for getting it merged, get those boxes checked off. Either way, mention me @sashadev-sky for a review.

Please keep us updated

💬⏰ - We encourage contributors to be respectful to the community and provide an update within a week of claiming a first-timers-only issue. We're happy to keep it assigned to you as long as you need if you update us, but if we don't see any activity a week after you claim it we may reassign it to give someone else a chance. Thank you in advance!

If this happens to you, don't sweat it! Grab another open issue.

💬 Get help

If you need any help - here are some options:

@sashadev-sky
Copy link
Member Author

assigned to @AdityaShD!

@AdityaShD
Copy link
Contributor

hey! @sashadev-sky thanks for assigning, I'll get right on it :)

@dannomayer
Copy link

Hello @sashadev-sky ! Love the description. I am looking to make my first contribution to an open source project and the documentation you've provided on how to do so is really helpful. I feel so overwhelmed whenever I try and contribute but this is clear and concise. Unfortunately... Both first timer issues I've found through this project appear to have been claimed. And this one in particular was assigned, causing me to wonder if there is some list you are pulling from of people who have expressed interest in contributing? Unfortunately I am not from an underrepresented group, but I am still very interested in contributing to open source!

@AdityaShD
Copy link
Contributor

@sashadev-sky I am done with making changes on my local machine, what are the steps which i need to follow now?

@AdityaShD
Copy link
Contributor

and also commited the code to a branch 'calculateAngle' .

@sashadev-sky
Copy link
Member Author

@dannomayer Hey, welcome to PL! You do not have to be from an underrepresented group to join!! Navigating PL takes a minute to get used to so i'll explain a little bit.

The most active repo currently is plots2, which is the source code for PL's website publiclab.org. There we have a pinned issue where we keep a list of users in need of FTOs and assign them out.

The FTO you receive will not necessarily be for plots2. I post a bunch for this repo there. You can feel free to comment there, so we'll add your name to the list and you'll be randomly assigned to an FTO shortly. If you want one in this repo specifically you can skip that and I'm glad to just make you one!

@sashadev-sky
Copy link
Member Author

@AdityaShD great! I think all you have left to do is:

  1. $ git push origin calculateAngle to submit a pull request
  2. visit the main repo page on Github and you'll see a prompt to create your PR

Let me know if you have more questions :)

@sashadev-sky
Copy link
Member Author

closed via #267

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants