Class ShapeFileReader
java.lang.Object
org.opentrafficsim.road.network.factory.nwb.ShapeFileReader
public class ShapeFileReader extends Object
Access to the NWB (Nationaal WegenBestand - Dutch National Road database) shape files.
Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version 4 may 2019
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Constructor Summary
Constructors Constructor Description ShapeFileReader(String baseDir, int date, String subDirAndShapeFile)Construct a new ShapeFileReader. -
Method Summary
Modifier and Type Method Description static OTSLine3DdesignLine(Feature feature)Construct the design line of a Feature.intfindBestDate(int ultimateDate, File dir)Find the last date, no later than the specifieddatefor which there is a sub directory.Map<Long,Feature>readShapeFile(org.opentrafficsim.road.network.factory.nwb.ShapeFileReader.FeatureQualifier qualifier)Read a shape file and collect records that match a caller-provided check.
-
Constructor Details
-
ShapeFileReader
public ShapeFileReader(String baseDir, int date, String subDirAndShapeFile) throws FileNotFoundExceptionConstruct a new ShapeFileReader.- Parameters:
baseDir- String; name of the directory under which the sub-directories with names representing the date of a version of the shape file database (formatted like YYYYMMDD) are storeddate- int; requested date (formatted like YYYYMMDD)subDirAndShapeFile- String; name of the sub-directory with the shape file relative to the date-named directory- Throws:
FileNotFoundException- when a needed directory does not exist
-
-
Method Details
-
findBestDate
Find the last date, no later than the specifieddatefor which there is a sub directory.- Parameters:
ultimateDate- int; date encoded as an 8-digit number (YYYYMMDD)dir- File; directory to scan for sub-directories that have 8-digit numerical names- Returns:
- int; the 8-digit number that identifies the best matching sub directory
- Throws:
FileNotFoundException- when no suitable sub directory exists
-
readShapeFile
public Map<Long,Feature> readShapeFile(org.opentrafficsim.road.network.factory.nwb.ShapeFileReader.FeatureQualifier qualifier) throws IOExceptionRead a shape file and collect records that match a caller-provided check.- Parameters:
qualifier- FeatureQualifier; the check to use- Returns:
- Map<Integer, Feature>; map with the Features that passed the check
- Throws:
IOException- when reading a file failed
-
designLine
Construct the design line of a Feature.- Parameters:
feature- Feature; the feature- Returns:
- OTSLine3D; the design line of the feature
- Throws:
OTSGeometryException- when the feature is not a proper line
-