Skip to content

Add new containsLocation() that takes latitude and longitude instead LatLng#331

Merged
stephenmcd merged 1 commit into
googlemaps:masterfrom
skedgo:thuy/less-alloc-PolyUtil
Dec 4, 2016
Merged

Add new containsLocation() that takes latitude and longitude instead LatLng#331
stephenmcd merged 1 commit into
googlemaps:masterfrom
skedgo:thuy/less-alloc-PolyUtil

Conversation

@thuytrinh
Copy link
Copy Markdown
Contributor

In our project, we use different data structure to represent coordinates rather than LatLng. As a result, in order to utilize containsLocation(), we have to convert into LatLng which causes an allocation. So if we call it inside a loop through a list of coordinates, that will cause a lot more allocations.

For example:

for (Location location : locations) {
  if (PolyUtil.containsLocation(new LatLng(location.lat(), location.lng()), polygon, true)) {
    return true;
  }
}

So it'd be better if we don't allocate LatLngs:

for (Location location : locations) {
  if (PolyUtil.containsLocation(location.lat(), location.lng(), polygon, true)) {
    return true;
  }
}

…of LatLng

In our project, we use different data structure to represent coordinates rather than LatLng. As a result, in order to utilize `containsLocation()`, we have to convert into LatLng which causes an allocation. So if we call it inside a loop through a list of coordinates, that will cause a lot more allocations.
@googlebot
Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@thuytrinh
Copy link
Copy Markdown
Contributor Author

I signed it!

@googlebot
Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@thuytrinh
Copy link
Copy Markdown
Contributor Author

I signed it!

@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

@barbeau
Copy link
Copy Markdown
Collaborator

barbeau commented Dec 1, 2016

+1 for this change, although we'll need to run unit tests manually - there seems to be an issue with recent API Level 24 emulator so Travis builds are hanging (for other projects too - see travis-ci/travis-ci#6122 (comment)).

@stephenmcd
Copy link
Copy Markdown
Contributor

Thanks @thuytrinh!

@stephenmcd stephenmcd merged commit cb1cfe0 into googlemaps:master Dec 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants