Commit 5c4c9573 authored by Evan W. Patton's avatar Evan W. Patton Committed by Jeffrey Schiller

Fix issues with HolePointsFromString in Polygon (#1654)

Change-Id: I9b23ee39bb46e63d56e4bd7b6cc24b8d32cdade3
parent 6d606ea1
......@@ -256,8 +256,8 @@ public class MockPolygon extends MockPolygonBase {
}
for (var i = 1; i < latlngs.length; i++) {
var hole = [];
for (var j = 0; j < latlngs[i].length; i++) {
holesJson.push([latlngs[i][j].lat, latlngs[i][j].lng]);
for (var j = 0; j < latlngs[i].length; j++) {
hole.push([latlngs[i][j].lat, latlngs[i][j].lng]);
}
holesJson.push(hole);
}
......
......@@ -46,6 +46,7 @@ public class Polygon extends PolygonBase implements MapPolygon {
private List<List<GeoPoint>> points = new ArrayList<List<GeoPoint>>();
private List<List<List<GeoPoint>>> holePoints = new ArrayList<List<List<GeoPoint>>>();
private boolean multipolygon = false;
private boolean initialized = false;
private static final MapFeatureVisitor<Double> distanceComputation = new MapFeatureVisitor<Double>() {
@Override
......@@ -99,6 +100,13 @@ public class Polygon extends PolygonBase implements MapPolygon {
container.addFeature(this);
}
public void Initialize() {
initialized = true;
clearGeometry();
map.getController().updateFeaturePosition(this);
map.getController().updateFeatureHoles(this);
}
@Override
@SimpleProperty(category = PropertyCategory.BEHAVIOR,
description = "The type of the feature. For polygons, this returns the text \"Polygon\".")
......@@ -140,8 +148,10 @@ public class Polygon extends PolygonBase implements MapPolygon {
throw new DispatchableError(ErrorMessages.ERROR_POLYGON_PARSE_ERROR,
"Unable to determine the structure of the points argument.");
}
clearGeometry();
map.getController().updateFeaturePosition(this);
if (initialized) {
clearGeometry();
map.getController().updateFeaturePosition(this);
}
} catch(DispatchableError e) {
container.$form().dispatchErrorOccurredEvent(this, "Points", e.getErrorCode(), e.getArguments());
}
......@@ -166,8 +176,10 @@ public class Polygon extends PolygonBase implements MapPolygon {
}
points = GeometryUtil.multiPolygonToList(content);
multipolygon = points.size() > 1;
clearGeometry();
map.getController().updateFeaturePosition(this);
if (initialized) {
clearGeometry();
map.getController().updateFeaturePosition(this);
}
} catch(JSONException e) {
container.$form().dispatchErrorOccurredEvent(this, "PointsFromString",
ErrorMessages.ERROR_POLYGON_PARSE_ERROR, e.getMessage());
......@@ -209,8 +221,10 @@ public class Polygon extends PolygonBase implements MapPolygon {
throw new DispatchableError(ErrorMessages.ERROR_POLYGON_PARSE_ERROR,
"Unable to determine the structure of the points argument.");
}
clearGeometry();
map.getController().updateFeatureHoles(this);
if (initialized) {
clearGeometry();
map.getController().updateFeatureHoles(this);
}
} catch(DispatchableError e) {
container.$form().dispatchErrorOccurredEvent(this, "HolePoints",
e.getErrorCode(), e.getArguments());
......@@ -234,7 +248,10 @@ public class Polygon extends PolygonBase implements MapPolygon {
return;
}
holePoints = GeometryUtil.multiPolygonHolesToList(content);
map.getController().updateFeatureHoles(this);
if (initialized) {
clearGeometry();
map.getController().updateFeatureHoles(this);
}
Log.d(TAG, "Points: " + points);
} catch(JSONException e) {
Log.e(TAG, "Unable to parse point string", e);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment