Skip to content

Commit

Permalink
Release 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdans-telenav committed Mar 3, 2017
1 parent e2a8f80 commit 30cfb11
Show file tree
Hide file tree
Showing 245 changed files with 11,503 additions and 3,516 deletions.
22 changes: 22 additions & 0 deletions OSCTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.skobbler.OSCTests</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
59 changes: 59 additions & 0 deletions OSCTests/MatcherDataSet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"segmentStartLocation":[46.773304, 23.590858],
"segmentEndLocation":[46.773253, 23.592299],
"aLocation":[46.773108, 23.591604],
"distance":18.46,
"description":"Midle bottom"
},
{
"segmentStartLocation":[46.773304, 23.590858],
"segmentEndLocation":[46.773253, 23.592299],
"aLocation":[46.773102, 23.592602],
"distance":28.25,
"description":"Exterior bottom right"
},
{
"segmentStartLocation":[46.773304, 23.590858],
"segmentEndLocation":[46.773253, 23.592299],
"aLocation":[46.773109, 23.590691],
"distance":25.14,
"description":"Exterior bottom left"
},
{
"segmentStartLocation":[46.773304, 23.590858],
"segmentEndLocation":[46.773253, 23.592299],
"aLocation":[46.773484, 23.590600],
"distance":28.48,
"description":"Exterior top left"
},
{
"segmentStartLocation":[46.773304, 23.590858],
"segmentEndLocation":[46.773253, 23.592299],
"aLocation":[46.773409, 23.592524],
"distance":24.67,
"description":"Exterior top right"
},
{
"segmentStartLocation":[46.773304, 23.590858],
"segmentEndLocation":[46.773253, 23.592299],
"aLocation":[46.773361, 23.591657],
"distance":9.21,
"description":"Midle top"
},
{
"segmentStartLocation":[46.773304, 23.590858],
"segmentEndLocation":[46.773253, 23.592299],
"aLocation":[46.773305, 23.591074],
"distance":0.51,
"description":"Midle top very close"
},
{
"segmentStartLocation":[46.773304, 23.590858],
"segmentEndLocation":[46.773253, 23.592299],
"aLocation":[46.773217, 23.592151],
"aLocationOnSegment":[46.773258, 23.592155],
"distance":5.3,
"description":"Midle bottom very close"
}
]
76 changes: 76 additions & 0 deletions OSCTests/OSCTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// OSCTests.m
// OSCTests
//
// Created by Bogdan Sala on 03/02/2017.
// Copyright © 2017 Bogdan Sala. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "OSVUtils.h"

@interface OSCTests : XCTestCase
@property (strong, nonatomic) NSArray *dataSet;
@end

@implementation OSCTests

- (void)setUp {
[super setUp];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MatcherDataSet" ofType:@"json"];
NSError *deserializingError;
NSURL *localFileURL = [NSURL fileURLWithPath:filePath];
NSData *contentOfLocalFile = [NSData dataWithContentsOfURL:localFileURL];
self.dataSet = [NSJSONSerialization JSONObjectWithData:contentOfLocalFile
options:NSJSONReadingAllowFragments
error:&deserializingError];

}

- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}

- (void)testExample {
NSLog(@">--- count: %ld ---<",self.dataSet.count);
for (NSDictionary *dict in self.dataSet) {
NSArray *aLocation = dict[@"aLocation"];
NSArray *aStart = dict[@"segmentStartLocation"];
NSArray *aEnd = dict[@"segmentEndLocation"];
NSString *aDesc = dict[@"description"];
NSNumber *aDistance = dict[@"distance"];

CLLocation *location = [[CLLocation alloc] initWithLatitude:[aLocation[0] doubleValue] longitude:[aLocation[1] doubleValue]];
CLLocation *start = [[CLLocation alloc] initWithLatitude:[aStart[0] doubleValue] longitude:[aStart[1] doubleValue]];
CLLocation *end = [[CLLocation alloc] initWithLatitude:[aEnd[0] doubleValue] longitude:[aEnd[1] doubleValue]];

double distance;
[OSVUtils nearestLocationToLocation:location
onLineSegmentLocationA:start
locationB:end
distance:&distance];
XCTAssert(ABS(distance - aDistance.doubleValue) < 1, @"\n %@ %f expected:%f result:%f \n", aDesc, distance - aDistance.doubleValue, aDistance.doubleValue, distance);

NSLog(@"%f",ABS(distance - aDistance.doubleValue));
}
}

- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
for (NSDictionary *dict in self.dataSet) {
NSArray *aLocation = dict[@"aLocation"];
NSArray *aStart = dict[@"segmentStartLocation"];
NSArray *aEnd = dict[@"segmentEndLocation"];

CLLocation *location = [[CLLocation alloc] initWithLatitude:[aLocation[0] doubleValue] longitude:[aLocation[1] doubleValue]];
CLLocation *start = [[CLLocation alloc] initWithLatitude:[aStart[0] doubleValue] longitude:[aStart[1] doubleValue]];
CLLocation *end = [[CLLocation alloc] initWithLatitude:[aEnd[0] doubleValue] longitude:[aEnd[1] doubleValue]];
double distance;
[OSVUtils nearestLocationToLocation:location onLineSegmentLocationA:start locationB:end distance:&distance];
}
}];
}

@end
Loading

0 comments on commit 30cfb11

Please sign in to comment.