getMapROI
Description
computes the geographic bounding box coordinates using latitude and longitude GPS data, and
returns the map parameters mapParameters
= getMapROI(lat
,lon
)mapParameters
.
computes the map parameters with the specified GPS buffer extent.mapParameters
= getMapROI(lat
,lon
,Extent=extent
)
Note
This function requires the Scenario Builder for Automated Driving Toolbox™ support package. You can install Scenario Builder for Automated Driving Toolbox from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.
Examples
Import OpenStreetMap Road Network Using Map ROI Parameters
Extract map ROI parameters from GPS data. Use the extracted osmUrl
parameter to import roads from the OpenStreetMap® web service into a driving scenario. Then, plot the scenario.
Load GPS data containing latitude and longitude values into the workspace.
load("GPSData.mat")
Use the latitude and longitude to fetch the map parameters.
mapParameters = getMapROI(gps.lat,gps.lon);
Use the osmUrl
parameter in the mapParameters
output structure to import and save the OpenStreetMap file.
fileName = websave("drive_map.osm",mapParameters.osmUrl, ... weboptions(ContentType="xml"));
Import the roads from the OpenStreetMap road network file into a driving scenario.
scenario = drivingScenario;
roadNetwork(scenario,"OpenStreetMap",fileName)
Plot the scenario.
plot(scenario)
Import OpenStreetMap Road Network Using GPS Data and Extent
Extract map ROI parameters from GPS data by specifying GPS buffer extent. Use the extracted osmUrl
parameter to import roads from the OpenStreetMap® web service into a driving scenario. Then, plot the scenario.
Load GPS data containing latitude and longitude values into the workspace.
load("GPSData.mat")
Specify the GPS buffer extent, in meters.
gpsBufferExtent = 10;
Use the latitude, longitude, and GPS buffer extent to fetch the map parameters.
mapParameters = getMapROI(gps.lat,gps.lon,Extent=gpsBufferExtent);
Use the osmUrl
parameter in the mapParameters
output structure to import and save the OpenStreetMap file.
fileName = websave("drive_map.osm",mapParameters.osmUrl, ... weboptions(ContentType="xml"));
Import the roads from the OpenStreetMap road network file into a driving scenario.
scenario = drivingScenario;
roadNetwork(scenario,"OpenStreetMap",fileName)
Plot the scenario.
plot(scenario)
Input Arguments
lat
— Latitude coordinates
numeric vector
Latitude coordinates in degrees, specified as a numeric vector. Each value in the
vector must be in the range [–90, 90]. lat
must be the same size as
lon
.
Data Types: single
| double
lon
— Longitude coordinates
numeric vector
Longitude coordinates in degrees, specified as a numeric vector. Each value in the
vector must be in the range [–180, 180]. lon
must be the same size
as lat
.
Data Types: single
| double
extent
— GPS buffer extent
0
(default) | nonnegative scalar
GPS buffer extent, in meters, specified as a nonnegative scalar. This function extends the rectangular GPS bounding box in all directions by the specified extent value.
Data Types: single
| double
Output Arguments
mapParameters
— Map region of interest parameters
structure
Map region of interest (ROI) parameters, returned as a structure.
The structure contains these fields:
Property | Description |
---|---|
bufferInMeters | GPS buffer extent, returned as a nonnegative scalar. Units are in meters. |
minLat | Minimum latitude, returned as a scalar. Units are in degrees. |
maxLat | Maximum latitude, returned as a scalar. Units are in degrees. |
minLon | Minimum longitude, returned as a scalar. Units are in degrees. |
maxLon | Maximum longitude, returned as a scalar. Units are in degrees. |
georeference | Reference GPS location, returned as a 3-element row vector of the form [latitude longitude altitude]. Latitude and longitude are in degrees, and altitude is in meters. |
osmUrl | OpenStreetMap® URL, returned as a character vector. |
minLatitudeString | Minimum latitude, returned as a character vector. Units are in degrees. |
minLongitudeString | Minimum longitude, returned as a character vector. Units are in degrees. |
maxLatitudeString | Maximum latitude, returned as a character vector. Units are in degrees. |
maxLongitudeString | Maximum longitude, returned as a character vector. Units are in degrees. |
The function computes the geographic bounding box coordinates using latitude and
longitude GPS data and the specified extent
value. The minimum and
maximum latitude and longitude values in the structure represent a rectangular bounding
box. This diagram displays the relationship between these coordinates.
Version History
Introduced in R2022b
See Also
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)