Skip to content

Conversation

@ahocevar
Copy link
Member

In GEM's Modeler's toolkit, there is a chance that model output results in a shapefile with just one point feature. The extent of such a shapefile will have no width and height. This pull request fixes the issue by protecting from div by zero exceptions that happen during updatelayers.

@ingenieroariel
Copy link
Member

This is an interesting fix, can you share with us one of those shapefiles so we can add it to the default set of test data and add it to the upload tests in the integration test suite?

Even without that file I would be happy for this to go in because the logic is sound. I have another suggestion, though:

try:
    dataAspect  = dx / dy
except ZeroDivisionError:
    dataAspect = 1

This seems a little bit more explicit and easier to read, but at the end of the day is a matter of style.

@ahocevar
Copy link
Member Author

See http://dl.dropbox.com/u/5489321/zeroextent.zip for an example shapefile that causes this issue.

@ahocevar
Copy link
Member Author

Regarding the try/catch or avoid zero value approach: I don't know about Python coding style or good practices, I only did what I would have done in JavaScript, where try/catch is usually only used when there is no other way to deal with the problem.

ingenieroariel added a commit that referenced this pull request May 27, 2011
protecting from div by zero when bbox has no extent
@ingenieroariel ingenieroariel merged commit a2893ec into GeoNode:master May 27, 2011
@ingenieroariel
Copy link
Member

This is the first time I used the github interface to automatically merge the pull request. Now I have to find out how to propagate this change to synth :)

ingenieroariel referenced this pull request in jj0hns0n/geonode May 19, 2014
protecting from div by zero when bbox has no extent
karakostis pushed a commit to wfp-ose/geonode that referenced this pull request Jun 3, 2016
gubuntu pushed a commit to gubuntu/geonode that referenced this pull request May 15, 2017
goudine pushed a commit to goudine/geonode that referenced this pull request Feb 1, 2018
…and_static

make package installs include essential templates and static files
goudine pushed a commit to goudine/geonode that referenced this pull request Feb 1, 2018
Harmonize Terranodo's repo w/ Boundless'
marthamareal pushed a commit to marthamareal/geonode that referenced this pull request Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants