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

Download filtered layer #3321

Merged
merged 27 commits into from
Oct 4, 2017
Merged

Download filtered layer #3321

merged 27 commits into from
Oct 4, 2017

Conversation

karakostis
Copy link
Contributor

@karakostis karakostis commented Sep 25, 2017

In GeoNode it is possible to download parts of a layer using a Query Builder. The Query Builder provides a step by step graphical environment, where the user is able to select attributes existing in the layer (e.g. population of an area) and set numerical or text filters.

The filters can be chained together either by an AND or an OR operator. Moreover when building the Query statements, the user can retrieve all the available values for each attribute. This is particularly useful, when the user wants to filter data based on numbers, locations etc. which he/she is not familiarized.

As this is my first commit to GeoNode community, kindly let me know in case of corrections, best practices and recommendations. Thanks!

@simod
Copy link
Member

simod commented Sep 26, 2017

Thanks @karakostis , some comments in line. The tests are failing, could you take a look? I could be simple pep8 violations.

@karakostis
Copy link
Contributor Author

karakostis commented Sep 26, 2017

Hey @simod thanks! I think it was a pep8 issue with setup.py. Lets see if is resolved. Silly question but where did u put the inline comments? :)

@simod
Copy link
Member

simod commented Sep 26, 2017

@@ -430,8 +432,117 @@ def layer_detail(request, layername, template='layers/layer_detail.html'):
if settings.SOCIAL_ORIGINS:
context_dict["social_links"] = build_social_links(request, layer)


#d
Copy link
Member

Choose a reason for hiding this comment

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

@karakostis Is this part of code needed by your feature?


# loop the dictionary based on the values on the list and add the properties
# in the dictionary (if doesn't exist) together with the value
from six import string_types
Copy link
Member

Choose a reason for hiding this comment

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

@karakostis can you import this at the top?

setup.py Outdated
@@ -141,7 +141,7 @@
"factory_boy",
# "WeasyPrint",

],
Copy link
Member

Choose a reason for hiding this comment

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

this is causing conflicts, can you merge with master?

@simod
Copy link
Member

simod commented Sep 26, 2017

oh probably was my fault, I didn't hit the submit comments... sorry

@karakostis
Copy link
Contributor Author

I am not really sure what is the issue. Is there a way to see where is the conflict?

@simod
Copy link
Member

simod commented Sep 27, 2017

woah this log became way too long to read. Did you run the tests locally? @afabiani most of the noise seems to be related to geoserver messaging, any way we can limit it?

@@ -429,12 +432,119 @@ def layer_detail(request, layername, template='layers/layer_detail.html'):
if settings.SOCIAL_ORIGINS:
context_dict["social_links"] = build_social_links(request, layer)


Copy link
Member

Choose a reason for hiding this comment

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

@karakostis I was talking about this whole chunk of code, is it related to your feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This part of code is related to the feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the issue must be related with the that chunk of code. As I see in the log file something breaks there and returns the Exception message:

LL: <CDLL 'libc.so.6', handle 7fb2157ee9b0 at 7fb1f573ce90>
.on_geoserver_messages: RECEIVED MSG - body: {'rating': '0', 'constraints_other': 'None', 'bbox_x0': 'None', 'csw_mdsource': 'local', 'csw_schema': 'http://www.isotc211.org/2005/gmd', 'csw_typename': 'gmd:MD_Metadata', 'date_type': 'publication', 'srid': 'EPSG:4326', 'bbox_x1': 'None', 'edition': 'None', 'featured': 'False', 'owner': 'None', 'detail_url': 'None', 'id': 1, 'category': 'None', 'license': 'None', 'spatial_representation_type': 'None', 'uuid': u'', 'title': u'', 'alternate': 'None', 'regions': '[]', 'thumbnail_url': 'None', 'share_count': '0', 'abstract': u'', 'bbox_y0': 'None', 'bbox_y1': 'None', 'popular_count': '0', 'contacts': '[]', 'purpose': 'None', 'date': '2017-09-26 15:58:14.589434', 'group': 'None', 'temporal_extent_end': 'None', 'language': 'eng', 'data_quality_statement': 'None', 'restriction_code_type': 'None', 'maintenance_frequency': 'None', 'csw_anytext': 'None', 'metadata_xml': '<gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd"/>', 'tkeywords': '[]', 'metadata_uploaded_preserve': 'False', 'csw_type': 'dataset', 'keywords': '[]', 'metadata_uploaded': 'False', 'csw_wkt_geometry': 'POLYGON((-180 -90,-180 90,180 90,180 -90,-180 -90))', 'temporal_extent_start': 'None', 'is_published': True}
Layer matching query does not exist.
Traceback (most recent call last):
File "/home/travis/build/GeoNode/geonode/geonode/geoserver/signals.py", line 94, in geoserver_post_save_local
instance = Layer.objects.get(id=layer_id)
File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/django/db/models/query.py", line 334, in get
self.model._meta.object_name
DoesNotExist: Layer matching query does not exist.
on_geoserver_messages: finished
finished.

Copy link
Member

Choose a reason for hiding this comment

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

it is not clear, a geoserver post_save signal cannot find the resource for which it was called. Strange.

@karakostis
Copy link
Contributor Author

karakostis commented Sep 28, 2017

The errors take place in the following two lines. In the first one I use gsconfig:
resource = cat.get_resource(name, workspace=workspace)
For some reason this returns nothing back ('resource', None)
The second line of code uses OWSLib:
schema = get_schema(location, name, username=username, password=password)
I wonder if this is actually related with the tests them selves and not with the code.
I have imported these two libs in views.py (for layers) specifically for this functionality).


try:
# get type of layer (raster or vector)
cat = Catalog(settings.OGC_SERVER['default']['LOCATION'] + "rest", settings.OGC_SERVER['default']['USER'], settings.OGC_SERVER['default']['PASSWORD'])
Copy link
Member

Choose a reason for hiding this comment

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

@karakostis we actually should avoid to call the catalog here. Catalog operations should only be delegated to the geoserver app, layer detail should only be reading from the database.

@karakostis
Copy link
Contributor Author

Thanks @simod . Well noted. I will change this. But I think there must be another more general issue. I tried to run the tests locally in my master branch and I still keep getting the same errors. Can you replicate? Tests run smoothly from your side?

@simod
Copy link
Member

simod commented Oct 2, 2017

@karakostis consider that right now the tests are failing on master, probably due to some recent updates in the java machinery packages. But I'll run them locally too and help out to see what we can change.

@simod
Copy link
Member

simod commented Oct 3, 2017

@karakostis can you merge from master now? Let's see if the tests give better result.

@karakostis
Copy link
Contributor Author

@simod I have refactored part of the code in the layers/views.py so that I don't call the Catalog. Running the tests causes same issues. When I run them locally I get errors in:

ERROR: testLayerNotifications (geonode.layers.tests.LayerNotificationsTestCase)
ERROR: testMapsNotifications (geonode.maps.tests.MapsNotificationsTestCase)
ERROR: testDocumentNotifications (geonode.documents.tests.DocumentNotificationsTestCase)

@afabiani
Copy link
Member

afabiani commented Oct 4, 2017

@karakostis @simod I pushed another build of this PR. Currently the unique issue should be related to formatting stuff

flake8 geonode
geonode/layers/views.py:436:5: E303 too many blank lines (2)
geonode/layers/views.py:441:13: F841 local variable 'workspace' is assigned to but never used
geonode/layers/views.py:487:5: E303 too many blank lines (2)
geonode/layers/views.py:490:1: E302 expected 2 blank lines, found 1
geonode/layers/views.py:513:9: E303 too many blank lines (2)
geonode/layers/views.py:534:1: E302 expected 2 blank lines, found 1

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 44.569% when pulling 5c719b9 on karakostis:download_filtered_layer into d4140ce on GeoNode:master.

@afabiani afabiani merged commit eb65887 into GeoNode:master Oct 4, 2017
@afabiani
Copy link
Member

afabiani commented Oct 4, 2017

@karakostis just tested it, It works but I noticed a javascript error when clicking on "+" button. Can you maybe double check?

image

@karakostis
Copy link
Contributor Author

@afabiani sure!

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.

6 participants