mapscript: $result->shapeindex returns 0 and querying failed

Lin Huang linh200210 at YAHOO.COM
Thu Oct 6 15:57:29 EDT 2005


Hi,

I posted this question earlier today. Hope someone has
seen this problem. One more thing is that the data I
used for this layer is from a "view" instead of a
"table" in the database. Would that cause query to
fail? 

Thanks very much for any help.

Lin  

--- Lin Huang <linh200210 at YAHOO.COM> wrote:

> Hi all,
> 
> My mapserver application using PHP/mapscripts works
> great. But I got errors when doing a query and hope
> someone could point out where did I do wrong.
> 
> The query part in my php code:
> ------------
> $layer = $mMap->getLayerByName(sites);
> 
> $layer->open();
> 
> //Querying one layer
> $res = $layer->getResult(0);    
> 
> //print shapeindex
> echo "shpaindex: {$res->shapeindex}";   
> 
> $shape =
>$layer->getShape($res->tileindex,$res->shapeindex);
> $i=0;
> while (list($key,$val) = each($shape->values) ) 
> {
>     $fields[$i++] = $key;
>     echo "Result: $key, $val";
>     if ($i>=4) break;
> }
> -------------
> 
> The output:
> ---------------
> shpaindex: 0
> Warning: Variable passed to each() is not an array
> or
> object
> in /usr/local/ms/htdocs/net.inc.php on line 294     
>  
>            
> -------------
> 
> The querying layer in my map file
> 
> -------------
>   LAYER
>      CONNECTIONTYPE postgis
>      NAME "sites"
>      DEBUG on
>      # Connect to a remote spatial database
>      CONNECTION "user=net100 dbname=netbase 
> host=localhost"
>     DATA "location from (select cust_id,
> site_id,location, product_id,
> site_name from customer_obs) as new_table using
> unique
> site_id using
> srid=4326"
>       
>      STATUS ON
>      TYPE POINT
>      TOLERANCE 5
> 
>      CLASSITEM    "product_id"
>      LABELITEM    "site_name"
>      CLASS
>         NAME 'wxm'
>         EXPRESSION /5/
>         STYLE
>           COLOR 255 000 255
>           SYMBOL 'star'
>           SIZE 9
>         END
>         LABEL
>            COLOR 255 000 255
>            SIZE small
>            POSITION CL
>            MINDISTANCE 100
>         END # end of label
>          TEMPLATE 'templates/icao_query.html'
>      END
> 
> 
>     HEADER "templates/icao_header.html" 
>     FOOTER "templates/footer.html"
>   END
> --------------------
> 
> Looks to me like the problem is in the shapeindex.
> Why
> it always returns
> 0?
> 
> Thanks very much for any help! 
> 
> Lin
> 
> 
> 		
> __________________________________ 
> Yahoo! Mail - PC Magazine Editors' Choice 2005 
> http://mail.yahoo.com
> 



		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com



More information about the mapserver-users mailing list