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

Wrong report of domains in a categorized rendering #11

Open
aperi2007 opened this issue Dec 29, 2015 · 7 comments
Open

Wrong report of domains in a categorized rendering #11

aperi2007 opened this issue Dec 29, 2015 · 7 comments

Comments

@aperi2007
Copy link

I see when the plugin export a categorized rendering it report the wrong values.

This is an image to show what is the legend in the qgis project:

img_project

And this is what is returned as legend in the layer from the wms exported:

img_wms

I will try to patch this in my customized fork and if the patch is quite standard wll produce a fork for this version.

@luipir
Copy link
Contributor

luipir commented Dec 29, 2015

are you talking about the "old" mapfile generator of the new one?

@aperi2007
Copy link
Author

The new one.

@luipir
Copy link
Contributor

luipir commented Dec 29, 2015

so better wait comment from @brncsk

@aperi2007
Copy link
Author

ok, for your original rt_mapserver_exporter code.
Meanwhile I try to find a solution for our version of rt_mapserver_exporter plugin.
Infact we need to publish a new wms service in the first day of the new year.
If I start with the qgis-server , due to the different url between the qgis-server and the mapserver will not possible to change it in a second time. So I try to find a internal code solution for this issue, and see if is possible to start the new wms with the mapserver instead of the qgis-server.

If I will have success, I will report the new code here.

@aperi2007
Copy link
Author

The qgis project I convert to mapserver as sample, use the graduate render not the categorized render.
So the issue is in the Graduate Render.

@aperi2007
Copy link
Author

...., perhaps the issue is in more than one renderer. surely in the graduate, and seem the code issue is also in the categorized and in the singlesymbol renderer.

@aperi2007
Copy link
Author

Resolved.
The change il all in the file "serialization.py".

The change for the categorized rendering is around the line 186.
Change che code:

        for cat in renderer.categories():
            msClass = mapscript.classObj(self.msLayer)
            # XXX: type(cat.value()) differs whether the script is being run in QGis or as 
            # a standalone PyQGis application, so we convert it accordingly.
            cv = cat.value()
            cv = cv.toString() if isinstance(cv, QVariant) else unicode(cv)
            msClass.setExpression((u'("[%s]" = "%s")' % (attr, cv)).encode('utf-8'))
            SymbolLayerSerializer(renderer.symbols()[i], msClass, self.msLayer, self.msMap)
            #add number to class name
            msClass.name+='_'+str(i)
            i = i + 1

with the code:

        for cat in renderer.categories():
            msClass = mapscript.classObj(self.msLayer)
            # XXX: type(cat.value()) differs whether the script is being run in QGis or as 
            # a standalone PyQGis application, so we convert it accordingly.
            cv = cat.value()
            cv = cv.toString() if isinstance(cv, QVariant) else unicode(cv)
            msClass.setExpression((u'("[%s]" = "%s")' % (attr, cv)).encode('utf-8'))
            SymbolLayerSerializer(renderer.symbols()[i], msClass, self.msLayer, self.msMap)
            msClass.name = cat.label()
            i = i + 1

Perhaps the i=i+1 is no more useful, but I leave it to avoid surprise.

For the Graduate rendering the change is around the line 208

changing the code:

        for range in renderer.ranges():
            msClass = mapscript.classObj(self.msLayer)
            # We use '>=' instead of '>' when defining the first class to also include the lowest
            # value of the range in the expression.
            msClass.setExpression((u'(([%s] %s %f) And ([%s] <= %f))' % ( \
                attr, \
                '>=' if (i == 0) else '>', \
                range.lowerValue(), \
                attr, \
                range.upperValue() \
            )).encode('utf-8'))
            SymbolLayerSerializer(renderer.symbols()[i], msClass, self.msLayer, self.msMap)
            #add number to class name
            msClass.name+='_'+str(i)
            i = i + 1

with the code:

        for range in renderer.ranges():
            msClass = mapscript.classObj(self.msLayer)
            # We use '>=' instead of '>' when defining the first class to also include the lowest
            # value of the range in the expression.
            msClass.setExpression((u'(([%s] %s %f) And ([%s] <= %f))' % ( \
                attr, \
                '>=' if (i == 0) else '>', \
                range.lowerValue(), \
                attr, \
                range.upperValue() \
            )).encode('utf-8'))
            SymbolLayerSerializer(renderer.symbols()[i], msClass, self.msLayer, self.msMap)
            msClass.name = range.label()
            i = i + 1

In this case the code "i=i+1" is mandatory to leave unchanged because is used to counting the range domain.

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

No branches or pull requests

2 participants