Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

avoid adding duplicate points to bounds #9955

Merged
merged 1 commit into from
Sep 11, 2017

Conversation

tobrun
Copy link
Member

@tobrun tobrun commented Sep 11, 2017

closes #9953, this PR validates if a point added to the LatLngBounds builder hasn't been added before. Atm a developer can create a bounds from one point by passing in the same point twice.

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Sep 11, 2017
@tobrun tobrun added this to the android-v5.1.4 milestone Sep 11, 2017
@tobrun tobrun self-assigned this Sep 11, 2017
@tobrun tobrun changed the title [android] - avoid adding duplicate points to bounds avoid adding duplicate points to bounds Sep 11, 2017
@@ -450,7 +450,9 @@ public LatLngBounds build() {
*/
public Builder includes(List<LatLng> latLngs) {
for (LatLng point : latLngs) {
latLngList.add(point);
if (!latLngList.contains(point)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you extract this into a private method? The same exact piece of code is duplicated and could be simplified and used from both includes and include methods.

@tobrun tobrun force-pushed the 9953-validate-if-point-was-contained branch from eb9cd34 to 6f5b62c Compare September 11, 2017 14:07
Copy link
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tobrun tobrun merged commit 738f682 into master Sep 11, 2017
@tobrun tobrun deleted the 9953-validate-if-point-was-contained branch September 11, 2017 17:26
@tobrun tobrun mentioned this pull request Sep 26, 2017
19 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LatLngBounds with one point
2 participants