-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow a GeoJSON collection's name to be set in write mode #1352
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
636da70
Allow a GeoJSON collection's name to be set in write mode
sgillies 259628d
Update change log entry
sgillies 6895170
Remove commented code
sgillies 8916681
Add coding directive to test file
sgillies 55e74ac
Skip a test on Windows
sgillies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,7 +1,10 @@ | ||
# Testing collections and workspaces | ||
"""Testing collections and workspaces.""" | ||
# coding=utf-8 | ||
|
||
import datetime | ||
import json | ||
import logging | ||
import os | ||
import random | ||
import re | ||
import sys | ||
|
@@ -10,8 +13,8 @@ | |
|
||
import fiona | ||
from fiona.collection import Collection | ||
from fiona.drvsupport import supported_drivers, driver_mode_mingdal | ||
from fiona.env import getenv, GDALVersion | ||
from fiona.drvsupport import supported_drivers | ||
from fiona.env import getenv | ||
from fiona.errors import ( | ||
AttributeFilterError, | ||
FionaValueError, | ||
|
@@ -20,7 +23,7 @@ | |
) | ||
from fiona.model import Feature, Geometry | ||
|
||
from .conftest import WGS84PATTERN, get_temp_filename | ||
from .conftest import WGS84PATTERN | ||
|
||
|
||
class TestSupportedDrivers: | ||
|
@@ -340,7 +343,7 @@ def test_include_fields__ignore_fields_error(self): | |
"r", | ||
include_fields=["AREA"], | ||
ignore_fields=["STATE"], | ||
) as collection: | ||
): | ||
pass | ||
|
||
def test_ignore_geometry(self): | ||
|
@@ -400,14 +403,6 @@ def test_filter_where(self): | |
results = list(self.c.filter()) | ||
assert len(results) == 67 | ||
|
||
def test_filter_bbox_where(self): | ||
# combined filter criteria | ||
results = set(self.c.keys( | ||
bbox=(-120.0, 40.0, -100.0, 50.0), where="NAME LIKE 'Mount%'")) | ||
assert results == set([0, 2, 5, 13]) | ||
results = set(self.c.keys()) | ||
assert len(results) == 67 | ||
|
||
def test_filter_where_error(self): | ||
for w in ["bad stuff", "NAME=3", "NNAME LIKE 'Mount%'"]: | ||
with pytest.raises(AttributeFilterError): | ||
|
@@ -422,11 +417,6 @@ def test_filter_bbox_where(self): | |
results = set(self.c.keys()) | ||
assert len(results) == 67 | ||
|
||
def test_filter_where_error(self): | ||
for w in ["bad stuff", "NAME=3", "NNAME LIKE 'Mount%'"]: | ||
with pytest.raises(AttributeFilterError): | ||
self.c.filter(where=w) | ||
|
||
|
||
class TestUnsupportedDriver: | ||
def test_immediate_fail_driver(self, tmpdir): | ||
|
@@ -1201,3 +1191,28 @@ def test_driver_detection(tmpdir, extension, driver): | |
crs="EPSG:4326", | ||
) as output: | ||
assert output.driver == driver | ||
|
||
|
||
@pytest.mark.skipif( | ||
sys.platform == "win32", | ||
reason="Windows test runners don't have full unicode support", | ||
) | ||
def test_collection_name(tmp_path): | ||
"""A Collection name is plumbed all the way through.""" | ||
filename = os.fspath(tmp_path.joinpath("test.geojson")) | ||
|
||
with fiona.Collection( | ||
filename, | ||
"w", | ||
driver="GeoJSON", | ||
crs="EPSG:4326", | ||
schema={"geometry": "Point", "properties": {"foo": "int"}}, | ||
layer="Darwin Núñez", | ||
write_name=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to be sure that we support Unicode layer names 😆 ⚽ 🇺🇾 🟥 |
||
) as colxn: | ||
assert colxn.name == "Darwin Núñez" | ||
|
||
with open(filename) as f: | ||
geojson = json.load(f) | ||
|
||
assert geojson["name"] == "Darwin Núñez" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll figure this out later. Some lack of libiconv or configuration thereof, I bet.