Skip to content
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

v.out.ogr: Fix exporting vector layers from a location whose CRS has no EPSG code #3869

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

ldesousa
Copy link
Contributor

@ldesousa ldesousa commented Jun 17, 2024

This PR addresses issue #2187: the v.out.ogr module fails to export vector layers from a location whose CRS does not have an entry in the EPSG registry. The root cause is the inadequate discarding of the Ogr_projection object in vector/v.out.ogr/main.c. In addition a new test is provided for this module verifying the correct creation of layers from such locations. This test fails with the current master branch (release 8.3).

This PR is incremental on PR #3848. Please merge that one before merging this one.

@github-actions github-actions bot added vector Related to vector data processing Python Related code is in Python C Related code is in C module tests Related to Test Suite labels Jun 17, 2024
@ldesousa ldesousa requested a review from wenzeslaus June 17, 2024 13:53
@veroandreo veroandreo changed the title Issue#2187 v.out.ogr: add basic unit test (cont.) Jun 18, 2024
@veroandreo veroandreo added this to the 8.5.0 milestone Jun 18, 2024
@ldesousa ldesousa changed the title v.out.ogr: add basic unit test (cont.) v.out.ogr: fixes #2187 and expands unit tests Jun 18, 2024
ldesousa and others added 5 commits July 31, 2024 17:43
…tion

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…tion

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@ldesousa ldesousa requested review from rouault and wenzeslaus August 1, 2024 13:54
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose OSRDestroySpatialReference is still missing, but the issue was there before. I'm fine with this PR just fixing the issue and adding a test for that.


# Create new session to avoid temporary region
self.session_file, env_new = gs.core.create_environment(
env_orig["GISDBASE"].replace("'", "").replace(";", ""),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a comment or two about why these two replace calls are needed. Are the characters an issue? Why are the characters there? How is the original GISDBASE working with them?

(Same for line 77.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those characters are included in the variable string, e.g. '/home/lads/GRASSDATA';. The tests do not fail if you don't remove them, however, the following call to rmtree then does not remove the actual temporary location. Garbage is thus left behind in the file system.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry to keep this hanging, but I find it both puzzling and concerning that GISDBASE retrieved by g.gisenv has quotes and a semicolon. Are you sure that's what you have there? Can you please directly run g.gisenv in the same or similar session you run the tests?

GRASS nc_basic_spm_grass7/user1:script > g.gisenv 
GISDBASE=/home/vpetras/grassdata
LOCATION_NAME=nc_basic_spm_grass7
MAPSET=user1
GUI=text
PID=1094462
GRASS nc_basic_spm_grass7/user1:script > python -c "import grass.script as gs; print(gs.gisenv())"
{'GISDBASE': '/home/vpetras/grassdata', 'LOCATION_NAME': 'nc_basic_spm_grass7', 'MAPSET': 'user1', 'GUI': 'text', 'PID': '1094462'}

And can you print from the test? (You may need to fail the test to get a print.)

self.assertFalse(env_orig)

vector/v.out.ogr/testsuite/test_v_out_ogr.py Outdated Show resolved Hide resolved
@wenzeslaus
Copy link
Member

@ldesousa Can you please:

  1. update the description to include what this is fixing and how and when it is failing (I suppose that the new test is failing without the change and passing with it, correct?)
  2. shorten the title

@ldesousa ldesousa changed the title v.out.ogr: fixes ERROR: Unable to create OGR spatial reference with Shapefile export and expands unit tests v.out.ogr: fixes #2187 and expands unit tests Aug 29, 2024
@ldesousa ldesousa requested a review from wenzeslaus August 29, 2024 13:55
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments are in my previous review (see the review and unresolved comments).

@echoix
Copy link
Member

echoix commented Sep 3, 2024

Once it will be ready for merging, the title isn't clear to me what it does (an issue number is great for PR descriptions, but less as a changelog entry and PR titles). Our PR titles are changelog entries, and are what we will see in the code in for the rest of the lifetime of the project

@ldesousa
Copy link
Contributor Author

ldesousa commented Sep 6, 2024

Once it will be ready for merging, the title isn't clear to me what it does (an issue number is great for PR descriptions, but less as a changelog entry and PR titles). Our PR titles are changelog entries, and are what we will see in the code in for the rest of the lifetime of the project

@echoix I already lengthened/shortened the title a few times. Could you confer with @wenzeslaus which kind of title you wish for this PR?

@rouault
Copy link
Member

rouault commented Sep 6, 2024

@rouault I already lengthened/shortened the title a few times. Could you confer with @wenzeslaus which kind of title you wish for this PR?

maybe "v.out.ogr: fix exporting vector layers from a location whose CRS has no EPSG code" ?

@ldesousa
Copy link
Contributor Author

ldesousa commented Sep 6, 2024

@rouault Sorry, wrong tag. Let's wait for all the internal GRASS procedures to be ready. Then I will ask for your review again. Thanks.

@echoix
Copy link
Member

echoix commented Sep 7, 2024

@rouault I already lengthened/shortened the title a few times. Could you confer with @wenzeslaus which kind of title you wish for this PR?

maybe "v.out.ogr: fix exporting vector layers from a location whose CRS has no EPSG code" ?

I actually find that great, I can't reword it any better way that doesn't end up sounding weird

@echoix echoix changed the title v.out.ogr: fixes #2187 and expands unit tests v.out.ogr: fix exporting vector layers from a location whose CRS has no EPSG code Sep 7, 2024
@echoix echoix changed the title v.out.ogr: fix exporting vector layers from a location whose CRS has no EPSG code v.out.ogr: Fix exporting vector layers from a location whose CRS has no EPSG code Sep 7, 2024
@echoix echoix requested a review from wenzeslaus September 7, 2024 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C module Python Related code is in Python tests Related to Test Suite vector Related to vector data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] v.out.ogr: ERROR: Unable to create OGR spatial reference with Shapefile export
5 participants