Skip to content

Change graph based on overlay data - #781

Closed
karussell wants to merge 5 commits into
masterfrom
reader-overlay-data
Closed

karussell wants to merge 5 commits into
masterfrom
reader-overlay-data

Conversation

@karussell

@karussell karussell commented Aug 26, 2016 •

Copy link
Copy Markdown
Member

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 commented Aug 30, 2016 •

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Member Author

Will merge soon

@karussell

Copy link
Copy Markdown
Member Author

Is now merged to master: 9a9f34a

@karussell karussell closed this Aug 31, 2016
@karussell

Copy link
Copy Markdown
Member Author

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.

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.

1 participant