Skip to content

Commit

Permalink
Map workaround for singapore-queenstown (nutonomy#190)
Browse files Browse the repository at this point in the history
* Fixed bug for Queenstown map which has a line without nodes

* Added warning note
  • Loading branch information
holger-motional authored Jul 22, 2019
1 parent 1c70dd0 commit 9984e71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
17 changes: 10 additions & 7 deletions python-sdk/nuscenes/map_expansion/map_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def get_records_in_patch(self,
"""
Get all the record token that intersects or is within a particular rectangular patch.
:param box_coords: The rectangular patch coordinates (x_min, y_min, x_max, y_max).
:param layer_names: Names of the layers that we want to retrieve in a particular patch. By default will always
:param layer_names: Names of the layers that we want to retrieve in a particular patch. By default will always
look at the all non geometric layers.
:param mode: "intersect" will return all non geometric records that intersects the patch, "within" will return
all non geometric records that are within the patch.
Expand Down Expand Up @@ -471,8 +471,8 @@ def get_map_mask(self,
def render_record(self,
layer_name: str,
token: str,
alpha: float,
figsize: Tuple[int, int],
alpha: float = 0.5,
figsize: Tuple[int, int] = (15, 15),
other_layers: List[str] = None) -> Tuple[Figure, Tuple[Axes, Axes]]:
"""
Render a single map graph record.
Expand All @@ -485,7 +485,6 @@ def render_record(self,
:param other_layers: What other layers to render aside from the one specified in `layer_name`.
:return: The matplotlib figure and axes of the rendered layers.
"""

if other_layers is None:
other_layers = list(self.representative_layers)

Expand Down Expand Up @@ -866,17 +865,21 @@ def _is_line_record_in_patch(self,
if layer_name not in self.map_api.non_geometric_line_layers:
raise ValueError("{} is not a line layer".format(layer_name))

x_min, y_min, x_max, y_max = box_coords

# Retrieve nodes of this line.
record = self.map_api.get(layer_name, token)
node_recs = [self.map_api.get('node', node_token) for node_token in record['node_tokens']]
node_coords = [[node['x'], node['y']] for node in node_recs]
node_coords = np.array(node_coords)

# A few lines in Queenstown have zero nodes. In this case we return False.
if len(node_coords) == 0:
return False

# Check that nodes fall inside the path.
x_min, y_min, x_max, y_max = box_coords
cond_x = np.logical_and(node_coords[:, 0] < x_max, node_coords[:, 0] > x_min)
cond_y = np.logical_and(node_coords[:, 1] < y_max, node_coords[:, 0] > y_min)
cond = np.logical_and(cond_x, cond_y)

if mode == 'intersect':
return np.any(cond)
elif mode == 'within':
Expand Down
3 changes: 2 additions & 1 deletion python-sdk/nuscenes/map_expansion/map_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@
"metadata": {},
"source": [
"#### a. Drivable Area\n",
"Drivable area is defined as the area where the car can drive, without consideration for driving directions or legal restrictions. This is the only layer in which the record can be represented by more than one geometric entity."
"Drivable area is defined as the area where the car can drive, without consideration for driving directions or legal restrictions. This is the only layer in which the record can be represented by more than one geometric entity.\n",
"*Note: On some machines this polygon renders incorrectly as a filled black rectangle.*"
]
},
{
Expand Down

0 comments on commit 9984e71

Please sign in to comment.