Skip to content

location lookup based on Weighting additionally to access - #1838

Merged
karussell merged 9 commits into
masterfrom
issue_729_2
Feb 3, 2020
Merged

karussell merged 9 commits into
masterfrom
issue_729_2

Conversation

@karussell

@karussell karussell commented Dec 30, 2019 •

Copy link
Copy Markdown
Member

fixes #729 before #1835

TODOs:

  • throw error if area contains one of the query points

Comment on lines +1045 to +1047
// TODO NOW for CH it will be overwritten by chProfile.getWeighting but now we need it for locationIndex -> #729
Weighting weighting = createWeighting(hints, encoder);

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 its fine to create the Weighting early here, but should we not better take it from the CHProfile, something like

- request comes in
- if LM/CH: select preparation using request parameters and take Weighting from the preparation/profile
- else: create Weighting from request parameters

instead of

- request comes in
- create Weighting from request parameters (hopefully we managed to re-create the same Weighting that was used for the preparation)
- later: use request parameters to select CHProfile to select CHGraph etc. and overwrite Weighting (?)

Two questions here:

  1. Should we support using another CH/LM Weighting for the request than it was used for the preparation ? Normally this is an error, but their might be some (rather special) use-cases for this (@michaz ?). Otherwise I think the first method is better because it automatically uses the right Weighting (or at least the one that is kept by the preparation).

  2. How are we supposed to select the CHProfile/Weighting given the request ? I think as soon as we want to use 'real' configurable weightings for CH we need to select the profiles by name (Select CH profiles by name ? #1708) and if we do we need to first select the CHProfile by name and then take the weighting from the profile (first method). Otherwise we would have to send the whole configuration with every request (makes sense for non-speedup algos, because thats the whole point of configurable weightings, but not so much for LM/CH where the idea is rather to create a (custom/configurable) preparation once and then use it for many or at least multiple requests.

@karussell karussell Jan 1, 2020 •

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.

Yes, thanks! Can you have a look into the new commit if this is what you meant?

Should we support using another CH/LM Weighting for the request than it was used for the preparation ?

For LM this works under special conditions (that increase the edge weight). For CH this won't work at the moment but it could be required for "Core CH"?

I think as soon as we want to use 'real' configurable weightings for CH we need to select the profiles by name (#1708)

I think this should be part of a different issue #1776 and the configuration (with which the CH preparation is done) could be picked up via the vehicle and/or weighting parameters (?)

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, thanks! Can you have a look into the new commit if this is what you meant?

Yes this is perfect!

For LM this works under special conditions (that increase the edge weight). For CH this won't work at the moment but it could be required for "Core CH"?

Yes but do we have to support this via the GraphHopper/high-level API here ? Do you (still) need this for the block-core thing @michaz ? Or maybe we can keep going here and add this functionality later (so far this is not really supported either) ?

I think this should be part of a different issue #1776

Do you mean it should be part of #1776 or it should not ? Sure, it should not be part of this (#1838) issue.

and the configuration (with which the CH preparation is done) could be picked up via the vehicle and/or weighting parameters (?)

This is a good/tough question, I'll move this question to #1708.

@michaz michaz Jan 2, 2020 •

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.

Should we support using another CH/LM Weighting for the request than it was used for the preparation

Only perhaps in a very weak sense of 'support':

I need to be able to write code where I pick the Graph I want to use and the Weighting I want to use by myself. Without fighting against anything. So there shouldn't be machinery which actively prevents me from doing so. For example, nothing should try to information-hide a CH-Graph away from me until I can show it the proper Weighting instance, or something like that.

But I don't need to have this as, for example, a config file option. Nor do I ask for special accomodations for such a (very experimental) thing (not even sure if it'll make it in the final TARDUR project branch). Just don't prevent this more than seems natural.

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 I'll try to keep in mind that it should be easy enough to use another weighting together with a partially contracted graph.

@easbar

easbar commented Jan 8, 2020

Copy link
Copy Markdown
Member

Looks good to me, except the remaining todo:

throw error if area contains one of the query points

Currently createWeighting is used for two different purposes: to create a weighting for preparation and to create a weighting at request time. For initCH/LMAlgoFactoryDecorator() the block area coordinates are not an issue, because there are no query points, but we need to run this check in GraphHopper#calcPaths and for the SPT&Isochrone endpoints. The easiest seems to be doing this check before calling createWeighting (wherever we have access to the requested points) with the only downside that one has to remember doing so. Basically it is about request validation, which already is partially duplicated between /route, /spt and /isochrone, so maybe its worth creating an extra method GraphHopper#validateRequest or similar that does the block area check and can be called from /route, /spt and /isochrone ?

@karussell

Copy link
Copy Markdown
Member Author

so maybe its worth creating an extra method GraphHopper#validateRequest or similar that does the block area check and can be called from /route, /spt and /isochrone ?

This is a good idea. Especially since this is already wanted from @boldtrn (see TODO comment before checkIfPointsAreInBounds call).

Should we do this in another issue (for 1.0) and merge here for now?

@easbar

easbar commented Jan 8, 2020 •

Copy link
Copy Markdown
Member

Ok. The only problem is that if we specify some query points within the block area the virtual edges will not be blocked ? But is this even such a big deal ? In most cases they won't be reachable anyway, because all the edges leading to the point lying in the blocked area will be blocked as well (?)

@karussell

Copy link
Copy Markdown
Member Author

The only problem is that if we specify some query points within the block area the virtual edges will not be blocked ?

Yes, but with a validation that ensures that query points cannot be inside the blocked areas this won't happen IMO. Which also makes sense as you cannot calculate a route where you block one of the waypoints.

Or ... if you mean this shouldn't go into a separate issue, I'll include the check here (introduce your proposed new method).

@karussell

karussell commented Jan 8, 2020 •

Copy link
Copy Markdown
Member Author

cannot be inside the blocked areas this won't happen IMO

Ok, there are cases where waypoints are outside of the block area but some involved virtual edges can still be inside. But when I went through the possibilities I did not find a case where the involved and blocked tower node did not manage the blocking.

Ie. an edge A-x-B with the query point on x where virtual edge A-x is blocked is already blocked because of non-virtual edges for A are blocked.

Okay there are cases where the virtual edge is inside the blocked area but not A and also not x like A-[blocked]-x-B ... related to #1324.

@easbar

easbar commented Jan 8, 2020

Copy link
Copy Markdown
Member

Ah I meant its not a big problem and we can merge and do the validation later. Yes once we do the validation the problem I mentioned does not occur anymore. Ok, like you said the query point might be outside of the blocked area and the validation would not throw an error. But is this really a problem ? It just means the edge won't be blocked, but who wants to block edges that are leading / coming from the query points (the places you want to go / start from) anyway ?

@easbar

easbar commented Jan 8, 2020 •

Copy link
Copy Markdown
Member

So I think we can:

  • merge now
  • add the validation method later where we only do a 'rough' consistency check to warn the user that the query point lies within the blocked area, which would be a contradiction

@easbar

easbar commented Jan 8, 2020

Copy link
Copy Markdown
Member

Ah I did not think of the case where a single point is blocked (how does that work ?). So far I was thinking of blocked areas.

@karussell

Copy link
Copy Markdown
Member Author

but who wants to block edges that are leading / coming from the query points (the places you want to go / start from) anyway ?

The use case could be to block only parts of the road and still make the rest of the road accessible and force a u-turn in those cases. But those issues should be probably fixed within #1324 as currently it does not work anyway. BTW: See this discussion.

Ah I did not think of the case where a single point is blocked (how does that work ?). So far I was thinking of blocked areas.

It is a LocationIndex lookup, i.e. not really a singular point: https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/storage/GraphEdgeIdFinder.java#L61

@karussell

karussell commented Jan 13, 2020 •

Copy link
Copy Markdown
Member Author

I will do the left TODO, but afterwards have to fix #1127 and #1324 via a cleaner block_area implementation e.g. replace our Polygon with the JTS Polygon implementation etc and also look into the work from @otbutz to maybe use his polygon work also on a per-request basis not just for import.

@otbutz

otbutz commented Jan 14, 2020

Copy link
Copy Markdown
Contributor

JTS doesn't really support circle as a geometry AFAIK. So we would have to remove this type of blocking functionality or use a polygon as an approximation:

https://github.com/locationtech/jts/blob/master/modules/core/src/main/java/org/locationtech/jts/util/GeometricShapeFactory.java#L199-L234

@easbar

easbar commented Feb 3, 2020

Copy link
Copy Markdown
Member

This looks good! And even better now that block area is no longer in createWeighting.

@karussell
karussell merged commit 9c2c9ec into master Feb 3, 2020
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.

Improve edge filtering for LocationIndex

4 participants