diff --git a/examples/development.py b/examples/development.py index c56ea36..1f5a216 100644 --- a/examples/development.py +++ b/examples/development.py @@ -24,12 +24,13 @@ fbn.settings.radius = 1000 fbn.fixbikenet( - city_query="Frederiksberg Municipality", + city_query="Turin center", min_gap_length = 0, max_gap_length = 100, num_gaps = 20, import_files={ - 'city_boundary': "./tests/test_data/frederiksberg_boundary.geojson", + 'city_boundary': "./tests/test_data/turin_center_boundary.geojson", + 'trip_data': "./tests/test_data/turin_trips.csv", # 'street_network': "./tests/test_data/frederiksberg_streetbike_network.gpkg", }, ) \ No newline at end of file diff --git a/fixbikenet/fixbikenet.py b/fixbikenet/fixbikenet.py index ff5ab5e..1a107da 100644 --- a/fixbikenet/fixbikenet.py +++ b/fixbikenet/fixbikenet.py @@ -1,5 +1,6 @@ """Main procedure for running `fixbikenet`.""" +import bikenetlib as bnl from . import constants, settings, osm, _overpass import os import geopandas as gpd @@ -24,6 +25,7 @@ _validate_parameters, _validate_settings, add_point_data_to_net, + add_trip_data_to_net, compute_local_betweenness_centrality, create_gdf_with_geoms, download_network, @@ -87,9 +89,9 @@ def fixbikenet( - 'city_boundary' : None or str, default None If not set to None, the study area is selected from the - (Multi)Polygon provided in the city_boundary shape or gpkg file, - ideally in unprojected latitude-longitude degrees (EPSG:4326), but - EPSG:3857 also works. + (Multi)Polygon provided in the city_boundary shape, gpkg, or + geojson file, ideally in unprojected latitude-longitude degrees + (EPSG:4326), but EPSG:3857 also works. - 'street_network' : str | None, default None If not set to None, the street network is loaded from this file. For best results, this network should encompass both car and @@ -106,6 +108,13 @@ def fixbikenet( from this file, representing point events like traffic crashes or citizen feedback to improve bike infrastructure. Must be a gpkg or geojson file in unprojected CRS EPSG:4326 containing only point objects, optionally with an int ``num`` column that encodes the number of point events. The data set is used to re-prioritize the ordering of the network gaps, controlled with `settings.import_data_impact`. + - 'trip_data' : None or str, default None + If not set to None, an additional data set of trips will be loaded + from this file, representing trip events for prioritizing bike + infrastructure growth. Must be a csv file in unprojected CRS EPSG:4326 containing the following fields: + ``o_lat, o_lon, d_lat, d_lon``. Optionally there can be an int + ``num`` field that encodes the number of trips between each origin + and destination. Returns ------- @@ -125,7 +134,7 @@ def fixbikenet( _print_header(city_query) ### Import data files - num_data_files, point_data, _ = _import_data_files(import_files) # trip_data set to _. To do in the future. + num_data_files, point_data, trip_data = _import_data_files(import_files) # Get city boundary if import_files['city_boundary']: @@ -198,6 +207,14 @@ def fixbikenet( G_lengths = nx.get_edge_attributes(G, "length") nx.set_edge_attributes(G, G_lengths, "distance") nx.set_edge_attributes(G, G_lengths, "distance_weighted") + + if trip_data is not None: + G_trips = add_trip_data_to_net(trip_data, nx.Graph(ox.project_graph(nx.MultiDiGraph(G)), to_crs=constants._CRS_CALCULATIONS), matching_distance=settings.import_trip_data_snap_distance) + trips = nx.get_edge_attributes(G_trips, 'num_trips') + print(trips) + sys.exit() + ebc = {key: value * trips[key] for key, value in ebc.items()} + # Add point data to edges if point_data is not None: G_gaps = nx.MultiGraph(G.subgraph(set(n for nlist in found_gaps_nsp for n in nlist))) # To do once pythonmin>=3.15: *nlist for nlist in found_gaps_nsp diff --git a/fixbikenet/settings.py b/fixbikenet/settings.py index c045692..aac52e1 100644 --- a/fixbikenet/settings.py +++ b/fixbikenet/settings.py @@ -11,6 +11,9 @@ import_point_data_snap_distance : int, default 100 Maximum distance between point data and network links for snapping, in meters. +import_trip_data_snap_distance : int, default 500 + Maximum distance between trip data and network links for snapping, in + meters. import_path : str Path to import files (as defined in `fixbikenet`'s import_files parameter). radius : int, default 2500 @@ -25,6 +28,7 @@ export_path = "./results/" import_data_impact = 10000 import_point_data_snap_distance = 100 +import_trip_data_snap_distance = 500 import_path = "./" radius = 2500 diff --git a/fixbikenet/utils.py b/fixbikenet/utils.py index 4c555d0..f047189 100644 --- a/fixbikenet/utils.py +++ b/fixbikenet/utils.py @@ -17,6 +17,7 @@ import shapely from shapely.geometry import LineString, Point from shapely.strtree import STRtree +from pyproj import Transformer from tqdm import tqdm @@ -136,6 +137,83 @@ def initialize_progress_bar(desc_string, total=1, unit="step"): disable=settings.silent, ) +def add_trip_data_to_net(trips, A, matching_distance=settings.import_trip_data_snap_distance): + """Match trip data to network edges. + + First, match origin and destination points given in trips to the nodes. + Only consider trips where both origins and nodes are matched within + `matching_distance`. Then, for each trip, find the shortest path over the + edges from matched origin node to matched destination node, and add 1 (or + optionally ``num`` if column provided in trips) to the affected edges. + + Parameters + ---------- + trips : pandas DataFrame + A dataframe of unprojected origin-destination coordinates (columns: + ``o_lat, o_lon, d_lat, d_lon``), with each row encoding a trip, in + unprojected CRS EPSG:4326. Optional with a column ``num`` containing an + integer. This could be (number of) trip events. If ``num`` column is + not provided, assumes 1 per trip. + A: networkx.graph + Graph to match trip data to, in projected crs + `constants._CRS_CALCULATIONS`. + matching_distance : int, default `settings.import_trip_data_snap_distance` + Matching distance in meters. Set via + `settings.import_trip_data_snap_distance`. + + Returns + ------- + graph_with_data : networkx.graph + The same graph created from triangulation edges list, but with a new + edge attribute 'num_trips' populated with the summed up ``num`` values + of all trips where both origins and destinations could be matched to + the closest network nodes within `matching_distance`. + """ + graph_with_data = A.copy() + transformer = Transformer.from_crs("EPSG:4326", constants._CRS_CALCULATIONS, always_xy=True) + + # If column "num" is not provided assume 1 trip per origin-destination (OD) pair + if 'num' in trips.columns: + nums = trips['num'] + else: + nums = [1] * len(trips) + + # Project trip data + trips_projected = trips.copy() + trips_projected['o_lon'], trips_projected['o_lat'] = transformer.transform(trips['o_lon'], trips['o_lat']) + trips_projected['d_lon'], trips_projected['d_lat'] = transformer.transform(trips['d_lon'], trips['d_lat']) + + # Match given origins and destinations to the closest nodes in the network + o_nodes, o_distances = ox.distance.nearest_nodes(graph_with_data, trips_projected['o_lon'], trips_projected['o_lat'], return_dist=True) + d_nodes, d_distances = ox.distance.nearest_nodes(graph_with_data, trips_projected['d_lon'], trips_projected['d_lat'], return_dist=True) + + # Add number of trips to graph + trip_dict = dict(zip(graph_with_data.edges, [0] * len(graph_with_data.edges))) + + for o_node, o_distance, d_node, d_distance, num in zip(o_nodes, o_distances, d_nodes, d_distances, nums): + # If: + # - origin and destination are snapped to the same node, or + # - origin is >500m away from the snapped node, or + # - destination is >500m away from the snapped node + # no trips are added + if o_node == d_node or o_distance > matching_distance or d_distance > matching_distance: + continue + + # Get shortest path between the snapped orgin and destination nodes + path = nx.shortest_path(graph_with_data, source=o_node, target=d_node, weight="distance") + path_edges = list(zip(path[:-1], path[1:])) + + # Add the number of trips to each edge of the shortest path + for i, edge_id in enumerate(path_edges): + if edge_id in trip_dict: + trip_dict[edge_id] += num + else: + edge_id = (path[i + 1], path[i]) # Inverse node order + if edge_id in trip_dict: + trip_dict[edge_id] += num + + nx.set_edge_attributes(graph_with_data, trip_dict, 'num_trips') + return graph_with_data def download_network(city_query, network_type='drive', custom_filter=None, retain_all=True, city_boundary_geometry=None): """Download and prepare a street network from OSM via OSMnx. @@ -171,16 +249,22 @@ def download_network(city_query, network_type='drive', custom_filter=None, retai # Fetch street network data from osmnx if city_boundary_geometry is None: g = ox.graph_from_place( - city_query, network_type=network_type, custom_filter=custom_filter, retain_all=retain_all + city_query, + network_type=network_type, + custom_filter=custom_filter, + retain_all=retain_all, + simplify=False ) else: g = ox.graph_from_polygon( - city_boundary_geometry, network_type=network_type, custom_filter=custom_filter, retain_all=retain_all + city_boundary_geometry, + network_type=network_type, + custom_filter=custom_filter, + retain_all=retain_all, + simplify=False ) - g_undir = g.to_undirected().copy() # convert to undirected (dropping OSMnx keys!) - - return g_undir + return g def import_network(street_network): diff --git a/tests/test_data/turin_center_boundary.geojson b/tests/test_data/turin_center_boundary.geojson new file mode 100644 index 0000000..d22872d --- /dev/null +++ b/tests/test_data/turin_center_boundary.geojson @@ -0,0 +1,8 @@ +{ +"type": "FeatureCollection", +"name": "turin_it", +"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, +"features": [ +{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 7.614512,45.066065 ], [ 7.614512,45.090278 ], [ 7.655497,45.090278 ], [ 7.655497,45.066065 ], [ 7.614512,45.066065 ] ] ] } } +] +} \ No newline at end of file diff --git a/tests/test_data/turin_trips.csv b/tests/test_data/turin_trips.csv new file mode 100644 index 0000000..677c17d --- /dev/null +++ b/tests/test_data/turin_trips.csv @@ -0,0 +1,623 @@ +o_lat,o_lon,d_lat,d_lon +45.076498,7.6257,45.08378,7.626436 +45.042701,7.640026,45.045875,7.645144 +45.057113,7.636342,45.060699,7.633862 +45.096796,7.632997,45.079011,7.677199 +45.094253,7.633431,45.09646,7.649023 +45.046661,7.641122,45.031114,7.663854 +45.062205,7.645045,45.071068,7.674979 +45.062255,7.647127,45.073437,7.693435 +45.082127,7.640412,45.070821,7.655737 +45.036604,7.657066,45.034391,7.637682 +45.069207,7.656652,45.044826,7.649443 +45.070946,7.655226,45.089453,7.664131 +45.080863,7.654841,45.074817,7.620712 +45.096616,7.65269,45.093626,7.659771 +45.057793,7.660939,45.073778,7.676435 +45.078834,7.662885,45.058535,7.677689 +45.086969,7.6659,45.074152,7.64628 +45.087107,7.668146,45.10606,7.66399 +45.081826,7.666313,45.074384,7.698017 +45.062163,7.677372,45.068381,7.715351 +45.064226,7.674753,45.093732,7.680247 +45.062805,7.679243,45.072508,7.707256 +45.066119,7.68829,45.086092,7.699812 +45.065111,7.696602,45.069399,7.70418 +45.10562,7.692,45.106507,7.690904 +45.034391,7.637682,45.071742,7.677805 +45.07857,7.636121,45.076703,7.680203 +45.075418,7.636406,45.074341,7.636458 +45.078036,7.635945,45.071306,7.653452 +45.096036,7.633596,45.086824,7.68395 +45.038083,7.643678,45.046622,7.640554 +45.057009,7.64557,45.098076,7.672219 +45.074152,7.64628,45.045714,7.650549 +45.084773,7.643164,45.084105,7.62124 +45.036708,7.657158,45.063046,7.689024 +45.030659,7.655551,45.041835,7.662071 +45.033116,7.653821,45.04462,7.6533 +45.033219,7.65292,45.054773,7.675873 +45.039332,7.655627,45.041926,7.674951 +45.034077,7.653675,45.046557,7.645911 +45.0574,7.656068,45.05393,7.670433 +45.051774,7.658275,45.076542,7.690365 +45.066228,7.651355,45.074007,7.695178 +45.046932,7.668278,45.070838,7.655923 +45.078209,7.667651,45.071141,7.656186 +45.077185,7.669341,45.073982,7.696051 +45.089453,7.664131,45.071915,7.682375 +45.093626,7.659771,45.094567,7.651247 +45.105378,7.667403,45.10246,7.673858 +45.036377,7.671592,45.07424,7.694834 +45.063057,7.67872,45.095212,7.694831 +45.06284,7.67934,45.062911,7.677596 +45.09776,7.679875,45.095921,7.675465 +45.093133,7.67697,45.095273,7.663517 +45.063197,7.68097,45.075477,7.695529 +45.074859,7.682252,45.073055,7.681644 +45.072928,7.681264,45.062922,7.677926 +45.073,7.681371,45.062915,7.677893 +45.098777,7.682659,45.073563,7.693707 +45.092092,7.689657,45.086684,7.684156 +45.106473,7.689896,45.101329,7.675262 +45.106507,7.690904,45.076058,7.695757 +45.094229,7.700985,45.074663,7.69485 +45.096053,7.691754,45.087594,7.669152 +45.068381,7.715351,45.063943,7.695875 +45.085791,7.619451,45.094199,7.653496 +45.078091,7.625945,45.099107,7.635658 +45.08376,7.626493,45.105785,7.683526 +45.04522,7.645221,45.032652,7.669443 +45.044442,7.647566,45.047898,7.637993 +45.094567,7.651247,45.102342,7.647472 +45.096966,7.641749,45.069169,7.705963 +45.041916,7.65494,45.083972,7.656187 +45.04462,7.6533,45.03142,7.662304 +45.074285,7.651713,45.031705,7.652671 +45.096922,7.657218,45.044829,7.649765 +45.1011,7.656262,45.095246,7.655744 +45.102079,7.659287,45.056182,7.64805 +45.044501,7.669529,45.096849,7.70794 +45.077025,7.669938,45.071044,7.683072 +45.087766,7.669313,45.043767,7.649887 +45.087684,7.665472,45.090833,7.65698 +45.087594,7.669152,45.094018,7.69662 +45.094685,7.671178,45.053794,7.669779 +45.095273,7.663517,45.092229,7.689813 +45.094538,7.666919,45.064978,7.649913 +45.09219,7.663129,45.08495,7.704687 +45.046054,7.674779,45.035045,7.648646 +45.057846,7.679664,45.043532,7.649927 +45.058995,7.677499,45.05557,7.660675 +45.063329,7.677019,45.052733,7.664383 +45.063032,7.677803,45.077579,7.665776 +45.065716,7.681147,45.078412,7.666438 +45.063256,7.677661,45.086157,7.693681 +45.062414,7.677215,45.073196,7.669076 +45.062922,7.677926,45.043888,7.67648 +45.062915,7.677893,45.091724,7.675652 +45.064736,7.67558,45.068098,7.664654 +45.064769,7.674317,45.062329,7.668652 +45.076091,7.67207,45.058573,7.655473 +45.073795,7.677473,45.058469,7.672084 +45.076703,7.680203,45.088186,7.683742 +45.078868,7.677298,45.095621,7.674984 +45.076544,7.674487,45.07405,7.667219 +45.093728,7.680318,45.095484,7.660858 +45.070794,7.684006,45.066833,7.683278 +45.07231,7.68396,45.103056,7.692158 +45.063943,7.695875,45.064486,7.683509 +45.073433,7.693421,45.084724,7.655794 +45.087416,7.698695,45.109025,7.705057 +45.086165,7.69974,45.084687,7.701668 +45.08611,7.699571,45.078867,7.677414 +45.08683,7.697631,45.104916,7.702228 +45.107403,7.700173,45.095914,7.718124 +45.063235,7.710574,45.062519,7.678757 +45.096022,7.701892,45.09393,7.696935 +45.07052,7.715298,45.073159,7.667284 +45.080766,7.614197,45.048051,7.636731 +45.071228,7.644526,45.082157,7.648112 +45.075576,7.657834,45.062855,7.678306 +45.054224,7.668555,45.084142,7.693944 +45.07405,7.667219,45.063564,7.676627 +45.078379,7.662622,45.0945,7.669588 +45.073113,7.667211,45.102402,7.699291 +45.072578,7.666346,45.063543,7.676553 +45.043888,7.67648,45.051409,7.688802 +45.065169,7.676671,45.065074,7.67995 +45.064916,7.688025,45.067864,7.694019 +45.045067,7.640677,45.047185,7.636581 +45.035504,7.643688,45.061814,7.65158 +45.062855,7.645205,45.057235,7.668214 +45.094621,7.67123,45.08075,7.68653 +45.063543,7.676553,45.066741,7.689066 +45.065074,7.67995,45.065269,7.676041 +45.088186,7.683742,45.108772,7.683558 +45.067864,7.694019,45.103659,7.695926 +45.074758,7.62542,45.082239,7.642923 +45.082248,7.62419,45.105811,7.637941 +45.100712,7.625691,45.105148,7.655056 +45.081586,7.638724,45.079146,7.644611 +45.093531,7.660758,45.078022,7.667251 +45.096556,7.659668,45.048057,7.63296 +45.054457,7.663328,45.058397,7.662786 +45.078738,7.667531,45.082238,7.653661 +45.056347,7.677081,45.032066,7.645441 +45.091281,7.705247,45.096877,7.693014 +45.06781,7.624186,45.081607,7.624139 +45.048057,7.63296,45.093154,7.653024 +45.07533,7.64057,45.097464,7.667683 +45.075395,7.63577,45.075742,7.649002 +45.105811,7.637941,45.103308,7.644502 +45.032066,7.645441,45.053436,7.681344 +45.046935,7.645973,45.057142,7.66124 +45.051768,7.647831,45.107219,7.691031 +45.065145,7.642023,45.064181,7.67389 +45.082395,7.648059,45.086545,7.687952 +45.034948,7.655126,45.053148,7.633045 +45.105148,7.655056,45.102988,7.67895 +45.058397,7.662786,45.054607,7.662912 +45.074022,7.667241,45.085742,7.694725 +45.072935,7.667065,45.087856,7.667131 +45.065269,7.676041,45.083659,7.688371 +45.05158,7.688816,45.043333,7.678858 +45.099245,7.696601,45.075924,7.644156 +45.101832,7.69202,45.096504,7.68007 +45.055894,7.621703,45.046697,7.640551 +45.060981,7.624176,45.06295,7.619816 +45.064202,7.627869,45.053114,7.63306 +45.081607,7.624139,45.07596,7.643792 +45.079119,7.636198,45.077595,7.664597 +45.082564,7.636543,45.084579,7.65593 +45.068883,7.64427,45.062357,7.647277 +45.075742,7.649002,45.080905,7.656111 +45.037299,7.655685,45.047397,7.64357 +45.069171,7.65316,45.07371,7.6772 +45.061873,7.651458,45.08186,7.666371 +45.08676,7.653763,45.102495,7.662232 +45.057142,7.66124,45.041657,7.646452 +45.081193,7.662116,45.085274,7.664443 +45.053436,7.681344,45.065385,7.691778 +45.083696,7.688319,45.072728,7.665531 +45.097947,7.634363,45.102405,7.678512 +45.049034,7.646237,45.066369,7.67989 +45.067997,7.643927,45.095472,7.66689 +45.082163,7.65357,45.078863,7.667344 +45.084579,7.65593,45.095521,7.690117 +45.097902,7.651879,45.081045,7.645389 +45.068098,7.664654,45.056344,7.671127 +45.077878,7.667204,45.077307,7.682355 +45.072728,7.665531,45.062346,7.644967 +45.083489,7.663278,45.061083,7.683202 +45.086108,7.668931,45.08638,7.665004 +45.062519,7.678757,45.033942,7.647939 +45.096453,7.68007,45.088536,7.697233 +45.064397,7.639227,45.067658,7.665887 +45.064848,7.654152,45.090652,7.655751 +45.094199,7.653496,45.093172,7.673324 +45.08525,7.664451,45.082559,7.664138 +45.086816,7.670059,45.0933157,7.689132 +45.095107,7.669647,45.103489,7.664255 +45.077307,7.682355,45.085085,7.666692 +45.088536,7.697233,45.065659,7.649612 +45.086766,7.69748,45.096191,7.682812 +45.077594,7.619402,45.066725938176326,7.692769335558111 +45.085293,7.615799,45.075184,7.619991 +45.042841,7.626132,45.047738,7.634412 +45.043858,7.634496,45.052855,7.650042 +45.053098,7.633056,45.062406,7.630061 +45.07554,7.639311,45.091085,7.66268 +45.095637,7.635142,45.0938526571459,7.661938440370816 +45.062465,7.644987,45.066561,7.687542 +45.069115,7.653173,45.089448,7.664512 +45.095484,7.660858,45.062836,7.677796 +45.095273,7.667241,45.087564,7.667337 +45.072185,7.683722,45.062819,7.686646 +45.070577,7.684782,45.096361,7.643011 +45.095795,7.702244,45.08666,7.67107 +45.04775,7.628059,45.033654,7.654817 +45.100632,7.626056,45.091928,7.706083 +45.037042,7.630861,45.046341,7.640547 +45.067284,7.640479,45.088174,7.664774 +45.070661,7.633407,45.071422,7.634094 +45.095891,7.635114,45.101609,7.656542 +45.09873,7.636084,45.0854575847805,7.650560577232341 +45.034482,7.643917,45.065135,7.641959 +45.083695,7.656909,45.076537,7.655408 +45.073357,7.667127,45.060957,7.642651 +45.062863,7.678326,45.057718,7.689698 +45.063992,7.673848,45.1047,7.699411 +45.061051,7.683224,45.086062,7.662324 +45.071041,7.683091,45.082628,7.685515 +45.083659,7.688371,45.075686,7.688388 +45.066725938176326,7.692769335558111,45.068047,7.694627 +45.08773,7.69153,45.084911,7.694451 +45.075122,7.620117,45.082558,7.626519 +45.056788,7.636169,45.06891,7.633215 +45.071422,7.634094,45.057714,7.649076 +45.065755,7.649683,45.091802,7.673079 +45.0838,7.65702,45.082067,7.654197 +45.101609,7.656542,45.087687,7.670195 +45.07776,7.664732,45.073986,7.66837 +45.08522,7.666435,45.079065,7.675496 +45.092077,7.662689,45.095784,7.693916 +45.074154,7.676791,45.086804,7.666226 +45.086786,7.669826,45.073898,7.668445 +45.077399,7.682172,45.078024,7.662698 +45.084911,7.694451,45.094251,7.691932 +45.091928,7.706083,45.085336,7.663538 +45.044499,7.632642,45.064225,7.651023 +45.038387601025846,7.645870445047425,45.046850579661495,7.67296504528763 +45.055202,7.643763,45.090971,7.662471 +45.033632,7.65483,45.044466,7.625181 +45.073936,7.668426,45.064905,7.694533 +45.078863,7.667344,45.08242,7.653827 +45.085377,7.667714,45.107931,7.689716 +45.036395,7.671662,45.048212,7.646043 +45.05772,7.689693,45.055464,7.672018 +45.066055,7.68929,45.067432,7.689847 +45.07569,7.688387,45.0737072,7.6837758 +45.0744002,7.6937603,45.073762,7.696092 +45.088167,7.705321,45.087875,7.666152 +45.064468,7.622908,45.067331,7.62694 +45.075073,7.620238,45.097847,7.650924 +45.105951,7.624879,45.095608,7.633284 +45.046692,7.640669,45.032874,7.633693 +45.04672,7.636447,45.092594,7.690481 +45.03403,7.647755,45.033443,7.638543 +45.048212,7.646043,45.052628,7.648956 +45.064225,7.651023,45.066389,7.673444 +45.05865,7.651505,45.071511,7.636745 +45.065563,7.661291,45.067834,7.640697 +45.076645,7.665984,45.073322,7.68228 +45.091053,7.662761,45.085115,7.668857 +45.10249,7.662228,45.104612,7.646112 +45.05632,7.671111,45.069474,7.655575 +45.064368,7.673797,45.074479,7.655178 +45.066693,7.679262,45.062812,7.68662 +45.07272,7.675755,45.071352,7.674974 +45.093245,7.674299,45.088037,7.675212 +45.071866,7.683683,45.072778,7.667561 +45.064891,7.694509,45.085563,7.655487 +45.065377,7.691765,45.052755,7.675843 +45.068003,7.703432,45.080679,7.715972 +45.063872,7.7134,45.066956,7.709422 +45.047148,7.63041,45.041604,7.622278 +45.032874,7.633693,45.033702,7.630953 +45.081082,7.638081,45.08336,7.630162 +45.042514,7.648223,45.063059,7.673368 +45.082491,7.64644,45.097719,7.651398 +45.088373,7.656174,45.087847,7.690956 +45.097847,7.650924,45.106779,7.678101 +45.05707,7.664799,45.068649,7.677422 +45.051711,7.662977,45.062511,7.662963 +45.07831145380375,7.667845497293291,45.062048,7.687665 +45.086649,7.67072,45.087166,7.673268 +45.073243,7.674479,45.086409,7.678763 +45.072666,7.67584,45.086904,7.669178 +45.091949,7.672911,45.101897,7.641495 +45.096889,7.671564,45.066037,7.636853 +45.064936,7.694569,45.066521,7.688217 +45.105637,7.696371,45.074323,7.668662 +45.06295,7.619816,45.070676,7.655683 +45.073955,7.614421,45.095766,7.632618 +45.037736,7.620605,45.045333,7.63303 +45.041604,7.622278,45.042333,7.630344 +45.082452,7.626804,45.082642,7.632357 +45.071817,7.636689,45.066725,7.644661 +45.053964,7.653425,45.065446,7.630499 +45.087261,7.652837,45.101664,7.655986 +45.086045,7.655541,45.072488,7.676789 +45.057235,7.668214,45.073124,7.672071 +45.067879,7.667838,45.055361,7.680495 +45.077898,7.662597,45.086079,7.666975 +45.086557,7.67085,45.074495,7.693704 +45.085442,7.670527,45.087057,7.669978 +45.085098,7.668869,45.093077,7.705363 +45.094844441415816,7.662974545317126,45.095895,7.660272 +45.063059,7.673368,45.068554,7.663433 +45.062048,7.687665,45.074153,7.694666 +45.078632,7.68481,45.064668,7.696726 +45.087847,7.690956,45.06553,7.647797 +45.08809,7.690554,45.076134,7.676203 +45.083873,7.61647,45.070772,7.655881 +45.033702,7.630953,45.042815,7.649124 +45.062432,7.62999,45.066225,7.688288 +45.047843,7.638194,45.043155,7.65042 +45.06553,7.647797,45.043687,7.649815 +45.095895,7.660272,45.087565,7.66738 +45.030994,7.666519,45.053653,7.650079 +45.078763,7.667485,45.094013,7.696623 +45.098082,7.662901,45.096121,7.689604 +45.103242,7.664248,45.091541,7.684125 +45.076134,7.676203,45.043422,7.65093 +45.087141,7.690368,45.086815,7.697562 +45.096183,7.68276,45.077347,7.682126 +45.095711,7.686099,45.087104,7.669759 +45.074153,7.694666,45.061656,7.681644 +45.093797,7.694654,45.073687,7.70327 +45.07342,7.706395,45.066922,7.696154 +45.09584,7.711752,45.075524,7.695662 +45.084614,7.636145,45.059278,7.634852 +45.083211,7.639212,45.056858,7.634747 +45.077883,7.649056,45.074772,7.62608 +45.082951,7.648633,45.076181,7.644258 +45.070902,7.655818,45.043593,7.649674 +45.097696,7.651362,45.105648,7.66244 +45.074222,7.668657,45.073466,7.69321 +45.077873,7.669148,45.042603,7.652572 +45.078412,7.666438,45.044703,7.646674 +45.072737,7.667488,45.106698,7.6773 +45.086853,7.669166,45.068164,7.666856 +45.085856,7.668864,45.0765767,7.6644383 +45.087975,7.6696,45.068566,7.663403 +45.087104,7.669759,45.076419,7.667206 +45.059075,7.672426,45.075818,7.717204 +45.058412,7.678926,45.081805,7.697068 +45.071348,7.674967,45.074383,7.700447 +45.073243,7.672326,45.094888,7.705744 +45.081791,7.674484,45.043848,7.649816 +45.065594,7.690841,45.06745,7.700123 +45.061656,7.681644,45.041521,7.645623 +45.071498,7.684696,45.042312,7.654176 +45.091541,7.684125,45.091685,7.693673 +45.094013,7.696623,45.073375,7.666081 +45.075495,7.62089,45.045609,7.630923 +45.107132,7.62873,45.095621,7.665094 +45.059278,7.634852,45.056787,7.634729 +45.051279,7.633439,45.038169,7.634342 +45.067085,7.633303,45.044067,7.648932 +45.044703,7.646674,45.062738,7.648723 +45.04684,7.641289,45.035835,7.62423 +45.043408,7.650836,45.042342,7.662959 +45.076206,7.647033,45.074217,7.620331 +45.076181,7.644258,45.104351,7.680155 +45.104589,7.645917,45.102318,7.645577 +45.069455,7.655721,45.044412,7.67357 +45.069467,7.655594,45.044354,7.673572 +45.070777,7.655891,45.064119,7.690646 +45.073375,7.666081,45.074055,7.697145 +45.0775494,7.6674251,45.082446,7.659248 +45.087055913824855,7.669978438794531,45.056662,7.669242 +45.085899,7.666964,45.081532,7.692278 +45.087449,7.667352,45.074115,7.641277 +45.086306,7.664677,45.07451,7.693688 +45.08607,7.666914,45.075577,7.672324 +45.086209,7.663841,45.074442,7.693776 +45.091985,7.661282,45.084768,7.653246 +45.066508,7.673494,45.102922,7.624982 +45.079065,7.675496,45.057467,7.678392 +45.077298,7.682129,45.068358,7.678768 +45.096446,7.688594,45.088515,7.684709 +45.064616,7.696617,45.072769,7.67384 +45.064908,7.694521,45.043561,7.649867 +45.073466,7.69321,45.093628,7.660716 +45.090903,7.714495,45.094525,7.713413 +45.064719,7.620346,45.065106,7.683891 +45.074217,7.620331,45.075311,7.626916 +45.062847,7.627678,45.062535,7.636538 +45.045609,7.630923,45.067431,7.641729 +45.095816,7.632579,45.039226,7.634602 +45.043561,7.649867,45.063905,7.694527 +45.042167,7.654387,45.053743,7.660842 +45.042611,7.652587,45.070674,7.656568 +45.056787,7.654,45.046895,7.646292 +45.070649,7.655691,45.078413,7.716252 +45.071184,7.656073,45.056977,7.636009 +45.062173,7.669424,45.074718,7.659663 +45.068565,7.663411,45.081136,7.716777 +45.076466,7.664335,45.065495,7.691214 +45.076246,7.663841,45.065564,7.691188 +45.092086,7.662645,45.062614,7.65569 +45.053597,7.678245,45.066518,7.661748 +45.076981,7.683613,45.036277,7.651849 +45.074442,7.693776,45.051764,7.678972 +45.074342,7.693899,45.081158,7.716966 +45.075606,7.695476,45.095836,7.713529 +45.074576,7.695245,45.063906,7.702363 +45.07429,7.694459,45.108834,7.702938 +45.074326,7.694322,45.101216,7.641816 +45.07436,7.694273,45.081256,7.716893 +45.074352,7.694321,45.101212,7.64186 +45.071948,7.697346,45.075605,7.672823 +45.07451,7.693688,45.073422,7.693727 +45.074369,7.700478,45.074499,7.702727 +45.075443,7.69568,45.094839,7.714474 +45.074579,7.695158,45.103079,7.679012 +45.064283,7.629999,45.05845,7.657452 +45.08161,7.62428,45.078982,7.623475 +45.046064,7.64493,45.037443,7.658166 +45.043376,7.649665,45.056773,7.664796 +45.084768,7.643255,45.104781,7.668949 +45.082343,7.645629,45.073472,7.684381 +45.101216,7.641816,45.075288,7.615238 +45.070674,7.656568,45.086273,7.655538 +45.066518,7.661748,45.063906,7.694405 +45.105666,7.662349,45.096822,7.676199 +45.046158,7.674832,45.102209,7.693866 +45.051764,7.678972,45.061363,7.688552 +45.062011,7.677183,45.088468,7.692175 +45.06214,7.673936,45.068972,7.672228 +45.063905,7.694527,45.093589,7.702931 +45.074282,7.694882,45.092679,7.65719 +45.091588,7.693295,45.107641,7.653342 +45.067864,7.701493,45.088308,7.684415 +45.07346645216468,7.70328010696662,45.071316,7.673607 +45.078413,7.716252,45.083472,7.692982 +45.074467,7.620469,45.095851,7.657964 +45.046564,7.64646,45.05216,7.652614 +45.046955,7.64629,45.052045,7.653145 +45.065756,7.64878,45.063365,7.623361 +45.062479,7.643492,45.098493,7.634627 +45.101342,7.641803,45.072645,7.647256 +45.094288,7.659115,45.098076,7.651948 +45.065502,7.661347,45.096016,7.662974 +45.071821,7.675183,45.050721,7.674411 +45.067463,7.70012,45.093969,7.696973 +45.066409,7.698172,45.065769,7.714621 +45.063901,7.696435,45.082526,7.646627 +45.081485,7.692227,45.084274,7.690259 +45.070714,7.625891,45.075323,7.65083 +45.057031,7.636078,45.084996,7.690345 +45.03652,7.650715,45.087079,7.699099 +45.062969,7.648809,45.063856,7.623535 +45.081232,7.644358,45.081576,7.632606 +45.036017,7.651897,45.055363,7.648471 +45.052002,7.654415,45.077764,7.670247 +45.064141,7.666577,45.053822,7.681537 +45.096016,7.662974,45.048036,7.66696 +45.050721,7.674411,45.044853,7.67228 +45.073076,7.677156,45.071158,7.652901 +45.081243,7.716926,45.075071,7.671134 +45.071427,7.625459,45.082125,7.642823 +45.035542,7.633606,45.04845,7.624234 +45.051941,7.633006,45.065327,7.651488 +45.065395,7.641192,45.055949,7.680594 +45.037225,7.647014,45.064206,7.622283 +45.05285,7.647186,45.085549,7.666859 +45.052309,7.664634,45.046479,7.662591 +45.084144,7.679873,45.084069,7.693702 +45.082254,7.617912,45.067879,7.649164 +45.055769,7.634611,45.095884,7.657326 +45.062158,7.635654,45.045612,7.634998 +45.070977,7.665075,45.063427,7.67701 +45.036799,7.646012,45.031711,7.655266 +45.053376,7.649928,45.09682,7.668346 +45.078698,7.668213,45.083137,7.64021 +45.062939,7.710212,45.098509,7.704986 +45.08149,7.632527,45.073436,7.665658 +45.067713,7.649165,45.075476,7.629214 +45.037756,7.657499,45.063553,7.685698 +45.1051,7.655245,45.105376,7.666667 +45.077856,7.670122,45.034625,7.6448 +45.088452,7.684533,45.095162,7.691328 +45.082573,7.694318,45.09708,7.706052 +45.075323,7.65083,45.03571,7.643891 +45.082463,7.645098,45.092295,7.661797 +45.105416,7.666624,45.063395,7.680806 +45.063555,7.685608,45.087225,7.684612 +45.095139,7.69141,45.071625,7.718456 +45.055365,7.648516,45.065603,7.644878 +45.083243,7.644148,45.081704,7.659285 +45.034542,7.65173,45.036323,7.651171 +45.073415,7.66591,45.07065,7.683883 +45.096839,7.668354,45.077888,7.714245 +45.092295,7.661797,45.077908,7.667279 +45.096781,7.689607,45.0954,7.670886 +45.102299,7.693862,45.07201,7.675535 +45.039101,7.627113,45.084809,7.638905 +45.065315,7.680277,45.075092,7.695947 +45.065401,7.67881,45.07731117932369,7.682453050910555 +45.082517,7.646621,45.07211,7.659791 +45.057979,7.65777,45.068847,7.633113 +45.072177,7.657719,45.085149,7.667346 +45.080969,7.656845,45.083286,7.644247 +45.098489,7.70488,45.069491,7.695089 +45.071888,7.647542,45.066511,7.693271 +45.077889,7.667277,45.061977,7.676876 +45.085149,7.667346,45.08729,7.665595 +45.044433,7.673486,45.065637,7.656284 +45.065199,7.680043,45.093896,7.713105 +45.094818,7.705767,45.097372,7.710129 +45.094677,7.713389,45.097534,7.66797 +45.075459,7.62921,45.075201,7.631106 +45.078095,7.635831,45.0755,7.646836 +45.055241,7.661096,45.057202,7.678214 +45.095881,7.657967,45.068181,7.683588 +45.098069,7.651986,45.107947,7.645354 +45.087054,7.699104,45.072952,7.702842 +45.097372,7.710129,45.095064,7.705971 +45.09594,7.635196,45.096636,7.652474 +45.083585,7.66019,45.087402,7.667261 +45.095855,7.657255,45.087994,7.690595 +45.043101,7.66917,45.045671,7.664409 +45.087298,7.665554,45.078552,7.715613 +45.099182,7.664105,45.095205,7.669487 +45.042119,7.674493,45.035144,7.67488 +45.069479,7.695092,45.086914,7.666364 +45.071725,7.718241,45.072781,7.717636 +45.045608,7.634995,45.042807,7.67081 +45.067789,7.632397,45.06553,7.6353 +45.083135,7.640007,45.073544,7.654622 +45.065833,7.656377,45.043878,7.677334 +45.096612,7.652704,45.106763,7.634963 +45.087402,7.667261,45.074364,7.661121 +45.097388,7.660453,45.095577,7.666161 +45.062975,7.677767,45.046876,7.643886 +45.077695,7.670235,45.077311,7.682349 +45.079049,7.675341,45.082287,7.650999 +45.059267,7.68355,45.058063,7.683564 +45.087994,7.690595,45.075267,7.694789 +45.037334,7.63386,45.036203,7.643872 +45.051086,7.633152,45.034766,7.667041 +45.068987,7.633198,45.075967,7.644234 +45.06553,7.6353,45.05087,7.623956 +45.061707,7.645405,45.091872,7.66069 +45.083402,7.641975,45.077574,7.666337 +45.105305,7.660131,45.081548,7.656132 +45.068253,7.666782,45.064955,7.658183 +45.086955,7.666235,45.091266,7.661731 +45.064087,7.678764,45.033871,7.648434 +45.097995,7.672042,45.070982,7.684856 +45.077311,7.682349,45.058829,7.684543 +45.084042,7.692857,45.087154,7.693074 +45.044699,7.62939,45.068289,7.638289 +45.067609,7.658299,45.064947,7.65592 +45.076418,7.65533,45.075675,7.646254 +45.091811,7.65469,45.083361,7.64418 +45.091872,7.66069,45.085799,7.67076 +45.09259,7.661126,45.091745,7.658012 +45.068163,7.683635,45.074695,7.677886 +45.039227,7.633886,45.065281,7.648031 +45.106798,7.633702,45.106314,7.671081 +45.075909,7.644185,45.084929,7.655675 +45.083199,7.649315,45.103001,7.68205 +45.064947,7.65592,45.073508,7.662091 +45.072748,7.655827,45.061989,7.655899 +45.084019,7.661065,45.065783,7.698402 +45.068132,7.66693,45.065537,7.679515 +45.085799,7.67076,45.077499,7.702242 +45.04476,7.672057,45.042761,7.675374 +45.057741,7.672076,45.067125,7.66423 +45.062563,7.676889,45.095222,7.660577 +45.061483,7.676773,45.051045,7.674831 +45.070991,7.684758,45.094844,7.69802 +45.063907,7.702365,45.068464,7.683595 +45.063331,7.62339,45.067235,7.627466 +45.03288,7.636457,45.0626,7.678652 +45.052073,7.632822,45.038375,7.625793 +45.034017,7.647661,45.063068,7.676093 +45.044378,7.648072,45.072407,7.67818 +45.072364,7.647451,45.095452,7.669297 +45.074733,7.677858,45.064492,7.683281 +45.105734,7.689398,45.096546,7.677691 +45.094671,7.692257,45.091405,7.695782 +45.075143,7.614864,45.086284,7.654223 +45.050947,7.623816,45.055598,7.654492 +45.041278,7.633777,45.041928,7.674825 +45.068449,7.63835,45.087984,7.665109 +45.074784,7.643018,45.085247,7.633774 +45.088369,7.649096,45.086468,7.653693 +45.103406,7.650468,45.082889,7.631229 +45.038007,7.652568,45.046862,7.668252 +45.064917,7.658212,45.067489,7.665387 +45.066104,7.657096,45.072824,7.66198 +45.061785,7.655935,45.072466,7.656671 +45.069248,7.653437,45.074286,7.694589 +45.033838,7.669426,45.037327,7.652511 +45.056828,7.669274,45.077583,7.68164 +45.070693,7.665734,45.056402,7.662569 +45.063068,7.676093,45.037799,7.651866 +45.064492,7.683281,45.073905,7.67827 +45.070776,7.685102,45.104021,7.678709 +45.072176,7.683803,45.08785,7.666267 +45.085868,7.61604,45.077643,7.666586 +45.042478,7.624508,45.04414,7.6247 +45.102929,7.624816,45.086942,7.684064 +45.040825,7.643799,45.051473,7.622405 +45.10794,7.645396,45.097489,7.652072 +45.084865,7.668145,45.087755,7.666159 +45.070671,7.68437,45.072679,7.66705 +45.097399,7.704756,45.091234,7.693056 +45.09401,7.713072,45.104408,7.676748 diff --git a/tests/test_fixbikenet.py b/tests/test_fixbikenet.py index 286587d..5b6297c 100644 --- a/tests/test_fixbikenet.py +++ b/tests/test_fixbikenet.py @@ -7,28 +7,42 @@ fbn.constants._CRS_CALCULATIONS = 'auto' valcols = ['source', 'target'] + +def test_fixbikenet_success_online(): + """Verify that the online version of fixbikenet does not throw an error. + """ + fbn.constants._ROUTING_PENALTY = {0: 1.5, 1: 1} + fbn.settings.radius = 1000 + gaps_ordered = fbn.fixbikenet( + city_query="Frederiksberg municipality", + min_gap_length = 0, + max_gap_length = 100, + num_gaps = 20, + ) + + @pytest.fixture def validation_gdf_frederiksberg(): gdf = gpd.read_file("./tests/test_data/frederiksberg-fixbikenet-gaps.gpkg", layer='Identified gaps') return gdf - -def test_fixbikenet_case_success_offline1(validation_gdf_frederiksberg): +def test_fixbikenet_success_offline(validation_gdf_frederiksberg): """Verify that the offline version of fixbikenet works as intended. """ fbn.constants._ROUTING_PENALTY = {0: 1.5, 1: 1} fbn.settings.radius = 1000 gaps_ordered = fbn.fixbikenet( - city_query="Frederiksberg", - min_gap_length = 0, - max_gap_length = 100, - num_gaps = 20, - import_files={ - 'city_boundary': "./tests/test_data/frederiksberg_boundary.geojson", - 'street_network': "./tests/test_data/frederiksberg_streetbike_network.gpkg", - }, - ) + city_query="Frederiksberg municipality", + min_gap_length = 0, + max_gap_length = 100, + num_gaps = 20, + import_files={ + 'city_boundary': "./tests/test_data/frederiksberg_boundary.geojson", + 'street_network': "./tests/test_data/frederiksberg_streetbike_network.gpkg", + }, + ) assert_frame_equal( validation_gdf_frederiksberg[valcols], gaps_ordered[valcols] ) +