kartoza / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
http://geonode.org/
GNU General Public License v3.0
8 stars 17 forks source link

Layer symbology differs from the one in thumbnails generated on map creation #406

Open NyakudyaA opened 6 years ago

NyakudyaA commented 6 years ago

Problem

When creating a map you expect the thumbnail to be generated to be identical to the icons/symbology of the layer used to create the map with. health

This is the thumbnail that is generated.

thumbs

Solution

Investigate what is happening there. Why is the request being made returning icons that are different

NyakudyaA commented 6 years ago

Also related to this is the update map thumbnail which seems not to be working because of the above scenario. You cannot be sure if the thumbnail has changed because it has wrong symbology

gubuntu commented 6 years ago

duplicate of #325?

boney-bun commented 6 years ago

i'm confused with this issue, particularly for health facilities layer. i've tried creating a map using other layers, all seems to be picked up the style: screen shot 2018-07-05 at 2 54 58 pm screen shot 2018-07-05 at 2 54 53 pm screen shot 2018-07-05 at 2 54 41 pm screen shot 2018-07-05 at 2 54 23 pm

trying passing STYLE parameter to a WMS GetMap request into qgis server. the returned image doesn't pick up the style. the qgis server seems to ignore the parameter.

this led me to think that maybe something is not right with the health facilities layer. how do we validate a style on a layer?

boney-bun commented 6 years ago

tested using postman on jalan sleman layer by specifyng either default or testing style, the qgis server can pick up the style.

so, my guess is the style of health facilities may have some bug. can you help me with this @NyakudyaA ?

styleProblem.gif

gubuntu commented 6 years ago

@boney-bun which server are these examples from? (Should be testing)

Note this issue is specifically about GeoNode Maps. The styles of the layers in maps are the same as the original layers. So the maps should use default layer styles.

This is still very much an issue (with Madagascar 1975 Map on testing)

There's no issue with Healthsites - the default style of any layer should be consistently used in layers, maps and thumbnails.

boney-bun commented 6 years ago

@gubuntu i've uploaded the health layer to the testing (http://testing.geonode.kartoza.com/layers/geonode:health_facilities). when creating a map using this layer, the thumbnail is in a round shape (the original style is stars). i think @NyakudyaA refers to this layer on the OP.

for the madagascar layer (and other layers), i think the qgis server tends to change the origin colors of the layer. an exception is for tandale layer.

NyakudyaA commented 6 years ago

@boney-bun You need to be checking this:

You need to make sure when a user clicks on save map the correct signal is passed to create the thumbnail.

A simple logic would be:

See the example below from Geoserver.

NB: If I am guessing right what could be happening is that for each time a user is creating a map QGIS server is creating a separate QGIS project for that layer and hence generate random colors for the layer as specified in the OTF and hence generating a thumbnail that is different. S

boney-bun commented 6 years ago

thanks for your explanation and hints @NyakudyaA ! Yes, you are right, the problem seems to be on the qgs file used by the map.

I've looked and compared at the qgs files of both map and layer from health layer. i found something interesting on both qgs files:

the original qgs layer: <prop k="name" v="star" />

the map qgs: <prop k="name" v="circle" />

i think the bug is because the map doesn't store a style. hence, the map qgs doesn't generate a proper style as well.

gubuntu commented 6 years ago

I think we should maybe refactor how a map is stored in QGIS server backend. Am I correct in understanding that it creates a new QGIS project to define a map? (what does it do when you edit the map?)

GeoNode-geoserver stores a map as a list of layers in the database, a bit like a simplified WMC.

Why can we not do the same with QGIS backend?

Or, if we keep the current method of creating a new project, then the layer styles used in the map project must be transferred (copied) from the original layers.

@timlinux, @Gustry your input?

NyakudyaA commented 6 years ago

@boney-bun the scenario you mentioned above is mainly because of what I said. The map creates a new QGIS project which it uses to create a thumbnail.

Solution

boney-bun commented 6 years ago

@gubuntu yes, you are right. everything in layers and maps should be on project format (qgs) in qgis-server backend. i think this is one of the reasons why we have otf-project. when we edit a map, the qgs will be updated by otf-project.

cmiiw, here is what happen when a user saves a map:

@NyakudyaA yes, it was your hint that helped me going deeper into qgs file. but, your solution seems to be infeasible.

When a user saves a map geonode creates a new project using OTF. This will have random symbology.

the random symbology from the OTF is because we didn't specify the style when generate a new project for the map. this is not the case for generating a new project for a new uploaded layer.

When a user then previews the created map it uses the old project for the layer hence the icons come out ok.

i have tested this with postman. the thumbnail for the map will be correct if we use the layer's qgs. but, we can't simply copy paste the layer's qgs into map's qgs, mostly for the case when a map has more than one layer.

I'm currently interested in modifying QgisServerMap model. It doesn't specify QgisServerStyle as in QgisServerLayer. so, the solution may go into this way: adding the style into QgisServerMap.

what do you think?

gubuntu commented 6 years ago

The only benefit of the former that I can see is that the map layers will be rendered together by QGIS, so will look better than if they are fetched separately by Leaflet and overlaid.

Behaviour should be as close as possible to Geoserver backend, so GeoNode users have a consistent experience.

@boney-bun before diving in, I want to see a clear plan of your approach to this, with at least you, me and @NyakudyaA on the same page.

boney-bun commented 6 years ago

if a map view is fetching layers from their original projects, then why do we need new projects for maps? Either we keep map projects for maps, in which case map views and thumbnails must come from that project AND styles in that project must be transferred from the original layer projects.

yes, this is what happens now with the current implementation. going to the second option will have big refactoring consequence. So, i believe we need to stick with the current implementation.

the bug is because the map projects don't store the style (or symbol) from its original layers. qgis-server create a new symbol when it doesn't find one.

i suspect that the qgis-server doesn't pick up the style from a layer because the map doesn't have style and default-style definitions in the model. so, my plan is:

So far, the QGIS server still doesn't pickup the style. probably because i still doing it wrong in my local. I need to understand the way QGIS server works in generating style for layer.

what do you think with this approach @gubuntu @NyakudyaA ?

gubuntu commented 6 years ago
gubuntu commented 6 years ago

this is not fixed on testing so should not be in the testing column. Moved back to review

boney-bun commented 6 years ago

cmiiw, the original problem can be found on this map: http://testing.geonode.kartoza.com/maps/30 the map's thumbnail differs from the map.

this PR intends to fix the issue above. just created a new map in the testing: http://testing.geonode.kartoza.com/maps/40 the screencast is: geonode 406

gubuntu commented 6 years ago

try a map with more than one layer, the thumbnail is still wrong

boney-bun commented 6 years ago

http://testing.geonode.kartoza.com/maps/41 seems to be fine

gubuntu commented 6 years ago

the thumbnail for gavin test map that I've just created, is not

NyakudyaA commented 6 years ago

@boney-bun this is not working at all. Here is a sample layer I have uploaded. layer_detail

In the map page. map

NyakudyaA commented 5 years ago

@boney-bun the following are my observations:

The following is not working: