Makes setCoordinates method on MLNImageSource public (#2198)

Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
Manuel Roth
2024-03-15 13:12:31 +01:00
committed by GitHub
parent 4bf99d8239
commit 41b7366285
2 changed files with 29 additions and 2 deletions

View File

@@ -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

View File

@@ -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