Class ShapeFileReader


  • public class ShapeFileReader
    extends java.lang.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​(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 OTSLine3D designLine​(Feature feature)
      Construct the design line of a Feature.
      int findBestDate​(int ultimateDate, java.io.File dir)
      Find the last date, no later than the specified date for 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShapeFileReader

        public ShapeFileReader​(java.lang.String baseDir,
                               int date,
                               java.lang.String subDirAndShapeFile)
                        throws java.io.FileNotFoundException
        Construct 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 stored
        date - 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.FileNotFoundException
        Find the last date, no later than the specified date for 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