1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2002-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file NIImporter_ArcView.h 11 /// @author Daniel Krajzewicz 12 /// @author Michael Behrisch 13 /// @author Jakob Erdmann 14 /// @date Sept 2002 15 /// @version $Id$ 16 /// 17 // Importer for networks stored in ArcView-shape format 18 /****************************************************************************/ 19 #ifndef NIImporter_ArcView_h 20 #define NIImporter_ArcView_h 21 22 23 // =========================================================================== 24 // included modules 25 // =========================================================================== 26 #include <config.h> 27 28 #include <string> 29 30 31 // =========================================================================== 32 // class declarations 33 // =========================================================================== 34 class OptionsCont; 35 class OGRFeature; 36 37 38 // =========================================================================== 39 // class definitions 40 // =========================================================================== 41 /** 42 * @class NIImporter_ArcView 43 * @brief Importer for networks stored in ArcView-shape format 44 * 45 * The current importer works only if SUMO was compiled with GDAL-support. 46 * If not, an error message is generated. 47 * 48 * @todo reinsert import via shapelib 49 */ 50 class NIImporter_ArcView { 51 public: 52 /** @brief Loads content of the optionally given ArcView Shape files 53 * 54 * If the option "shapefile-prefix" is set, the file stored therein is read and 55 * the network definition stored therein is stored within the given network 56 * builder. 57 * 58 * If the option "shapefile-prefix" is not set, this method simply returns. 59 * 60 * @param[in] oc The options to use 61 * @param[in] nb The network builder to fill 62 */ 63 static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb); 64 65 66 protected: 67 /** @brief Constructor 68 * @param[in] oc Options container to read options from 69 * @param[in] nc The node container to store nodes into 70 * @param[in] ec The edge container to store edges into 71 * @param[in] tc The type container to get edge types from 72 * @param[in] dbf_name The name of the according database file 73 * @param[in] shp_name The name of the according shape file 74 * @param[in] speedInKMH Whether the speed shall be assumed to be given in km/h 75 */ 76 NIImporter_ArcView(const OptionsCont& oc, 77 NBNodeCont& nc, NBEdgeCont& ec, NBTypeCont& tc, 78 const std::string& dbf_name, const std::string& shp_name, 79 bool speedInKMH); 80 81 /// @brief Destructor 82 ~NIImporter_ArcView(); 83 84 85 /** @brief Loads the shape files 86 */ 87 void load(); 88 89 90 private: 91 #ifdef HAVE_GDAL 92 /** @brief Parses the maximum speed allowed on the edge currently processed 93 * @param[in] f The entry to read the speed from 94 * @param[in] edgeid The id of the edge for error output 95 */ 96 double getSpeed(OGRFeature& f, const std::string& edgeid); 97 98 99 /** @brief Parses the number of lanes of the edge currently processed 100 * @param[in] f The entry to read the lane number from 101 * @param[in] edgeid The id of the edge for error output 102 * @param[in] speed The edge's speed used to help determinig the edge's lane number 103 */ 104 int getLaneNo(OGRFeature& f, 105 const std::string& edgeid, double speed); 106 107 /** @brief Parses the priority of the edge currently processed 108 * @param[in] f The entry to read the priority from 109 * @param[in] edgeid The id of the edge for error output 110 */ 111 int getPriority(OGRFeature& f, const std::string& edgeid); 112 113 114 /** @brief Checks whether the lane spread shall be changed 115 * 116 * If for the given edge an edge into the vice direction is already 117 * stored, both edges' lane spread functions are set to LANESPREAD_RIGHT. 118 * 119 * @param[in] e The edge to check 120 */ 121 void checkSpread(NBEdge* e); 122 123 124 /** @brief Sets the value from the named field into "into" 125 * 126 * If the field's name was set on the command line, the value is tried to be retrieved, returning true on success. 127 * If it cannot be retrieved, false is retuned, and the field's name is inserted into "into". 128 * 129 * If no field name was given, the standard value (defaultName) is used. In this case, an empty string is returned 130 * if the field does not exist. 131 * @param[in] poFeature The feature to read from 132 * @param[in] optionName The name of the option at which an optional field name is stored 133 * @param[in] defaultName The field's default name 134 * @param[in] prune Whether the value shall be prunned 135 * @param[out] into The read value/missing field is stored here 136 */ 137 bool getStringEntry(OGRFeature* poFeature, const std::string& optionName, const char* defaultName, bool prune, std::string& into); 138 139 /// @brief return all fields support by the given feature 140 std::vector<std::string> getFieldNames(OGRFeature* poFeature) const; 141 142 /// @brief add list of parameters to edge 143 void addParams(NBEdge* edge, OGRFeature* poFeature, const std::vector<std::string>& params) const; 144 145 #endif 146 147 private: 148 /// @brief The options to use 149 const OptionsCont& myOptions; 150 151 /// @brief The name of the shape file 152 std::string mySHPName; 153 154 /// @brief A running number to assure unique edge ids 155 int myNameAddition; 156 157 /// @brief The container to add nodes to 158 NBNodeCont& myNodeCont; 159 160 /// @brief The container to add edges to 161 NBEdgeCont& myEdgeCont; 162 163 /// @brief The container to get the types from 164 NBTypeCont& myTypeCont; 165 166 /// @brief Whether the speed is given in km/h 167 bool mySpeedInKMH; 168 169 /// @brief A running number to assure unique ids (as fallback) 170 int myRunningEdgeID; 171 int myRunningNodeID; 172 173 174 private: 175 /// @brief Invalidated copy constructor. 176 NIImporter_ArcView(const NIImporter_ArcView&); 177 178 /// @brief Invalidated assignment operator. 179 NIImporter_ArcView& operator=(const NIImporter_ArcView&); 180 181 }; 182 183 184 #endif 185 186 /****************************************************************************/ 187 188