1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
|
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
function test_read_FeatureInfoResponse(t) {
t.plan(7);
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
// read empty response
var text =
'<?xml version="1.0" encoding="UTF-8" ?>' +
'<FeatureInfoResponse>' +
'</FeatureInfoResponse>';
var features = parser.read(text);
t.eq(features.length, 0,
"Parsing empty FeatureInfoResponse response succesfull");
// read 1 feature
text =
'<?xml version="1.0" encoding="UTF-8" ?>' +
'<FeatureInfoResponse>' +
' <FIELDS OBJECTID="1188" HECTARES="1819.734" ZONENR="5854" NULZONES=" " AREA="18197340.1426" PERIMETER="19177.4073627" SHAPE="NULL" SE_ANNO_CAD_DATA="NULL" SHAPE.AREA="0" SHAPE.LEN="0"/>' +
'</FeatureInfoResponse>';
features = parser.read(text);
t.eq(features.length, 1,
"Parsed 1 feature in total");
t.eq(features[0].attributes.OBJECTID, '1188',
"Attribute OBJECTID contains the right value");
// read multiple features
text =
'<?xml version="1.0" encoding="UTF-8" ?>' +
'<FeatureInfoResponse>' +
' <FIELDS OBJECTID="551" Shape="NULL" NAME="Carbon" STATE_NAME="Wyoming" AREA="7999.91062" POP2000="15639" POP00_SQMI="2" Shape_Length="6.61737274334215" Shape_Area="2.23938983524154"/>' +
' <FIELDS OBJECTID="7" Shape="NULL" AREA="97803.199" STATE_NAME="Wyoming" SUB_REGION="Mtn" STATE_ABBR="WY" POP2000="493782" POP00_SQMI="5" Shape_Length="21.9870297323522" Shape_Area="27.9666881382635"/>' +
' <FIELDS OBJECTID="99" Shape="NULL" LENGTH="378.836" TYPE="Multi-Lane Divided" ADMN_CLASS="Interstate" TOLL_RD="N" RTE_NUM1=" 80" RTE_NUM2=" " ROUTE="Interstate 80" Shape_Length="7.04294883879398"/>' +
'</FeatureInfoResponse>';
features = parser.read(text);
t.eq(features.length, 3,
"Parsed 3 features in total");
t.eq(features[1].attributes.STATE_NAME, 'Wyoming',
"Attribute STATE_NAME contains the right value");
text = '<FeatureInfoResponse>' +
'<FIELDS>' +
'<FIELD name="ID" value="B31A0154"/>' +
'<FIELD name="FID" value="31AL0011"/>' +
'</FIELDS>' +
'<FIELDS>' +
'<FIELD name="ID" value="B31A0153"/>' +
'<FIELD name="FID" value="31AL0011"/>' +
'</FIELDS>' +
'</FeatureInfoResponse>';
features = parser.read(text);
t.eq(features.length, 2,
"Parsed 2 features in total");
t.eq(features[1].attributes.FID, '31AL0011',
"Attribute FID contains the right value");
}
function test_read_msGMLOutput(t) {
t.plan(13);
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
// read empty response
var text =
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput ' +
' xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
'</msGMLOutput>';
var features = parser.read(text);
t.eq(features.length, 0,
"Parsing empty msGMLOutput response succesfull");
// read empty attribute
text =
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput ' +
' xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
' <AAA64_layer>' +
' <AAA64_feature>' +
' <gml:boundedBy>' +
' <gml:Box srsName="EPSG:28992">' +
' <gml:coordinates>107397.266000,460681.063000 116568.188000,480609.250000</gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <FOO>bar</FOO>' +
' <EMPTY></EMPTY>' +
' </AAA64_feature>' +
' </AAA64_layer>' +
'</msGMLOutput>';
features = parser.read(text);
t.eq((features[0].attributes.EMPTY === null), true, "Empty attribute is parsed as null");
// read 1 feature from 1 layer
text =
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput ' +
' xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
' <AAA64_layer>' +
' <AAA64_feature>' +
' <gml:boundedBy>' +
' <gml:Box srsName="EPSG:28992">' +
' <gml:coordinates>107397.266000,460681.063000 116568.188000,480609.250000</gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <OBJECTID>109</OBJECTID>' +
' <ROUTE>N231</ROUTE>' +
' <ROUTE_CH>#N231</ROUTE_CH>' +
' <COUNT>2</COUNT>' +
' <BEHEERDER>P</BEHEERDER>' +
' <LENGTH>28641.7</LENGTH>' +
' <SHAPE><shape></SHAPE>' +
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
' </AAA64_feature>' +
' </AAA64_layer>' +
'</msGMLOutput>';
features = parser.read(text);
t.eq(features.length, 1,
"Parsed 1 feature in total");
t.eq(features[0].attributes.OBJECTID, '109',
"Attribute OBJECTID contains the right value");
t.eq(features[0].type, 'AAA64',
"Parsed the layer name correctly");
var bounds = features[0].bounds;
t.ok(bounds instanceof OpenLayers.Bounds, "feature given a bounds");
t.eq(bounds.left.toFixed(3), "107397.266", "Bounds left parsed correctly");
t.eq(bounds.right.toFixed(3), "116568.188", "Bounds right parsed correctly");
t.eq(bounds.bottom.toFixed(3), "460681.063", "Bounds bottom parsed correctly");
t.eq(bounds.top.toFixed(3), "480609.250", "Bounds top parsed correctly");
// read 2 features from 2 layers
text =
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput ' +
' xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
' <AAA64_layer>' +
' <AAA64_feature>' +
' <gml:boundedBy>' +
' <gml:Box srsName="EPSG:28992">' +
' <gml:coordinates>129799.109000,467950.250000 133199.906000,468904.063000</gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <OBJECTID>287</OBJECTID>' +
' <ROUTE>N403</ROUTE>' +
' <ROUTE_CH>#N403</ROUTE_CH>' +
' <COUNT>1</COUNT>' +
' <BEHEERDER>P</BEHEERDER>' +
' <LENGTH>4091.25</LENGTH>' +
' <SHAPE><shape></SHAPE>' +
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
' </AAA64_feature>' +
' </AAA64_layer>' +
' <AAA62_layer>' +
' <AAA62_feature>' +
' <gml:boundedBy>' +
' <gml:Box srsName="EPSG:28992">' +
' <gml:coordinates>129936.000000,468362.000000 131686.000000,473119.000000</gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <OBJECTID>1251</OBJECTID>' +
' <VWK_ID>1515</VWK_ID>' +
' <VWK_BEGDTM>00:00:00 01/01/1998</VWK_BEGDTM>' +
' <VWJ_ID_BEG>1472</VWJ_ID_BEG>' +
' <VWJ_ID_END>1309</VWJ_ID_END>' +
' <VAKTYPE>D</VAKTYPE>' +
' <VRT_CODE>227</VRT_CODE>' +
' <VRT_NAAM>Vecht</VRT_NAAM>' +
' <VWG_NR>2</VWG_NR>' +
' <VWG_NAAM>Vecht</VWG_NAAM>' +
' <BEGKM>18.25</BEGKM>' +
' <ENDKM>23.995</ENDKM>' +
' <LENGTH>5745.09</LENGTH>' +
' <SHAPE><shape></SHAPE>' +
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
' </AAA62_feature>' +
' </AAA62_layer>' +
'</msGMLOutput>';
features = parser.read(text);
t.eq(features.length, 2,
"Parsed 2 features in total");
t.eq((features[0].type == features[1].type), false,
"The layer name differs for the two features");
text =
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<msGMLOutput ' +
' xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
' <wegbeheerderinfo_layer>' +
' <wegbeheerderinfo_feature>' +
' <gml:boundedBy>' +
' <gml:Box srsName="EPSG:28992">' +
' <gml:coordinates>105002.943000,490037.863000 105271.523000,490262.208000</gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <geometry>' +
' <gml:MultiLineString srsName="EPSG:28992">' +
' <gml:lineStringMember>' +
' <gml:LineString>' +
' <gml:coordinates>105270.164000,490262.208000 105098.274000,490258.040000 105028.045000,490089.576000 105002.943000,490048.851000 105049.666000,490037.863000 105271.523000,490064.957000 </gml:coordinates>' +
' </gml:LineString>' +
' </gml:lineStringMember>' +
' </gml:MultiLineString>' +
' </geometry>' +
' <OGR_FID>203327</OGR_FID>' +
' </wegbeheerderinfo_feature>' +
' </wegbeheerderinfo_layer>' +
'</msGMLOutput>';
features = parser.read(text);
t.eq((features[0].geometry instanceof OpenLayers.Geometry.MultiLineString), true,
"Parsed geometry is of type multi line string");
}
function test_read_GMLFeatureInfoResponse(t) {
t.plan(4);
var parser = new OpenLayers.Format.WMSGetFeatureInfo();
// read Ionic response, see if parser falls back to GML format
// url used:
/* http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?service=WMS&request=GetFeatureInfo&layers=roads&version=1.1.1&bbox=-71.1,42.25,-71.05,42.3&width=500&height=500&format=image/png&SRS=EPSG:4326&styles=&x=174&y=252&query_layers=roads&info_format=application/vnd.ogc.gml */
var text =
"<?xml version='1.0' encoding='utf-8' ?>" +
' <ogcwfs:FeatureCollection xsi:schemaLocation="http://www.ionicsoft.com/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?REQUEST=DescribeAllFeatureType&SERVICE=WFS http://www.opengis.net/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA/REQUEST/get/DATA/LPR/wfs/1.0.0/WFS-basic.xsd" xmlns:wfs="http://www.ionicsoft.com/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogcwfs="http://www.opengis.net/wfs">' +
' <gml:boundedBy>' +
' <gml:Box srsName="EPSG:4326">' +
' <gml:coordinates>-71.08301710045646,42.27320863544783 -71.08020014900377,42.27480054530114</gml:coordinates>' +
' </gml:Box>' +
' </gml:boundedBy>' +
' <gml:featureMember>' +
' <wfs:roads fid="roads.9453.0">' +
' <wfs:FNODE_>8943.0</wfs:FNODE_>' +
' <wfs:TNODE_>9070.0</wfs:TNODE_>' +
' <wfs:LPOLY_>0.0</wfs:LPOLY_>' +
' <wfs:RPOLY_>0.0</wfs:RPOLY_>' +
' <wfs:LENGTH>306.875</wfs:LENGTH>' +
' <wfs:MRD_>13109.0</wfs:MRD_>' +
' <wfs:MRD_ID>9453.0</wfs:MRD_ID>' +
' <wfs:TILE_NAME>126</wfs:TILE_NAME>' +
' <wfs:COUNTYCODE>M</wfs:COUNTYCODE>' +
' <wfs:SERIAL_NUM>26000.0</wfs:SERIAL_NUM>' +
' <wfs:CLASS>5.0</wfs:CLASS>' +
' <wfs:ADMIN_TYPE>0.0</wfs:ADMIN_TYPE>' +
' <wfs:ALTRT1TYPE>0.0</wfs:ALTRT1TYPE>' +
' <wfs:STREETNAME>DOCTOR MARY MOORE BEATTY CIRCLE</wfs:STREETNAME>' +
' <wfs:CSN>M 26000</wfs:CSN>' +
' <wfs:GEOMETRY>' +
' <gml:LineString srsName="EPSG:4326">' +
' <gml:coordinates>-71.08300668868151,42.27480054530114 -71.08155305289881,42.27452010256956 -71.08021063085208,42.27320863544783</gml:coordinates>' +
' </gml:LineString>' +
' </wfs:GEOMETRY>' +
' </wfs:roads>' +
' </gml:featureMember>' +
' </ogcwfs:FeatureCollection>';
var features = parser.read(text);
t.eq(features.length, 1,
"Parsing GML GetFeatureInfo response from Ionic succesfull");
t.eq(features[0].attributes.TILE_NAME, '126',
"Attribute TILE_NAME contains the right value");
// read Geoserver response
// taken from:
/* http://demo.opengeo.org/geoserver/wms?service=WMS&request=GetFeatureInfo&layers=opengeo:roads&query_layers=opengeo:roads&format=image/png&version=1.1.1&styles=&bbox=-103.9,44.4,-103.7,44.5&srs=EPSG:4326&width=500&height=500&x=158&y=98&info_format=application/vnd.ogc.gml*/
text = '<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:opengeo="http://opengeo.org" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://opengeo.org http://demo.opengeo.org:80/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=opengeo:roads http://www.opengis.net/wfs http://demo.opengeo.org:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd"><gml:boundedBy><gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#26713"><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">591943.9375,4925605 593045.625,4925845</gml:coordinates></gml:Box></gml:boundedBy><gml:featureMember><opengeo:roads fid="roads.90"><opengeo:cat>3</opengeo:cat><opengeo:label>secondary highway, hard surface</opengeo:label><opengeo:the_geom><gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#26713"><gml:lineStringMember><gml:LineString><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">593045.60746465,4925605.0059156 593024.32382915,4925606.79305411 592907.54863574,4925624.85647524 592687.35111096,4925670.76834012 592430.76279218,4925678.79393165 592285.97636109,4925715.70811767 592173.39165655,4925761.83511156 592071.1753393,4925793.95523514 591985.96972625,4925831.59842486 591943.98769455,4925844.93220071</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString></opengeo:the_geom></opengeo:roads></gml:featureMember></wfs:FeatureCollection>';
features = parser.read(text);
t.eq(features.length, 1,
"Parsing GML GetFeatureInfo response from Geoserver succesfull");
t.eq(features[0].attributes.cat, '3',
"Attribute cat contains the right value");
}
</script>
</head>
<body>
</body>
</html>
|