-
Notifications
You must be signed in to change notification settings - Fork 12
Add geometrycolumn validation warning for GeoJSON write function #114
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
Draft
Copilot
wants to merge
2
commits into
main
Choose a base branch
from
copilot/fix-101
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 | ||||
---|---|---|---|---|---|---|
|
@@ -399,6 +399,16 @@ include("geojson_samples.jl") | |||||
@test t2_geojson.prop1 == getproperty.(t2, :prop1) | ||||||
@test t2_geojson.prop2 == getproperty.(t2, :prop2) | ||||||
|
||||||
@testset "geometrycolumn warnings" begin | ||||||
# Test warning is shown for non-geometry column | ||||||
t_warn = [(somethingelse=(1.0, 2.0), prop1=1)] | ||||||
@test_logs (:warn, r"GeoJSON specification requires.*geometry.*somethingelse.*") GeoJSON.write(t_warn; geometrycolumn = :somethingelse) | ||||||
|
||||||
# Test no warning for geometry column | ||||||
t_no_warn = [(geometry=(1.0, 2.0), prop1=1)] | ||||||
@test_logs GeoJSON.write(t_no_warn; geometrycolumn = :geometry) | ||||||
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.
Suggested change
|
||||||
end | ||||||
|
||||||
@testset "Metadata" begin | ||||||
@test GI.DataAPI.metadatasupport(typeof(t2_geojson)) == (; read = true, write = false) | ||||||
@test GI.DataAPI.metadatakeys(t2_geojson) == ("GEOINTERFACE:geometrycolumns", "GEOINTERFACE:crs") | ||||||
|
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Not sure if we want this to warn, actually...it seems like a legitimate usecase. @copilot give a boolean option to turn this off as a kwarg, default to false. @visr what do you think?
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.
I usually prefer errors (or no errors) instead of warnings. In this case I'd throw an error since the users wants something that is invalid. We could just also just update the line above.
Last time I was bitten by
@warn
was 3 days ago: apache/arrow-julia#559There 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.
Hmm, my concern is that if you read something from e.g. a database with a geometry column called
:MYGEOM
, and you now have that in memory as a DataFrame, then you would have to make the change manually rather than simply specifyinggeometrycolumn
to write.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.
I see, and what about just ignoring it? The docstring is already pretty clear:
According to this description it is about identifying the right column in the table, which is a useful feature for
:MYGEOM
.Actually the default of
first(GI.geometrycolumns(obj))
can perhaps also be surprising. If there is more than one you probably want people to choose and not pick the first.