[mapserver-users] Problem with wfs.php

Olivier BEDEL o.bedel at alkante.com
Wed Oct 13 02:55:09 PDT 2010


Hi Robert,

The file_get_contents error you get doesn't come from your code but is return by the Carmen wfs server.
As Jukka said, your filter seems too long to be sent in a GET parameter. But when querying the wfs server in POST, you should send your query in XML and not use Key Value Pair encoding (FILTER=...).

In fact, the content of your POST query should look like this :

<?xml version="1.0" encoding="utf-8"?><GetFeature xmlns="http://www.opengis.net/wfs"  xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" service="WFS" version="1.0.0" outputFormat="GML2" maxFeatures="100" handle="" ><Query typeName="ZNIEFF_de_type_1" srsName="EPSG:2154" ><ogc:Filter><Intersect><PropertyName>Geometry</PropertyName><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>(526467,6821671 526471,6821675 526480,6821677 526482,6821676 526491,6821679 526490,6821682 526546,6821697 526615,6821701 526616,6821699 526627,6821699 526628,6821702 526708,6821705 526804,6821709 526821,6821701 526886,6821665 526916,6821658 526933,6821616 526961,6821574 526969,6821565 526982,6821513 526833,6821533 526833,6821517 526813,6821513 526801,6821508 526749,6821480 526732,6821469 526718,6821484 526688,6821481 526616,6821481 526620,6821448 526584,6821438 526547,6821401 526545,6821397 526533,6821376 526455,6821381 526453,6821379 526409,6821377 526415,6821415 526429,6821499 526440,6821569 526377,6821567 526362,6821463 526357,6821393 526359,6821371 526360,6821362 526365,6821332 526325,6821292 526315,6821308 526302,6821322 526296,6821325 526277,6821347 526286,6821417 526286,6821447 526295,6821516 526303,6821549 526308,6821569 526314,6821571 526320,6821578 526328,6821580 526340,6821589 526381,6821619 526466,6821673 526467,6821671 526467,6821671) (526489,6821639 526492,6821655 526493,6821655 526489,6821639 526489,6821639) (526467,6821588 526466,6821586 526464,6821585 526467,6821588 526467,6821588) (526479,6821603 526478,6821601 526477,6821599 526479,6821603 526479,6821603) (526489,6821639 526489,6821639 526486,6821627 526489,6821639 526489,6821639)) ((527187,6822859 527158,6822860 527138,6822862 527110,6822871 527104,6822873 527098,6822871 527054,6822879 527003,6822885 526998,6822885 526995,6822885 526972,6822882 526964,6822889 526955,6822894 526935,6822910 526922,6822929 526916,6822946 526910,6822973 526917,6822980 526917,6822987 526915,6823010 526942,6823015 526943,6823045 526945,6823052 526948,6823056 526956,6823059 526969,6823073 526973,6823081 526975,6823094 526970,6823097 526971,6823102 526987,6823123 527004,6823131 527019,6823103 527050,6823109 527134,6823120 527137,6823099 527133,6823084 527134,6823050 527190,6823074 527199,6823016 527220,6823014 527213,6822861 527204,6822860 527187,6822859 527187,6822859) (527114,6823008 527114,6823001 527071,6822980 527059,6822982 527050,6822978 527032,6822968 527024,6823072 527047,6823070 527043,6823034 527049,6822983 527068,6822984 527114,6823008 527114,6823008) (527112,6822930 527115,6822933 527118,6822943 527118,6822947 527119,6822955 527124,6822954 527123,6822945 527119,6822930 527115,6822925 527112,6822930 527112,6822930)) ((526685,6821896 526737,6821974 526766,6822042 526771,6822072 526782,6822030 526808,6821981 526869,6821901 526875,6821889 526909,6821797 526908,6821779 526900,6821771 526832,6821727 526812,6821722 526787,6821720 526785,6821761 526666,6821870 526685,6821896 526685,6821896)) ((527009,6822654 527076,6822645 527077,6822629 527076,6822611 527076,6822608 527079,6822589 527070,6822587 527063,6822589 527038,6822623 527012,6822641 527009,6822649 527007,6822650 527002,6822652 526984,6822657 526953,6822666 526917,6822684 526898,6822697 526901,6822703 526949,6822680 526958,6822701 526927,6822716 526946,6822718 526955,6822714 526961,6822709 526980,6822748 526988,6822809 526997,6822811 527002,6822843 527040,6822877 527052,6822875 527086,6822868 527100,6822860 527104,6822849 527107,6822845 527113,6822839 527120,6822826 527134,6822803 527147,6822771 527160,6822720 527168,6822679 527153,6822679 527132,6822678 527079,6822677 527012,6822671 527009,6822654 527009,6822654)) ((527249,6822166 527250,6822157 527257,6822142 527274,6822104 527280,6822079 527265,6822097 527230,6822148 527205,6822195 527179,6822230 527163,6822262 527205,6822288 527251,6822297 527270,6822298 527334,6822298 527376,6822304 527391,6822304 527503,6822328 527554,6822333 527572,6822322 527548,6822299 527542,6822296 527545,6822281 527391,6822246 527282,6822211 527218,6822199 527249,6822166 527249,6822166)) ((526821,6822064 526901,6822093 526939,6822084 526962,6822085 526985,6822075 527018,6822113 527046,6822155 527068,6822140 527064,6822093 527061,6822073 527051,6822041 527024,6821996 526906,6821995 526896,6821998 526889,6822002 526868,6822015 526852,6822029 526821,6822064 526821,6822064)) ((527082,6822584 527086,6822573 527091,6822566 527073,6822564 527065,6822561 527046,6822526 527047,6822455 527052,6822410 527053,6822381 527038,6822382 527036,6822378 526966,6822403 526967,6822435 526972,6822476 526983,6822538 527010,6822639 527032,6822623 527036,6822619 527055,6822594 527060,6822586 527066,6822584 527081,6822585 527082,6822584 527082,6822584)) ((526546,6821979 526549,6822025 526551,6822040 526563,6822075 526684,6822011 526655,6821986 526614,6821947 526680,6821898 526664,6821872 526662,6821873 526546,6821979 526546,6821979)) ((527014,6821959 527090,6821938 527116,6821929 527112,6821927 527110,6821928 527103,6821924 527104,6821920 527060,6821893 527019,6821865 527017,6821866 527006,6821858 527008,6821855 526927,6821792 526923,6821792 526922,6821794 526924,6821803 526984,6821906 527006,6821947 527014,6821959 527014,6821959)) ((527170,6822232 527134,6822195 527134,6822164 527129,6822155 527102,6822120 527073,6822133 527074,6822170 527083,6822210 527123,6822234 527156,6822262 527170,6822232 527170,6822232)) ((526582,6822099 526581,6822099 526584,6822100 526592,6822098 526600,6822099 526626,6822130 526741,6822056 526740,6822052 526704,6822025 526582,6822099 526582,6822099)) ((527461,6822398 527434,6822522 527484,6822557 527504,6822464 527472,6822443 527472,6822435 527489,6822377 527461,6822398 527461,6822398)) ((527423,6822716 527345,6822691 527339,6822710 527302,6822693 527289,6822721 527396,6822770 527414,6822736 527423,6822716 527423,6822716)) ((527726,6822272 527788,6822255 527792,6822219 527799,6822180 527817,6822133 527792,6822152 527774,6822172 527747,6822196 527727,6822269 527726,6822272 527726,6822272)) ((527835,6823091 527845,6823121 527847,6823122 527871,6823117 527904,6823102 527896,6823091 527911,6823082 527889,6823053 527858,6823079 527835,6823091 527835,6823091)) ((527129,6822598 527125,6822597 527154,6822653 527171,6822677 527210,6822631 527129,6822598 527129,6822598)) ((527184,6822670 527176,6822681 527190,6822695 527236,6822770 527269,6822749 527184,6822670 527184,6822670)) ((526719,6821400 526751,6821412 526776,6821372 526747,6821327 526719,6821400 526719,6821400)) ((527143,6822790 527141,6822795 527133,6822810 527128,6822819 527124,6822825 527117,6822840 527110,6822846 527107,6822851 527103,6822862 527106,6822865 527110,6822865 527139,6822859 527135,6822836 527160,6822831 527174,6822853 527177,6822854 527187,6822855 527164,6822818 527143,6822790 527143,6822790)) ((527423,6822716 527420,6822725 527449,6822734 527480,6822692 527430,6822672 527428,6822676 527431,6822697 527423,6822716 527423,6822716)) ((526654,6822160 526675,6822186 526685,6822193 526698,6822175 526692,6822165 526679,6822144 526654,6822160 526654,6822160)</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersect></ogc:Filter></Query></GetFeature>

Regards,

Olivier.




----- Mail Original -----
De: "Richard LEHAUT" <richard.lehaut at gmail.com>
À: "Yves Jacolin" <yves.jacolin at camptocamp.com>
Cc: "Rahkonen Jukka" <Jukka.Rahkonen at mmmtike.fi>, mapserver-users at lists.osgeo.org
Envoyé: Mardi 12 Octobre 2010 16:59:49
Objet: Re: [mapserver-users] Problem with wfs.php


Hi, 
I followed your instructions, I try use "curl-setopt-array" with "curl_multi_init". 

function curl_get_multi_content($list_layer) { 
$curl_init = array(); 

foreach($list_layer as $i => $layer) { 
unset($options); 
$options = array 
( 
CURLOPT_RETURNTRANSFER => true, 
CURLOPT_CONNECTTIMEOUT => 120, 
CURLOPT_TIMEOUT => 120, 
CURLOPT_POST => 1, 
CURLOPT_POSTFIELDS => $layer['data'].$layer['filter'], 
); 

$curl_init[$i] = curl_init($layer['url']); 
curl_setopt_array($curl_init[$i],$options); 
} 

$curl_multi = curl_multi_init(); 

foreach($list_layer as $i => $layer) { 
curl_multi_add_handle($curl_multi, $curl_init[$i]); 
} 
do { 
curl_multi_exec($curl_multi, $running); 
} while($running > 0); 

foreach($list_layer as $i => $layer) { 
echo curl_multi_getcontent($curl_init[$i]); 
$list_layer[$i] = $layer+Array('info'=>get_info_xml(curl_multi_getcontent($curl_init[$i]), $layer['name'])); 
curl_close($curl_init[$i]); 
} 
return $list_layer; 
} 

With my server, result is correct. I've a error with server Carmen : 
ZNIEFF_de_type_1=======> 
Warning: file_get_contents( http://ws.carmen.developpement-durable.gouv.fr/cgi-bin/mapserv?service_idx=8&map=%2Fmnt%2Fdata_carmen%2FBN%2FPublication%2Fwms_nature.map&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&TYPENAME=ZNIEFF_de_type_1&FILTER=%3CFilter%3E%3CIntersect%3E%3CPropertyName%3EGeometry%3C%2FPropertyName%3E%3Cgml%3APolygon%3E%3Cgml%3AouterBoundaryIs%3E%3Cgml%3ALinearRing%3E%3Cgml%3Acoordinates%3E%28526467%2C6821671%20526471%2C6821675%20526480%2C6821677%20526482%2C6821676%20526491%2C6821679%20526490%2C6821682%20526546%2C6821697%20526615%2C6821701%20526616%2C6821699%20526627%2C6821699%20526628%2C6821702%20526708%2C6821705%20526804%2C6821709%20526821%2C6821701%20526886%2C6821665%20526916%2C6821658%20526933%2C6821616%20526961%2C6821574%20526969%2C6821565%20526982%2C6821513%20526833%2C6821533%20526833%2C6821517%20526813%2C6821513%20526801%2C6821508%20526749%2C6821480%20526732%2C6821469%20526718%2C6821484%20526688%2C6821481%20526616%2C6821481%20526620%2C6821448%20526584%2C6821438%20526547%2C in /applications/www/carmen/WFS/wfs.php on line 123 

Warning: Cannot modify header information - headers already sent by (output started at /applications/www/carmen/WFS/wfs.php:123) in /applications/www/carmen/WFS/wfs.php on line 91. 

It's the same message of the first error (number of ligne changed), but the function working properly on my server!!!! 

Thanks for your help. 

Richard LEHAUT/Tiolebucheron 


2010/10/11 Yves Jacolin < yves.jacolin at camptocamp.com > 


Hi, 

Don't use file_get_contents but cURL rather: 
http://www.php.net/manual/fr/function.curl-setopt-array.php 

Regards, 

Y. 


_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the MapServer-users mailing list