Skip to content

Commit 31552b8

Browse files
committed
changed plotting function
1 parent 382d6aa commit 31552b8

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

omega_prime/map_odr.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
22
from dataclasses import dataclass
33
from omega_prime.map import Map, Lane, LaneBoundary
4-
from shapely import LineString, Polygon, simplify
5-
from shapely.plotting import plot_polygon
4+
from shapely import LineString, Polygon, simplify, MultiPolygon
5+
from matplotlib.patches import Polygon as PltPolygon
66
import numpy as np
77
import matplotlib.pyplot as plt
88
from betterosi import LaneClassificationType, LaneClassificationSubtype, LaneBoundaryClassificationType
@@ -17,6 +17,7 @@
1717
import betterosi
1818
from betterosi import MapAsamOpenDrive
1919
from collections import namedtuple
20+
import warnings
2021

2122

2223
logger = logging.getLogger(__name__)
@@ -476,15 +477,20 @@ def set_polygon(self):
476477
if not polygon.is_valid:
477478
raise ValueError(f"Could not compute valid polygon for Lane {self.xodr_idx}")
478479
else:
479-
# warnings.warn(f"Needed to simplify and buffer polygon for Lane {self.xodr_idx}.")
480+
warnings.warn(f"Needed to simplify and buffer polygon for Lane {self.xodr_idx}.")
480481
pass
481482
else:
482-
# warnings.warn(f"Needed to simplify polygon for Lane {self.xodr_idx}.")
483+
warnings.warn(f"Needed to simplify polygon for Lane {self.xodr_idx}.")
483484
pass
484485
self.polygon = polygon
485486
return self
486487

487488
def plot(self, ax: plt.Axes):
488489
c = "green" if self.type != LaneClassificationType.TYPE_INTERSECTION else "black"
489490
ax.plot(*np.asarray(self.centerline).T, color=c, alpha=0.5)
490-
plot_polygon(self.polygon, ax=ax, facecolor="blue", edgecolor="green", alpha=0.2)
491+
if isinstance(self.polygon, MultiPolygon):
492+
ps = self.polygon.geoms
493+
else:
494+
ps = [self.polygon]
495+
for p in ps:
496+
ax.add_patch(PltPolygon(p.exterior.coords, fc="blue", alpha=0.2, ec="black"))

0 commit comments

Comments
 (0)