Skip to content

Commit

Permalink
engine_config is instantiated in __cinit__ now of PyOSRM (was causing…
Browse files Browse the repository at this point in the history
… segfault)
  • Loading branch information
enricodvn committed Mar 3, 2020
1 parent 35288ad commit e446dd7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pyosrm/core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ from enum import Enum

cdef class PyOSRM:
cdef:
osrm.EngineConfig engine_config
osrm.OSRM* _thisptr

def __cinit__(self, path, algorithm="CH", use_shared_memory=False):
encoded_path = path.encode("UTF-8")
cdef osrm.EngineConfig engine_config
cdef char* path_c = encoded_path
cdef osrm.StorageConfig *store_config = new osrm.StorageConfig(path_c)
self.engine_config.storage_config = store_config[0]
self.engine_config.use_shared_memory = use_shared_memory
engine_config.storage_config = store_config[0]
engine_config.use_shared_memory = use_shared_memory

if algorithm=="CH":
self.engine_config.algorithm = osrm.Algorithm.CH
engine_config.algorithm = osrm.Algorithm.CH
elif algorithm=="MLD":
self.engine_config.algorithm = osrm.Algorithm.MLD
engine_config.algorithm = osrm.Algorithm.MLD
else:
raise ValueError("algorithm can be either 'CH' or 'MLD'")

self._thisptr = new osrm.OSRM(self.engine_config)
self._thisptr = new osrm.OSRM(engine_config)


def route(self, route_coords, generate_hints=True):
Expand Down

0 comments on commit e446dd7

Please sign in to comment.