[mapserver-users] mapscript queryUsing Point question

Robert Chavez rchavez at perseus.tufts.edu
Mon Oct 22 15:59:08 EDT 2001


Greetings,

I'm having some trouble workign with a point query in mapscript, I'm
using the 3.3.011 release.

I have the following Perl code and map file working, but I get no
results from a point query when there should definitely be some results.

First, here's the Perl code:

<snip>
sub shape_query {

    my ($x, $y, @imgclick, $query_point, $query_buffer, $layer,
$results, $foo);

    ##Capture the user's click point
    @imageclick = split (' ', $cgi->param('imgxy'));
    print STDERR "The imageclick is: @imageclick\n";
    $x = $imageclick[0];
    $y = $imageclick[1];


    ##Setup the queryByPoint parameters
    $query_point = new pointObj;
    print STDERR "x: $x\n";
    print STDERR "y: $y\n";
    $query_point->{x} = $x;
    $query_point->{y} = $y;


    ##Get the layer, perform the query
    $layer = $map->getLayerByName('kwstreetVRnodes');
    $layer->{status} = $mapscript::MS_ON;


    print STDERR "About to start\n";
    $results = $layer->queryUsingPoint($map, $query_point, MS_SINGLE,
-1);
    print STDERR "Finished\n";
    my $foo = $results->{numresults};
    print STDERR "The number of results is: $foo\n";

    ##Put the results in some useable form
    for (my $i=0; $i<$results->{numresults}; $i++) {

 $data = $results->next();
    }

    print STDERR "the shape_query results are: $data\n";
    $results->free();
    return;
}

</snip>

And the map file:

<snip>
LAYER
 NAME kwstreetVRnodes
 TYPE POINT
 STATUS DEFAULT
 DATA kwstreetnodes
 SYMBOLSCALE 5000
 LABELMAXSCALE 1550
 TOLERANCE 10
 CLASS
   SYMBOL 3
   MAXSIZE 25
   MINSIZE 3
   SIZE 3
   COLOR 204 0 0
   TEXT ([STREET_NAM],[CAMERA_NAM])
   LABEL
        FORCE TRUE
        COLOR 0 0 0
        FONT arial
        TYPE TRUETYPE
        SIZE 3
        MINSIZE 3
        MAXSIZE 7
        ANTIALIAS
        POSITION CR
   END
 END
 QUERY
   TEMPLATE dummy
 END
END
</snip>

Basically, for any click on a feature on a map, I get no results (I
copied an output sample from my error_log below).   It's almost as if
mapscript isn't picking up the layer or the query in the layer, but I
can't figure out why.  I was also thinking that my mapObj ($map) was the
problem, but it checks out OK (it's a global).

Any help would be greatly appreciated.
Rob

>From the error_log:
The imageclick is: 226 223
x: 226
y: 223
About to start
Finished
The number of results is:
the shape_query results are:
Can't call method "free" on unblessed reference at
/home/rchavez/www/web/cgi-bin/city-view.pl line 51.
[Mon Oct 22 15:45:56 2001] [error] [client 130.64.37.59] Premature end
of script headers: /home/rchavez/www/web/cgi-bin/city-view.pl





More information about the mapserver-users mailing list