Skip to content

Commit

Permalink
check geometry possible types
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Jul 29, 2024
1 parent 45972de commit 4fbf448
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,21 @@ public static Feature createInstanceFromJson(String json) throws ArcgisException
*/
public static Feature createInstanceFromJson(JsonObject json) throws ArcgisException {
try {
Geometry geometry;
Geometry geometry = null;
if (json.has(GEOMETRY_TAG)) {
JsonObject jsonGeometry = json.get(GEOMETRY_TAG).getAsJsonObject();
geometry = Point.createInstanceFromJson(jsonGeometry); // TODO another
//geometry types?
} else {
geometry = null;
JsonElement jsonGeometryElement = json.get(GEOMETRY_TAG);
if (jsonGeometryElement.isJsonObject()) {
JsonObject jsonGeometry = jsonGeometryElement.getAsJsonObject();
if (jsonGeometry.get("x") != null) {
geometry = Point.createInstanceFromJson(jsonGeometry);
} else if (jsonGeometry.get("paths") != null) {
// geometry = Polyline.createInstance(jsonGeometry);
} else if (jsonGeometry.get("points") != null) {
// geometry = MultiPoint.createInstance(jsonGeometry);
} else if (jsonGeometry.get("rings") != null) {
// geometry = Polygon.createInstance(jsonGeometry);
}
}
}
Map<String, Object> attributes = attToMap(json.get(ATTRIBUTES_TAG).getAsJsonObject());
return new Feature(geometry, attributes);
Expand Down

0 comments on commit 4fbf448

Please sign in to comment.