SKmaps failed to perform multi level search - ios

I want to make a multi level offline search in my app.
I followed the directions at official Skobbler page and only difference is that l did not download map of France, but map of Wyoming instead.
Offline package code for it is USWY if I am right.
-(void)prepareForSearch{
[SKSearchService sharedInstance].searchServiceDelegate = self;
[SKSearchService sharedInstance].searchResultsNumber = 500;
_listLevel = SKCountryList;
_searchSettings = [SKMultiStepSearchSettings multiStepSearchSettings];
_searchSettings.listLevel = _listLevel;
_searchSettings.offlinePackageCode = #"USWY";
_searchSettings.parentIndex=-1;
}
- (IBAction)searchAction:(UIButton *)sender {
_searchSettings.searchTerm = [NSString stringWithFormat:#"%#",_searchBar.text];
[[SKSearchService sharedInstance]startMultiStepSearchWithSettings:_searchSettings];
}
-(void)searchService:(SKSearchService *)searchService didRetrieveMultiStepSearchResults:(NSArray *)searchResults
{
if ([searchResults count] !=0 && _listLevel<SKInvalidListLevel){
if (_listLevel == SKCountryList) {
_listLevel = SKCityList;
}
else{
_listLevel++;
}
SKSearchResult *searchResult = searchResults[0];
SKMultiStepSearchSettings* multiStepSearchObject = [SKMultiStepSearchSettings multiStepSearchSettings];
multiStepSearchObject.listLevel = _listLevel++;
multiStepSearchObject.offlinePackageCode = _searchSettings.offlinePackageCode;
multiStepSearchObject.searchTerm = _searchBar.text;
multiStepSearchObject.parentIndex = searchResult.identifier;
[[SKSearchService sharedInstance]startMultiStepSearchWithSettings:multiStepSearchObject];
}
}
-(void)searchServiceDidFailToRetrieveMultiStepSearchResults:(SKSearchService *)searchService
{
NSLog(#"Multi Level Search failed");
}
Whatever I put as a searchTerm, I end up with "MultiLevel Search Failed".
from this screenshot, you can see that my map package for Wyoming is included in my SKMaps.bundle:
(Also, if anyone can answer me this: Versioning was different in my app and in the simulator folder in the test app, from where I downloaded an offline package. So, for testing purposes, I made two folders and put Wyoming package in both of them(20140807 and 20140910). Are there any rules regarding this?)
What could be the problem?

Ok, after few days I managed to find the source of the problem.
First, I found out which version I'm using and it's the 20140910.
Second, For some reason, the entire folder containing maps was not recognised. So I took the entire SKMaps.bundle, together with some pre-bundled maps from the demo app, provided by the Skobbler team, and put it in my project and now everything works fine.

Related

Vuforia iOS example project can't show AR model after replace .dat and .xml image target

I got Vuforia official example project and someone else's Vuforia Swift project. I have to do a lot of configuration to make both projects finish compile. (something like vuforiaLicenseKey and vuforiaDataSetFile)After that, I found the AR model doesn't show on the demo image target after I replace the demo database by my database.
I have updated source code to do so. When I debug, I can see my image target has been detected. And, both official example and other one's example start draw OpenGL 3D model or draw Scene kit node. Problem is I can't see them on screen. But if I configure example database back, I can see the AR view working.
The below code is the swift project example from yshrkt/VuforiaSampleSwift . It is working, and the condition of trackerableName == "coaster" is true. It means the app detected the coaster image.
func vuforiaManager(_ manager: VuforiaManager!, didUpdateWith state: VuforiaState!) {
for index in 0 ..< state.numberOfTrackableResults {
let result = state.trackableResult(at: index)
let trackerableName = result?.trackable.name
//print("\(trackerableName)")
if trackerableName == "coaster" {
boxMaterial.diffuse.contents = UIColor.yellow
if lastSceneName != "coaster" {
manager.eaglView.setNeedsChangeSceneWithUserInfo(["scene" : "coaster"])
lastSceneName = "coaster "
}
} else {
print("\(trackerableName?.description)")
boxMaterial.diffuse.contents = UIColor.blue
if lastSceneName != "chips" {
manager.eaglView.setNeedsChangeSceneWithUserInfo(["scene" : "chips"])
lastSceneName = "chips"
}
}
}
}
And, it invoked the below fun. Everything looks right.
(void)setNeedsChangeSceneWithUserInfo: (NSDictionary*)userInfo {
SCNScene* scene = [self.sceneSource sceneForEAGLView:self userInfo:userInfo];
if (scene == nil) {
return;
}
SCNCamera* camera = [SCNCamera camera];
_cameraNode = [SCNNode node];
_cameraNode.camera = camera;
_cameraNode.camera.projectionTransform = _projectionTransform;
[scene.rootNode addChildNode:_cameraNode];
_renderer.scene = scene;
_renderer.pointOfView = _cameraNode;
}
Same project, before I update my image target database, it works fine, detect image target then draw model on AR view. But, after I replace database it only can detect image target, it can't draw model on AR view anymore.
Two possible things that may explain this - if your target size is wrong or if there's something wrong in the 'coaster' scene. You should first try to use the 'coaster' scene with the 'chips' target. If you can see the scene, the problem is probably with your target size. If it doesn't work, try using you new target with the 'chips' scene.
This should help you isolate the problem, and perhaps bring more details here.

How to download offline maps with SKMaps?

I tried downloading offline maps with SKMaps.
At first I'd like to create a region from a self made SKTPackage like this:
SKTPackage* packageToDownload;
packageToDownload.type = 3;
packageToDownload.packageCode = #"DEBY";
SKTDownloadObjectHelper* region = [SKTDownloadObjectHelper downloadObjectHelperWithSKTPackage:packageToDownload];
Unfortunately the region is empty and every attempt to add packageToDownload.languages led to a crash. What can I do to initiate an offline map download with only the packageCode and packageType?
Thanks for your help!
In the provided code snippet, the packageToDownload object is never initialized. Replace the first line with:
SKTPackage *packageToDownload = [[SKTPackage alloc] init];

How would I translate this Swift to Obj-C?

This is probably simple enough, but Im not a regular iOS dev but have a decent understanding of Obj-C and Xcode however not so much with Swift yet.
I am playing around with a mapping SDK called Skobbler and downloaded both Swift and iOS examples.
The Swift example gives me some useful text/console logs of directions turn by turn however the Obj-C doesn't and having a tough time exposing them.
The Swift example looks like this
let advices: Array<SKRouteAdvice> = SKRoutingService.sharedInstance().routeAdviceListWithDistanceFormat(SKDistanceFormat.Metric) as! Array<SKRouteAdvice>
for advice: SKRouteAdvice in advices
{
let instructions = advice.adviceInstruction
print(instructions)
}
NSArray<SKRouteAdvice *> *advices = [[SKRoutingService sharedInstance] routeAdviceListWIthDistanceFormat:SKDistanceFormat.Metric];
for (SKRouteAdvice *advice in advices)
{
NSLog(#"%#", instructions);
}
NSArray *advices = [[SKRoutingService sharedInstance]routeAdviceListWithDistanceFormat:SKDistanceFormat.Metric];
for (SKRouteAdvice *advice in advices) {
NSLog(#"%#", [advice adviceInstruction]);
}
as! doesn't need translating - the compiler will just believe you (you might want to add an assert for identical behaviour). The print is replaced with NSLog (#"%#", instructions).

How can I use NSRunningApplication to see running applications in swift?

I'm new in swift , and I'd like to see running application in the device or extract different information from the device like how many times the application was used ...
This will probably work for you or get you close to what you want.
for runningApp in NSWorkspace.sharedWorkspace().runningApplications as! [NSRunningApplication] {
if let bundleIdentifier = runningApp.bundleIdentifier {
NSLog(bundleIdentifier)
}
if let launchDate = runningApp.launchDate {
NSLog(launchDate.description)
}
}

is it possible to access pdf outline when developing for iOS

being that PDFKit is not available on iOS, how is it possible to get the outline of a pdf document in that environment? Is commercial libraries like FastPdfKit or PSPDFKit the only solution?
It's not TOO tricky to access the pdf outline. My outline parser has about 420 LOC. I'll post some snippets, so you'll get the idea. I can't post the full code as it's a commercial library.
You basically start like this:
CGPDFDictionaryRef outlineRef;
if(CGPDFDictionaryGetDictionary(pdfDocDictionary, "Outlines", &outlineRef)) {
going down to
NSArray *outlineElements = nil;
CGPDFDictionaryRef firstEntry;
if (CGPDFDictionaryGetDictionary(outlineRef, "First", &firstEntry)) {
NSMutableArray *pageCache = [NSMutableArray arrayWithCapacity:CGPDFDocumentGetNumberOfPages(documentRef)];
outlineElements = [self parseOutlineElements:firstEntry level:0 error:&error documentRef:documentRef cache:pageCache];
}else {
PSPDFLogWarning(#"Error while parsing outline. First entry not found!");
}
you parse single items like this:
// parse title
NSString *outlineTitle = stringFromCGPDFDictionary(outlineElementRef, #"Title");
PSPDFLogVerbose(#"outline title: %#", outlineTitle);
if (!outlineTitle) {
if (error_) {
*error_ = [NSError errorWithDomain:kPSPDFOutlineParserErrorDomain code:1 userInfo:nil];
}
return nil;
}
NSString *namedDestination = nil;
CGPDFObjectRef destinationRef;
if (CGPDFDictionaryGetObject(outlineElementRef, "Dest", &destinationRef)) {
CGPDFObjectType destinationType = CGPDFObjectGetType(destinationRef);
The most annoying thing is that you have Named Destinations in most pdf documents, which need additional steps to resolve. I save those in an array and resolve them later.
It took quite a while to "get it right" as there are LOTS of differences in the PDFs that are around, and even if you implement everything in compliance to the PDF reference, some files won't work until you apply further tweaking. (PDF is a mess!)
It is now possible in iOS 11+.
https://developer.apple.com/documentation/pdfkit
You can get the PDFOutline of a PDFDocument.
The PDFOutline's outlineRoot will return outline items if there are any and NULL if none.

Resources