diff --git a/platform/darwin/src/MLNImageSource.h b/platform/darwin/src/MLNImageSource.h index 5edddb3db..36165809f 100644 --- a/platform/darwin/src/MLNImageSource.h +++ b/platform/darwin/src/MLNImageSource.h @@ -99,6 +99,14 @@ MLN_EXPORT The coordinates at which the corners of the source image will be placed. */ @property (nonatomic) MLNCoordinateQuad coordinates; + +/** + Sets the coordinates for the image source. + + @param coordinateQuad The coordinates to set for the image source. + */ +- (void)setCoordinates:(MLNCoordinateQuad)coordinateQuad; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/test/MLNImageSourceTests.m b/platform/darwin/test/MLNImageSourceTests.m index c9a3dc1b1..101264e62 100644 --- a/platform/darwin/test/MLNImageSourceTests.m +++ b/platform/darwin/test/MLNImageSourceTests.m @@ -43,15 +43,34 @@ // Create a test instance of MLNImageSource MLNCoordinateQuad quad = { { 80, 37}, { 81, 37}, { 81, 39}, { 80, 39}}; MLNImageSource *source = [[MLNImageSource alloc] initWithIdentifier:@"source-id" coordinateQuad:quad URL:[NSURL URLWithString:@"http://host/image.png"]]; - + // Set the URL using setURL NSURL *testURL = [NSURL URLWithString:@"http://host/image1.png"]; [source setURL:testURL]; - + // Assert that the URL is set correctly XCTAssertNotNil(source.URL); XCTAssertEqualObjects(source.URL.absoluteString, @"http://host/image1.png"); XCTAssertNil(source.image); } +- (void)testMLNImageSourceSetCoordinates { + // Create a test instance of MLNImageSource + MLNCoordinateQuad quad = { { 80, 37}, { 81, 37}, { 81, 39}, { 80, 39}}; + MLNImageSource *source = [[MLNImageSource alloc] initWithIdentifier:@"source-id" coordinateQuad:quad URL:[NSURL URLWithString:@"http://host/image.png"]]; + + // Define a new set of coordinates + MLNCoordinateQuad newQuad = { { 40, 50}, { 41, 50}, { 41, 52}, { 40, 52} }; + + // Set the coordinates using the setCoordinates method + [source setCoordinates:newQuad]; + + // Get the current coordinates from the source + MLNCoordinateQuad retrievedQuad = source.coordinates; + + // Assert that the coordinates are set correctly + XCTAssertEqual(retrievedQuad.bottomLeft.latitude, newQuad.bottomLeft.latitude); + XCTAssertEqual(retrievedQuad.bottomLeft.longitude, newQuad.bottomLeft.longitude); +} + @end