diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3a301b..6bdb67a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: caching: strategy: matrix: - python-version: ["3.12"] + python-version: ["3.12", "3.14"] os: [ ubuntu-latest ] fail-fast: false env: @@ -40,7 +40,7 @@ jobs: run: echo "WEEK=$(date +'%V')" >> $GITHUB_ENV - name: Set up Python ${{ matrix.python-version }} - uses: mamba-org/setup-micromamba@v2 + uses: mamba-org/setup-micromamba@v3 with: create-args: python=${{ matrix.python-version }} environment-file: environment-dev.yml @@ -51,12 +51,11 @@ jobs: needs: caching strategy: matrix: - python-version: ["3.12"] + python-version: ["3.12", "3.14"] os: [ ubuntu-latest ] submodule: - - { - name: "Functions", - pytest_args: "tests/test_functions.py" } + - { name: "Main", pytest_args: "tests/test_main.py" } + - { name: "Functions", pytest_args: "tests/test_functions.py" } fail-fast: false name: ${{ matrix.submodule.name }} (${{ matrix.python-version }} on ${{ matrix.os }}) @@ -73,7 +72,7 @@ jobs: run: echo "WEEK=$(date +'%V')" >> $GITHUB_ENV - name: Set up Python ${{ matrix.python-version }} - uses: mamba-org/setup-micromamba@v2 + uses: mamba-org/setup-micromamba@v3 with: create-args: python=${{ matrix.python-version }} environment-file: environment-dev.yml diff --git a/environment-dev.yml b/environment-dev.yml index eae63f9..c5d0ce4 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - python>=3.12 - - osmnx>=1.9.4 + - osmnx>=2 - tqdm # additional to the non-dev env diff --git a/environment.yml b/environment.yml index b913237..ab2aba2 100644 --- a/environment.yml +++ b/environment.yml @@ -3,5 +3,5 @@ channels: - conda-forge dependencies: - python>=3.12 - - osmnx>=1.9.4 + - osmnx>=2 - tqdm \ No newline at end of file diff --git a/examples/development.py b/examples/development.py index 004a787..fbfd6df 100644 --- a/examples/development.py +++ b/examples/development.py @@ -3,12 +3,14 @@ import fixbikenet as fbn fbn.settings.import_path = '../dataexport/cities/cityexport/' -fbn.constants._BETWEENNESS_RANDOM_NODES = 300 +fbn.constants._BETWEENNESS_RANDOM_NODES = 100 gaps = fbn.fixbikenet( - city_query="Frederiksberg Municipality", - export_file_format="geojson", - maxgap = 800, + city_query="Frederiksberg", + radius = 1000, + mingap = 0, + maxgap = 500, + numgaps = 20, import_files = { 'city_boundary': 'boundaries/frederiksberg_dk.geojson', 'street_network': 'streetbike_networks/frederiksberg_dk.gpkg', diff --git a/fixbikenet/fixbikenet.py b/fixbikenet/fixbikenet.py index 9957dda..1adefac 100644 --- a/fixbikenet/fixbikenet.py +++ b/fixbikenet/fixbikenet.py @@ -45,7 +45,6 @@ def fixbikenet( numgaps = 50, export_data = True, city_id = None, - export_file_format="geojson", export_plot=False, import_files={}, ): @@ -68,8 +67,6 @@ def fixbikenet( If set to True, data will be saved to a file. The filename is [slug].gpkg, where slug is a string id made out of city_name city_id : str | None, default None If set, the slugified city_id is used in the filename of the data export. For example, a city_id "Athens" will slugify into "athens" in filenames. If set to None, the slugified city_query is used in the filename of the data export. It is useful to set a city_id for cities where the city_query is not the city name, for example to set for a city_query "Municipality of Athens" the city_id to "Athens". - export_file_format : str, optional, default "geojson" - File format for the data export, relevant if export_data set to True. Default "geojson", also possible "gpkg". If exporting as geojson, generates extra files for street network and city boundary. If exporting as gkpg, these are added all in one file as extra layers. export_plot : bool, optional, default False If set to True, plot will be saved to a file import_files: dict, default {} @@ -100,7 +97,7 @@ def fixbikenet( starttime = time.time() np.random.seed(settings.random_seed) # Set random number generator seed for reproducibility setting_was_auto = _validate_settings() - import_files = _validate_parameters(city_query, radius, mingap, maxgap, export_data, export_file_format, import_files) + import_files = _validate_parameters(city_query, radius, mingap, maxgap, export_data, import_files) _print_header(city_query) # Get city boundary @@ -212,6 +209,8 @@ def fixbikenet( gaps_ordered.to_crs(epsg=4326, inplace=True) edges_pbi_gdf.to_crs(epsg=4326, inplace=True) edges_gdf.to_crs(epsg=4326, inplace=True) + gaps_ordered = gaps_ordered[['path', 'benefit', 'name', 'edge_list', 'source', 'target', 'ordering', 'length', 'geometry']] + progress_bar.update(1) progress_bar.close() @@ -223,14 +222,14 @@ def fixbikenet( else: city_string = city_id export_data_filename = ( - slugify(city_string) + "-fixbikenet-gaps" + "." + export_file_format + slugify(city_string) + "-fixbikenet-gaps" + "." + settings.export_file_format ) if export_data: edges_pbi_gdf.drop(["osmid"], axis=1, inplace=True) edges_gdf.drop(["osmid"], axis=1, inplace=True) city_boundary.to_crs(epsg=4326, inplace=True) - if export_file_format == "geojson": + if settings.export_file_format == "geojson": progress_bar = initialize_progress_bar("Exporting data", 4, "file") gaps_ordered.to_file(settings.export_path + export_data_filename, driver="GeoJSON", RFC7946="YES") progress_bar.update(1) @@ -240,12 +239,15 @@ def fixbikenet( progress_bar.update(1) city_boundary.to_file(settings.export_path + slugify(city_string) + "-city_boundary.geojson", driver="GeoJSON", RFC7946="YES") progress_bar.update(1) - elif export_file_format == "gpkg": + elif settings.export_file_format == "gpkg": + f = settings.export_path + export_data_filename + if os.path.exists(f): + os.remove(f) # mode="w" does not work for to_file with gpkg. It always appends. Therefore, existing file needs to be deleted. progress_bar = initialize_progress_bar("Exporting data", 1, "file") - gaps_ordered.to_file(settings.export_path + export_data_filename, driver="GPKG", layer="Identified gaps") - edges_pbi_gdf.to_file(settings.export_path + export_data_filename, driver="GPKG", layer="Existing bike network", append=True) - edges_gdf.to_file(settings.export_path + export_data_filename, driver="GPKG", layer="Existing street network", append=True) - city_boundary.to_file(settings.export_path + export_data_filename, driver="GPKG", layer="City boundary", append=True) + gaps_ordered.to_file(f, driver="GPKG", layer="Identified gaps") + edges_pbi_gdf.to_file(f, driver="GPKG", layer="Existing bike network", append=True) + edges_gdf.to_file(f, driver="GPKG", layer="Existing street network", append=True) + city_boundary.to_file(f, driver="GPKG", layer="City boundary", append=True) progress_bar.update(1) progress_bar.close() diff --git a/fixbikenet/functions.py b/fixbikenet/functions.py index 306c218..f03b933 100644 --- a/fixbikenet/functions.py +++ b/fixbikenet/functions.py @@ -28,7 +28,6 @@ def _validate_parameters( mingap, maxgap, export_data, - export_file_format, import_files, ): """ Check if user parameter input is valid. If not, raise an exception or @@ -57,8 +56,6 @@ def _validate_parameters( raise TypeError("maxgap must be an integer") if type(export_data) is not bool: raise TypeError("export_data must be a boolean") - if export_file_format != "geojson" and export_file_format != "gpkg": - raise ValueError("export_file_format must be 'geojson' or 'gpkg'") if type(import_files) is not dict: raise TypeError("import_files must be a dictionary") @@ -85,6 +82,8 @@ def _validate_settings(): if type(constants._CRS_CALCULATIONS) is not str: raise TypeError("constants._CRS_CALCULATIONS must be a string") + if settings.export_file_format != "geojson" and settings.export_file_format != "gpkg": + raise ValueError("settings.export_file_format must be 'geojson' or 'gpkg'") setting_was_auto = {'crs_calculations': False} # Ask whether constants._CRS_CALCULATIONS was 'auto' diff --git a/fixbikenet/settings.py b/fixbikenet/settings.py index 226c71a..43e4755 100644 --- a/fixbikenet/settings.py +++ b/fixbikenet/settings.py @@ -1,5 +1,9 @@ """Global settings for `fixbikenet` that can be configured by the user. +export_file_format : {'gpkg', 'geojson'}, default 'gpkg' + File format for the data export, relevant if `export_data` is set to True. + If exporting as geojson, generates extra files for seed points, city + boundary, and existing bicycle network (if relevant). If exporting as gkpg, these are added all in one file as extra layers. export_path : dict(str) Paths to results folder to save data. import_path : str @@ -10,6 +14,7 @@ If set to True, suppresses all user feedback. Useful for batch exports. """ +export_file_format = 'gpkg' export_path = "./results/" import_path = "./" diff --git a/pyproject.toml b/pyproject.toml index a0eeebc..d223e10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,45 +6,50 @@ build-backend = "setuptools.build_meta" name = "fixbikenet" version = "0.7.0" authors = [ - { name = "Manuel Knepper" }, - { name = "Anastassia Vybornova" }, - { name = "Michael Szell" }, + {name = "Manuel Knepper"}, + {name = "Anastassia Vybornova"}, + {name = "Michael Szell", email = "michael@szell.net"}, +] +maintainers = [ + {name = "Michael Szell", email = "michael@szell.net"}, ] -maintainers = [{ name = "Manuel Knepper", email = "manuel.knepper@gmx.net" }] license = "AGPL-3.0-or-later" readme = "README.md" description = "BikeNetKit Python package to detect gaps in developed bicycle networks" keywords = ["Bicycle network planning", "Networks", "OpenStreetMap", "Urban Planning", "Urban Mobility"] classifiers = [ - "Development Status :: 3 - Alpha", + "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Science/Research", + "Intended Audience :: Other Audience", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Natural Language :: English", + "Topic :: Scientific/Engineering :: GIS", ] -requires-python = ">=3.10" +requires-python = ">=3.12" dependencies = [ - "geopandas>=0.14", + "geopandas>=1", "matplotlib", - "osmnx>=1.9.4", + "osmnx>=2", "geojson", "tqdm", - "pip", - "momepy", ] [project.urls] +Homepage = "https://bikenetkit.org/" +Documentation = "https://docs.bikenetkit.org/FixBikeNet/" Repository = "https://github.com/BikeNetKit/FixBikeNet" Issues = "https://github.com/BikeNetKit/FixBikeNet/issues" +Changelog = "https://docs.bikenetkit.org/FixBikeNet/changelog/" [project.optional-dependencies] test = ["pytest"] -doc = ["sphinx", "momepy"] +doc = ["sphinx"] [tool.ruff.lint.extend-per-file-ignores] "__init__.py" = ["F401"] # "Imported but unused: happens with packages diff --git a/tests/test_data/frederiksberg-fixbikenet-gaps.gpkg b/tests/test_data/frederiksberg-fixbikenet-gaps.gpkg new file mode 100644 index 0000000..bec4c79 Binary files /dev/null and b/tests/test_data/frederiksberg-fixbikenet-gaps.gpkg differ diff --git a/tests/test_data/frederiksberg_boundary.geojson b/tests/test_data/frederiksberg_boundary.geojson new file mode 100644 index 0000000..6082ac3 --- /dev/null +++ b/tests/test_data/frederiksberg_boundary.geojson @@ -0,0 +1,8 @@ +{ +"type": "FeatureCollection", +"name": "frederiksberg_dk", +"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, +"features": [ +{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 12.4913156, 55.6790825 ], [ 12.4914503, 55.6789363 ], [ 12.4920541, 55.6782512 ], [ 12.4921208, 55.6781767 ], [ 12.4922012, 55.6780867 ], [ 12.4924432, 55.6778103 ], [ 12.4925969, 55.6776178 ], [ 12.4925933, 55.677519 ], [ 12.4926013, 55.6772358 ], [ 12.4926224, 55.6769563 ], [ 12.4926628, 55.6766727 ], [ 12.4927812, 55.6758303 ], [ 12.492911, 55.6749873 ], [ 12.4929719, 55.6747059 ], [ 12.4930909, 55.6738665 ], [ 12.4932308, 55.6730186 ], [ 12.4932969, 55.672602 ], [ 12.4933641, 55.6725681 ], [ 12.4933648, 55.6725624 ], [ 12.4946079, 55.6725347 ], [ 12.4952161, 55.6725229 ], [ 12.4952224, 55.6725045 ], [ 12.495235, 55.6725035 ], [ 12.4952894, 55.6723194 ], [ 12.495448, 55.6723286 ], [ 12.4954774, 55.6722512 ], [ 12.4955964, 55.6718967 ], [ 12.4957996, 55.6712844 ], [ 12.4958829, 55.670973 ], [ 12.4959157, 55.6708644 ], [ 12.495921, 55.6708539 ], [ 12.4959513, 55.6707545 ], [ 12.4962252, 55.6698404 ], [ 12.4963666, 55.6693701 ], [ 12.4964185, 55.6692144 ], [ 12.4965331, 55.6689282 ], [ 12.4965771, 55.6689299 ], [ 12.4987899, 55.6690211 ], [ 12.5010268, 55.6691237 ], [ 12.5010561, 55.6692886 ], [ 12.5022063, 55.6693417 ], [ 12.5026308, 55.6693614 ], [ 12.5030722, 55.6691106 ], [ 12.5035968, 55.6691369 ], [ 12.5036453, 55.6691395 ], [ 12.5037194, 55.6691428 ], [ 12.5043001, 55.6691709 ], [ 12.5043744, 55.669174 ], [ 12.5047284, 55.6691917 ], [ 12.5047843, 55.6691944 ], [ 12.5048913, 55.6691994 ], [ 12.5049213, 55.669201 ], [ 12.5049721, 55.6692035 ], [ 12.5050161, 55.6692046 ], [ 12.5050794, 55.6692082 ], [ 12.5051909, 55.6692153 ], [ 12.5052074, 55.6692162 ], [ 12.5052966, 55.6692196 ], [ 12.5054888, 55.6692292 ], [ 12.5056708, 55.6692386 ], [ 12.5056879, 55.6692394 ], [ 12.5057836, 55.6692448 ], [ 12.50605, 55.6692577 ], [ 12.5062739, 55.669267 ], [ 12.5064235, 55.6692749 ], [ 12.5066405, 55.6692843 ], [ 12.5069366, 55.6693021 ], [ 12.5069495, 55.6693029 ], [ 12.5075417, 55.6693375 ], [ 12.5077735, 55.6693513 ], [ 12.5079003, 55.6693574 ], [ 12.5080109, 55.6693627 ], [ 12.5081683, 55.6693703 ], [ 12.5083254, 55.6693777 ], [ 12.5083413, 55.6693786 ], [ 12.5085654, 55.6693894 ], [ 12.508571, 55.6693897 ], [ 12.5086765, 55.6693952 ], [ 12.5088978, 55.6694057 ], [ 12.5089662, 55.6694095 ], [ 12.5090084, 55.6694113 ], [ 12.509169, 55.6694192 ], [ 12.5093281, 55.6694274 ], [ 12.5093654, 55.669429 ], [ 12.5094373, 55.6694321 ], [ 12.5095485, 55.669438 ], [ 12.5096584, 55.669443 ], [ 12.5097716, 55.6694485 ], [ 12.5097783, 55.6694488 ], [ 12.5098815, 55.6694542 ], [ 12.5101952, 55.6694693 ], [ 12.5102137, 55.6694703 ], [ 12.5103239, 55.669476 ], [ 12.5109573, 55.6695065 ], [ 12.5109608, 55.6695082 ], [ 12.5109763, 55.6695153 ], [ 12.5110041, 55.6696122 ], [ 12.5114015, 55.6695085 ], [ 12.5116101, 55.6694555 ], [ 12.5117418, 55.6694206 ], [ 12.5117775, 55.6694114 ], [ 12.511878, 55.6693853 ], [ 12.5118869, 55.669383 ], [ 12.5120752, 55.6693338 ], [ 12.5124441, 55.6692379 ], [ 12.5129398, 55.6691098 ], [ 12.5130767, 55.6690744 ], [ 12.5132124, 55.6690396 ], [ 12.5135728, 55.6689466 ], [ 12.5137072, 55.6689123 ], [ 12.5139219, 55.6688565 ], [ 12.5144993, 55.6687077 ], [ 12.5150563, 55.6685638 ], [ 12.5150872, 55.6685559 ], [ 12.5153176, 55.6684967 ], [ 12.515369, 55.6684833 ], [ 12.5158138, 55.6683699 ], [ 12.5158546, 55.6683581 ], [ 12.515964, 55.6683304 ], [ 12.5159672, 55.6683284 ], [ 12.5161371, 55.668286 ], [ 12.5161896, 55.6682718 ], [ 12.5168425, 55.6681055 ], [ 12.5170094, 55.6680642 ], [ 12.5170357, 55.6680579 ], [ 12.5173371, 55.6679888 ], [ 12.5173395, 55.6679518 ], [ 12.5174431, 55.6679536 ], [ 12.5176016, 55.6679564 ], [ 12.5176039, 55.667914 ], [ 12.5177501, 55.6678793 ], [ 12.5179215, 55.6678385 ], [ 12.5183004, 55.6677474 ], [ 12.5184736, 55.6677057 ], [ 12.5188333, 55.6676193 ], [ 12.5189815, 55.6675832 ], [ 12.5190118, 55.6675758 ], [ 12.5191877, 55.6675338 ], [ 12.5195479, 55.6675168 ], [ 12.5195382, 55.6674485 ], [ 12.5199865, 55.6673398 ], [ 12.5201768, 55.6672933 ], [ 12.5202716, 55.6672699 ], [ 12.5203286, 55.6672559 ], [ 12.5203195, 55.6672149 ], [ 12.5203773, 55.6672108 ], [ 12.5204761, 55.6672037 ], [ 12.5207639, 55.6671821 ], [ 12.5207564, 55.6671512 ], [ 12.5208716, 55.6671224 ], [ 12.5209524, 55.6671027 ], [ 12.5215799, 55.6669448 ], [ 12.5217071, 55.6669135 ], [ 12.5222268, 55.6667866 ], [ 12.5225266, 55.6667118 ], [ 12.5225376, 55.6667194 ], [ 12.5230892, 55.6666984 ], [ 12.523241, 55.666725 ], [ 12.5232544, 55.6666962 ], [ 12.5232653, 55.6666672 ], [ 12.5233129, 55.6665058 ], [ 12.5233421, 55.6665072 ], [ 12.5233709, 55.6665091 ], [ 12.5234265, 55.6665141 ], [ 12.5236157, 55.6665409 ], [ 12.5236984, 55.6665561 ], [ 12.5246148, 55.6667047 ], [ 12.5251015, 55.6667867 ], [ 12.5251135, 55.6667886 ], [ 12.5253864, 55.6668311 ], [ 12.5261229, 55.6669551 ], [ 12.5261814, 55.6669651 ], [ 12.526668, 55.6670597 ], [ 12.5266904, 55.6670646 ], [ 12.5270844, 55.667136 ], [ 12.527501, 55.6672179 ], [ 12.5279347, 55.6672979 ], [ 12.5281675, 55.6673424 ], [ 12.5282185, 55.6673513 ], [ 12.5283141, 55.6673692 ], [ 12.5284698, 55.6673998 ], [ 12.5288299, 55.6674758 ], [ 12.5290535, 55.6675258 ], [ 12.5292112, 55.6675628 ], [ 12.5293454, 55.6675938 ], [ 12.5295625, 55.6676475 ], [ 12.5296585, 55.6676751 ], [ 12.5297533, 55.6677058 ], [ 12.5298361, 55.6677355 ], [ 12.529918, 55.6677668 ], [ 12.5299271, 55.6677712 ], [ 12.5299528, 55.6677837 ], [ 12.5301715, 55.6677635 ], [ 12.530376, 55.667745 ], [ 12.5304138, 55.6677603 ], [ 12.5304352, 55.6677677 ], [ 12.5305477, 55.6677899 ], [ 12.5305532, 55.6677911 ], [ 12.5309399, 55.6678707 ], [ 12.5315383, 55.6679939 ], [ 12.5315422, 55.6679947 ], [ 12.5323785, 55.6681552 ], [ 12.5325506, 55.6682004 ], [ 12.53272, 55.6682264 ], [ 12.5332443, 55.6683749 ], [ 12.5332538, 55.6683648 ], [ 12.5334428, 55.6684192 ], [ 12.5334822, 55.6684228 ], [ 12.5335022, 55.6684324 ], [ 12.5335094, 55.6684521 ], [ 12.5335759, 55.6684696 ], [ 12.5343012, 55.6686598 ], [ 12.5349317, 55.6688192 ], [ 12.5348996, 55.6689335 ], [ 12.5350348, 55.6689708 ], [ 12.5348216, 55.6692932 ], [ 12.5350533, 55.6693592 ], [ 12.5357835, 55.6695675 ], [ 12.5358131, 55.6695759 ], [ 12.5362713, 55.6697059 ], [ 12.5368339, 55.6698664 ], [ 12.537202, 55.669971 ], [ 12.5375959, 55.6700836 ], [ 12.5379039, 55.6701717 ], [ 12.5379088, 55.6701731 ], [ 12.5380711, 55.6702191 ], [ 12.538319, 55.6702928 ], [ 12.5394042, 55.6702088 ], [ 12.5394264, 55.6702967 ], [ 12.5395115, 55.6706375 ], [ 12.5396178, 55.6706678 ], [ 12.5398667, 55.6707404 ], [ 12.5398772, 55.6707435 ], [ 12.5398838, 55.6707454 ], [ 12.5403012, 55.6708632 ], [ 12.5405562, 55.6709384 ], [ 12.541042, 55.67108 ], [ 12.5411594, 55.6711143 ], [ 12.5411956, 55.6711247 ], [ 12.5417579, 55.6712837 ], [ 12.5417597, 55.6712842 ], [ 12.542014, 55.6713577 ], [ 12.5420163, 55.6713583 ], [ 12.5422832, 55.671436 ], [ 12.5423435, 55.6714532 ], [ 12.5427665, 55.6715749 ], [ 12.5429902, 55.6716391 ], [ 12.5432589, 55.6717158 ], [ 12.5435254, 55.671792 ], [ 12.5437928, 55.6718693 ], [ 12.5441328, 55.6719667 ], [ 12.5443277, 55.672023 ], [ 12.5446492, 55.6721144 ], [ 12.544964, 55.6722053 ], [ 12.5451591, 55.6722615 ], [ 12.5460851, 55.6725285 ], [ 12.5467538, 55.6727203 ], [ 12.5470735, 55.6728119 ], [ 12.547022, 55.6728912 ], [ 12.5471054, 55.6729005 ], [ 12.5471324, 55.6729053 ], [ 12.5471365, 55.6729155 ], [ 12.5472463, 55.6729385 ], [ 12.5473647, 55.6729735 ], [ 12.5473736, 55.672978 ], [ 12.5474092, 55.6729978 ], [ 12.5474188, 55.6730038 ], [ 12.5474266, 55.6730075 ], [ 12.5474353, 55.6730118 ], [ 12.5474532, 55.6730212 ], [ 12.547462, 55.6730259 ], [ 12.5474712, 55.6730309 ], [ 12.5474803, 55.6730361 ], [ 12.5474909, 55.6730421 ], [ 12.5475019, 55.6730484 ], [ 12.547513, 55.6730551 ], [ 12.5475227, 55.6730618 ], [ 12.5475246, 55.6730631 ], [ 12.5475263, 55.6730643 ], [ 12.5475299, 55.6730669 ], [ 12.5476529, 55.6730607 ], [ 12.5480086, 55.6730354 ], [ 12.5480277, 55.673034 ], [ 12.5480516, 55.6730315 ], [ 12.5484032, 55.6729918 ], [ 12.5484685, 55.672984 ], [ 12.5488503, 55.6728914 ], [ 12.5495282, 55.6727271 ], [ 12.5497492, 55.672673 ], [ 12.5497712, 55.6727 ], [ 12.5498874, 55.6726973 ], [ 12.5499506, 55.672701 ], [ 12.5499751, 55.6727293 ], [ 12.5499937, 55.6728323 ], [ 12.5499556, 55.6730697 ], [ 12.5499147, 55.6733429 ], [ 12.549891, 55.6733408 ], [ 12.549875, 55.6734578 ], [ 12.5498779, 55.673463 ], [ 12.5498544, 55.6736627 ], [ 12.5500033, 55.6736649 ], [ 12.5499896, 55.6737693 ], [ 12.5499711, 55.6738926 ], [ 12.549952, 55.674022 ], [ 12.5499325, 55.6741528 ], [ 12.549896, 55.6743994 ], [ 12.5498924, 55.6744262 ], [ 12.5499269, 55.6744397 ], [ 12.5504591, 55.6743173 ], [ 12.5507551, 55.6742485 ], [ 12.5508643, 55.674223 ], [ 12.5513128, 55.6741171 ], [ 12.5515933, 55.6740559 ], [ 12.5518099, 55.6740086 ], [ 12.5519479, 55.6739771 ], [ 12.5523631, 55.6738822 ], [ 12.5524531, 55.6738616 ], [ 12.5534852, 55.6736262 ], [ 12.5537176, 55.6735741 ], [ 12.5540633, 55.6734965 ], [ 12.5540665, 55.6734721 ], [ 12.5540995, 55.6734722 ], [ 12.5550862, 55.6735274 ], [ 12.5551448, 55.6735387 ], [ 12.555177, 55.6735451 ], [ 12.5552489, 55.6738224 ], [ 12.5552619, 55.6738737 ], [ 12.5553054, 55.6740421 ], [ 12.5554572, 55.6746301 ], [ 12.555465, 55.6746606 ], [ 12.555546, 55.6749746 ], [ 12.5556695, 55.6754632 ], [ 12.5557272, 55.6756891 ], [ 12.555794, 55.6759407 ], [ 12.5560223, 55.6767972 ], [ 12.5560391, 55.6768594 ], [ 12.5561142, 55.6771438 ], [ 12.5561872, 55.6774267 ], [ 12.5562045, 55.6774938 ], [ 12.5563342, 55.6780062 ], [ 12.5563484, 55.6780617 ], [ 12.5563654, 55.6781274 ], [ 12.5563714, 55.6781504 ], [ 12.5564391, 55.6784119 ], [ 12.5565093, 55.6786817 ], [ 12.5565266, 55.6787483 ], [ 12.5566011, 55.6790348 ], [ 12.5566316, 55.6791558 ], [ 12.5566723, 55.6793087 ], [ 12.556691, 55.6793745 ], [ 12.5567696, 55.6796648 ], [ 12.5567705, 55.679668 ], [ 12.5568389, 55.6799302 ], [ 12.5568412, 55.6799535 ], [ 12.5569181, 55.6802605 ], [ 12.5569202, 55.6802692 ], [ 12.5569544, 55.6803823 ], [ 12.5570147, 55.6806133 ], [ 12.5570304, 55.6806723 ], [ 12.5570625, 55.680779 ], [ 12.5571248, 55.6810012 ], [ 12.5571679, 55.6811515 ], [ 12.5572594, 55.6814709 ], [ 12.5573205, 55.6816821 ], [ 12.5573242, 55.6816937 ], [ 12.5573411, 55.6817492 ], [ 12.5569014, 55.6817138 ], [ 12.5566573, 55.6816947 ], [ 12.5554137, 55.6815963 ], [ 12.5550511, 55.6815673 ], [ 12.5546077, 55.6815324 ], [ 12.5542674, 55.6815051 ], [ 12.5541873, 55.6814985 ], [ 12.5536924, 55.6816135 ], [ 12.5539388, 55.6819729 ], [ 12.5542774, 55.6824646 ], [ 12.5550786, 55.6836289 ], [ 12.5551086, 55.6836224 ], [ 12.5552355, 55.6838059 ], [ 12.5552669, 55.683853 ], [ 12.5548959, 55.6842441 ], [ 12.5547087, 55.6843575 ], [ 12.5546193, 55.6844037 ], [ 12.5543948, 55.6844935 ], [ 12.5542129, 55.6845572 ], [ 12.5537283, 55.6847269 ], [ 12.5534018, 55.6848393 ], [ 12.5533335, 55.6848592 ], [ 12.5532402, 55.6848742 ], [ 12.5527626, 55.6849044 ], [ 12.5523772, 55.6849289 ], [ 12.5515107, 55.6849778 ], [ 12.5513723, 55.684986 ], [ 12.5510538, 55.6850041 ], [ 12.5501608, 55.6850561 ], [ 12.5498648, 55.6850734 ], [ 12.5491336, 55.6851148 ], [ 12.5470783, 55.6852344 ], [ 12.5470603, 55.6852441 ], [ 12.5469662, 55.6852522 ], [ 12.5468731, 55.6852646 ], [ 12.5467821, 55.6852815 ], [ 12.5466941, 55.6853026 ], [ 12.5466129, 55.6853265 ], [ 12.5465354, 55.6853542 ], [ 12.5464619, 55.6853852 ], [ 12.5463933, 55.6854195 ], [ 12.546173, 55.6855385 ], [ 12.5461498, 55.685525 ], [ 12.545284, 55.6859925 ], [ 12.5451298, 55.6860774 ], [ 12.5449283, 55.6861859 ], [ 12.5448692, 55.6862183 ], [ 12.54477, 55.6862698 ], [ 12.5447288, 55.6862873 ], [ 12.5445384, 55.6863649 ], [ 12.5443683, 55.6864346 ], [ 12.5442997, 55.6864609 ], [ 12.5439018, 55.6865855 ], [ 12.5435886, 55.6866819 ], [ 12.5432386, 55.6867934 ], [ 12.5431706, 55.6868144 ], [ 12.5427611, 55.6869417 ], [ 12.5427202, 55.6869536 ], [ 12.5426471, 55.6869784 ], [ 12.5424716, 55.6870429 ], [ 12.5422802, 55.6871135 ], [ 12.542222, 55.6871378 ], [ 12.5421776, 55.6871641 ], [ 12.5421243, 55.6871975 ], [ 12.5421444, 55.687212 ], [ 12.5419909, 55.6872724 ], [ 12.5418027, 55.6873553 ], [ 12.5414493, 55.6875941 ], [ 12.5413862, 55.687621 ], [ 12.5411811, 55.6877088 ], [ 12.5408882, 55.6880322 ], [ 12.5405551, 55.6883789 ], [ 12.5404963, 55.6884247 ], [ 12.5402835, 55.6885378 ], [ 12.540022, 55.688677 ], [ 12.5392511, 55.6890744 ], [ 12.5390529, 55.6891762 ], [ 12.5386775, 55.6893694 ], [ 12.5383313, 55.6895539 ], [ 12.5382151, 55.6896087 ], [ 12.5381402, 55.6896393 ], [ 12.5379453, 55.6897103 ], [ 12.5378383, 55.6897497 ], [ 12.5377741, 55.689789 ], [ 12.5376332, 55.6899075 ], [ 12.5375219, 55.6900271 ], [ 12.537309, 55.6902351 ], [ 12.5372187, 55.690331 ], [ 12.5371263, 55.6904499 ], [ 12.5369084, 55.6906768 ], [ 12.5367407, 55.6908517 ], [ 12.5367268, 55.6908661 ], [ 12.5365682, 55.691039 ], [ 12.5356786, 55.6920421 ], [ 12.535649, 55.6920898 ], [ 12.5355301, 55.6923749 ], [ 12.5355251, 55.6924082 ], [ 12.5355297, 55.6924545 ], [ 12.535545, 55.6925162 ], [ 12.5355783, 55.6926358 ], [ 12.5355932, 55.6926869 ], [ 12.535601, 55.6927027 ], [ 12.5356371, 55.6927655 ], [ 12.5357339, 55.6929181 ], [ 12.5358424, 55.6930864 ], [ 12.5358655, 55.6931347 ], [ 12.535871, 55.6931742 ], [ 12.5358685, 55.6932314 ], [ 12.5357462, 55.693806 ], [ 12.5357285, 55.6938514 ], [ 12.5356669, 55.6939071 ], [ 12.5355741, 55.6939686 ], [ 12.5351374, 55.6942566 ], [ 12.5350852, 55.694294 ], [ 12.5350198, 55.6943279 ], [ 12.5350153, 55.6943299 ], [ 12.5348918, 55.6943886 ], [ 12.5348175, 55.6944208 ], [ 12.5347638, 55.6944424 ], [ 12.5348357, 55.6945032 ], [ 12.5350599, 55.6946923 ], [ 12.5354162, 55.6949728 ], [ 12.5354242, 55.6949792 ], [ 12.5355269, 55.6950632 ], [ 12.5355648, 55.6951215 ], [ 12.535691, 55.6954071 ], [ 12.5357469, 55.6955584 ], [ 12.5357703, 55.6956426 ], [ 12.5357971, 55.6956968 ], [ 12.5360979, 55.6959439 ], [ 12.5362073, 55.6959952 ], [ 12.5363767, 55.6960513 ], [ 12.5364929, 55.6960868 ], [ 12.5365537, 55.6961138 ], [ 12.536575, 55.6961232 ], [ 12.5366212, 55.6961629 ], [ 12.5366445, 55.6961925 ], [ 12.5367025, 55.6962657 ], [ 12.5368037, 55.6963945 ], [ 12.5368486, 55.6964431 ], [ 12.5369399, 55.6964871 ], [ 12.5370428, 55.6965273 ], [ 12.5373549, 55.6966054 ], [ 12.5374922, 55.6966498 ], [ 12.537696, 55.6967649 ], [ 12.5377583, 55.6967985 ], [ 12.5381033, 55.6970029 ], [ 12.5381136, 55.6970101 ], [ 12.5382691, 55.6971137 ], [ 12.5382796, 55.6973149 ], [ 12.5382987, 55.6976716 ], [ 12.5380906, 55.6976791 ], [ 12.5379735, 55.6976707 ], [ 12.5378594, 55.6976576 ], [ 12.5378277, 55.6976506 ], [ 12.5373029, 55.6976028 ], [ 12.5365563, 55.6975361 ], [ 12.5363978, 55.6975207 ], [ 12.5363104, 55.6975126 ], [ 12.5362533, 55.6975069 ], [ 12.5362183, 55.6975036 ], [ 12.5361837, 55.6975 ], [ 12.5360042, 55.6974836 ], [ 12.5359616, 55.6974795 ], [ 12.5354296, 55.6974312 ], [ 12.5330208, 55.6972103 ], [ 12.5321495, 55.6971308 ], [ 12.5320854, 55.6970945 ], [ 12.5321599, 55.6969054 ], [ 12.5321744, 55.6968602 ], [ 12.5321925, 55.6968223 ], [ 12.5321998, 55.6968069 ], [ 12.5322532, 55.696679 ], [ 12.5319997, 55.6966875 ], [ 12.5309281, 55.6967109 ], [ 12.530807, 55.6967111 ], [ 12.5306366, 55.6967164 ], [ 12.5303832, 55.6964721 ], [ 12.5301608, 55.6962571 ], [ 12.5301389, 55.6962367 ], [ 12.529878, 55.6959802 ], [ 12.5298221, 55.6959309 ], [ 12.5297253, 55.6958342 ], [ 12.5294186, 55.6958015 ], [ 12.5283232, 55.6956698 ], [ 12.5281577, 55.6956508 ], [ 12.5280814, 55.6956411 ], [ 12.527808, 55.6956097 ], [ 12.527642, 55.6955912 ], [ 12.5274769, 55.6955728 ], [ 12.5273218, 55.6955548 ], [ 12.5273064, 55.6955626 ], [ 12.526584, 55.6954867 ], [ 12.5265029, 55.6954756 ], [ 12.5261494, 55.6954193 ], [ 12.5260608, 55.6954015 ], [ 12.5256556, 55.6953107 ], [ 12.5249678, 55.6951579 ], [ 12.5248835, 55.6951305 ], [ 12.524691, 55.695068 ], [ 12.523543, 55.69468 ], [ 12.5233469, 55.6946137 ], [ 12.5229791, 55.6944651 ], [ 12.5227777, 55.6943701 ], [ 12.5225042, 55.6942436 ], [ 12.5221793, 55.6940863 ], [ 12.5220331, 55.6940128 ], [ 12.5218376, 55.6938047 ], [ 12.52183, 55.6937981 ], [ 12.5218227, 55.6937915 ], [ 12.5218147, 55.6937846 ], [ 12.5218069, 55.6937784 ], [ 12.5218005, 55.6937724 ], [ 12.5217918, 55.6937656 ], [ 12.5217844, 55.6937591 ], [ 12.5217758, 55.6937525 ], [ 12.5217721, 55.6937497 ], [ 12.5217638, 55.6937434 ], [ 12.5217547, 55.6937368 ], [ 12.521746, 55.6937307 ], [ 12.5217379, 55.6937246 ], [ 12.5217296, 55.6937192 ], [ 12.5217212, 55.6937129 ], [ 12.5217117, 55.6937068 ], [ 12.521703, 55.6937011 ], [ 12.5216982, 55.6936977 ], [ 12.5215678, 55.6936158 ], [ 12.5214357, 55.6935263 ], [ 12.5212468, 55.6933659 ], [ 12.521189, 55.6933061 ], [ 12.5211439, 55.693202 ], [ 12.5211035, 55.693157 ], [ 12.5210454, 55.6931145 ], [ 12.5208933, 55.6930038 ], [ 12.5206494, 55.692817 ], [ 12.5205711, 55.6927413 ], [ 12.5204203, 55.692588 ], [ 12.520344, 55.6925199 ], [ 12.5201075, 55.6923549 ], [ 12.5200339, 55.6923088 ], [ 12.5198979, 55.6922316 ], [ 12.5197563, 55.6921424 ], [ 12.519565, 55.6920001 ], [ 12.5194976, 55.6919569 ], [ 12.5194245, 55.6919101 ], [ 12.5193766, 55.6918807 ], [ 12.5191935, 55.6917756 ], [ 12.5190111, 55.6916648 ], [ 12.5188005, 55.6915362 ], [ 12.5185406, 55.6913958 ], [ 12.517999, 55.6911232 ], [ 12.5178553, 55.6910391 ], [ 12.5176161, 55.690894 ], [ 12.5175249, 55.6908511 ], [ 12.5174502, 55.6908288 ], [ 12.5173814, 55.690815 ], [ 12.5170605, 55.6907719 ], [ 12.5168289, 55.690718 ], [ 12.5165332, 55.690643 ], [ 12.5164793, 55.6906207 ], [ 12.5160971, 55.6905668 ], [ 12.5158308, 55.690432 ], [ 12.515793, 55.6904137 ], [ 12.5156297, 55.6903282 ], [ 12.5155106, 55.6902768 ], [ 12.5152766, 55.690223 ], [ 12.5150202, 55.6901655 ], [ 12.5147202, 55.6901208 ], [ 12.514486, 55.6900811 ], [ 12.514072, 55.6900107 ], [ 12.51391, 55.6899646 ], [ 12.5138164, 55.6899412 ], [ 12.5137857, 55.6899337 ], [ 12.5135512, 55.6898704 ], [ 12.5130808, 55.6897517 ], [ 12.5125394, 55.6896272 ], [ 12.5123803, 55.6895892 ], [ 12.5122158, 55.6895493 ], [ 12.5118453, 55.6894629 ], [ 12.5109266, 55.6892342 ], [ 12.5103872, 55.6891051 ], [ 12.5094884, 55.6890204 ], [ 12.5086861, 55.6889275 ], [ 12.5085598, 55.6889099 ], [ 12.508496, 55.6889064 ], [ 12.5083727, 55.6888853 ], [ 12.5082605, 55.6888632 ], [ 12.5080102, 55.6888187 ], [ 12.5078584, 55.6887908 ], [ 12.5076712, 55.688756 ], [ 12.5074148, 55.68871 ], [ 12.5072959, 55.6886896 ], [ 12.5068295, 55.6886033 ], [ 12.5066638, 55.6885759 ], [ 12.5066576, 55.6885847 ], [ 12.5066325, 55.6885823 ], [ 12.5063081, 55.6885651 ], [ 12.5060788, 55.6885462 ], [ 12.5059759, 55.6885258 ], [ 12.505744, 55.6885001 ], [ 12.5055682, 55.6884716 ], [ 12.505026, 55.688399 ], [ 12.5043924, 55.6883174 ], [ 12.5040466, 55.6882654 ], [ 12.5040218, 55.6882602 ], [ 12.5039184, 55.6882396 ], [ 12.5037968, 55.6881981 ], [ 12.5036732, 55.6881621 ], [ 12.5033756, 55.6880682 ], [ 12.5031077, 55.6879844 ], [ 12.5028319, 55.6878964 ], [ 12.5027053, 55.6878562 ], [ 12.5025102, 55.6878027 ], [ 12.5024503, 55.6877843 ], [ 12.5024111, 55.6877693 ], [ 12.5023817, 55.687758 ], [ 12.5023088, 55.6876999 ], [ 12.5022677, 55.6876701 ], [ 12.5022069, 55.6876296 ], [ 12.5021995, 55.6876245 ], [ 12.5020473, 55.6875225 ], [ 12.5014544, 55.6871173 ], [ 12.5014118, 55.687088 ], [ 12.5010678, 55.6869454 ], [ 12.5008361, 55.6868491 ], [ 12.5006758, 55.6867905 ], [ 12.5006206, 55.6867712 ], [ 12.5004431, 55.6867134 ], [ 12.5004273, 55.6866615 ], [ 12.5004207, 55.6866477 ], [ 12.5004083, 55.6866346 ], [ 12.5003905, 55.6866206 ], [ 12.500371, 55.6866076 ], [ 12.500328, 55.6865886 ], [ 12.5002206, 55.6865506 ], [ 12.5001505, 55.6865231 ], [ 12.5000899, 55.6864967 ], [ 12.5000431, 55.6864749 ], [ 12.4999903, 55.6864496 ], [ 12.4999717, 55.6864401 ], [ 12.4999362, 55.6864225 ], [ 12.4998807, 55.6863942 ], [ 12.4996775, 55.6862864 ], [ 12.4996648, 55.686294 ], [ 12.4994638, 55.6861871 ], [ 12.4994599, 55.6861895 ], [ 12.4991447, 55.6860222 ], [ 12.4988948, 55.6858897 ], [ 12.498452, 55.6856545 ], [ 12.4982032, 55.6855222 ], [ 12.4980322, 55.6854313 ], [ 12.4980405, 55.6854263 ], [ 12.4980149, 55.6854124 ], [ 12.4978448, 55.6853195 ], [ 12.4978481, 55.6853176 ], [ 12.4980299, 55.6852112 ], [ 12.4975002, 55.6849361 ], [ 12.4967689, 55.6845569 ], [ 12.4964338, 55.6843712 ], [ 12.4959653, 55.6840925 ], [ 12.4959182, 55.6840625 ], [ 12.4958266, 55.6841108 ], [ 12.4959046, 55.6842637 ], [ 12.4959407, 55.6844023 ], [ 12.4959765, 55.6845416 ], [ 12.4959167, 55.684529 ], [ 12.4958705, 55.6845228 ], [ 12.4958491, 55.6845599 ], [ 12.495853, 55.6846059 ], [ 12.4956783, 55.6845364 ], [ 12.4956664, 55.6844269 ], [ 12.4954789, 55.6843184 ], [ 12.4953701, 55.6840962 ], [ 12.4952558, 55.6839044 ], [ 12.4951691, 55.6837393 ], [ 12.4948976, 55.683444 ], [ 12.4947652, 55.6833021 ], [ 12.4945884, 55.6831463 ], [ 12.4944883, 55.6831246 ], [ 12.494485, 55.6831212 ], [ 12.4943232, 55.682962 ], [ 12.4942781, 55.6829763 ], [ 12.4941706, 55.6830107 ], [ 12.494021, 55.6830499 ], [ 12.493976, 55.6830565 ], [ 12.4939584, 55.6830616 ], [ 12.4939313, 55.683033 ], [ 12.4938952, 55.6829921 ], [ 12.4938678, 55.682962 ], [ 12.4936717, 55.6827879 ], [ 12.4936206, 55.6827279 ], [ 12.4935612, 55.6826618 ], [ 12.493518, 55.6826122 ], [ 12.4934672, 55.6825612 ], [ 12.4933736, 55.6824678 ], [ 12.4932967, 55.6823901 ], [ 12.4932374, 55.6823295 ], [ 12.4931074, 55.6821947 ], [ 12.4930495, 55.6821234 ], [ 12.4930052, 55.6820459 ], [ 12.4929997, 55.6820349 ], [ 12.4929529, 55.6819472 ], [ 12.4928933, 55.6818366 ], [ 12.4927934, 55.6816552 ], [ 12.4927887, 55.6816466 ], [ 12.492711, 55.6815168 ], [ 12.4926616, 55.6814344 ], [ 12.4926033, 55.6813316 ], [ 12.4925791, 55.6812874 ], [ 12.4925273, 55.6811926 ], [ 12.4924746, 55.681098 ], [ 12.4924633, 55.6810772 ], [ 12.4924285, 55.6810142 ], [ 12.4923723, 55.6809148 ], [ 12.4923696, 55.6809092 ], [ 12.4923349, 55.6808436 ], [ 12.4923187, 55.6808061 ], [ 12.4922691, 55.6807244 ], [ 12.4921844, 55.6805632 ], [ 12.49216, 55.6805142 ], [ 12.4921286, 55.6804573 ], [ 12.4920974, 55.6803956 ], [ 12.4920902, 55.6803829 ], [ 12.4920356, 55.680288 ], [ 12.4920293, 55.6802767 ], [ 12.4919933, 55.6802135 ], [ 12.4919755, 55.6801827 ], [ 12.491963, 55.6801614 ], [ 12.4919048, 55.6800619 ], [ 12.4918835, 55.6800257 ], [ 12.4918252, 55.6799332 ], [ 12.4917665, 55.6798386 ], [ 12.4917524, 55.6798139 ], [ 12.4917311, 55.6797787 ], [ 12.491701, 55.6797262 ], [ 12.4916866, 55.6796935 ], [ 12.4916698, 55.6796512 ], [ 12.491658, 55.6796213 ], [ 12.4916068, 55.6794788 ], [ 12.4916016, 55.6794612 ], [ 12.4915893, 55.6794247 ], [ 12.4915762, 55.6793858 ], [ 12.4915655, 55.6793498 ], [ 12.4915638, 55.6793457 ], [ 12.4915408, 55.6792845 ], [ 12.4915314, 55.6792526 ], [ 12.4915144, 55.6791745 ], [ 12.4913156, 55.6790825 ] ] ] } } +] +} diff --git a/tests/test_data/frederiksberg_streetbike_network.gpkg b/tests/test_data/frederiksberg_streetbike_network.gpkg new file mode 100644 index 0000000..1a5bf7f Binary files /dev/null and b/tests/test_data/frederiksberg_streetbike_network.gpkg differ diff --git a/tests/test_functions.py b/tests/test_functions.py index 8609e67..5b0b988 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -1,14 +1,16 @@ -from fixbikenet import constants from fixbikenet import settings +from fixbikenet import constants from fixbikenet import config import pytest from networkx.utils.misc import graphs_equal import geopandas as gpd from shapely.geometry import Point +import fixbikenet as fbn from fixbikenet.functions import * -constants._ROUTING_PENALTY = {0: 5, 1: 1} +fbn.constants._ROUTING_PENALTY = {0: 5, 1: 1} +fbn.constants._BETWEENNESS_RANDOM_NODES = 300 @pytest.fixture def create_test_graph(): @@ -73,6 +75,7 @@ def create_weighted_graph(): return G def test_weigh_edges(create_graph_to_weigh, create_weighted_graph): + fbn.constants._ROUTING_PENALTY = {0: 5, 1: 1} assert graphs_equal(weigh_edges(create_graph_to_weigh), create_weighted_graph) @pytest.fixture diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..024e624 --- /dev/null +++ b/tests/test_main.py @@ -0,0 +1,36 @@ +import pytest +import geopandas as gpd +import osmnx as ox +import fixbikenet as fbn +from pandas.testing import assert_frame_equal + +fbn.constants._CRS_CALCULATIONS = 'auto' +fbn.constants._BETWEENNESS_RANDOM_NODES = 100 + + +@pytest.fixture +def validation_gdf_frederiksberg(): + gdf = gpd.read_file("./tests/test_data/frederiksberg-fixbikenet-gaps.gpkg", layer='Identified gaps') + return gdf[['source', 'target']] + + +def test_fixbikenet_case_success_offline1(validation_gdf_frederiksberg): + """Verify that the offline version of fixbikenet works as intended. + """ + fbn.constants._ROUTING_PENALTY = {0: 1.5, 1: 1} + gaps_ordered = fbn.fixbikenet( + city_query="Frederiksberg", + radius = 1000, + mingap = 0, + maxgap = 500, + numgaps = 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, + gaps_ordered[['source', 'target']] + )