While debugging #2828 (a hard failure of gazebo when loading certain Dem files), I noticed the following error message from the reported UNIT_Dem_TEST failure:
[ RUN ] DemTest.NegDem
ERROR 1: PROJ: proj_create_operations: Source and target ellipsoid do not belong to the same celestial body
ERROR 6: Cannot find coordinate operations from
`PROJCRS["Moon2000_npole",BASEGEOGCRS["GCS_Moon",DATUM["Moon_2000",ELLIPSOID["Moon_2000_IAU_IAG",1737400,0,LENGTHUNIT["metre",1,ID["EPSG",9001]]]],PRIMEM["Reference_Meridian",0,ANGLEUNIT["degree",0.0174532925199433,ID["EPSG",9122]]]],CONVERSION["unnamed",METHOD["Polar Stereographic (variant B)",ID["EPSG",9829]],PARAMETER["Latitude of standard parallel",90,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8832]],PARAMETER["Longitude of origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8833]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting",south,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing",south,ORDER[2],LENGTHUNIT["metre",1]]]'
to `EPSG:4326'
Based on the first error message "Source and target ellipsoid do not belong to the same celestial body" and noting that EPSG:4326 refers to the WGS84 model of earth and that the PROJCRS string for dem_neg.tif used in this test appears to refer to the moon, there are clearly issues with the coordinate transformations used in our Dem class.
The following is the output of gdalinfo dem_neg.tif -mm:
Driver: GTiff/GeoTIFF
Files: ../test/media/materials/textures/dem_neg.tif
Size is 33, 33
Coordinate System is:
PROJCS["Moon2000_npole",
GEOGCS["GCS_Moon",
DATUM["Moon_2000",
SPHEROID["Moon_2000_IAU_IAG",1737400,0]],
PRIMEM["Reference_Meridian",0],
UNIT["degree",0.0174532925199433]],
PROJECTION["Polar_Stereographic"],
PARAMETER["latitude_of_origin",90],
PARAMETER["central_meridian",0],
PARAMETER["scale_factor",1],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]]]
Origin = (-53750.000000000000000,-51050.000000000000000)
Pixel Size = (2.426609848484849,-2.426609848484849)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( -53750.000, -51050.000) ( 46d28'32.90"W, 87d33'20.67"N)
Lower Left ( -53750.000, -51130.078) ( 46d25'51.46"W, 87d33'14.12"N)
Upper Right ( -53669.922, -51050.000) ( 46d25'59.33"W, 87d33'27.55"N)
Lower Right ( -53669.922, -51130.078) ( 46d23'17.88"W, 87d33'21.00"N)
Center ( -53709.961, -51090.039) ( 46d25'55.39"W, 87d33'20.84"N)
Band 1 Block=33x33 Type=Float32, ColorInterp=Gray
Computed Min/Max=-212.296,-205.440
Based on its 33x33 image size and Pixel Size = (2.426609848484849,-2.426609848484849), I would expect the world height and width of this Dem to be 33 * 2.426609848484849 ~= 80.078125, but Dem_TEST expects 293.51068 for the height and width.