Change graph based on overlay data #781

Closed
wants to merge 5 commits into
from

Projects

None yet

1 participant

@karussell
Member
karussell commented Aug 26, 2016 edited

This PR makes it possible to feed external speed or access changes via GeoJSON. For now it is not yet integrated in e.g. GraphHopper core or web. But you can easily add it via:

GraphHopper myHopper = new GraphHopperOSM() {
    @Override
    public void postProcessing() {
        super.postProcessing();

        String fileOrFolderAsString = args.get("overlay_data.location", "");
        if (!fileOrFolderAsString.isEmpty()) {
            FeedOverlayData instance = new FeedOverlayData(getGraphHopperStorage(),
                    getEncodingManager(), getLocationIndex(), new GHsonBuilder().create());
            instance.setLogging(args.getBool("overlay_data.logging", true));
            long updates = instance.applyChanges(fileOrFolderAsString);
            logger.info("Applied " + updates + " updates from overlay data");
        }
    }
}

pom.xml:

        <dependency>
            <groupId>com.graphhopper</groupId>
            <artifactId>graphhopper-reader-overlay-data</artifactId>
            <version>0.8-SNAPSHOT</version>           
        </dependency>

E.g. see FeedOverlayDataTest or an example json file

Keep in mind that the order of any coordinate array is lon,lat and e.g. the bbox is min_lon,min_lat,max_lon,max_lat like specified in the Geojson spec. Also currently only three cases for a Feature are implemented:

  • type=Point,
  • type=MultiPoint and
  • no type and no properties.coordinates entry but with a bounding box entry bbox

It furthermore introduces a Json reader wrapper as discussed in #773 backed by Gson.

The overlay change functionality will stay in separate module reader-overlay-data. It goes even further and as we need map matching functionality in this reader module, we potentially have to move the currently separate map matching component into this repository here. Keeping it necessary and still depend on it would not work well.

Keep in mind: the feeding mechanism is not thread safe, so you should not use this for real time updates without some locking. And it would work only for non-CH, but this method here is before the preparation and works with CH as applied only once.

@karussell karussell initial commit to change graph based on some overlay data
7855e37
@karussell karussell added this to the 0.8 milestone Aug 26, 2016
@karussell
Member
karussell commented Aug 30, 2016 edited

Currently the default is to pick the first vehicle if non is specified in the file, maybe we should apply the change to all vehicles instead in these cases.

@karussell karussell improve exception handling, logging and multiple encoders
3761040
@karussell
Member

Will merge soon

@karussell karussell make sure id is properly read 54a27cb
karussell added some commits Aug 30, 2016
@karussell karussell fix id reading
816c3d8
@karussell karussell added missing license header
de402aa
@karussell
Member

Is now merged to master: 9a9f34a

@karussell karussell closed this Aug 31, 2016
@karussell
Member

Using serialization classes e.g. 'ConfigurationPojo' in the core will avoid using this 'heavier' dependency into the core. We can deserialize the json in the web module into such a 'serialization object' and forward this.

@karussell karussell deleted the reader-overlay-data branch Oct 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment