Skip to content

Commit

Permalink
Deprecated PolygonalRegion points method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Vin committed Jul 18, 2024
1 parent 6b7f3ab commit b4a3b04
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
18 changes: 10 additions & 8 deletions src/scenic/core/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,6 @@ def __init__(
points = tuple(pt[:2] for pt in points)
if len(points) == 0:
raise ValueError("tried to create PolygonalRegion from empty point list!")
self.points = points
polygon = shapely.geometry.Polygon(points)

if isinstance(polygon, shapely.geometry.Polygon):
Expand All @@ -2791,13 +2790,6 @@ def __init__(
"tried to create PolygonalRegion with " f"invalid polygon {self.polygons}"
)

if (
points is None
and len(self.polygons.geoms) == 1
and len(self.polygons.geoms[0].interiors) == 0
):
self.points = tuple(self.polygons.geoms[0].exterior.coords[:-1])

if self.polygons.is_empty:
raise ValueError("tried to create empty PolygonalRegion")
shapely.prepare(self.polygons)
Expand Down Expand Up @@ -2972,6 +2964,16 @@ def unionAll(regions, buf=0):
z = 0 if z is None else z
return PolygonalRegion(polygon=union, orientation=orientation, z=z)

@property
@distributionFunction
def points(self):
warnings.warn(

Check warning on line 2970 in src/scenic/core/regions.py

View check run for this annotation

Codecov / codecov/patch

src/scenic/core/regions.py#L2970

Added line #L2970 was not covered by tests
"The `points` method is deprecated and will be removed in Scenic 3.3.0."
"Users should use the `boundary` method instead.",
DeprecationWarning,
)
return self.boundary.points

Check warning on line 2975 in src/scenic/core/regions.py

View check run for this annotation

Codecov / codecov/patch

src/scenic/core/regions.py#L2975

Added line #L2975 was not covered by tests

@property
@distributionFunction
def boundary(self) -> "PolylineRegion":
Expand Down
11 changes: 7 additions & 4 deletions src/scenic/simulators/webots/road/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ def computeGeometry(self, crossroads, snapTolerance=0.05):

def show(self, plt):
if self.hasLeftSidewalk:
x, y = zip(*self.leftSidewalk.points)
x, y = zip(*[p[:2] for p in self.leftSidewalk.boundary.points])
plt.fill(x, y, "#A0A0FF")
if self.hasRightSidewalk:
x, y = zip(*self.rightSidewalk.points)
x, y = zip(*[p[:2] for p in self.rightSidewalk.boundary.points])
plt.fill(x, y, "#A0A0FF")
self.region.show(plt, style="r:")
x, y = zip(*self.lanes[0].points)
x, y = zip(*[p[:2] for p in self.lanes[0].boundary.points])
plt.fill(x, y, color=(0.8, 1.0, 0.8))
for lane, markers in enumerate(self.laneMarkers):
x, y = zip(*markers)
Expand Down Expand Up @@ -296,7 +296,10 @@ def __init__(self, world):
allCells = []
drivableAreas = []
for road in self.roads:
assert road.region.polygons.is_valid, (road.waypoints, road.region.points)
assert road.region.polygons.is_valid, (
road.waypoints,
road.region.boundary.points,
)
allCells.extend(road.cells)
for crossroad in self.crossroads:
if crossroad.region is not None:
Expand Down

0 comments on commit b4a3b04

Please sign in to comment.