PageRenderTime 27ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tine20/library/OpenLayers/tests/Format/WMSGetFeatureInfo.html

https://gitlab.com/rsilveira1987/Expresso
HTML | 271 lines | 229 code | 42 blank | 0 comment | 0 complexity | 804ea79aea57fb3544bd3c6154c541cc MD5 | raw file
  1. <html>
  2. <head>
  3. <script src="../../lib/OpenLayers.js"></script>
  4. <script type="text/javascript">
  5. function test_read_FeatureInfoResponse(t) {
  6. t.plan(5);
  7. var parser = new OpenLayers.Format.WMSGetFeatureInfo();
  8. // read empty response
  9. var text =
  10. '<?xml version="1.0" encoding="UTF-8" ?>' +
  11. '<FeatureInfoResponse>' +
  12. '</FeatureInfoResponse>';
  13. var features = parser.read(text);
  14. t.eq(features.length, 0,
  15. "Parsing empty FeatureInfoResponse response succesfull");
  16. // read 1 feature
  17. text =
  18. '<?xml version="1.0" encoding="UTF-8" ?>' +
  19. '<FeatureInfoResponse>' +
  20. ' <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"/>' +
  21. '</FeatureInfoResponse>';
  22. features = parser.read(text);
  23. t.eq(features.length, 1,
  24. "Parsed 1 feature in total");
  25. t.eq(features[0].attributes.OBJECTID, '1188',
  26. "Attribute OBJECTID contains the right value");
  27. // read multiple features
  28. text =
  29. '<?xml version="1.0" encoding="UTF-8" ?>' +
  30. '<FeatureInfoResponse>' +
  31. ' <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"/>' +
  32. ' <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"/>' +
  33. ' <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"/>' +
  34. '</FeatureInfoResponse>';
  35. features = parser.read(text);
  36. t.eq(features.length, 3,
  37. "Parsed 3 features in total");
  38. t.eq(features[1].attributes.STATE_NAME, 'Wyoming',
  39. "Attribute STATE_NAME contains the right value");
  40. }
  41. function test_read_msGMLOutput(t) {
  42. t.plan(7);
  43. var parser = new OpenLayers.Format.WMSGetFeatureInfo();
  44. // read empty response
  45. var text =
  46. '<?xml version="1.0" encoding="ISO-8859-1"?>' +
  47. '<msGMLOutput ' +
  48. ' xmlns:gml="http://www.opengis.net/gml"' +
  49. ' xmlns:xlink="http://www.w3.org/1999/xlink"' +
  50. ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
  51. '</msGMLOutput>';
  52. var features = parser.read(text);
  53. t.eq(features.length, 0,
  54. "Parsing empty msGMLOutput response succesfull");
  55. // read 1 feature from 1 layer
  56. text =
  57. '<?xml version="1.0" encoding="ISO-8859-1"?>' +
  58. '<msGMLOutput ' +
  59. ' xmlns:gml="http://www.opengis.net/gml"' +
  60. ' xmlns:xlink="http://www.w3.org/1999/xlink"' +
  61. ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
  62. ' <AAA64_layer>' +
  63. ' <AAA64_feature>' +
  64. ' <gml:boundedBy>' +
  65. ' <gml:Box srsName="EPSG:28992">' +
  66. ' <gml:coordinates>107397.266000,460681.063000 116568.188000,480609.250000</gml:coordinates>' +
  67. ' </gml:Box>' +
  68. ' </gml:boundedBy>' +
  69. ' <OBJECTID>109</OBJECTID>' +
  70. ' <ROUTE>N231</ROUTE>' +
  71. ' <ROUTE_CH>#N231</ROUTE_CH>' +
  72. ' <COUNT>2</COUNT>' +
  73. ' <BEHEERDER>P</BEHEERDER>' +
  74. ' <LENGTH>28641.7</LENGTH>' +
  75. ' <SHAPE>&lt;shape&gt;</SHAPE>' +
  76. ' <SE_ANNO_CAD_DATA>&lt;null&gt;</SE_ANNO_CAD_DATA>' +
  77. ' </AAA64_feature>' +
  78. ' </AAA64_layer>' +
  79. '</msGMLOutput>';
  80. features = parser.read(text);
  81. t.eq(features.length, 1,
  82. "Parsed 1 feature in total");
  83. t.eq(features[0].attributes.OBJECTID, '109',
  84. "Attribute OBJECTID contains the right value");
  85. t.eq(features[0].type, 'AAA64',
  86. "Parsed the layer name correctly");
  87. // read 2 features from 2 layers
  88. text =
  89. '<?xml version="1.0" encoding="ISO-8859-1"?>' +
  90. '<msGMLOutput ' +
  91. ' xmlns:gml="http://www.opengis.net/gml"' +
  92. ' xmlns:xlink="http://www.w3.org/1999/xlink"' +
  93. ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
  94. ' <AAA64_layer>' +
  95. ' <AAA64_feature>' +
  96. ' <gml:boundedBy>' +
  97. ' <gml:Box srsName="EPSG:28992">' +
  98. ' <gml:coordinates>129799.109000,467950.250000 133199.906000,468904.063000</gml:coordinates>' +
  99. ' </gml:Box>' +
  100. ' </gml:boundedBy>' +
  101. ' <OBJECTID>287</OBJECTID>' +
  102. ' <ROUTE>N403</ROUTE>' +
  103. ' <ROUTE_CH>#N403</ROUTE_CH>' +
  104. ' <COUNT>1</COUNT>' +
  105. ' <BEHEERDER>P</BEHEERDER>' +
  106. ' <LENGTH>4091.25</LENGTH>' +
  107. ' <SHAPE>&lt;shape&gt;</SHAPE>' +
  108. ' <SE_ANNO_CAD_DATA>&lt;null&gt;</SE_ANNO_CAD_DATA>' +
  109. ' </AAA64_feature>' +
  110. ' </AAA64_layer>' +
  111. ' <AAA62_layer>' +
  112. ' <AAA62_feature>' +
  113. ' <gml:boundedBy>' +
  114. ' <gml:Box srsName="EPSG:28992">' +
  115. ' <gml:coordinates>129936.000000,468362.000000 131686.000000,473119.000000</gml:coordinates>' +
  116. ' </gml:Box>' +
  117. ' </gml:boundedBy>' +
  118. ' <OBJECTID>1251</OBJECTID>' +
  119. ' <VWK_ID>1515</VWK_ID>' +
  120. ' <VWK_BEGDTM>00:00:00 01/01/1998</VWK_BEGDTM>' +
  121. ' <VWJ_ID_BEG>1472</VWJ_ID_BEG>' +
  122. ' <VWJ_ID_END>1309</VWJ_ID_END>' +
  123. ' <VAKTYPE>D</VAKTYPE>' +
  124. ' <VRT_CODE>227</VRT_CODE>' +
  125. ' <VRT_NAAM>Vecht</VRT_NAAM>' +
  126. ' <VWG_NR>2</VWG_NR>' +
  127. ' <VWG_NAAM>Vecht</VWG_NAAM>' +
  128. ' <BEGKM>18.25</BEGKM>' +
  129. ' <ENDKM>23.995</ENDKM>' +
  130. ' <LENGTH>5745.09</LENGTH>' +
  131. ' <SHAPE>&lt;shape&gt;</SHAPE>' +
  132. ' <SE_ANNO_CAD_DATA>&lt;null&gt;</SE_ANNO_CAD_DATA>' +
  133. ' </AAA62_feature>' +
  134. ' </AAA62_layer>' +
  135. '</msGMLOutput>';
  136. features = parser.read(text);
  137. t.eq(features.length, 2,
  138. "Parsed 2 features in total");
  139. t.eq((features[0].type == features[1].type), false,
  140. "The layer name differs for the two features");
  141. text =
  142. '<?xml version="1.0" encoding="ISO-8859-1"?>' +
  143. '<msGMLOutput ' +
  144. ' xmlns:gml="http://www.opengis.net/gml"' +
  145. ' xmlns:xlink="http://www.w3.org/1999/xlink"' +
  146. ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
  147. ' <wegbeheerderinfo_layer>' +
  148. ' <wegbeheerderinfo_feature>' +
  149. ' <gml:boundedBy>' +
  150. ' <gml:Box srsName="EPSG:28992">' +
  151. ' <gml:coordinates>105002.943000,490037.863000 105271.523000,490262.208000</gml:coordinates>' +
  152. ' </gml:Box>' +
  153. ' </gml:boundedBy>' +
  154. ' <geometry>' +
  155. ' <gml:MultiLineString srsName="EPSG:28992">' +
  156. ' <gml:lineStringMember>' +
  157. ' <gml:LineString>' +
  158. ' <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>' +
  159. ' </gml:LineString>' +
  160. ' </gml:lineStringMember>' +
  161. ' </gml:MultiLineString>' +
  162. ' </geometry>' +
  163. ' <OGR_FID>203327</OGR_FID>' +
  164. ' </wegbeheerderinfo_feature>' +
  165. ' </wegbeheerderinfo_layer>' +
  166. '</msGMLOutput>';
  167. features = parser.read(text);
  168. t.eq((features[0].geometry instanceof OpenLayers.Geometry.MultiLineString), true,
  169. "Parsed geometry is of type multi line string");
  170. }
  171. function test_read_GMLFeatureInfoResponse(t) {
  172. t.plan(4);
  173. var parser = new OpenLayers.Format.WMSGetFeatureInfo();
  174. // read Ionic response, see if parser falls back to GML format
  175. // url used:
  176. /* 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 */
  177. var text =
  178. "<?xml version='1.0' encoding='utf-8' ?>" +
  179. ' <ogcwfs:FeatureCollection xsi:schemaLocation="http://www.ionicsoft.com/wfs http://webservices.ionicsoft.com/ionicweb/wfs/BOSTON_ORA?REQUEST=DescribeAllFeatureType&amp;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">' +
  180. ' <gml:boundedBy>' +
  181. ' <gml:Box srsName="EPSG:4326">' +
  182. ' <gml:coordinates>-71.08301710045646,42.27320863544783 -71.08020014900377,42.27480054530114</gml:coordinates>' +
  183. ' </gml:Box>' +
  184. ' </gml:boundedBy>' +
  185. ' <gml:featureMember>' +
  186. ' <wfs:roads fid="roads.9453.0">' +
  187. ' <wfs:FNODE_>8943.0</wfs:FNODE_>' +
  188. ' <wfs:TNODE_>9070.0</wfs:TNODE_>' +
  189. ' <wfs:LPOLY_>0.0</wfs:LPOLY_>' +
  190. ' <wfs:RPOLY_>0.0</wfs:RPOLY_>' +
  191. ' <wfs:LENGTH>306.875</wfs:LENGTH>' +
  192. ' <wfs:MRD_>13109.0</wfs:MRD_>' +
  193. ' <wfs:MRD_ID>9453.0</wfs:MRD_ID>' +
  194. ' <wfs:TILE_NAME>126</wfs:TILE_NAME>' +
  195. ' <wfs:COUNTYCODE>M</wfs:COUNTYCODE>' +
  196. ' <wfs:SERIAL_NUM>26000.0</wfs:SERIAL_NUM>' +
  197. ' <wfs:CLASS>5.0</wfs:CLASS>' +
  198. ' <wfs:ADMIN_TYPE>0.0</wfs:ADMIN_TYPE>' +
  199. ' <wfs:ALTRT1TYPE>0.0</wfs:ALTRT1TYPE>' +
  200. ' <wfs:STREETNAME>DOCTOR MARY MOORE BEATTY CIRCLE</wfs:STREETNAME>' +
  201. ' <wfs:CSN>M 26000</wfs:CSN>' +
  202. ' <wfs:GEOMETRY>' +
  203. ' <gml:LineString srsName="EPSG:4326">' +
  204. ' <gml:coordinates>-71.08300668868151,42.27480054530114 -71.08155305289881,42.27452010256956 -71.08021063085208,42.27320863544783</gml:coordinates>' +
  205. ' </gml:LineString>' +
  206. ' </wfs:GEOMETRY>' +
  207. ' </wfs:roads>' +
  208. ' </gml:featureMember>' +
  209. ' </ogcwfs:FeatureCollection>';
  210. var features = parser.read(text);
  211. t.eq(features.length, 1,
  212. "Parsing GML GetFeatureInfo response from Ionic succesfull");
  213. t.eq(features[0].attributes.TILE_NAME, '126',
  214. "Attribute TILE_NAME contains the right value");
  215. // read Geoserver response
  216. // taken from:
  217. /* 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*/
  218. 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&amp;version=1.0.0&amp;request=DescribeFeatureType&amp;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>';
  219. features = parser.read(text);
  220. t.eq(features.length, 1,
  221. "Parsing GML GetFeatureInfo response from Geoserver succesfull");
  222. t.eq(features[0].attributes.cat, '3',
  223. "Attribute cat contains the right value");
  224. }
  225. </script>
  226. </head>
  227. <body>
  228. </body>
  229. </html>