Skip to content

Commit

Permalink
Corrected altitude value for MULTIPOLYGON bounding box
Browse files Browse the repository at this point in the history
  • Loading branch information
floeschau committed May 5, 2022
1 parent 7c20209 commit 29bb8e5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/DotNetStac/StacGeometryHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public static IPosition[] GetBoundingBox(this IGeometryObject geometry)
break;
case GeoJSONObjectType.MultiPolygon:
MultiPolygon multiPolygon = geometry as MultiPolygon;
double lowerLeftLon = multiPolygon.Coordinates.Min(poly => poly.GetBoundingBox()[0].Longitude);
double lowerLeftLat = multiPolygon.Coordinates.Min(poly => poly.GetBoundingBox()[0].Latitude);
double upperRightLon = multiPolygon.Coordinates.Max(poly => poly.GetBoundingBox()[1].Longitude);
double upperRightLat = multiPolygon.Coordinates.Max(poly => poly.GetBoundingBox()[1].Latitude);
lowerLeft = new Position(lowerLeftLat, lowerLeftLon);
upperRight = new Position(upperRightLat, upperRightLon);
IPosition lowerLeftLonPos = multiPolygon.Coordinates.Min(poly => poly.GetBoundingBox()[0]);
IPosition lowerLeftLatPos = multiPolygon.Coordinates.Min(poly => poly.GetBoundingBox()[0]);
IPosition upperRightLonPos = multiPolygon.Coordinates.Max(poly => poly.GetBoundingBox()[1]);
IPosition upperRightLatPos = multiPolygon.Coordinates.Max(poly => poly.GetBoundingBox()[1]);
lowerLeft = new Position(lowerLeftLatPos.Latitude, lowerLeftLonPos.Longitude, (lowerLeftLatPos.Altitude + lowerLeftLonPos.Altitude) / 2);
upperRight = new Position(upperRightLatPos.Latitude, upperRightLonPos.Longitude, (upperRightLatPos.Altitude + upperRightLonPos.Altitude) / 2);
break;
case GeoJSONObjectType.Point:
Point point = geometry as Point;
Expand Down

0 comments on commit 29bb8e5

Please sign in to comment.