Skip to content
Permalink
Browse files

msProjectRect(): fix when reprojecting from north polar stereographic…

… to WGS84.
  • Loading branch information
rouault committed Feb 23, 2017
1 parent 4c2aeb4 commit 14243fa9c605bd497d5a8aa6c725cf98045ff9f8
@@ -954,6 +954,40 @@ int msProjectRect(projectionObj *in, projectionObj *out, rectObj *rect)
char *over = "+over";
int ret;
projectionObj in_over,out_over,*inp,*outp;

#if USE_PROJ
/* Detect projecting from north polar stereographic to longlat */
if( in && !in->gt.need_geotransform &&
out && !out->gt.need_geotransform &&
!pj_is_latlong(in->proj) && pj_is_latlong(out->proj) )
{
pointObj p;
p.x = 0.0;
p.y = 0.0;
if( msProjectPoint(in, out, &p) == MS_SUCCESS &&
fabs(p.y - 90) < 1e-8 )
{
/* Is the pole in the rectangle ? */
if( 0 >= rect->minx && 0 >= rect->miny &&
0 <= rect->maxx && 0 <= rect->maxy )
{
if( msProjectRectAsPolygon(in, out, rect ) == MS_SUCCESS )
{
rect->minx = -180.0;
rect->maxx = 180.0;
rect->maxy = 90.0;
return MS_SUCCESS;
}
}
/* Are we sure the dateline is not enclosed ? */
else if( rect->maxy < 0 || rect->maxx < 0 || rect->minx > 0 )
{
return msProjectRectAsPolygon(in, out, rect );
}
}
}
#endif

/*
* Issue #4892: When projecting a rectangle we do not want proj to wrap resulting
* coordinates around the dateline, as in practice a requested bounding box of
@@ -0,0 +1,142 @@
Content-Type: text/xml; charset=UTF-8

<?xml version='1.0' encoding="UTF-8" standalone="no" ?>
<WMS_Capabilities version="1.3.0" xmlns="http://www.opengis.net/wms" xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://mapserver.gis.umn.edu/mapserver http://localhost/path/to/wms_simple?service=WMS&amp;version=1.3.0&amp;request=GetSchemaExtension">

<Service>
<Name>WMS</Name>
<Title>Test simple wms</Title>
<KeywordList>
<Keyword>ogc</Keyword>
<Keyword>wms</Keyword>
<Keyword>mapserver</Keyword>
</KeywordList>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.mapserver.org/"/>
<ContactInformation>
<ContactPersonPrimary>
<ContactPerson>Tom Kralidis</ContactPerson>
<ContactOrganization>MapServer</ContactOrganization>
</ContactPersonPrimary>
<ContactPosition>self</ContactPosition>
<ContactAddress>
<AddressType>postal</AddressType>
<Address>123 SomeRoad Road</Address>
<City>Toronto</City>
<StateOrProvince>Ontario</StateOrProvince>
<PostCode>xxx-xxx</PostCode>
<Country>Canada</Country>
</ContactAddress>
<ContactVoiceTelephone>+xx-xxx-xxx-xxxx</ContactVoiceTelephone>
<ContactFacsimileTelephone>+xx-xxx-xxx-xxxx</ContactFacsimileTelephone>
<ContactElectronicMailAddress>tomkralidis@xxxxxxx.xxx</ContactElectronicMailAddress>
</ContactInformation>
<Fees>None</Fees>
<AccessConstraints>None</AccessConstraints>
<MaxWidth>4096</MaxWidth>
<MaxHeight>4096</MaxHeight>
</Service>

<Capability>
<Request>
<GetCapabilities>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Post>
</HTTP>
</DCPType>
</GetCapabilities>
<GetMap>
<Format>image/png</Format>
<Format>image/jpeg</Format>
<Format>image/png; mode=8bit</Format>
<Format>application/x-pdf</Format>
<Format>image/svg+xml</Format>
<Format>image/tiff</Format>
<Format>application/vnd.google-earth.kml+xml</Format>
<Format>application/vnd.google-earth.kmz</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Post>
</HTTP>
</DCPType>
</GetMap>
<GetFeatureInfo>
<Format>text/plain</Format>
<Format>application/vnd.ogc.gml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Post>
</HTTP>
</DCPType>
</GetFeatureInfo>
<sld:DescribeLayer>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Post>
</HTTP>
</DCPType>
</sld:DescribeLayer>
<sld:GetLegendGraphic>
<Format>image/png</Format>
<Format>image/jpeg</Format>
<Format>image/png; mode=8bit</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Post>
</HTTP>
</DCPType>
</sld:GetLegendGraphic>
<ms:GetStyles>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/wms_simple?"/></Post>
</HTTP>
</DCPType>
</ms:GetStyles>
</Request>
<Exception>
<Format>XML</Format>
<Format>INIMAGE</Format>
<Format>BLANK</Format>
</Exception>
<sld:UserDefinedSymbolization SupportSLD="1" UserLayer="0" UserStyle="1" RemoteWFS="0" InlineFeature="0" RemoteWCS="0"/>
<Layer>
<Name>WMS_TEST</Name>
<Title>Test simple wms</Title>
<Abstract>WMS_TEST</Abstract>
<KeywordList>
<Keyword>ogc</Keyword>
<Keyword>wms</Keyword>
<Keyword>mapserver</Keyword>
</KeywordList>
<CRS>EPSG:4326</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-180</westBoundLongitude>
<eastBoundLongitude>180</eastBoundLongitude>
<southBoundLatitude>-90</southBoundLatitude>
<northBoundLatitude>90</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:4326"
minx="-90" miny="-180" maxx="90" maxy="180" />
<Layer queryable="1" opaque="0" cascaded="0">
<Name>fake</Name>
<Title>fake</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>-152.996</westBoundLongitude>
<eastBoundLongitude>-43.8099</eastBoundLongitude>
<southBoundLatitude>27.6287</southBoundLatitude>
<northBoundLatitude>69.9699</northBoundLatitude>
</EX_GeographicBoundingBox>
</Layer>
</Layer>
</Capability>
</WMS_Capabilities>
@@ -0,0 +1,88 @@
#
# Test WMS
#
# REQUIRES: INPUT=GDAL OUTPUT=PNG SUPPORTS=WMS
#
#
# Test Ex_GeographicBoundingBox in Capabilities
# RUN_PARMS: wms_north_polar_stereo_extent.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities" > [RESULT_DEVERSION]
#

MAP

NAME WMS_TEST

EXTENT -180 -90 180 90
SIZE 500 300
PROJECTION
"init=epsg:4326"
END

UNITS DD

#
# Start of web interface definition
#
WEB

IMAGEPATH "/tmp/ms_tmp/"
IMAGEURL "/ms_tmp/"

METADATA
"wms_title" "Test simple wms"
"wms_onlineresource" "http://localhost/path/to/wms_simple?"
"wms_srs" "EPSG:4326"
"ows_schemas_location" "http://schemas.opengis.net"
"ows_keywordlist" "ogc,wms,mapserver"
"ows_service_onlineresource" "http://www.mapserver.org/"
"ows_fees" "None"
"ows_accessconstraints" "None"
"ows_addresstype" "postal"
"ows_address" "123 SomeRoad Road"
"ows_city" "Toronto"
"ows_stateorprovince" "Ontario"
"ows_postcode" "xxx-xxx"
"ows_country" "Canada"
"ows_contactelectronicmailaddress" "tomkralidis@xxxxxxx.xxx"
"ows_contactvoicetelephone" "+xx-xxx-xxx-xxxx"
"ows_contactfacsimiletelephone" "+xx-xxx-xxx-xxxx"
"ows_contactperson" "Tom Kralidis"
"ows_contactorganization" "MapServer"
"ows_contactposition" "self"

"ows_enable_request" "*"
END
END

#
# Start of layer definitions
#

LAYER
NAME fake
DATA fake
TEMPLATE "ttt"
METADATA
"wms_title" "fake"
"wms_description" "fake"
"ows_extent" "-2099127.494 -5739388.521 4340872.506 -2099388.521"
END
TYPE LINE
STATUS ON
PROJECTION
"proj=stere"
"lat_0=90"
"lat_ts=60"
"lon_0=252"
"k=90"
"x_0=0"
"y_0=0"
"a=6371229"
"b=6371229"
"units=m"
"no_defs"
END

END # Layer

END # Map File

0 comments on commit 14243fa

Please sign in to comment.
You can’t perform that action at this time.