[Mapserver-users] phpmapscript getShape ???
steff
stephane.riff at cerene.fr
Fri Apr 11 05:33:25 PDT 2003
This is a multi-part message in MIME format.
------=_NextPart_000_0005_01C30037.4F816FF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all.
My problem is :
I've got a postgis layer
LAYER
CONNECTIONTYPE postgis
NAME "Contour_Departements"
CONNECTION "dbname=3Ddb port=3D5555 user=3Dapache"
DATA "the_geom from giscontourdepartement"
TYPE POLYGON
STATUS OFF
GROUP "Contour"
# FILTER "shapdpt_id LIKE '%value%%'"
HEADER blank.html
FOOTER blank.html
CLASS
NAME "Contour_Departements1"
EXPRESSION ([dept_id] =3D 0)
SYMBOL "star"
SIZE 8
OUTLINECOLOR 255 0 0
COLOR 255 0 255
OVERLAYSYMBOL "downwarddiagonalfill"
OVERLAYSIZE 6
OVERLAYCOLOR 0 0 0
TEMPLATE "itemquery_template.html"
END
CLASS
NAME "Contour_Departements2"
EXPRESSION ([dept_id] =3D 1)
SYMBOL "cross"
SIZE 8
OUTLINECOLOR 255 0 0
COLOR 255 128 64
TEMPLATE "itemquery_template.html"
END
METADATA
LYRNAME "Contour de D=E9partements"
TABLE_NAME "giscontourdepartement"
RESULT_FIELDS "area"
WMS_SRS "EPSG:27582"
WMS_ORDER "2"
END
END
I want to query this layer with :
$nClickGeoX =3D pix2Geo($_SESSION["map_x"], 0, $map->width,$dfMinX, =
$dfMaxX, 0);
$nClickGeoY =3D pix2Geo($_SESSION["map_y"], 0, $map->height,$dfMinY, =
$dfMaxY, 1);
$oClickGeo =3D ms_newPointObj();
$oClickGeo->setXY($nClickGeoX, $nClickGeoY);
$err =3D @$map->queryByPoint($oClickGeo, MS_SINGLE, -1);
if($err =3D=3D MS_SUCCESS)
{
$queryResults=3DTRUE;
dumpQueryResults () ;
print( "<script =
language=3D\"javascript\">parent.queryResult.window.location =
=3D\"legend/queryResult.php\";</script>" );
}
function dumpQueryResults()
{
GLOBAL $map;
$numResultsTotal =3D 0;
$fp =3D fopen("legend/queryResult.php", "w+");
for($iLayer=3D0; $iLayer < $map->numlayers; $iLayer++)
{
$oLayer =3D $map->GetLayer($iLayer);
$numResults =3D $oLayer->getNumResults();
if ($numResults =3D=3D 0)
continue; // No results in this layer
// Open layer's table... take the list of fields to display from =
// the "HEADERRESULT_FIELDS" metadata in the layer object.
//$oLayer->open($map->shapepath);
$oLayer->open("");
$selFields =3D explode(" ", =
$oLayer->getMetaData("RESULT_FIELDS")); =20
fwrite($fp,"<html>\n<body bgcolor=3D\"#ADCEED\">\n<TABLE =
BORDER=3D0 CELLSPACING=3D1 CELLPADDING=3D2 WIDTH=3D100%%>\n");
fwrite($fp,"<TR>\n");
fwrite($fp,"<TD COLSPAN=3D".sizeof($selFields)." =
BGCOLOR=3D#C1D8E3>");
fwrite($fp,"<CENTER> ".$oLayer->getMetaData("LYRNAME")." =
</CENTER>" );
fwrite($fp,"</TR>\n");=20
//
// Table header: attribute names...
//
fwrite($fp,"<TR>\n");=20
for ($iField=3D0; $iField < sizeof($selFields); $iField++)
{
fwrite($fp,"<TD BGCOLOR=3D#E2EFF5>");
fwrite($fp,"".$selFields[$iField]."");
fwrite($fp,"</TD>");
}
fwrite($fp,"</TR>\n");
//
// One row in table for each selected record
//
for ($iRes=3D0; $iRes < $numResults; $iRes++)
{
$oRes =3D $oLayer->getResult($iRes);
if($oRes !=3D FALSE)
{
$oShape =3D $oLayer->getShape(-1,$oRes->shapeindex);
fwrite($fp,"<TR>\n");
//fwrite($fp,"<!-- =
bounds(".$oShape->bounds->minx.",".$oShape->bounds->miny.")-(".$oShape->b=
ounds->maxx.",."$oShape->bounds->maxy.")-->\n" );
for($iField=3D0; $iField < sizeof($selFields); $iField++)
{
fwrite($fp,"<TD BGCOLOR=3D#FFFFFF>");
fwrite($fp,"".$oShape->values[$selFields[$iField]]."");
fwrite($fp,"</TD>");
}
fwrite($fp,"</TR>\n");
$oShape->free();
$numResultsTotal++;
}
}
$oLayer->close();
fwrite($fp,"</TABLE>\n</body>\n</html>\n");
}
if ($numResultsTotal =3D=3D 0)
fwrite($fp,"Nothing found at query location.");
fclose($fp);
}
But i get always the same error :
Fatal error: Assertion failed, Could not set shape values: 0, 0
I already look in the users-list but there is no answer...
The only answer is to use layer->open(""); but i already do this =
without result....
So help me please
------=_NextPart_000_0005_01C30037.4F816FF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi all.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>My problem is :</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> I've got a postgis =
layer</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>LAYER<BR> CONNECTIONTYPE =
postgis<BR> =20
NAME "Contour_Departements"<BR> CONNECTION "dbname=3Ddb =
port=3D5555=20
user=3Dapache"<BR> DATA "the_geom from =
giscontourdepartement"<BR> TYPE=20
POLYGON<BR> STATUS OFF<BR> GROUP "Contour"<BR># FILTER =
"shapdpt_id LIKE '%value%%'"<BR> HEADER blank.html<BR> =
FOOTER=20
blank.html<BR> CLASS<BR> NAME=20
"Contour_Departements1"<BR> EXPRESSION ([dept_id] =3D=20
0)<BR> SYMBOL "star"<BR> SIZE=20
8<BR> OUTLINECOLOR 255 0 0<BR> COLOR =
255 0=20
255<BR> OVERLAYSYMBOL=20
"downwarddiagonalfill"<BR> OVERLAYSIZE =
6<BR> =20
OVERLAYCOLOR 0 0 0<BR> TEMPLATE=20
"itemquery_template.html"<BR> END<BR> =
CLASS<BR> =20
NAME "Contour_Departements2"<BR> EXPRESSION ([dept_id] =
=3D=20
1)<BR> SYMBOL "cross"<BR> SIZE=20
8<BR> OUTLINECOLOR 255 0 0<BR> COLOR =
255 128=20
64<BR> TEMPLATE "itemquery_template.html"<BR> =20
END</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> METADATA<BR> LYRNAME =
"Contour de=20
D=E9partements"<BR> TABLE_NAME =
"giscontourdepartement"<BR> =20
RESULT_FIELDS "area"<BR> WMS_SRS =
"EPSG:27582"<BR> =20
WMS_ORDER "2"<BR> END</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>END</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I want to query this layer with =
:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial =
size=3D2> $nClickGeoX =3D=20
pix2Geo($_SESSION["map_x"], 0, $map->width,$dfMinX, $dfMaxX,=20
0);<BR> $nClickGeoY =3D pix2Geo($_SESSION["map_y"], 0, =
$map->height,$dfMinY, $dfMaxY, 1);<BR> $oClickGeo =
=3D=20
ms_newPointObj();<BR> =
$oClickGeo->setXY($nClickGeoX,=20
$nClickGeoY);<BR> $err =3D =
@$map->queryByPoint($oClickGeo,=20
MS_SINGLE, -1);<BR> if($err =3D=3D=20
MS_SUCCESS)<BR> {<BR> =20
$queryResults=3DTRUE;<BR> dumpQueryResults =
()=20
;<BR> print( "<script=20
language=3D\"javascript\">parent.queryResult.window.location=20
=3D\"legend/queryResult.php\";</script>" );<BR> =20
}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>function=20
dumpQueryResults()<BR>{<BR> GLOBAL $map;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> $numResultsTotal =3D =
0;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> $fp =3D=20
fopen("legend/queryResult.php", "w+");</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> for($iLayer=3D0; =
$iLayer <=20
$map->numlayers; $iLayer++)<BR> =20
{<BR> $oLayer =3D=20
$map->GetLayer($iLayer);</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> =20
$numResults =3D $oLayer->getNumResults();</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> if=20
($numResults =3D=3D=20
0)<BR> =
continue; // No results in this layer</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> // Open=20
layer's table... take the list of fields to display from=20
<BR> // the =
"HEADERRESULT_FIELDS"=20
metadata in the layer =
object.<BR> =20
//$oLayer->open($map->shapepath);<BR> =
=20
$oLayer->open("");</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> =20
$selFields =3D explode(" ",=20
$oLayer->getMetaData("RESULT_FIELDS")); <=
BR> =20
fwrite($fp,"<html>\n<body bgcolor=3D\"#ADCEED\">\n<TABLE =
BORDER=3D0=20
CELLSPACING=3D1 CELLPADDING=3D2=20
WIDTH=3D100%%>\n");<BR> =20
fwrite($fp,"<TR>\n");<BR> =
=20
fwrite($fp,"<TD COLSPAN=3D".sizeof($selFields)."=20
BGCOLOR=3D#C1D8E3>");<BR> =20
fwrite($fp,"<CENTER> ".$oLayer->getMetaData("LYRNAME")."=20
</CENTER>" );<BR> =20
fwrite($fp,"</TR>\n"); <BR>  =
; =20
//<BR> // Table header: =
attribute=20
names...<BR> =20
//<BR> =20
fwrite($fp,"<TR>\n"); <BR> =
=20
for ($iField=3D0; $iField < sizeof($selFields);=20
$iField++)<BR> =20
{<BR> =20
fwrite($fp,"<TD=20
BGCOLOR=3D#E2EFF5>");<BR> &nb=
sp; =20
fwrite($fp,"".$selFields[$iField]."");<BR> &=
nbsp; =20
fwrite($fp,"</TD>");<BR> =
}<BR> =20
fwrite($fp,"</TR>\n");</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
//<BR> // One row in =
table for=20
each selected record<BR> =20
//</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> for=20
($iRes=3D0; $iRes < $numResults;=20
$iRes++)<BR> =20
{<BR> =
$oRes =3D=20
$oLayer->getResult($iRes);<BR> =20
if($oRes !=3D=20
FALSE)<BR> =20
{<BR> &n=
bsp; =20
$oShape =3D $oLayer->getShape(-1,$oRes->shapeindex);</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
fwrite($fp,"<TR>\n");</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
//fwrite($fp,"<!--=20
bounds(".$oShape->bounds->minx.",".$oShape->bounds->miny.")-(=
".$oShape->bounds->maxx.",."$oShape->bounds->maxy.")-->\n"=
=20
);</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
for($iField=3D0; $iField < sizeof($selFields);=20
$iField++)<BR>  =
; =20
{<BR> &n=
bsp; =20
fwrite($fp,"<TD=20
BGCOLOR=3D#FFFFFF>");<BR> &nb=
sp; =20
fwrite($fp,"".$oShape->values[$selFields[$iField]]."");<BR>  =
; =
=20
fwrite($fp,"</TD>");<BR> &=
nbsp; =20
}<BR> &n=
bsp; =20
fwrite($fp,"</TR>\n");</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
$oShape->free();</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
$numResultsTotal++;<BR> &n=
bsp; =20
}<BR> }</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> =20
$oLayer->close();</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> =20
fwrite($fp,"</TABLE>\n</body>\n</html>\n");<BR> &n=
bsp; =20
}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> if ($numResultsTotal =
=3D=3D=20
0)<BR> fwrite($fp,"Nothing =
found at=20
query location.");<BR> fclose($fp);<BR>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>But i get always the same error =
:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> <FONT size=3D3><FONT=20
face=3D"Times New Roman"><STRONG>Fatal error</STRONG>: Assertion failed, =
Could not=20
set shape values: 0, 0</FONT></FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I already look in the users-list but =
there is no=20
answer...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>The only answer is to use =
layer->open("");=20
but i already do this without result....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>So help me =
please</FONT></DIV></BODY></HTML>
------=_NextPart_000_0005_01C30037.4F816FF0--
More information about the MapServer-users
mailing list