graphhopper / graphhopper-ios

iOS Port of the GraphHopper road routing engine
https://www.graphhopper.com/open-source/
Apache License 2.0
69 stars 28 forks source link

NSInternalInconsistencyException shortcutId not in bounds #28

Closed randyhbh closed 7 years ago

randyhbh commented 7 years ago

When i try to initialize graphhopper give me an error this is my code to initialize graphhoper

func initGraphhoper(){
        let location: String? = Bundle.main.path(forResource: "graph-data", ofType: "osm-gh")
        self.hopper = GraphHopper.init()
        self.hopper!.setCHEnabledWithBoolean(false)
        self.hopper!.setEnableInstructionsWithBoolean(true)
        self.hopper!.setAllowWritesWithBoolean(true)
        self.hopper!.setEncodingManagerWith(EncodingManager.init(nsString: "car,foot,bike"))
        self.hopper!.forMobile()
        self.hopper!.load__(with: location) 
    }

and this is the error that xcode give me

017-10-05 23:01:13.900457 WeGoCuba[2302:53775] [] __nw_connection_get_connected_socket_block_invoke 1 Connection has no connected handler
2017-10-05 23:02:11.629 WeGoCuba[2302:53722] *** Terminating app due to uncaught exception 'JavaLangRuntimeException', reason: 'java.lang.IllegalStateException: No input stream found in class path!?'
*** First throw call stack:
(
    0   CoreFoundation                      0x05026bf2 __exceptionPreprocess + 194
    1   libobjc.A.dylib                     0x04adfe66 objc_exception_throw + 52
    2   WeGoCuba                            0x00c55506 -[TranslationMap doImport] + 1030
    3   WeGoCuba                            0x00b47164 -[GraphHopper init] + 404
    4   WeGoCuba                            0x000cf681 _TTOFCSo11GraphHoppercfT_GSQS__ + 33
    5   WeGoCuba                            0x000ce7b6 _TFCSo11GraphHopperCfT_GSQS__ + 86
    6   WeGoCuba                            0x000ce01d _TFC8WeGoCuba7Routing14initGraphhoperfT_T_ + 685
    7   WeGoCuba                            0x000c86f5 _TFC8WeGoCuba7RoutingcfT7mapViewCSo9NTMapView_S0_ + 181
    8   WeGoCuba                            0x000ca7d8 _TFC8WeGoCuba7RoutingCfT7mapViewCSo9NTMapView_S0_ + 72
    9   WeGoCuba                            0x000e4e30 _TFC8WeGoCuba14ViewController17routeSwitchTappedfT_T_ + 1408
    10  WeGoCuba                            0x000eb467 _TTWC8WeGoCuba14ViewControllerS_19RouteButtonDelegateS_FS1_17routeSwitchTappedfT_T_ + 39
    11  WeGoCuba                            0x000f09f6 _TFC8WeGoCuba11RouteButton13switchChangedfCSo22UITapGestureRecognizerT_ + 214
    12  WeGoCuba                            0x000f0a8d _TToFC8WeGoCuba11RouteButton13switchChangedfCSo22UITapGestureRecognizerT_ + 61
    13  UIKit                               0x03580d3b -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 64
    14  UIKit                               0x0358975e _UIGestureRecognizerSendTargetActions + 109
    15  UIKit                               0x03586dee _UIGestureRecognizerSendActions + 288
    16  UIKit                               0x03585ca8 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 1059
    17  UIKit                               0x03570670 _UIGestureEnvironmentUpdate + 1461
    18  UIKit                               0x03570073 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 494
    19  UIKit                               0x0356f21d -[UIGestureEnvironment _updateGesturesForEvent:window:] + 259
    20  UIKit                               0x03044637 -[UIWindow sendEvent:] + 4276
    21  UIKit                               0x02feaad4 -[UIApplication sendEvent:] + 395
    22  UIKit                               0x0388ea8c __dispatchPreprocessedEventFromEventQueue + 3706
    23  UIKit                               0x03886b8a __handleEventQueue + 5345
    24  CoreFoundation                      0x04fc5edf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    25  CoreFoundation                      0x04fa9fa7 __CFRunLoopDoSources0 + 519
    26  CoreFoundation                      0x04fa9434 __CFRunLoopRun + 1124
    27  CoreFoundation                      0x04fa8d5b CFRunLoopRunSpecific + 395
    28  CoreFoundation                      0x04fa8bbb CFRunLoopRunInMode + 123
    29  GraphicsServices                    0x07e77b4c GSEventRunModal + 177
    30  GraphicsServices                    0x07e779c7 GSEventRun + 80
    31  UIKit                               0x02fc9ff3 UIApplicationMain + 148
    32  WeGoCuba                            0x000ee331 main + 145
    33  libdyld.dylib                       0x05efc799 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type JavaLangRuntimeException

EDIT I debug the code and is failing in this line self.hopper = GraphHopper.init() bacause inside this is looking for ar.txt IN Transaltion Directory but this file dosn't exist, why is looking for this file? how i can change it?

tnmendes commented 7 years ago

To fix that you need to drag and drop all translation files to your project, the location of the files in your project are: graphhopper/core/src/main/resources/com/graphhopper/util/

as you can see in this link: https://github.com/graphhopper/graphhopper/tree/fe358725e7ae2526dae258bc3dc80a83d616055a/core/src/main/resources/com/graphhopper/util

You can also have look to the sample project that they did the same.

randyhbh commented 7 years ago

I already fix it but i am facing an error in this line self.hopper!.load__(with: location), xcode throw

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'shortcutId 541319 not in bounds [314191 J2OBJC_COMMA() 541246)'
*** First throw call stack:
(
    0   CoreFoundation                      0x05030bf2 __exceptionPreprocess + 194
    1   libobjc.A.dylib                     0x04ae9e66 objc_exception_throw + 52
    2   CoreFoundation                      0x05034d12 +[NSException raise:format:arguments:] + 130
    3   Foundation                          0x02b76d86 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 77
    4   WeGoCuba                            0x00bf8b51 CHGraphImpl_$1_toPointerWithInt_ + 561
    5   WeGoCuba                            0x00bf8917 -[CHGraphImpl_$1 toPointerWithInt:] + 39
    6   WeGoCuba                            0x00beec1e BaseGraph_EdgeIterable_next + 142
    7   WeGoCuba                            0x00bf1c2d -[BaseGraph_EdgeIterable next] + 29
    8   WeGoCuba                            0x00b8f1c3 -[DijkstraOneToMany findEndNodeWithInt:withInt:] + 2547
    9   WeGoCuba                            0x00b85bbf -[PrepareContractionHierarchies findShortcutsWithPrepareContractionHierarchies_ShortcutHandler:] + 1903
    10  WeGoCuba                            0x00b85364 -[PrepareContractionHierarchies calculatePriorityWithInt:] + 116
    11  WeGoCuba                            0x00b83155 -[PrepareContractionHierarchies prepareNodes] + 213
    12  WeGoCuba                            0x00b8304f -[PrepareContractionHierarchies doWork] + 271
    13  WeGoCuba                            0x00b8080e -[CHAlgoFactoryDecorator_$1 run] + 286
    14  WeGoCuba                            0x00a59de0 JavaUtilConcurrentThreadPoolExecutor_runTaskWithJavaLangRunnable_ + 46
    15  WeGoCuba                            0x00a59cb8 JavaUtilConcurrentThreadPoolExecutor_runWorkerWithJavaUtilConcurrentThreadPoolExecutor_Worker_ + 477
    16  WeGoCuba                            0x00a5c6e2 -[JavaUtilConcurrentThreadPoolExecutor_Worker run] + 29
    17  WeGoCuba                            0x0089d6ea -[JavaLangThread run] + 108
    18  WeGoCuba                            0x0089d71e -[JavaLangThread run0WithId:] + 36
    19  Foundation                          0x02a96bab -[NSThread main] + 68
    20  Foundation                          0x02a96930 __NSThread__start__ + 1332
    21  libsystem_pthread.dylib             0x06246780 _pthread_body + 138
    22  libsystem_pthread.dylib             0x062466f6 _pthread_body + 0
    23  libsystem_pthread.dylib             0x06243f7a thread_start + 34
)
libc++abi.dylib: terminating with uncaught exception of type NSException
randyhbh commented 7 years ago

Any help whit this?

tnmendes commented 7 years ago

Hi @RandyHBH did you notice this line in the error msg "reason: 'shortcutId 541319 not in bounds"?

Possibly you are generating route but the file that you have don't have that part of the city.

randyhbh commented 7 years ago

@tnmendes Already solved it, removing graphhopper and configuring it again, it looks like something bad happened before. Can you see this new issue