GraphHopper.com | Forum | GitHub | Maps | Blog

Turn Restrictions don't working in iOS app using Swift 3


#1

Hi, i am trying to rout with turn restrictions, this is my code for setup graphhopper.

func initGraphhoper(){
        let location: String? = Bundle.main.path(forResource: "graph-data", ofType: "osm-gh")
        self.hopper = GraphHopper()
        self.hopper.getCHWeightings().add(withId: "shortest")
        self.hopper!.setAllowWritesWithBoolean(false)
        self.hopper!.forMobile()
        self.hopper!.load__(with: location)
    }

this is the code for the Graphhopper Request

       var request = GHRequest(double: latitud1, with: longitud1, with: latitud2, with: longitud2).setVehicleWith("car").setWeightingWith("fastest").setLocaleWith("es")
        request.getHints().put(with: "ch.disable", withId: true)

        result = self.hopper?.route(with: request)

But is not working, when show the rout is not takeing in account the “ch.disable”=true

Any Help? Any Tip?


#2

Do you use a graph created with turn restrictions enabled for that vehicle?


#3

yes, i am, this is my entire config file

graph.bytes_for_flags=8

##### Vehicles #####


# Possible options: car,foot,bike,bike2,mtb,racingbike,motorcycle (comma separated)
# bike2 takes elevation data into account (like up-hill is slower than down-hill) and requires enabling graph.elevation.provider below
#graph.flag_encoders=car,motorcycle,bike,foot

# Enable turn restrictions for car or motorcycle. 
graph.flag_encoders=car|turn_costs=true,motorcycle|turn_costs=true,bike|turn_costs=true,foot|turn_costs=false


##### Elevation #####


# To populate your graph with elevation data use SRTM, default is noop (no elevation)
# graph.elevation.provider=srtm


# default location for cache is /tmp/srtm
# graph.elevation.cache_dir=./srtmprovider/


# If you have a slow disk or plenty of RAM change the default MMAP to:
# graph.elevation.dataaccess=RAM_STORE



#### Speed, hybrid and flexible mode ####


# By default the speed mode with the 'fastest' weighting is used. Internally a graph preparation via
# contraction hierarchies (CH) is done to speed routing up. This requires more RAM/disc space for holding the
# graph but less for every request. You can also setup multiple weightings, by providing a comma separated list.
prepare.ch.weightings=fastest,shortest


# Disable the speed mode. Should be used only with routing.max_visited_nodes or when the hybrid mode is enabled instead
#prepare.ch.weightings=no


# To make CH preparation faster for multiple flagEncoders you can increase the default threads if you have enough RAM.
# Change this setting only if you know what you are doing and if the default worked for you.
# prepare.ch.threads=1


# The hybrid mode can be enabled with
#prepare.lm.weightings=fastest, shortest

# To tune the performance vs. memory usage for the hybrid mode use
# prepare.lm.landmarks=16

# Make landmark preparation parallel if you have enough RAM. Change this only if you know what you are doing and if the default worked for you.
# prepare.lm.threads=1


# avoid being stuck in a (oneway) subnetwork, see https://discuss.graphhopper.com/t/93
prepare.min_network_size=200
prepare.min_one_way_network_size=200



##### Routing #####


# You can define the maximum visited nodes when routing. This may result in not found connections if there is no
# connection between two points within the given visited nodes. The default is Integer.MAX_VALUE. Useful for flexibility mode
routing.max_visited_nodes = 1000000


# If enabled, allows a user to run flexibility requests even if speed mode is enabled. Every request then has to include a hint routing.ch.disable=true.
# Attention, non-CH route calculations take way more time and resources, compared to CH routing.
# A possible attacker might exploit this to slow down your service. Only enable it if you need it and with routing.maxVisitedNodes
routing.ch.disabling_allowed=true


# If enabled, allows a user to run flexible mode requests even if the hybrid mode is enabled. Every such request then has to include a hint routing.lm.disable=true.
# routing.lm.disabling_allowed=true

# Control how many active landmarks are picked per default, this can improve query performance
# routing.lm.active_landmarks=4


# You can limit the max distance between two consecutive waypoints of flexible routing requests to be less or equal
# the given distance in meter. Default is set to 1000km.
routing.non_ch.max_waypoint_distance = 1000000



##### Web #####


# if you want to support jsonp response type you need to add it explicitly here. By default it is disabled for stronger security.
# web.jsonp_allowed=true



##### Storage #####


# configure the memory access, use RAM_STORE for well equipped servers (default and recommended)
graph.dataaccess=RAM_STORE


# will write way names in the preferred language (language code as defined in ISO 639-1 or ISO 639-2):
# datareader.preferred_language=en


# Sort the graph after import to make requests roughly ~10% faster. Note that this requires significantly more RAM on import.
# graph.do_sort=true



##### Spatial Rules #####
# Spatial Rules require some configuration and only work with the DataFlagEncoder.


# Spatial Rules require you to provide Polygons in which the rules are enforced
# The line below contains the default location for these rules
# spatial_rules.location=core/files/spatialrules/countries.geo.json

# You can define the maximum BBox for which spatial rules are loaded.
# You might want to do this if you are only importing a small area and don't need rules for other countries.
# Having less rules, might result in a smaller graph. The line below contains the world-wide bounding box, uncomment and adapt to your need.
# spatial_rules.max_bbox=-180,180,-90,90

#4

Any help with this issue???


#5

any help with this issue?