Skip to content

Commit

Permalink
add PHP MapScript setProjection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmckenna authored and github-actions[bot] committed Jun 2, 2023
1 parent 321c78f commit 400a8d9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
Binary file added msautotest/php/expected/setprojection-3857.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added msautotest/php/expected/setprojection-3978.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 33 additions & 1 deletion msautotest/php/mapObjTest.php
Expand Up @@ -74,9 +74,41 @@ public function test__setNumlayers()
#$this->map->numlayers = 2;
}

//also testing multiple setProjection cache issue #6896
public function test__setProjection()
{
$map_file = 'maps/reprojection.map';
$map = new mapObj($map_file);
$this->assertEquals(0, $map->setProjection('init=epsg:3857'), 'Failed to set MAP projection to EPSG:3857');
$map->setExtent(-7913606, 5346829, -6120700, 6522760);
$layer = $map->getLayerByName('ns-places');
$this->assertEquals(0, $layer->setProjection('init=epsg:4326'), 'Failed to set LAYER projection to EPSG:4326');
$image4326 = $map->draw();
$image4326->save('./result/setprojection-3857.png');
//test multiple reprojections
$this->assertEquals(0, $map->setProjection('init=epsg:3978'), 'Failed to set MAP projection to EPSG:3978');
$map->setExtent(1394924, -279190, 3376084, 1020214);
$image3978 = $map->draw();
$image3978->save('./result/setprojection-3978.png');
//compare the EPSG:3857 map image
$expectedImage3857 = './expected/setprojection-3857.png';
$resultImage3857 = './result/setprojection-3857.png';
$this->assertFileEquals($expectedImage3857 , $resultImage3857, 'Result setProjection EPSG:3857 map image is not same as Expected');
//compare the EPSG:3978 map image
$expectedImage3978 = './expected/setprojection-3978.png';
$resultImage3978 = './result/setprojection-3978.png';
$this->assertFileEquals($expectedImage3978 , $resultImage3978, 'Result setProjection EPSG:3978 map image is not same as Expected');
}

# destroy variables, if not can lead to segmentation fault
public function tearDown(): void {
unset($map, $map_file, $this->map_file, $this->map->numoutputformats, $this->map->numlayers, $this->map->imagetype, $this->map->queryByRect, $this->map->saveQueryAsGML);
unset($map, $map_file);
unset($image4326, $image3978);
unset($expectedImage3857, $resultImage3857);
unset($expectedImage3978, $resultImage3978);
unset($this->map_file, $this->map->numoutputformats);
unset($this->map->numlayers, $this->map->imagetype);
unset($this->map->queryByRect, $this->map->saveQueryAsGML);
}

}
Expand Down
2 changes: 2 additions & 0 deletions msautotest/php/result/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit 400a8d9

Please sign in to comment.