Merge pull request #3906 from rldhont/server-wms-stretch-compliancy

[BUGFIX][Server] WMS compliance: stretched, distort, increase, decrease
This commit is contained in:
rldhont 2017-01-03 15:13:48 +01:00 committed by GitHub
commit 9fd65a236f
9 changed files with 31 additions and 25 deletions

View File

@ -1974,26 +1974,32 @@ QImage* QgsWmsServer::createImage( int width, int height, bool useBbox ) const
//Adapt width / height if the aspect ratio does not correspond with the BBOX.
//Required by WMS spec. 1.3.
if ( useBbox )
QString version = mParameters.value( QStringLiteral( "VERSION" ), QStringLiteral( "1.3.0" ) );
if ( useBbox && version != QLatin1String( "1.1.1" ) )
{
bool bboxOk;
QgsRectangle mapExtent = _parseBBOX( mParameters.value( "BBOX" ), bboxOk );
QString crs = mParameters.value( QStringLiteral( "CRS" ), mParameters.value( QStringLiteral( "SRS" ) ) );
if ( crs.compare( "CRS:84", Qt::CaseInsensitive ) == 0 )
{
crs = QString( "EPSG:4326" );
mapExtent.invert();
}
QgsCoordinateReferenceSystem outputCRS = QgsCoordinateReferenceSystem::fromOgcWmsCrs( crs );
if ( outputCRS.hasAxisInverted() )
{
mapExtent.invert();
}
if ( bboxOk )
{
double mapWidthHeightRatio = mapExtent.width() / mapExtent.height();
double imageWidthHeightRatio = ( double )width / ( double )height;
if ( !qgsDoubleNear( mapWidthHeightRatio, imageWidthHeightRatio, 0.0001 ) )
{
if ( mapWidthHeightRatio >= imageWidthHeightRatio )
{
//increase image height
height = width * mapWidthHeightRatio;
}
else
{
//increase image width
width = height / mapWidthHeightRatio;
}
// inspired by MapServer, mapdraw.c L115
double cellsize = ( mapExtent.width() / ( double )width ) * 0.5 + ( mapExtent.height() / ( double )height ) * 0.5;
width = mapExtent.width() / cellsize;
height = mapExtent.height() / cellsize;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -180,7 +180,7 @@
<ymax>0.0022</ymax>
</extent>
<id>shapefile_Autos_any20161212175224004</id>
<datasource>./shapefile|layername=Autos</datasource>
<datasource>./shapefile/Autos.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -456,7 +456,7 @@ def my_form_open(dialog, layer, feature):
<ymax>6</ymax>
</extent>
<id>shapefile_BasicPolygons_any20161212175223962</id>
<datasource>./shapefile|layername=BasicPolygons</datasource>
<datasource>./shapefile/BasicPolygons.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -720,7 +720,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.0007</ymax>
</extent>
<id>shapefile_Bridges_any20161212175224135</id>
<datasource>./shapefile|layername=Bridges</datasource>
<datasource>./shapefile/Bridges.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -993,7 +993,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.0009</ymax>
</extent>
<id>shapefile_BuildingCenters_any20161212175224065</id>
<datasource>./shapefile|layername=BuildingCenters</datasource>
<datasource>./shapefile/BuildingCenters.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -1266,7 +1266,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.001</ymax>
</extent>
<id>shapefile_Buildings_any20161212175224108</id>
<datasource>./shapefile|layername=Buildings</datasource>
<datasource>./shapefile/Buildings.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -1533,7 +1533,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.0024</ymax>
</extent>
<id>shapefile_DividedRoutes_any20161212175224115</id>
<datasource>./shapefile|layername=DividedRoutes</datasource>
<datasource>./shapefile/DividedRoutes.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -1807,7 +1807,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.0018</ymax>
</extent>
<id>shapefile_Forests_any20161212175224149</id>
<datasource>./shapefile|layername=Forests</datasource>
<datasource>./shapefile/Forests.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -2074,7 +2074,7 @@ def my_form_open(dialog, layer, feature):
<ymax>-0.0001</ymax>
</extent>
<id>shapefile_Lakes_any20161212175224157</id>
<datasource>./shapefile|layername=Lakes</datasource>
<datasource>./shapefile/Lakes.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -2341,7 +2341,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.0024</ymax>
</extent>
<id>shapefile_MapNeatline_any20161212175224085</id>
<datasource>./shapefile|layername=MapNeatline</datasource>
<datasource>./shapefile/MapNeatline.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -2609,7 +2609,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.0024</ymax>
</extent>
<id>shapefile_NamedPlaces_any20161212175224102</id>
<datasource>./shapefile|layername=NamedPlaces</datasource>
<datasource>./shapefile/NamedPlaces.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -2876,7 +2876,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.002</ymax>
</extent>
<id>shapefile_Ponds_any20161212175224054</id>
<datasource>./shapefile|layername=Ponds</datasource>
<datasource>./shapefile/Ponds.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -3146,7 +3146,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.0024</ymax>
</extent>
<id>shapefile_RoadSegments_any20161212175224127</id>
<datasource>./shapefile|layername=RoadSegments</datasource>
<datasource>./shapefile/RoadSegments.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -3417,7 +3417,7 @@ def my_form_open(dialog, layer, feature):
<ymax>0.0024</ymax>
</extent>
<id>shapefile_Streams_any20161212175223969</id>
<datasource>./shapefile|layername=Streams</datasource>
<datasource>./shapefile/Streams.shp</datasource>
<keywordList>
<value></value>
</keywordList>
@ -3688,7 +3688,7 @@ def my_form_open(dialog, layer, feature):
<ymax>-0.0001</ymax>
</extent>
<id>shapefile_lakesWithElevation_any20161212175224039</id>
<datasource>./shapefile|layername=lakesWithElevation</datasource>
<datasource>./shapefile/lakesWithElevation.shp</datasource>
<keywordList>
<value></value>
</keywordList>