/** * This method applies the changes to the graph specified as feature collection. It does so by locking the routing * to avoid concurrent changes which could result in incorrect routing (like when done while a Dijkstra search) or * also while just reading one edge row (inconsistent edge properties). */ public ChangeGraphResponse changeGraph(Collection<JsonFeature> collection) { // TODO allow calling this method if called before CH preparation if (getCHFactoryDecorator().isEnabled()) throw new IllegalArgumentException("To use the changeGraph API you need to turn off CH"); Lock writeLock = readWriteLock.writeLock(); writeLock.lock(); try { ChangeGraphHelper overlay = createChangeGraphHelper(ghStorage, locationIndex); long updateCount = overlay.applyChanges(encodingManager, collection); return new ChangeGraphResponse(updateCount); } finally { writeLock.unlock(); } }
ChangeGraphHelper instance = new ChangeGraphHelper(graph, locationIndex); JsonFeatureCollection collection = Jackson.newObjectMapper().readValue(reader, JsonFeatureCollection.class); long updates = instance.applyChanges(encodingManager, collection.getFeatures()); assertEquals(2, updates);
/** * This method applies changes to the graph, specified by the reader. * * @return number of successfully applied edge changes */ public long applyChanges(Reader reader) { // read full file, later support one json feature or collection per line to avoid high mem consumption JsonFeatureCollection data = ghson.fromJson(reader, JsonFeatureCollection.class); return changeGraphHelper.applyChanges(encodingManager, data.getFeatures()); } }
/** * This method applies the changes to the graph specified as feature collection. It does so by locking the routing * to avoid concurrent changes which could result in incorrect routing (like when done while a Dijkstra search) or * also while just reading one edge row (inconsistent edge properties). */ public ChangeGraphResponse changeGraph(Collection<JsonFeature> collection) { // TODO allow calling this method if called before CH preparation if (getCHFactoryDecorator().isEnabled()) throw new IllegalArgumentException("To use the changeGraph API you need to turn off CH"); Lock writeLock = readWriteLock.writeLock(); writeLock.lock(); try { ChangeGraphHelper overlay = createChangeGraphHelper(ghStorage, locationIndex); long updateCount = overlay.applyChanges(encodingManager, collection); return new ChangeGraphResponse(updateCount); } finally { writeLock.unlock(); } }
/** * This method applies the changes to the graph specified as feature collection. It does so by locking the routing * to avoid concurrent changes which could result in incorrect routing (like when done while a Dijkstra search) or * also while just reading one edge row (inconsistent edge properties). */ public ChangeGraphResponse changeGraph(Collection<JsonFeature> collection) { // TODO allow calling this method if called before CH preparation if (getCHFactoryDecorator().isEnabled()) throw new IllegalArgumentException("To use the changeGraph API you need to turn off CH"); Lock writeLock = readWriteLock.writeLock(); writeLock.lock(); try { ChangeGraphHelper overlay = createChangeGraphHelper(ghStorage, locationIndex); long updateCount = overlay.applyChanges(encodingManager, collection); return new ChangeGraphResponse(updateCount); } finally { writeLock.unlock(); } }