Fix naming in components tool
This commit is contained in:
		
							parent
							
								
									ccd3872bf1
								
							
						
					
					
						commit
						5b0e2e487a
					
				@ -40,7 +40,7 @@ struct TarjanEdgeData
 | 
				
			|||||||
using TarjanGraph = StaticGraph<TarjanEdgeData>;
 | 
					using TarjanGraph = StaticGraph<TarjanEdgeData>;
 | 
				
			||||||
using TarjanEdge = TarjanGraph::InputEdge;
 | 
					using TarjanEdge = TarjanGraph::InputEdge;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DeleteFileIfExists(const std::string &file_name)
 | 
					void deleteFileIfExists(const std::string &file_name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (boost::filesystem::exists(file_name))
 | 
					    if (boost::filesystem::exists(file_name))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -49,7 +49,7 @@ void DeleteFileIfExists(const std::string &file_name)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::size_t LoadGraph(const char *path,
 | 
					std::size_t loadGraph(const char *path,
 | 
				
			||||||
                      std::vector<QueryNode> &coordinate_list,
 | 
					                      std::vector<QueryNode> &coordinate_list,
 | 
				
			||||||
                      std::vector<TarjanEdge> &graph_edge_list)
 | 
					                      std::vector<TarjanEdge> &graph_edge_list)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -110,7 +110,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        std::vector<TarjanEdge> graph_edge_list;
 | 
					        std::vector<TarjanEdge> graph_edge_list;
 | 
				
			||||||
        auto number_of_nodes = LoadGraph(argv[1], coordinate_list, graph_edge_list);
 | 
					        auto number_of_nodes = loadGraph(argv[1], coordinate_list, graph_edge_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        tbb::parallel_sort(graph_edge_list.begin(), graph_edge_list.end());
 | 
					        tbb::parallel_sort(graph_edge_list.begin(), graph_edge_list.end());
 | 
				
			||||||
        const auto graph = std::make_shared<TarjanGraph>(number_of_nodes, graph_edge_list);
 | 
					        const auto graph = std::make_shared<TarjanGraph>(number_of_nodes, graph_edge_list);
 | 
				
			||||||
@ -129,34 +129,34 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
        TIMER_START(SCC_RUN_SETUP);
 | 
					        TIMER_START(SCC_RUN_SETUP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // remove files from previous run if exist
 | 
					        // remove files from previous run if exist
 | 
				
			||||||
        DeleteFileIfExists("component.dbf");
 | 
					        deleteFileIfExists("component.dbf");
 | 
				
			||||||
        DeleteFileIfExists("component.shx");
 | 
					        deleteFileIfExists("component.shx");
 | 
				
			||||||
        DeleteFileIfExists("component.shp");
 | 
					        deleteFileIfExists("component.shp");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Percent percentage(graph->GetNumberOfNodes());
 | 
					        Percent percentage(graph->GetNumberOfNodes());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        OGRRegisterAll();
 | 
					        OGRRegisterAll();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const char *pszDriverName = "ESRI Shapefile";
 | 
					        const char *psz_driver_name = "ESRI Shapefile";
 | 
				
			||||||
        OGRSFDriver *poDriver =
 | 
					        auto *po_driver =
 | 
				
			||||||
            OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(pszDriverName);
 | 
					            OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(psz_driver_name);
 | 
				
			||||||
        if (nullptr == poDriver)
 | 
					        if (nullptr == po_driver)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw osrm::exception("ESRI Shapefile driver not available");
 | 
					            throw osrm::exception("ESRI Shapefile driver not available");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        OGRDataSource *poDS = poDriver->CreateDataSource("component.shp", nullptr);
 | 
					        auto *po_datasource = po_driver->CreateDataSource("component.shp", nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (nullptr == poDS)
 | 
					        if (nullptr == po_datasource)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw osrm::exception("Creation of output file failed");
 | 
					            throw osrm::exception("Creation of output file failed");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        OGRSpatialReference *poSRS = new OGRSpatialReference();
 | 
					        auto *po_srs = new OGRSpatialReference();
 | 
				
			||||||
        poSRS->importFromEPSG(4326);
 | 
					        po_srs->importFromEPSG(4326);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        OGRLayer *poLayer = poDS->CreateLayer("component", poSRS, wkbLineString, nullptr);
 | 
					        auto *po_layer = po_datasource->CreateLayer("component", po_srs, wkbLineString, nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (nullptr == poLayer)
 | 
					        if (nullptr == po_layer)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            throw osrm::exception("Layer creation failed.");
 | 
					            throw osrm::exception("Layer creation failed.");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -192,26 +192,26 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
                    // edges that end on bollard nodes may actually be in two distinct components
 | 
					                    // edges that end on bollard nodes may actually be in two distinct components
 | 
				
			||||||
                    if (size_of_containing_component < 1000)
 | 
					                    if (size_of_containing_component < 1000)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        OGRLineString lineString;
 | 
					                        OGRLineString line_string;
 | 
				
			||||||
                        lineString.addPoint(coordinate_list[source].lon / COORDINATE_PRECISION,
 | 
					                        line_string.addPoint(coordinate_list[source].lon / COORDINATE_PRECISION,
 | 
				
			||||||
                                             coordinate_list[source].lat / COORDINATE_PRECISION);
 | 
					                                             coordinate_list[source].lat / COORDINATE_PRECISION);
 | 
				
			||||||
                        lineString.addPoint(coordinate_list[target].lon / COORDINATE_PRECISION,
 | 
					                        line_string.addPoint(coordinate_list[target].lon / COORDINATE_PRECISION,
 | 
				
			||||||
                                            coordinate_list[target].lat / COORDINATE_PRECISION);
 | 
					                                            coordinate_list[target].lat / COORDINATE_PRECISION);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        OGRFeature *poFeature = OGRFeature::CreateFeature(poLayer->GetLayerDefn());
 | 
					                        OGRFeature *po_feature = OGRFeature::CreateFeature(po_layer->GetLayerDefn());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        poFeature->SetGeometry(&lineString);
 | 
					                        po_feature->SetGeometry(&line_string);
 | 
				
			||||||
                        if (OGRERR_NONE != poLayer->CreateFeature(poFeature))
 | 
					                        if (OGRERR_NONE != po_layer->CreateFeature(po_feature))
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            throw osrm::exception("Failed to create feature in shapefile.");
 | 
					                            throw osrm::exception("Failed to create feature in shapefile.");
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        OGRFeature::DestroyFeature(poFeature);
 | 
					                        OGRFeature::DestroyFeature(po_feature);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        OGRSpatialReference::DestroySpatialReference(poSRS);
 | 
					        OGRSpatialReference::DestroySpatialReference(po_srs);
 | 
				
			||||||
        OGRDataSource::DestroyDataSource(poDS);
 | 
					        OGRDataSource::DestroyDataSource(po_datasource);
 | 
				
			||||||
        TIMER_STOP(SCC_OUTPUT);
 | 
					        TIMER_STOP(SCC_OUTPUT);
 | 
				
			||||||
        SimpleLogger().Write() << "generating output took: " << TIMER_MSEC(SCC_OUTPUT) / 1000.
 | 
					        SimpleLogger().Write() << "generating output took: " << TIMER_MSEC(SCC_OUTPUT) / 1000.
 | 
				
			||||||
                               << "s";
 | 
					                               << "s";
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user