Skip to content

Commit

Permalink
GeoPoly: Fix #2868.
Browse files Browse the repository at this point in the history
  • Loading branch information
zestyping committed Mar 4, 2019
1 parent ba25e07 commit 0f60ca5
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,11 @@ private void saveAsPolygon() {
polygonOrPolylineDialog.dismiss();
if (map.getPolyPoints(featureId).size() > 2) {
// Close the polygon.
map.appendPointToPoly(featureId, map.getPolyPoints(featureId).get(0));
List<MapPoint> points = map.getPolyPoints(featureId);
int count = points.size();
if (count > 1 && !points.get(0).equals(points.get(count - 1))) {
map.appendPointToPoly(featureId, points.get(0));
}
finishWithResult();
} else {
ToastUtils.showShortToastInMiddle(getString(R.string.polygon_validator));
Expand Down Expand Up @@ -404,7 +408,7 @@ private String formatAccuracyThreshold(int meters) {

/**
* Parses a form result string, as previously formatted by formatPoints,
* into a list of polyline vertices.
* into a list of vertices.
*/
private List<MapPoint> parsePoints(String coords) {
List<MapPoint> points = new ArrayList<>();
Expand Down Expand Up @@ -439,7 +443,7 @@ private List<MapPoint> parsePoints(String coords) {
}

/**
* Serializes a list of polyline vertices into a string, in the format
* Serializes a list of vertices into a string, in the format
* appropriate for storing as the result of this form question.
*/
private String formatPoints(List<MapPoint> points) {
Expand Down

0 comments on commit 0f60ca5

Please sign in to comment.