-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
172 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,50 @@ | ||
""" | ||
Test module for feature conversions. | ||
""" | ||
import os | ||
|
||
import json | ||
from pathlib import Path | ||
import os | ||
import unittest | ||
from pathlib import Path | ||
|
||
from turfpy.feature_conversion import ( | ||
polygon_to_line | ||
) | ||
from turfpy.feature_conversion import polygon_to_line | ||
|
||
# Define directories | ||
current_dir = Path(__file__).resolve().parent | ||
directories = { | ||
'in': current_dir / 'feature_conversion_polygon_to_line_test' / 'in', | ||
'out': current_dir / 'feature_conversion_polygon_to_line_test' / 'out', | ||
"in": current_dir / "feature_conversion_polygon_to_line_test" / "in", | ||
"out": current_dir / "feature_conversion_polygon_to_line_test" / "out", | ||
} | ||
|
||
# Load fixtures | ||
fixtures = [] | ||
for filename in os.listdir(directories['in']): | ||
filepath = directories['in'] / filename | ||
with open(filepath, 'r') as file: | ||
for filename in os.listdir(directories["in"]): | ||
filepath = directories["in"] / filename | ||
with open(filepath, "r") as file: | ||
geojson = json.load(file) | ||
fixtures.append({ | ||
'filename': filename, | ||
'name': Path(filename).stem, | ||
'geojson': geojson, | ||
}) | ||
fixtures.append( | ||
{ | ||
"filename": filename, | ||
"name": Path(filename).stem, | ||
"geojson": geojson, | ||
} | ||
) | ||
|
||
|
||
class TestPolygonToLine(unittest.TestCase): | ||
|
||
def test_polygon_to_linestring(self): | ||
for fixture in fixtures: | ||
name = fixture['name'] | ||
filename = fixture['filename'] | ||
geojson = fixture['geojson'] | ||
name = fixture["name"] | ||
filename = fixture["filename"] | ||
geojson = fixture["geojson"] | ||
|
||
# Perform the conversion | ||
results = polygon_to_line(geojson) | ||
|
||
# Load the expected results | ||
with open(directories['out'] / filename, 'r') as file: | ||
with open(directories["out"] / filename, "r") as file: | ||
expected_results = json.load(file) | ||
|
||
# Assert the results are as expected | ||
self.assertEqual(results, expected_results, name) | ||
self.assertEqual(results, expected_results, name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
""" | ||
Test module for transformations. | ||
""" | ||
|
||
from geojson import ( | ||
Feature, | ||
FeatureCollection, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
"""A Python library for performing geospatial data analysis which reimplements turf.js | ||
""" | ||
|
||
from .__version__ import __version__ # noqa F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.