[mapserver-users] php/mapscript and querybypoint

Thorsten Fischer thfischer at mapmedia.de
Thu Sep 13 11:24:14 PDT 2001


Ladies and gentlemen,


I am confused. I do the following in php/mapscript:

($extent coming in to the script as extents in a way like minx+miny+maxx+maxy,
this appears to be computed correctly; $mapbild_x and _y are the points clicked
on in the map)

$extvalues = split ("\+", $extent);
$map -> setExtent  ($extvalues [0], $extvalues [1], $extvalues [2], $extvalues [3]);
$pointclickedX = $extvalues [0] + (($extvalues [2] - $extvalues [0]) / (double) $map -> width) * (double) $mapbild_x;
$pointclickedY = $extvalues [1] + (($extvalues [3] - $extvalues [1]) / (double) $map -> height) * (double) $mapbild_y;
$querypoint = ms_newPointObj ();
$querypoint -> setXY ($pointclickedX, $pointclickedY);
$queryresult = @$map -> queryByPoint ($querypoint, MS_SINGLE, -1);

Maybe my mapfile is set up in a wrong way, i am spending some time to figure
out how queries work at all. My mapfile shows the following layer:

LAYER
  CONNECTIONTYPE postgis
  NAME objekte
  TYPE POLYGON
  STATUS default
  DATA "geo_value from objekte"
  CONNECTION "user=xxx password=xxx dbname=xxx"
  CLASSITEM "id"
  CLASS
    EXPRESSION ([id] eq 0)
    NAME "geoid_hilite"
    SYMBOL 0
    SIZE 1
    COLOR 255 0 0 
    OUTLINECOLOR 0 0 0
    TEMPLATE ""
  END
  CLASS
    EXPRESSION /1 neq 1/
    NAME "geoid_current"
    SYMBOL 0
    SIZE 1
    COLOR 135 206 250
    OUTLINECOLOR 0 0 0
    TEMPLATE ""
  END
  CLASS
    EXPRESSION /./
    NAME "geoid_normal"
    SYMBOL 0
    SIZE 1
    COLOR 240 230 140
    OUTLINECOLOR 0 0 0
    TEMPLATE ""
  END
END

The expressions are always overridden in each map and provide useful default
values.


According to php/mapscript 3.5 docs, $queryresult now holds (should hold) an
integer. My problems are:

1) I am getting more or less random results, either 1 or 0
for my clicks in the map. Heavy investigations into the code by several people
show that the passing of parameters to/from the script appears to be correct.
So do included debugging printing options: the computation is ok. But the
results are obviously not. What am I doing wrong?

2) what am I to do with the final integer? In the end, I need the number
of the shape i clicked.


thanks in advance from a desperate developer,

thorsten

-- 

Thorsten Fischer          thfischer at mapmedia.de

---------------------------------------------------------
MapMedia - Kartographie und raumbezogene Informationssysteme
Am Borsigturm 42
13507 Berlin
Deutschland
http://www.mapmedia.de tel: +49 (0)30 43032102
---------------------------------------------------------





More information about the MapServer-users mailing list