Skip to content

Commit

Permalink
Merge pull request #6388 from rouault/fix_6387
Browse files Browse the repository at this point in the history
WMS capabilities output: increase precision of long/lat in bounding boxes to 6 decimal places (fixes #6387)
  • Loading branch information
jmckenna committed Aug 25, 2021
2 parents 01d0e7c + 19bc6cc commit eef5954
Show file tree
Hide file tree
Showing 276 changed files with 4,460 additions and 10,207 deletions.
2 changes: 1 addition & 1 deletion mapmetadata.c
Expand Up @@ -213,7 +213,7 @@ xmlNodePtr _msMetadataGetDecimal(xmlNsPtr namespace, const char *name, double va

xmlNodePtr psNode = NULL;

sprintf(buffer, "%f", value);
snprintf(buffer, sizeof(buffer), "%.6f", value);

if( *ppsNsGco == NULL )
*ppsNsGco = xmlNewNs(NULL, BAD_CAST "http://www.isotc211.org/2005/gmd", BAD_CAST "gco");
Expand Down
28 changes: 16 additions & 12 deletions mapows.c
Expand Up @@ -2205,10 +2205,10 @@ void msOWSPrintEX_GeographicBoundingBox(FILE *stream, const char *tabspace,
msOWSProjectToWGS84(srcproj, &ext);

msIO_fprintf(stream, "%s<%s>\n", tabspace, pszTag);
msIO_fprintf(stream, "%s <westBoundLongitude>%g</westBoundLongitude>\n", tabspace, ext.minx);
msIO_fprintf(stream, "%s <eastBoundLongitude>%g</eastBoundLongitude>\n", tabspace, ext.maxx);
msIO_fprintf(stream, "%s <southBoundLatitude>%g</southBoundLatitude>\n", tabspace, ext.miny);
msIO_fprintf(stream, "%s <northBoundLatitude>%g</northBoundLatitude>\n", tabspace, ext.maxy);
msIO_fprintf(stream, "%s <westBoundLongitude>%.6f</westBoundLongitude>\n", tabspace, ext.minx);
msIO_fprintf(stream, "%s <eastBoundLongitude>%.6f</eastBoundLongitude>\n", tabspace, ext.maxx);
msIO_fprintf(stream, "%s <southBoundLatitude>%.6f</southBoundLatitude>\n", tabspace, ext.miny);
msIO_fprintf(stream, "%s <northBoundLatitude>%.6f</northBoundLatitude>\n", tabspace, ext.maxy);
msIO_fprintf(stream, "%s</%s>\n", tabspace, pszTag);

/* msIO_fprintf(stream, "%s<%s minx=\"%g\" miny=\"%g\" maxx=\"%g\" maxy=\"%g\" />\n",
Expand Down Expand Up @@ -2241,7 +2241,7 @@ void msOWSPrintLatLonBoundingBox(FILE *stream, const char *tabspace,
}
}

msIO_fprintf(stream, "%s<%s minx=\"%g\" miny=\"%g\" maxx=\"%g\" maxy=\"%g\" />\n",
msIO_fprintf(stream, "%s<%s minx=\"%.6f\" miny=\"%.6f\" maxx=\"%.6f\" maxy=\"%.6f\" />\n",
tabspace, pszTag, ext.minx, ext.miny, ext.maxx, ext.maxy);
}

Expand Down Expand Up @@ -2310,23 +2310,27 @@ void msOWSPrintBoundingBox(FILE *stream, const char *tabspace,
msAxisNormalizePoints( &proj, 1, &(ext.maxx), &(ext.maxy) );
}
}
msFreeProjection( &proj );

encoded = msEncodeHTMLEntities(value);
if (wms_version >= OWS_1_3_0)
msIO_fprintf(stream, "%s<BoundingBox CRS=\"%s\"\n"
"%s minx=\"%g\" miny=\"%g\" maxx=\"%g\" maxy=\"%g\"",
tabspace, encoded,
if (msProjIsGeographicCRS(&proj) )
msIO_fprintf(stream, "%s<BoundingBox %s=\"%s\"\n"
"%s minx=\"%.6f\" miny=\"%.6f\" maxx=\"%.6f\" maxy=\"%.6f\"",
tabspace,
(wms_version >= OWS_1_3_0) ? "CRS" : "SRS",
encoded,
tabspace, ext.minx, ext.miny,
ext.maxx, ext.maxy);
else
msIO_fprintf(stream, "%s<BoundingBox SRS=\"%s\"\n"
msIO_fprintf(stream, "%s<BoundingBox %s=\"%s\"\n"
"%s minx=\"%g\" miny=\"%g\" maxx=\"%g\" maxy=\"%g\"",
tabspace, encoded,
tabspace,
(wms_version >= OWS_1_3_0) ? "CRS" : "SRS",
encoded,
tabspace, ext.minx, ext.miny,
ext.maxx, ext.maxy);

msFree(encoded);
msFreeProjection( &proj );

if( (resx = msOWSLookupMetadata2( layer_meta, map_meta, "MFO", "resx" )) != NULL &&
(resy = msOWSLookupMetadata2( layer_meta, map_meta, "MFO", "resy" )) != NULL ) {
Expand Down
4 changes: 2 additions & 2 deletions mapowscommon.c
Expand Up @@ -589,8 +589,8 @@ xmlNodePtr msOWSCommonWGS84BoundingBox(xmlNsPtr psNsOws, int dimensions, double
snprintf( dim_string, sizeof(dim_string), "%d", dimensions );
xmlNewProp(psRootNode, BAD_CAST "dimensions", BAD_CAST dim_string);

snprintf(LowerCorner, sizeof(LowerCorner), "%.15g %.15g", minx, miny);
snprintf(UpperCorner, sizeof(UpperCorner), "%.15g %.15g", maxx, maxy);
snprintf(LowerCorner, sizeof(LowerCorner), "%.6f %.6f", minx, miny);
snprintf(UpperCorner, sizeof(UpperCorner), "%.6f %.6f", maxx, maxy);

/* add child elements */
xmlNewChild(psRootNode, psNsOws,BAD_CAST "LowerCorner",BAD_CAST LowerCorner);
Expand Down
2 changes: 1 addition & 1 deletion mapproject.c
Expand Up @@ -2605,7 +2605,7 @@ int msProjIsGeographicCRS(projectionObj* proj)
}
return FALSE;
#else
return pj_is_latlong(proj->proj);
return proj->proj != NULL && pj_is_latlong(proj->proj);
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions msautotest/misc/expected/encodings.xml
Expand Up @@ -11,19 +11,19 @@ Content-Type: text/xml; charset=UTF-8
http://mapserver.gis.umn.edu/mapserver http://foo?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=encoded&amp;OUTPUTFORMAT=XMLSCHEMA">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-0.95118,0.39958 -0.95118,0.39958</gml:coordinates>
<gml:coordinates>-0.951189,0.399582 -0.951189,0.399582</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:encoded>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-0.95118,0.39958 -0.95118,0.39958</gml:coordinates>
<gml:coordinates>-0.951189,0.399582 -0.951189,0.399582</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-0.95118,0.39958</gml:coordinates>
<gml:coordinates>-0.951189,0.399582</gml:coordinates>
</gml:Point>
</ms:msGeometry>
</ms:encoded>
Expand Down
48 changes: 24 additions & 24 deletions msautotest/misc/expected/runtime_sub_test_caps.xml
Expand Up @@ -39,10 +39,10 @@ Content-Type: text/xml; charset=UTF-8
<Abstract>runtime_sub</Abstract>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>1.12289</westBoundLongitude>
<eastBoundLongitude>7.08771</eastBoundLongitude>
<southBoundLatitude>39.4407</southBoundLatitude>
<northBoundLatitude>44.152</northBoundLatitude>
<westBoundLongitude>1.122894</westBoundLongitude>
<eastBoundLongitude>7.087708</eastBoundLongitude>
<southBoundLatitude>39.440727</southBoundLatitude>
<northBoundLatitude>44.152034</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:3857"
minx="125000" miny="4.785e+06" maxx="789000" maxy="5.489e+06" />
Expand Down Expand Up @@ -81,10 +81,10 @@ Content-Type: text/xml; charset=UTF-8
<!-- WARNING: Mandatory metadata '..._title' was missing in this context. -->
<Title>layer5</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>1.10894</westBoundLongitude>
<eastBoundLongitude>7.19753</eastBoundLongitude>
<southBoundLatitude>39.2727</southBoundLatitude>
<northBoundLatitude>44.1415</northBoundLatitude>
<westBoundLongitude>1.108938</westBoundLongitude>
<eastBoundLongitude>7.197525</eastBoundLongitude>
<southBoundLatitude>39.272716</southBoundLatitude>
<northBoundLatitude>44.141505</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:3857"
minx="123446" miny="4.76081e+06" maxx="801225" maxy="5.48737e+06" />
Expand All @@ -98,10 +98,10 @@ Content-Type: text/xml; charset=UTF-8
<!-- WARNING: Mandatory metadata '..._title' was missing in this context. -->
<Title>layer5b</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>1.10894</westBoundLongitude>
<eastBoundLongitude>7.19753</eastBoundLongitude>
<southBoundLatitude>39.2727</southBoundLatitude>
<northBoundLatitude>44.1415</northBoundLatitude>
<westBoundLongitude>1.108938</westBoundLongitude>
<eastBoundLongitude>7.197525</eastBoundLongitude>
<southBoundLatitude>39.272716</southBoundLatitude>
<northBoundLatitude>44.141505</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:3857"
minx="123446" miny="4.76081e+06" maxx="801225" maxy="5.48737e+06" />
Expand All @@ -115,10 +115,10 @@ Content-Type: text/xml; charset=UTF-8
<!-- WARNING: Mandatory metadata '..._title' was missing in this context. -->
<Title>layer6</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>1.10894</westBoundLongitude>
<eastBoundLongitude>7.19753</eastBoundLongitude>
<southBoundLatitude>39.2727</southBoundLatitude>
<northBoundLatitude>44.1415</northBoundLatitude>
<westBoundLongitude>1.108938</westBoundLongitude>
<eastBoundLongitude>7.197525</eastBoundLongitude>
<southBoundLatitude>39.272716</southBoundLatitude>
<northBoundLatitude>44.141505</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:3857"
minx="123446" miny="4.76081e+06" maxx="801225" maxy="5.48737e+06" />
Expand All @@ -132,10 +132,10 @@ Content-Type: text/xml; charset=UTF-8
<!-- WARNING: Mandatory metadata '..._title' was missing in this context. -->
<Title>layer7</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>1.10894</westBoundLongitude>
<eastBoundLongitude>7.19753</eastBoundLongitude>
<southBoundLatitude>39.2727</southBoundLatitude>
<northBoundLatitude>44.1415</northBoundLatitude>
<westBoundLongitude>1.108938</westBoundLongitude>
<eastBoundLongitude>7.197525</eastBoundLongitude>
<southBoundLatitude>39.272716</southBoundLatitude>
<northBoundLatitude>44.141505</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:3857"
minx="123446" miny="4.76081e+06" maxx="801225" maxy="5.48737e+06" />
Expand All @@ -149,10 +149,10 @@ Content-Type: text/xml; charset=UTF-8
<!-- WARNING: Mandatory metadata '..._title' was missing in this context. -->
<Title>layer8</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>1.10894</westBoundLongitude>
<eastBoundLongitude>7.19753</eastBoundLongitude>
<southBoundLatitude>39.2727</southBoundLatitude>
<northBoundLatitude>44.1415</northBoundLatitude>
<westBoundLongitude>1.108938</westBoundLongitude>
<eastBoundLongitude>7.197525</eastBoundLongitude>
<southBoundLatitude>39.272716</southBoundLatitude>
<northBoundLatitude>44.141505</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:3857"
minx="123446" miny="4.76081e+06" maxx="801225" maxy="5.48737e+06" />
Expand Down
33 changes: 0 additions & 33 deletions msautotest/pymod/mstestlib.py
Expand Up @@ -400,38 +400,6 @@ def fixexponent_file( filename ):
return

###############################################################################
# Do windows number of decimal truncation.

def truncate_one_decimal( filename ):
import re

data = open(filename,'rb').read()

from sys import version_info
if version_info >= (3,0,0):
data = str(data, 'iso-8859-1')

numbers_found = re.compile('[0-9]+\.[0-9]{6,24}', re.M)

start = 0
new_data = ''
for number in numbers_found.finditer(data):
end = number.end() - 1
new_data = new_data + data[start:end]
start = number.end()

if new_data != '':
new_data = new_data + data[start:]


if new_data != '' and new_data != data:
if version_info >= (3,0,0):
open(filename,'wb').write(bytes(new_data, 'iso-8859-1'))
else:
open(filename,'wb').write(new_data)

return
###############################################################################
# Replace CR+LF by CR

def crlf( filename ):
Expand Down Expand Up @@ -649,7 +617,6 @@ def _run(map, out_file, command, extra_args):
deversion_file( 'result/'+out_file )
degdalversion_file( 'result/'+out_file )
fixexponent_file( 'result/'+out_file )
truncate_one_decimal( 'result/'+out_file )
detimestamp_file( 'result/'+out_file )
if extractserviceversion:
extract_service_version_file( 'result/'+out_file )
Expand Down
26 changes: 13 additions & 13 deletions msautotest/wxs/expected/ows_all_wms_capabilities.xml
Expand Up @@ -132,22 +132,22 @@ Content-Type: text/xml; charset=UTF-8
</KeywordList>
<CRS>EPSG:4326</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-1</westBoundLongitude>
<eastBoundLongitude>-1</eastBoundLongitude>
<southBoundLatitude>-1</southBoundLatitude>
<northBoundLatitude>-1</northBoundLatitude>
<westBoundLongitude>-1.000000</westBoundLongitude>
<eastBoundLongitude>-1.000000</eastBoundLongitude>
<southBoundLatitude>-1.000000</southBoundLatitude>
<northBoundLatitude>-1.000000</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:4326"
minx="-1" miny="-1" maxx="-1" maxy="-1" />
minx="-1.000000" miny="-1.000000" maxx="-1.000000" maxy="-1.000000" />
<Layer queryable="1" opaque="0" cascaded="0">
<Name>road</Name>
<Title>road</Title>
<CRS>EPSG:43204</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-66.6333</westBoundLongitude>
<eastBoundLongitude>-59.2921</eastBoundLongitude>
<southBoundLatitude>42.3821</southBoundLatitude>
<northBoundLatitude>48.2955</northBoundLatitude>
<westBoundLongitude>-66.633318</westBoundLongitude>
<eastBoundLongitude>-59.292114</eastBoundLongitude>
<southBoundLatitude>42.382054</southBoundLatitude>
<northBoundLatitude>48.295512</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:43204"
minx="2.25898e+06" miny="-70747.9" maxx="2.61535e+06" maxy="495481" />
Expand All @@ -169,10 +169,10 @@ Content-Type: text/xml; charset=UTF-8
<!-- WARNING: Mandatory metadata '..._title' was missing in this context. -->
<Title>province</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>-66.7243</westBoundLongitude>
<eastBoundLongitude>-57.7217</eastBoundLongitude>
<southBoundLatitude>41.7705</southBoundLatitude>
<northBoundLatitude>48.4773</northBoundLatitude>
<westBoundLongitude>-66.724329</westBoundLongitude>
<eastBoundLongitude>-57.721680</eastBoundLongitude>
<southBoundLatitude>41.770508</southBoundLatitude>
<northBoundLatitude>48.477314</northBoundLatitude>
</EX_GeographicBoundingBox>
<MetadataURL type="TC211">
<Format>text/xml</Format>
Expand Down
26 changes: 13 additions & 13 deletions msautotest/wxs/expected/ows_all_wms_capabilities_post.xml
Expand Up @@ -132,22 +132,22 @@ Content-Type: text/xml; charset=UTF-8
</KeywordList>
<CRS>EPSG:4326</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-1</westBoundLongitude>
<eastBoundLongitude>-1</eastBoundLongitude>
<southBoundLatitude>-1</southBoundLatitude>
<northBoundLatitude>-1</northBoundLatitude>
<westBoundLongitude>-1.000000</westBoundLongitude>
<eastBoundLongitude>-1.000000</eastBoundLongitude>
<southBoundLatitude>-1.000000</southBoundLatitude>
<northBoundLatitude>-1.000000</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:4326"
minx="-1" miny="-1" maxx="-1" maxy="-1" />
minx="-1.000000" miny="-1.000000" maxx="-1.000000" maxy="-1.000000" />
<Layer queryable="1" opaque="0" cascaded="0">
<Name>road</Name>
<Title>road</Title>
<CRS>EPSG:43204</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-66.6333</westBoundLongitude>
<eastBoundLongitude>-59.2921</eastBoundLongitude>
<southBoundLatitude>42.3821</southBoundLatitude>
<northBoundLatitude>48.2955</northBoundLatitude>
<westBoundLongitude>-66.633318</westBoundLongitude>
<eastBoundLongitude>-59.292114</eastBoundLongitude>
<southBoundLatitude>42.382054</southBoundLatitude>
<northBoundLatitude>48.295512</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:43204"
minx="2.25898e+06" miny="-70747.9" maxx="2.61535e+06" maxy="495481" />
Expand All @@ -169,10 +169,10 @@ Content-Type: text/xml; charset=UTF-8
<!-- WARNING: Mandatory metadata '..._title' was missing in this context. -->
<Title>province</Title>
<EX_GeographicBoundingBox>
<westBoundLongitude>-66.7243</westBoundLongitude>
<eastBoundLongitude>-57.7217</eastBoundLongitude>
<southBoundLatitude>41.7705</southBoundLatitude>
<northBoundLatitude>48.4773</northBoundLatitude>
<westBoundLongitude>-66.724329</westBoundLongitude>
<eastBoundLongitude>-57.721680</eastBoundLongitude>
<southBoundLatitude>41.770508</southBoundLatitude>
<northBoundLatitude>48.477314</northBoundLatitude>
</EX_GeographicBoundingBox>
<MetadataURL type="TC211">
<Format>text/xml</Format>
Expand Down
10 changes: 5 additions & 5 deletions msautotest/wxs/expected/ows_all_wms_getfeatureinfo.xml
Expand Up @@ -11,7 +11,7 @@ Content-Type: application/vnd.ogc.gml; charset=UTF-8
<road_feature>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-64.61702,44.55887 -64.37038,45.03870</gml:coordinates>
<gml:coordinates>-64.617027,44.558875 -64.370387,45.038703</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<FNODE_>903</FNODE_>
Expand All @@ -28,7 +28,7 @@ Content-Type: application/vnd.ogc.gml; charset=UTF-8
<road_feature>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-65.12722,44.39911 -64.55216,44.93469</gml:coordinates>
<gml:coordinates>-65.127228,44.399110 -64.552161,44.934696</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<FNODE_>950</FNODE_>
Expand All @@ -45,7 +45,7 @@ Content-Type: application/vnd.ogc.gml; charset=UTF-8
<road_feature>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-64.57786,44.69501 -63.70018,45.04540</gml:coordinates>
<gml:coordinates>-64.577864,44.695012 -63.700184,45.045403</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<FNODE_>903</FNODE_>
Expand All @@ -62,7 +62,7 @@ Content-Type: application/vnd.ogc.gml; charset=UTF-8
<road_feature>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-63.71454,44.64282 -63.70018,44.69501</gml:coordinates>
<gml:coordinates>-63.714548,44.642829 -63.700184,44.695012</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<FNODE_>908</FNODE_>
Expand All @@ -79,7 +79,7 @@ Content-Type: application/vnd.ogc.gml; charset=UTF-8
<road_feature>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-64.37038,44.55887 -63.71454,44.67929</gml:coordinates>
<gml:coordinates>-64.370387,44.558875 -63.714548,44.679291</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<FNODE_>914</FNODE_>
Expand Down

0 comments on commit eef5954

Please sign in to comment.