Skip to content

Block area setting for all weightings - #1078

Merged
karussell merged 6 commits into
masterfrom
blockarea_forall_weightings
May 31, 2017
Merged

karussell merged 6 commits into
masterfrom
blockarea_forall_weightings

Conversation

@karussell

@karussell karussell commented May 29, 2017 •

Copy link
Copy Markdown
Member

This is a replacement for #1029 (as no feedback and want to have it in 0.9) ie. a fix for #958. Furthermore it does some cleanup in DataFlagEncoder, allows the block area option for all weightings and removes ConfigMap to improve #940 too.

It is not yet complete although all tests pass: the setGraph method is removed but necessary. I think a graph creation with the block area setting in the config will fail. We should add a test for this.

cloneDoubleAttribute(weightingMap, cMap, GenericWeighting.HEIGHT_LIMIT, 0d);
cloneDoubleAttribute(weightingMap, cMap, GenericWeighting.WEIGHT_LIMIT, 0d);
cloneDoubleAttribute(weightingMap, cMap, GenericWeighting.WIDTH_LIMIT, 0d);
public class Result {

@karussell karussell May 29, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I like how we can keep the 'strange' speedArray local to the DataFlagEncoder

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this called result? Wouldn't be Config or RoadConfig or something similar be a better matching name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The naming is indeed suboptimal it should be more like RequestConfig ... as this class is probably always used via DataFlagEncoder.XY the naming could be done with this association in mind

return blockArea;
}

public static class BlockArea {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same here: the logic and difference of shapes and edgeIds is all local to this class and no longer in the Weighting

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is nice 👍


return cMap;
}
public double getSpeed(EdgeIteratorState edgeState) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would expect this method to check the speed encoder of the edge as well, if there is no speed stored, we return the value of speedArray.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

check the speed encoder of the edge as well

What do you mean here? There is no speed for DataFlagEncoder. Only a max speed value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes sorry, this is what I meant. I would have expected the same result as when calling getSpeed in a different Encoder.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So, what you mean is that if there is no request value for the speed we should use the default maxspeed value of the highway?

@boldtrn boldtrn May 30, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is just what I would have expected when reading the method head. The getSpeed method of the other encoders reads the speed that is saved in the edge. So here I would have expected that there is a check, if maxSpeed stored -> return maxSpeed, else return speed for highway type. In this case we would also need to pass a forward flag to do this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think we need to adjust the createResult method and use Math.min(requestSpeedValue, storedSpeedValue). So the provided request parameters should be able to reduce the stored maxspeed values.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let us do this in a later issue as this was so before

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok no problem, it always bothered me ;).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

BTW: this seems to be already implemented in GenericWeighting.calcMillis

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know, I am just used to have the getSpeed in the FlageEncoder ;).

/**
* This weighting is a wrapper for every weighting to support block_area
*/
public class BlockAreaWeighting implements Weighting {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there are reason to not use the AbstractAdjustedWeighting?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

👍 :)

protected final DataFlagEncoder.Result result;
protected final int accessType;
protected final int eventuallAccessiblePenalty = 10;
protected final int eventualAccessiblePenalty = 10;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think naming this uncertainAccessiblePenaltyor something like this would be better. Eventual is a false friend to the German eventuell. I think this was introduced by me some time ago :), but since I just saw it, we should fix it.

if (tmpSpeed > encoder.getMaxPossibleSpeed())
throw new IllegalArgumentException("Speed bigger than maximum speed: " + tmpSpeed + " > " + encoder.getMaxPossibleSpeed());
result = encoder.createResult(hintsMap);
double biggestSpecifiedSpeed = result.getMaxspeed();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should rename the getMaxspeed method also to biggestSpecifiedSpeed?

@boldtrn boldtrn left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR adds a lot of nice things and really improves the handling of blocked areas.

Currently the init part for CH is commented out.
Also as you noted, an integration test with DefaultBlockedAreas + adding a new area would be very nice.
I didn't run the code yet. Would do this once it's ready.

@karussell

Copy link
Copy Markdown
Member Author

The problem with the default block_area is that we would have to lazy load the GraphEdge finding stuff too and not only the setGraph. Because the weighting should be read very early but the graph and locationIndex might be still uninitialized. So I have decided to remove this for now.

@boldtrn boldtrn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good to me. I think removing the default blocked areas is OK, as I think most want to use this on demand anyway. Still a bit unfortunate.

@karussell

Copy link
Copy Markdown
Member Author

Still a bit unfortunate.

Yes. But better a smaller feature now than a bigger or more features later (?)

@karussell
karussell merged commit bbd62fd into master May 31, 2017
@karussell
karussell deleted the blockarea_forall_weightings branch May 31, 2017 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants