GithubHelp home page GithubHelp logo

Comments (11)

otbutz avatar otbutz commented on June 13, 2024

Judging from the values on the taginfo website, we should probably increase the size of the encoded value to 9 bits:

https://taginfo.openstreetmap.org/keys/maxweight#values

A maximum value of 0.1 * 2^9 = 51,2 would cover the heaviest trucks in Europe and most of the USA.

The alternative approach of increasing the factor to 0.2, 0.3 or 0.5 causes us to lose precision for frequently used values. e.g:

Value / Factor 0.1 0.2 0.5
3.5 x x
2.8 x x
51.4 x x
6000lbs (~2.72) (x)

from graphhopper.

otbutz avatar otbutz commented on June 13, 2024

Is it really a good idea to silently cap values here?

} else if (value >= maxStorableValue * factor) { // equality is important as maxStorableValue is reserved for infinity
super.uncheckedSet(reverse, edgeId, edgeIntAccess, maxStorableValue - 1);
return;
}

I'd argue that we should treat "overflows" the same way as deliberately passing Double.POSITIVE_INFINITY:

if (useMaximumAsInfinity && value >= maxStorableValue * factor) {
    super.setInt(reverse, edgeId, edgeIntAccess, maxStorableValue);
    return;
}

This would also restore symmetry with DecimalEncodedValue.getNextStorableValue(double) which also returns Double.POSITIVE_INFINITY in this case.

See #2990

from graphhopper.

otbutz avatar otbutz commented on June 13, 2024

@karussell we can also stick with 8 bits and try to map the values as an enum instead. With 256 possible values, we should be able to cover all common limitations in the source material. The downside, of course, is that an enum is a single point of failure and would need to be evaluated from time to time.

from graphhopper.

karussell avatar karussell commented on June 13, 2024

try to map the values as an enum instead

But then it can no longer be (easily) used as a number in a custom model (?)

from graphhopper.

otbutz avatar otbutz commented on June 13, 2024

Agreed. Let's roll with 9bits 🙂

from graphhopper.

karussell avatar karussell commented on June 13, 2024

There is still the idea of a "Mapped"EncodedValue, i.e. instead of a factor it holds only distinct values. This could be interesting for a couple of EncodedValues as it could be still used as a number. The tricky thing could be the rounding.

from graphhopper.

otbutz avatar otbutz commented on June 13, 2024

The tricky thing could be the rounding.

I'd search the value with a configurable epsilon per EV.

from graphhopper.

karussell avatar karussell commented on June 13, 2024

What I meant is if you have the values and some with a bigger gap like: 3, 4, 10, 27. Then the value 20 should be rounded up to 27 but this would be IMO against the conservative approach and a vehicle of weight 22 would pass although it shouldn't. So, it might be necessary to implement different rounding strategies or something.

from graphhopper.

otbutz avatar otbutz commented on June 13, 2024

It's also tricky from a maintenance perspective. How do we know if we're missing a popular value? We would need to keep track of all the variants and how often they occur during import to be able to provide meaningful logging.

from graphhopper.

karussell avatar karussell commented on June 13, 2024

Yes, sounds tricky. We could collect this information directly in the encoded value and then after "graph.freeze" decide on how to best use the available bits. We could limit the values to 100 * available values and throw out less frequent values while the import to avoid a memory problem. But not sure how feasible this is.

from graphhopper.

otbutz avatar otbutz commented on June 13, 2024
private static final Map<Double,Integer> ENCOUNTERED_VALUES = new LinkedHashMap<>() {
    @Override
    protected boolean removeEldestEntry(Map.Entry<Double, Integer> eldest) {
        return size() > 10_000;
    }
};

// ...

ENCOUNTERED_VALUES.compute(value, (k, v) -> v == null ? 1 : v + 1);

Edit: If we want to only log offending ones

from graphhopper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.