[Mapserver-users] Re: querybyattributes with Postgres/Postgis Layer
Damian Schroder
map_surfer at yahoo.com
Mon Dec 1 12:09:47 PST 2003
--0-735338114-1070309387=:61657
Content-Type: text/plain; charset=us-ascii
You should try using a filter with querybyrect. here is an example:
$oRect = $oMap->extent;//or set it to your map's max extents
$oLayer = $oMap->getLayerbyName("yourlayername");
$filter = "\"query ="."'".$yourattributename."'\"";
$oLayer->setFilter($filter);
if ($oLayer->queryByrect($oRect) == MS_SUCCESS){
whatever you want to code here
}
Nicol Hermann <mapserver at geochem.de> wrote:
Hi Colin,
thank you very much for your answer.
I'am not sure if i understood your tip correct.
I modified my code to:
$layer = $Map ->getLayerbyname("Regionen");
$layer -> set("status", MS_ON );
$cobj = $layer -> getclass(0);
$cobj -> set ("template", "postgis_query_attribut.php");
$status = $layer->querybyattributes("plzort01", "Mutterstadt",
MS_MULTIPLE);
The url/filename of my template is the name of the script itself. Is
this right?
When i execute my script with the 'getclass(0)' request the Message:
"Warning: [MapServer Error]: prep_DB(): Error executing POSTGIS DECLARE
..." disappeared and i get back a blank page. If i comment out the line
with this request the message appears again.
I both cases i futher on get the Message:
ERROR: Attribute "mutterstadt" not found
on my shell whenever i reload my script.
According to the documentation "mutterstadt" is the 'qstring' of the
method an not the 'qitem' (->
int queryByAttributes(string qitem, string qstring, int mode) )
Futher hints would be greatly appreciated.
Many thanks
Nicol
Am Mo, 2003-12-01 um 15.25 schrieb cgowens at softhome.net:
> Try using the TEMPLATE option under CLASS for the LAYER. Set the the url to
> your query.php file that runs the SQL statement.
>
> Colin
>
>
> mapserver-users-request at lists.gis.umn.edu writes:
>
> > Send Mapserver-users mailing list submissions to
> > mapserver-users at lists.gis.umn.edu
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> > or, via email, send a message with subject or body 'help' to
> > mapserver-users-request at lists.gis.umn.edu
> >
> > You can reach the person managing the list at
> > mapserver-users-admin at lists.gis.umn.edu
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of Mapserver-users digest..."
> >
> >
> > Today's Topics:
> >
> > 1. Problems with tab files in MapLab (Stephen Wallace)
> > 2. Re: [ms4w-users] Problems with tab files in MapLab (Daniel Morissette)
> > 3. MapServer passes 82/83 tests of the OGC WMS testsuite (Daniel Morissette)
> > 4. Re: MapServer passes 82/83 tests of the OGC WMS testsuite (Daniel Morissette)
> > 5. Re: Re: MapServer passes 82/83 tests of the OGC
> > WMS testsuite (Doug Cates)
> > 6. RE: MapServer passes 82/83 tests of the OGC WMS
> > testsuite (Kralidis,Tom [Burlington])
> > 7. Re: Re: MapServer passes 82/83 tests of the OGC
> > WMS testsuite (Gerry Creager N5JXS)
> > 8. Re: MapServer passes 82/83 tests of the OGC WMS testsuite (Bart van den Eijnden)
> > 9. Re: querybyattributes with Postgres/Postgis Layer (Damian Schroder)
> > 10. Segmentation Fault -- reference image -- PHP (Ed Martin)
> >
> > --__--__--
>
> >
> > Message: 9
> > Date: Sat, 29 Nov 2003 08:41:48 -0800 (PST)
> > From: Damian Schroder
> > Subject: Re: [Mapserver-users] querybyattributes with Postgres/Postgis Layer
> > To: mapserver-users at lists.gis.umn.edu
> >
> > --0-1435250590-1070124108=:89418
> > Content-Type: text/plain; charset=us-ascii
> >
> > try using a filter instead of querybyattributes.
> >
> > Nicol Hermann wrote:Dear List,
> >
> > i trying to do a querybyattributes Query with a Postgres/Postgis layer
> > and get the following error:
> >
> > Warning: [MapServer Error]: prep_DB(): Error executing POSTGIS DECLARE
> > (the actual query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT
> > plzort01::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),OID::text from plz_gebiete WHERE (Mutterstadt) and (the_geom && setSRID( 'BOX3D(5.865627 46.57242768,15.039879 55.75900832)'::BOX3D,find_srid('','plz_gebiete','the_geom') ))'
> >
> > here is the relevant part of my code:
> >
> > $layer = $Map ->getLayerbyname("Regionen");
> > $layer -> set("status", MS_ON );
> > $status = $layer->querybyattributes("plzort01", "Mutterstadt",
> > MS_MULTIPLE);
> >
> > It seems that the 'qitem' (plzort01) won't be evaluated because it is
> > not present in the SQL statement.
> > I also tried the qitem with upper case. The same error appears.
> >
> > The debugging message on my shell says:
> > ERROR: Attribute "mutterstadt" not found
> >
> > My Postgis Version is: Mappostgis.c - version of June 12/2003.
> > and i`am using Mapserver 4.0.1 on a Linux box.
> >
> > Does anybody know how I can solve this problem?
> > Many thanks
> > Nicol
> >
> >
> > --
> > Nicol Hermann
> >
> > _______________________________________________
> > Mapserver-users mailing list
> > Mapserver-users at lists.gis.umn.edu
> > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > Free Pop-Up Blocker - Get it now
> > --0-1435250590-1070124108=:89418
> > Content-Type: text/html; charset=us-ascii
> >
> > try using a filter instead of querybyattributes.
Nicol Hermann <mapserver at geochem.de> wrote:
> > Dear List,
i trying to do a querybyattributes Query with a Postgres/Postgis layer
and get the following error:
Warning: [MapServer Error]: prep_DB(): Error executing POSTGIS DECLARE
(the actual query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT
plzort01::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),OID::text from plz_gebiete WHERE (Mutterstadt) and (the_geom && setSRID( 'BOX3D(5.865627 46.57242768,15.039879 55.75900832)'::BOX3D,find_srid('','plz_gebiete','the_geom') ))'
here is the relevant part of my code:
$layer = $Map ->getLayerbyname("Regionen");
$layer -> set("status", MS_ON );
$status = $layer->querybyattributes("plzort01", "Mutterstadt",
MS_MULTIPLE);
It seems that the 'qitem' (plzort01) won't be evaluated because it is
not present in the SQL statement.
I also tried t!
he!
> q!
> > item with
> > upper case. The same error appears.
The debugging message on my shell says:
ERROR: Attribute "mutterstadt" not found
My Postgis Version is: Mappostgis.c - version of June 12/2003.
and i`am using Mapserver 4.0.1 on a Linux box.
Does anybody know how I can solve this problem?
Many thanks
Nicol
--
Nicol Hermann
_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
---------------------------------
> > Do you Yahoo!?
> > Free Pop-Up Blocker - Get it now
> > --0-1435250590-1070124108=:89418--
> >
> > --__--__--
> >
> > Message: 10
> > Date: Sat, 29 Nov 2003 11:59:53 -0500
> > From: Ed Martin
> > To: mapserver-users at lists.gis.umn.edu
> > Subject: [Mapserver-users] Segmentation Fault -- reference image -- PHP
> >
> > i am using the map file and map stuff from the cvs mapserver (did not
> > compile from cvs, i used the stable version 4.0.1) and when i try to
> > get the reference image using a very simple script i get the jpeg
> > header an then a segmentation fault when run in the command line and a
> > blank page when in a browser, turning off the jpeg header still gives
> > me a blank page
> >
> > here is the php file i am using
> >
> > > > require_once('../inc/conf.inc.php');//get config
> > //load mapscript
> > dl("php_mapscript.so");
> > header("Content-type: image/jpeg");
> > // start map
> > $map=ms_newMapObj("tests/test.map");
> > $img=$map->drawReferenceMap();
> > $img->saveImage('');
> > ?>
> >
> > and here is the reference part of the map file
> >
> > #refence map
> > REFERENCE
> > IMAGE ./reference.jpeg
> > EXTENT -0.5 50.977222 0.5 51.977222
> > SIZE 120 120
> > STATUS ON
> > COLOR 255 255 0
> > OUTLINECOLOR 255 100 0
> > STATUS ON
> > MARKER "line"
> > MARKERSIZE 5
> > MINBOXSIZE 50
> > MINBOXSIZE 100
> > END
> >
> > i have output set to jpeg and changing the reference image to jpg or
> > png doesn't help and i tried gif and that gave an error saying that it
> > couldn't load it (probably because gifs aren't supported by gd, but
> > this page (
> > http://mapserver.gis.umn.edu/doc40/mapfile-reference.html#referencemap
> > ) says it has to be a gif)
> >
> > could it be the way i made the reference image, i just took the main
> > image, cropped out the boarder, shrunk it to 120x120 and saved it in
> > various formats
> >
> > i see nothing in my apache logs, but i know it is logging to them
> > because a parse error will show up, i have error reporting set to the
> > highest (E_ALL), i'm using mapserver 4.0.1, php 4.3.4 as CGI, apache
> > 2.0.48, slackware linux 9.0
> >
> > so does anyone have any clue as to what is causing this, my map file,
> > do i have to put more stuff in the php file, is it the way i made the
> > image, or is it a bug
> >
> >
> >
> > --__--__--
> >
> > _______________________________________________
> > Mapserver-users mailing list
> > Mapserver-users at lists.gis.umn.edu
> > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> >
> >
> > End of Mapserver-users Digest
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
--
Nicol Hermann
_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
---------------------------------
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
--0-735338114-1070309387=:61657
Content-Type: text/html; charset=us-ascii
<DIV>You should try using a filter with querybyrect. here is an example:</DIV>
<DIV><FONT size=2>
<P>$oRect = $oMap->extent;//or set it to your map's max extents</P>
<P>$oLayer = $oMap->getLayerbyName("yourlayername");</P>
<P>$filter = "\"query ="."'".$yourattributename."'\"";</P>
<P>$oLayer->setFilter($filter);</P>
<P>if ($oLayer->queryByrect($oRect) == MS_SUCCESS){</P>
<P>whatever you want to code here</P></FONT>}<BR><BR><B><I>Nicol Hermann <mapserver at geochem.de></I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hi Colin,<BR><BR>thank you very much for your answer.<BR>I'am not sure if i understood your tip correct.<BR><BR>I modified my code to:<BR><BR>$layer = $Map ->getLayerbyname("Regionen");<BR>$layer -> set("status", MS_ON );<BR>$cobj = $layer -> getclass(0);<BR>$cobj -> set ("template", "postgis_query_attribut.php");<BR>$status = $layer->querybyattributes("plzort01", "Mutterstadt",<BR>MS_MULTIPLE);<BR><BR>The url/filename of my template is the name of the script itself. Is<BR>this right?<BR><BR>When i execute my script with the 'getclass(0)' request the Message: <BR>"Warning: [MapServer Error]: prep_DB(): Error executing POSTGIS DECLARE<BR>..." disappeared and i get back a blank page. If i comment out the line<BR>with this request the message appears again. <BR><BR>I both cases i futher on get the Message:<BR>ERROR: Attribute "mutterstadt" not found<BR>on my shell whenever
i reload my script.<BR><BR>According to the documentation "mutterstadt" is the 'qstring' of the<BR>method an not the 'qitem' (-><BR>int queryByAttributes(string qitem, string qstring, int mode) )<BR><BR>Futher hints would be greatly appreciated.<BR>Many thanks<BR>Nicol<BR><BR><BR>Am Mo, 2003-12-01 um 15.25 schrieb cgowens at softhome.net:<BR>> Try using the TEMPLATE option under CLASS for the LAYER. Set the the url to <BR>> your query.php file that runs the SQL statement. <BR>> <BR>> Colin <BR>> <BR>> <BR>> mapserver-users-request at lists.gis.umn.edu writes: <BR>> <BR>> > Send Mapserver-users mailing list submissions to<BR>> > mapserver-users at lists.gis.umn.edu <BR>> > <BR>> > To subscribe or unsubscribe via the World Wide Web, visit<BR>> > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users<BR>> > or, via email, send a message with subject or body 'help' to<BR>> > mapserver-users-request at lists.gis.umn.edu <BR>>
> <BR>> > You can reach the person managing the list at<BR>> > mapserver-users-admin at lists.gis.umn.edu <BR>> > <BR>> > When replying, please edit your Subject line so it is more specific<BR>> > than "Re: Contents of Mapserver-users digest..." <BR>> > <BR>> > <BR>> > Today's Topics: <BR>> > <BR>> > 1. Problems with tab files in MapLab (Stephen Wallace)<BR>> > 2. Re: [ms4w-users] Problems with tab files in MapLab (Daniel Morissette)<BR>> > 3. MapServer passes 82/83 tests of the OGC WMS testsuite (Daniel Morissette)<BR>> > 4. Re: MapServer passes 82/83 tests of the OGC WMS testsuite (Daniel Morissette)<BR>> > 5. Re: Re: MapServer passes 82/83 tests of the OGC<BR>> > WMS testsuite (Doug Cates)<BR>> > 6. RE: MapServer passes 82/83 tests of the OGC WMS<BR>> > testsuite (Kralidis,Tom [Burlington])<BR>> > 7. Re: Re: MapServer passes 82/83 tests of the OGC<BR>> > WMS testsuite
(Gerry Creager N5JXS)<BR>> > 8. Re: MapServer passes 82/83 tests of the OGC WMS testsuite (Bart van den Eijnden)<BR>> > 9. Re: querybyattributes with Postgres/Postgis Layer (Damian Schroder)<BR>> > 10. Segmentation Fault -- reference image -- PHP (Ed Martin) <BR>> > <BR>> > --__--__--<BR>> <BR>> > <BR>> > Message: 9<BR>> > Date: Sat, 29 Nov 2003 08:41:48 -0800 (PST)<BR>> > From: Damian Schroder <MAP_SURFER at YAHOO.COM><BR>> > Subject: Re: [Mapserver-users] querybyattributes with Postgres/Postgis Layer<BR>> > To: mapserver-users at lists.gis.umn.edu <BR>> > <BR>> > --0-1435250590-1070124108=:89418<BR>> > Content-Type: text/plain; charset=us-ascii <BR>> > <BR>> > try using a filter instead of querybyattributes. <BR>> > <BR>> > Nicol Hermann <MAPSERVER at GEOCHEM.DE>wrote:Dear List, <BR>> > <BR>> > i trying to do a querybyattributes Query with a Postgres/Postgis
layer<BR>> > and get the following error: <BR>> > <BR>> > Warning: [MapServer Error]: prep_DB(): Error executing POSTGIS DECLARE<BR>> > (the actual query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT<BR>> > plzort01::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),OID::text from plz_gebiete WHERE (Mutterstadt) and (the_geom && setSRID( 'BOX3D(5.865627 46.57242768,15.039879 55.75900832)'::BOX3D,find_srid('','plz_gebiete','the_geom') ))' <BR>> > <BR>> > here is the relevant part of my code: <BR>> > <BR>> > $layer = $Map ->getLayerbyname("Regionen");<BR>> > $layer -> set("status", MS_ON );<BR>> > $status = $layer->querybyattributes("plzort01", "Mutterstadt",<BR>> > MS_MULTIPLE); <BR>> > <BR>> > It seems that the 'qitem' (plzort01) won't be evaluated because it is<BR>> > not present in the SQL statement.<BR>> > I also tried the qitem with upper case. The
same error appears. <BR>> > <BR>> > The debugging message on my shell says: <BR>> > ERROR: Attribute "mutterstadt" not found <BR>> > <BR>> > My Postgis Version is: Mappostgis.c - version of June 12/2003. <BR>> > and i`am using Mapserver 4.0.1 on a Linux box. <BR>> > <BR>> > Does anybody know how I can solve this problem?<BR>> > Many thanks<BR>> > Nicol <BR>> > <BR>> > <BR>> > -- <BR>> > Nicol Hermann <BR>> > <BR>> > _______________________________________________<BR>> > Mapserver-users mailing list<BR>> > Mapserver-users at lists.gis.umn.edu<BR>> > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users<BR>> > <BR>> > <BR>> > ---------------------------------<BR>> > Do you Yahoo!?<BR>> > Free Pop-Up Blocker - Get it now<BR>> > --0-1435250590-1070124108=:89418<BR>> > Content-Type: text/html; charset=us-ascii <BR>> > <BR>>
>
<DIV>try using a filter instead of querybyattributes.<BR><BR><B><I>Nicol Hermann <mapserver at geochem.de></I></B> wrote:<BR>> >
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Dear List,<BR><BR>i trying to do a querybyattributes Query with a Postgres/Postgis layer<BR>and get the following error:<BR><BR>Warning: [MapServer Error]: prep_DB(): Error executing POSTGIS DECLARE<BR>(the actual query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT<BR>plzort01::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),OID::text from plz_gebiete WHERE (Mutterstadt) and (the_geom && setSRID( 'BOX3D(5.865627 46.57242768,15.039879 55.75900832)'::BOX3D,find_srid('','plz_gebiete','the_geom') ))'<BR><BR>here is the relevant part of my code:<BR><BR>$layer = $Map ->getLayerbyname("Regionen");<BR>$layer -> set("status", MS_ON );<BR>$status = $layer->querybyattributes("plzort01", "Mutterstadt",<BR>MS_MULTIPLE);<BR><BR>It seems that the 'qitem' (plzort01) won't be evaluated because it is<BR>not present in the SQL statement.<BR>I also tried
t!<BR>he!<BR>> q!<BR>> > item with<BR>> > upper case. The same error appears.<BR><BR>The debugging message on my shell says: <BR>ERROR: Attribute "mutterstadt" not found<BR><BR>My Postgis Version is: Mappostgis.c - version of June 12/2003. <BR>and i`am using Mapserver 4.0.1 on a Linux box.<BR><BR>Does anybody know how I can solve this problem?<BR>Many thanks<BR>Nicol<BR><BR><BR>-- <BR>Nicol Hermann <MAPSERVER at GEOCHEM.DE><BR><BR>_______________________________________________<BR>Mapserver-users mailing list<BR>Mapserver-users at lists.gis.umn.edu<BR>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users</BLOCKQUOTE></DIV>
<P>
<HR SIZE=1>
<BR>> > Do you Yahoo!?<BR><BR>> > <A href="http://us.rd.yahoo.com/slv/mailtag/*http://companion.yahoo.com/">Free Pop-Up Blocker - Get it now</A><BR>> > --0-1435250590-1070124108=:89418-- <BR>> > <BR>> > --__--__-- <BR>> > <BR>> > Message: 10<BR>> > Date: Sat, 29 Nov 2003 11:59:53 -0500<BR>> > From: Ed Martin <EDMAN007X at MAC.COM><BR>> > To: mapserver-users at lists.gis.umn.edu<BR>> > Subject: [Mapserver-users] Segmentation Fault -- reference image -- PHP <BR>> > <BR>> > i am using the map file and map stuff from the cvs mapserver (did not <BR>> > compile from cvs, i used the stable version 4.0.1) and when i try to <BR>> > get the reference image using a very simple script i get the jpeg <BR>> > header an then a segmentation fault when run in the command line and a <BR>> > blank page when in a browser, turning off the jpeg header still gives <BR>> > me a blank page <BR>> >
<BR>> > here is the php file i am using <BR>> > <BR>> > <?<br>> > require_once('../inc/conf.inc.php');//get config<BR>> > //load mapscript<BR>> > dl("php_mapscript.so");<BR>> > header("Content-type: image/jpeg");<BR>> > // start map<BR>> > $map=ms_newMapObj("tests/test.map");<BR>> > $img=$map->drawReferenceMap();<BR>> > $img->saveImage('');<BR>> > ?> <BR>> > <BR>> > and here is the reference part of the map file <BR>> > <BR>> > #refence map<BR>> > REFERENCE<BR>> > IMAGE ./reference.jpeg<BR>> > EXTENT -0.5 50.977222 0.5 51.977222<BR>> > SIZE 120 120<BR>> > STATUS ON<BR>> > COLOR 255 255 0<BR>> > OUTLINECOLOR 255 100 0<BR>> > STATUS ON<BR>> > MARKER "line"<BR>> > MARKERSIZE 5<BR>> > MINBOXSIZE 50<BR>> > MINBOXSIZE 100<BR>> > END <BR>> > <BR>> > i have output set to jpeg and changing the
reference image to jpg or <BR>> > png doesn't help and i tried gif and that gave an error saying that it <BR>> > couldn't load it (probably because gifs aren't supported by gd, but <BR>> > this page ( <BR>> > http://mapserver.gis.umn.edu/doc40/mapfile-reference.html#referencemap<BR>> > ) says it has to be a gif) <BR>> > <BR>> > could it be the way i made the reference image, i just took the main <BR>> > image, cropped out the boarder, shrunk it to 120x120 and saved it in <BR>> > various formats <BR>> > <BR>> > i see nothing in my apache logs, but i know it is logging to them <BR>> > because a parse error will show up, i have error reporting set to the <BR>> > highest (E_ALL), i'm using mapserver 4.0.1, php 4.3.4 as CGI, apache <BR>> > 2.0.48, slackware linux 9.0 <BR>> > <BR>> > so does anyone have any clue as to what is causing this, my map file, <BR>> > do i have to put more stuff
in the php file, is it the way i made the <BR>> > image, or is it a bug <BR>> > <BR>> > <BR>> > <BR>> > --__--__-- <BR>> > <BR>> > _______________________________________________<BR>> > Mapserver-users mailing list<BR>> > Mapserver-users at lists.gis.umn.edu<BR>> > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users<BR>> > <BR>> > <BR>> > End of Mapserver-users Digest<BR>> <BR>> _______________________________________________<BR>> Mapserver-users mailing list<BR>> Mapserver-users at lists.gis.umn.edu<BR>> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users<BR>-- <BR>Nicol Hermann <MAPSERVER at GEOCHEM.DE><BR><BR>_______________________________________________<BR>Mapserver-users mailing list<BR>Mapserver-users at lists.gis.umn.edu<BR>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users</BLOCKQUOTE><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/slv/mailtag/*http://companion.yahoo.com/">Free Pop-Up Blocker - Get it now</a>
--0-735338114-1070309387=:61657--
More information about the MapServer-users
mailing list