Skip to content

Commit

Permalink
Makes setCoordinates method on MLNImageSource public (#2198)
Browse files Browse the repository at this point in the history
Co-authored-by: Bart Louwers <[email protected]>
Co-authored-by: Bart Louwers <[email protected]>
  • Loading branch information
3 people authored Mar 15, 2024
1 parent 4bf99d8 commit 41b7366
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 8 additions & 0 deletions platform/darwin/src/MLNImageSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 21 additions & 2 deletions platform/darwin/test/MLNImageSourceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,34 @@ - (void)testMLNImageSourceSetURL {
// 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

0 comments on commit 41b7366

Please sign in to comment.