//27\r
$p_wms_foreground,\r
//28\r
-$p_dest_epsg_projection\r
+$p_dest_epsg_projection,\r
+//29\r
+$p_no_header_for_tests=FALSE\r
)\r
{\r
\r
//ftheeten 2013/01/11\r
//error_reporting(0);\r
\r
- ob_start();\r
+ //ob_start();\r
$conn = pg_pconnect(POSTGIS_CS);\r
$flagError=false;\r
$errorMessages=array();\r
\r
- $flagDisplayPoints=falses;\r
+ $flagDisplayPoints=false;\r
//ftheeten 24/01/2013\r
$arrayWMSIdxURLs=parseWMS($p_externalwms, $p_externalwms_versions, $p_externalwms_filter);\r
$convertedCoordinates=array();\r
\r
$prefix_wms="topp:";\r
\r
- \r
- \r
- $random=md5($p_uri ).".sld";\r
- \r
+ $ls_string=NULL;\r
+ $title_external=NULL;\r
+ $title=NULL;\r
+ $layer=NULL;\r
+ $field=NULL;\r
+ $label_field=NULL;\r
+ $label=NULL; \r
+ $random=md5($p_uri .get_current_user()).".sld";\r
+ $sessionid=$random;\r
+ $legend_url=NULL;\r
+ $sld_url=NULL;\r
+ $geo=NULL;\r
+ $ratio_y=NULL;\r
$leg=$p_legend;\r
\r
\r
//bug 16/04/2010 (pb with imagemagick package in filename?)\r
- $image_radical=md5($p_uri );\r
+ $image_radical=md5($p_uri .get_current_user());\r
$image_file=$image_radical."_layers.png";\r
\r
$random2=V1_IMG.$image_file;\r
$id=$specie[0];\r
\r
//geodata of each recordset\r
- \r
- $geo=explode('|',$specie[1]);\r
- \r
- foreach ($geo as $key=>$value)\r
- \r
+ if(isset($specie[1]))\r
{\r
- $geos=explode(',',$value);\r
-\r
- if(count($geos)>=2&&strlen($geos[0])>0&&strlen($geos[1])>0)\r
+ $geo=explode('|',$specie[1]);\r
+ foreach ($geo as $key=>$value)\r
+ \r
{\r
+ $geos=explode(',',$value);\r
+\r
+ if(count($geos)>=2&&strlen($geos[0])>0&&strlen($geos[1])>0)\r
+ {\r
\r
\r
- $geodata[$id]['geodata']['lon'][]=$geos[1]; \r
- $geodata[$id]['geodata']['lat'][]=$geos[0];\r
- }\r
+ $geodata[$id]['geodata']['lon'][]=$geos[1]; \r
+ $geodata[$id]['geodata']['lat'][]=$geos[0];\r
+ }\r
\r
\r
+ }\r
}\r
+ \r
\r
}\r
\r
\r
$xsl->setParameter( '', 'userid', $random);\r
\r
- $style = realpath('points_transparent.xsl');\r
+ $style = realpath(dirname(__FILE__)."/".'points_transparent.xsl');\r
\r
$dom_new->load($style);\r
\r
\r
//print($path_towrite);\r
\r
- $fp=fopen("$path_towrite","w");\r
+ $fp=fopen("$path_towrite","w+");\r
\r
$write=fwrite($fp,$out);\r
\r
\r
{//if title\r
\r
- $title=$p_title;\r
+ $title_external=$p_title;\r
\r
}//if title\r
\r
//title=a:cultivated|b:forest\r
\r
- $t=explode('|',$title);\r
+ $t=explode('|',$title_external);\r
\r
$title_array=array();\r
\r
{//loop t\r
\r
$title=explode(':',$v);\r
- \r
- $title_array[$title[0]]=$title[1];\r
- \r
+ if(isset($title[1]))\r
+ {\r
+ $title_array[$title[0]]=$title[1];\r
+ }\r
+ else\r
+ {\r
+ $title_array[$title[0]]=NULL;\r
+ }\r
}//loop t\r
\r
\r
$symbols=explode(':',$v);\r
\r
$keys=explode(',',$symbols[0]);\r
- \r
- $get_v=explode(',',$symbols[1]);\r
- \r
+ if(isset($symbols[1]))\r
+ {\r
+ $get_v=explode(',',$symbols[1]);\r
+ }\r
+ else\r
+ {\r
+ $get_v=array();\r
+ }\r
// var_dump ($get_v);\r
\r
if ($p_img_url)\r
\r
$ms=$p_size;\r
\r
- if (ereg(",",$ms))\r
- \r
+ if (@ereg(",",$ms))\r
{\r
\r
$ms=explode(',',$ms);\r
$symbols_val=$color[1];\r
*/\r
\r
- if (!ereg(",",$symbols_val))\r
+ if (!@ereg(",",$symbols_val))\r
\r
{\r
\r
\r
//}\r
\r
- \r
+ break;\r
\r
case 1:\r
- \r
- if($total_symbols[$k][$i]=="")\r
- \r
+ if(isset($total_symbols[$k][$i]))\r
{\r
+ if($total_symbols[$k][$i]=="")\r
\r
- $total_symbols[$k][$i]="10090b"; \r
+ {\r
\r
- }\r
+ $total_symbols[$k][$i]="10090b"; \r
\r
+ }\r
+ }\r
+ break;\r
case 2:\r
- \r
- if($total_symbols[$k][$i]=="")\r
+ \r
+ if(isset($total_symbols[$k][$i])===FALSE||$total_symbols[$k][$i]=="")\r
\r
{\r
\r
$total_symbols[$k][$i]="0.5"; \r
\r
}\r
- \r
+ break;\r
/* case 3:\r
\r
if($total_symbols[$k][$i]=="")\r
\r
case 3:\r
\r
- if($total_symbols[$k][$i]=="")\r
+ if(isset($total_symbols[$k][$i])===FALSE||$total_symbols[$k][$i]=="")\r
\r
{\r
\r
$total_symbols[$k][$i]="no_style";\r
\r
}\r
- \r
+ break;\r
case 4:\r
\r
- if($total_symbols[$k][$i]=="")\r
+ if(isset($total_symbols[$k][$i])===FALSE||$total_symbols[$k][$i]=="")\r
\r
{\r
\r
$total_symbols[$k][$i]="no_label";\r
\r
}\r
+ break;\r
\r
}//fi switch\r
\r
//var_dump($v);\r
\r
\r
- if (!ereg(",",$first_pol))\r
+ if (!@ereg(",",$first_pol))\r
\r
{//loop first pol\r
\r
\r
$wms_field_array[$first_layer]=$first_wms_field;\r
\r
- if (!ereg(",",$data[1]))\r
+ if (!@ereg(",",$data[1]))\r
\r
{//if data 1\r
\r
foreach ($total_symbols as $k=>$v)\r
\r
{//loop total symbols in gml\r
- if(strlen($title_array[$k])>0)\r
+ if(isset($title_array[$k]))\r
{\r
+ if(strlen($title_array[$k])>0)\r
+ {\r
\r
- //var_dump($k); //a,b\r
+ //var_dump($k); //a,b\r
\r
- $legend.="<style><name>".$title_array[$k]."</name>";\r
+ $legend.="<style><name>".$title_array[$k]."</name>";\r
\r
- //$legend.="<style><name>".$total_symbols[$k][4]."</name>";\r
+ //$legend.="<style><name>".$total_symbols[$k][4]."</name>";\r
\r
\r
\r
- $legend.="<label>".$k."</label>";\r
+ $legend.="<label>".$k."</label>";\r
\r
\r
\r
- if (array_key_exists($k['url'],$symbols_url))\r
+ if (array_key_exists($k['url'],$symbols_url))\r
\r
- {//if key in symbol\r
+ {//if key in symbol\r
\r
\r
\r
\r
\r
- $legend.="<hatching>http://".$symbols_url[$k]['url']."/".$symbols_url[$k]['symbols'].".".$symbols_url[$k]['format']."</hatching>";\r
+ $legend.="<hatching>http://".$symbols_url[$k]['url']."/".$symbols_url[$k]['symbols'].".".$symbols_url[$k]['format']."</hatching>";\r
\r
- switch ($symbols_url[$k]['format'])\r
+ switch ($symbols_url[$k]['format'])\r
\r
- {\r
+ {\r
\r
- case ('gif'): $format='image/gif';break;\r
+ case ('gif'): $format='image/gif';break;\r
\r
- case ('png'): $format='image/png';break;\r
+ case ('png'): $format='image/png';break;\r
\r
- case ('jpeg'): $format='image/jpeg';break;\r
+ case ('jpeg'): $format='image/jpeg';break;\r
\r
- }\r
+ }\r
\r
\r
\r
- $legend.="<symbol_size>".$symbols_url[$k]['size']."</symbol_size>";\r
+ $legend.="<symbol_size>".$symbols_url[$k]['size']."</symbol_size>";\r
\r
- $legend.="<symbol_format>".$format."</symbol_format>";\r
+ $legend.="<symbol_format>".$format."</symbol_format>";\r
\r
- //$xml.="<hatch_symbol>".."</hatch_symbol>";\r
+ //$xml.="<hatch_symbol>".."</hatch_symbol>";\r
\r
- $legend.="<color>hatching</color>";\r
+ $legend.="<color>hatching</color>";\r
\r
- }//end if array key in symbol\r
+ }//end if array key in symbol\r
\r
- else \r
- { // if array key in symbol\r
+ else \r
+ { // if array key in symbol\r
\r
- $legend.="<hatching>NO</hatching>";\r
+ $legend.="<hatching>NO</hatching>";\r
\r
- $legend.="<color>".$total_symbols[$k][0]."</color>";\r
+ $legend.="<color>".$total_symbols[$k][0]."</color>";\r
\r
- } //end array key in symbol\r
+ } //end array key in symbol\r
+\r
+\r
+\r
+\r
+\r
+\r
\r
\r
\r
\r
\r
- $legend.="<stroke_color>".$total_symbols[$k][1]."</stroke_color>";\r
+ $legend.="<stroke_color>".$total_symbols[$k][1]."</stroke_color>";\r
\r
- $legend.="<stroke_width>".$total_symbols[$k][2]."</stroke_width>";\r
+ $legend.="<stroke_width>".$total_symbols[$k][2]."</stroke_width>";\r
\r
- switch ($total_symbols[$k][3])\r
+ switch ($total_symbols[$k][3])\r
\r
- {// switch total symbols\r
+ {// switch total symbols\r
\r
- case ('1_2'): \r
- $total_symbols[$k][3]="1 2 1 2";\r
- break;\r
+ case ('1_2'): \r
+ $total_symbols[$k][3]="1 2 1 2";\r
+ break;\r
\r
- case ('1_4'): \r
- $total_symbols[$k][3]="1 4 1 4";\r
- break;\r
+ case ('1_4'): \r
+ $total_symbols[$k][3]="1 4 1 4";\r
+ break;\r
\r
- case ('2_2'): \r
- $total_symbols[$k][3]="2 2 2 2";\r
- break;\r
+ case ('2_2'): \r
+ $total_symbols[$k][3]="2 2 2 2";\r
+ break;\r
\r
- case ('2_4'):\r
- $total_symbols[$k][3]="2 4 2 4";\r
- break;\r
+ case ('2_4'):\r
+ $total_symbols[$k][3]="2 4 2 4";\r
+ break;\r
\r
- case ('5_7'): \r
- $total_symbols[$k][3]="5 7 5 7";\r
- break;\r
+ case ('5_7'): \r
+ $total_symbols[$k][3]="5 7 5 7";\r
+ break;\r
\r
- case ('10_5'): \r
- $total_symbols[$k][3]="10 5 10 5";\r
- break;\r
+ case ('10_5'): \r
+ $total_symbols[$k][3]="10 5 10 5";\r
+ break;\r
\r
- }//end switch\r
+ }//end switch\r
\r
- $legend.="<stroke_style>".$total_symbols[$k][3]."</stroke_style>";\r
+ $legend.="<stroke_style>".$total_symbols[$k][3]."</stroke_style>";\r
\r
- $legend.="</style>";\r
+ $legend.="</style>";\r
+ }\r
}\r
\r
}//end loop symbols in gml\r
\r
$xsl->setParameter( '', 'label_field', $label_field);\r
\r
- $style = realpath('areas_legend_no.xsl');\r
+ $style = realpath(dirname(__FILE__)."/".'areas_legend_no.xsl');\r
\r
$dom_new = new DOMDocument();\r
\r
\r
$leg_path_towrite="/var/www/synthesys/www/v1/sld/$random";\r
\r
- $fp=fopen("$leg_path_towrite","w");\r
+ $fp=fopen("$leg_path_towrite","w+");\r
\r
$write=fwrite($fp,$out);\r
\r
\r
}\r
\r
+ if(strlen($displayedLayer)==0||strlen($field)==0)\r
+ {\r
+ print("It seems that the name of the layer for area and/or the name of its indexing column is missing. \n Syntax is \"ad=layer_name:indexer_column:alias_for_style:Value in DB\" (exemple: \"&ad=em_tiny_jan2003:emarea:a:Ge\")\n Please check the structure of the layer in WMS/WFS for the name of the columns");\r
+ }\r
+\r
$xsl->setParameter( '', 'layer', $displayedLayer);\r
//ftheeten 2011/05/27\r
\r
//$xsl->setParameter( '', 'label_field', $label_field);\r
$xsl->setParameter( '', 'label_field', $field);\r
\r
- $style = realpath('areas_pattern.xsl');\r
+ $style = realpath(dirname(__FILE__)."/".'areas_pattern.xsl');\r
\r
$dom_new->load($style);\r
\r
\r
$url2_array=array();\r
$url2="";\r
- $c="convert convert -size '".$width."x".$height."' xc:transparent $random3";\r
+ $c=" convert -size '".$width."x".$height."' xc:transparent $random3";\r
if(isset($arrayBackgroundStyle)===true)\r
{\r
if(count($arrayBackgroundStyle)>0)\r
//print($returnedXML);\r
$path_towrite="/var/www/synthesys/www/v1/sld/"."_backsld_".$displayedLayer_sld.$random;\r
//print($path_towrite);\r
- xml_to_sld_xslt($returnedXML, $displayedLayer_sld,'areas_pattern.xsl', $path_towrite );\r
+ xml_to_sld_xslt($returnedXML, $displayedLayer_sld,dirname(__FILE__)."/".'areas_pattern.xsl', $path_towrite );\r
$url_back_sld=V1_SLD_URL."/_backsld_".$displayedLayer_sld.$random;\r
$url2.="&SLD=".$url_back_sld;\r
}\r
\r
\r
\r
- $c="convert convert -size '".$width."x".$height."' xc:transparent $random3";\r
+ $c=" convert -size '".$width."x".$height."' xc:transparent $random3";\r
\r
shell_exec($c);\r
\r
}\r
elseif(count($url_list)==0)\r
{\r
- $c="convert convert -size '".$width."x".$height."' xc:transparent $random2";\r
+ $c="convert -size '".$width."x".$height."' xc:transparent $random2";\r
\r
shell_exec($c);\r
}\r
\r
$legend_url=URL_GEOSERVER."/wms?REQUEST=GetLegendGraphic&VERSION=1.1.1&format=image/png&WIDTH=64&HEIGHT=36&";\r
\r
+\r
$legend_url.="layer=topp:tdwg_level_3&LEGEND_OPTIONS=forceLabels:on;fontStyle:italic;fontSize:12&SLD=".$leg_url;\r
$com="convert '$legend_url' '$random2_legend'";\r
shell_exec($com);\r
//{\r
if(strtolower($img)=='false')\r
{\r
- $headerText="Content-Type: application/json"; \r
- header($headerText);\r
- header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1\r
- header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé\r
+ $headerText="Content-Type: application/json";\r
+ if($p_no_header_for_tests===FALSE)\r
+ { \r
+ header($headerText);\r
+ header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1\r
+ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé\r
+ } \r
print($json);\r
}\r
else\r
{\r
- $headerText="Content-Type: image/png"; \r
- header($headerText);\r
- header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1\r
- header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé\r
- \r
+ if($p_no_header_for_tests===FALSE)\r
+ {\r
+ $headerText="Content-Type: image/png"; \r
+ header($headerText);\r
+ header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1\r
+ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé\r
+ }\r
+ \r
readfile($random2);\r
\r
}\r
// print($errorMessage);\r
//}\r
\r
- ob_flush();\r
+ //ob_flush();\r
if(strtolower($p_jsoncreatefile)!="true")\r
{\r
unlink($random2);\r