Class ShapeFileReader
- java.lang.Object
-
- org.opentrafficsim.road.network.factory.nwb.ShapeFileReader
-
public class ShapeFileReader extends java.lang.ObjectAccess 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(java.lang.String baseDir, int date, java.lang.String subDirAndShapeFile)Construct a new ShapeFileReader.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OTSLine3DdesignLine(Feature feature)Construct the design line of a Feature.intfindBestDate(int ultimateDate, java.io.File dir)Find the last date, no later than the specifieddatefor which there is a sub directory.java.util.Map<java.lang.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 Detail
-
ShapeFileReader
public ShapeFileReader(java.lang.String baseDir, int date, java.lang.String subDirAndShapeFile) throws java.io.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:
java.io.FileNotFoundException- when a needed directory does not exist
-
-
Method Detail
-
findBestDate
public int findBestDate(int ultimateDate, java.io.File dir) throws java.io.FileNotFoundExceptionFind 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:
java.io.FileNotFoundException- when no suitable sub directory exists
-
readShapeFile
public java.util.Map<java.lang.Long,Feature> readShapeFile(org.opentrafficsim.road.network.factory.nwb.ShapeFileReader.FeatureQualifier qualifier) throws java.io.IOException
Read 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:
java.io.IOException- when reading a file failed
-
designLine
public static OTSLine3D designLine(Feature feature) throws OTSGeometryException
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
-
-