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

Rendering way of type "_route" is masked by bridges #1478

Closed
vvyskocil opened this issue Aug 6, 2023 · 6 comments
Closed

Rendering way of type "_route" is masked by bridges #1478

vvyskocil opened this issue Aug 6, 2023 · 6 comments

Comments

@vvyskocil
Copy link
Contributor

vvyskocil commented Aug 6, 2023

I don't know if it is a error in the usage of the library on my side or a issue in the lib ?

Screenshot 2023-08-06 at 11 43 11

@Framstag
Copy link
Owner

Framstag commented Aug 6, 2023

Strange:

In the standard configuration (standard.oss) in include/route.oss you can find:

OSS

CONST
  COLOR routeColor = #ff000088;

STYLE
  [MAG world-] {
    [TYPE _route] WAY {color: @routeColor; displayWidth: 1.5mm; width: 6m; priority: 100; }
  }

END

Important in context is the priority: 100. This sets WayData.priority. See also OSS.atg/WAYGROUP where WayData.wayPriority is set.

See also MapPainter::WayData::operator<which orders the way. Ways are rendered in the resulting order.

Which should result in the route being the last entry in the way render list, thus rendering on top of everything else. Looking at the code however, it seems like the way needs to have a "high" layer value for this, too, to be rendered after "lower" layers like bridges (which should have low positive values).

In the Qt code, the initialization for the route is done in OverlayObject.cpp/OverlayWay::toWay (and functions called from there).

In the header, you see that Overlay objects have

  int8_t                              layer{std::numeric_limits<int8_t>::max()};

:-)

I assume some of these internal "tricks" are missing in your code?

@Framstag
Copy link
Owner

Framstag commented Aug 6, 2023

@Karry : Right?

We also have zIndex. I do not remember the purpose of this one. Karry, can you help? We should also document it ;-)

@Karry
Copy link
Collaborator

Karry commented Aug 6, 2023

Just see "Section ORDER WAYS" in our documentation

This section defines in which order ways are rendered. It defines a number groups which contains ways types. Ways types in the same group have the same rendering priority. Groups further down the style sheet are rendered below ways further up in the GROUP list. Rendering order is only relevant if ways of different types cross each other. Note that ways are first ordered by layer, then within a layer by rendering priority. So a bridge will always be rendered on top a “bridged” way, a tunnel always below a “tunneled” ways.

And yes, in Qt, I just setup layer to maximum for "overlay" objects.

Regarding zIndex, it is really missing in documentation. Looking to stylesheets, it seems to me that it is used just for way decorations - to render outlines first. With that, I would guess that zIndex is used as last property for sorting (just order individual lines for the same way), but looking to the code, sorting order is: layer, zIndex, style priority, style sheet priority (ORDER WAYS). Should we change it?

@vyskocil
Copy link
Collaborator

vyskocil commented Aug 8, 2023

Thank you @Framstag and @Karry for the hints, I checked all this in my code, tried to use the standard.oss stylesheet from the distribution but the rendering is still the same...
Maybe the issue is in the code I use to inject the _route path ?

       std::vector<RenderSteps> renderSteps {
            FirstStep, DrawAreas, DrawWays, DrawHillShading, DrawLabels, LastStep
        };
        
        unsigned long lastMapIndex = ctx->mapServices.size() - 1;
        
        for (int step = 0; step < renderSteps.size()/2; step++) {
            
            RenderSteps startRenderStep = renderSteps[step*2];
            RenderSteps endRenderStep = renderSteps[step*2 + 1];
            
            // render the active maps
            for(int i = 0; i <= lastMapIndex; i++){
...
                // Append the routeWay data in the last rendered database to paint it on top
                if (i == lastMapIndex && step == 0 && routeWay) {
                    TypeInfoRef type=ctx->databases[i]->GetTypeConfig()->GetTypeInfo("_route");
                                        
                    osmscout::FeatureValueBuffer features;
                    size_t featureIndex;
                    features.SetType(type);
                    if (type->GetFeature(osmscout::LayerFeature::NAME,
                                         featureIndex)) {
                        auto* value=dynamic_cast<osmscout::LayerFeatureValue*>(features.AllocateValue(featureIndex));
                        assert(value);
                        value->SetLayer(std::numeric_limits<int8_t>::max());
                    }
                    
                    if (type){
                        if(routeWay){
                            if (!routeWay->GetType()) {
                                routeWay->SetType(type);
                            }
                            ctx->datas[i].ways.push_back(routeWay);
                        }
                      }
...

@Karry
Copy link
Collaborator

Karry commented Aug 8, 2023

I am missing routeWay->SetFeatures(features); in your snippet

@vyskocil
Copy link
Collaborator

vyskocil commented Aug 8, 2023

Thank you @Karry, this is the solution !

@vyskocil vyskocil closed this as completed Aug 8, 2023
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

4 participants