[mapserver-users] PHP MapScript - Trouble with Point Query

Hankley, Chip Chip.Hankley at GASAI.Com
Wed Jul 4 18:01:57 EDT 2001


Hi List,

Totally stumped...

I'm having trouble with a point query and a shapefile.

What I'm trying to do is set up an app that will let users point at a
polygon, and have an attribute from that polygon be returned. The attribute
(field value) that is returned will always be the same (i.e. I'm not
returning values from multiple fields...just one).

Anyway, I followed the way this is done in DMSolutions GMap application, and
it works...most of the time. But, on certain shapefiles, for certain
polygons, I get the following PHP error:

Fatal error: Call to a member function on a non-object in
C:\Inetpub\wwwroot/seating/test_seat1.php on line 49

Doesn't happen for every polygon in an effected shapefile, but it does
happen to the same polygons consistently.

Here's my php code around line 49:

44    $x_click = $HTTP_POST_VARS["img_x"];
45    $y_click = $HTTP_POST_VARS["img_y"];
46    $real_pts = getRealPts($x_click, $y_click, $map);
47    
48    $q_map_res = $map->queryUsingPoint($real_pts[2], MS_SINGLE, -1);
49    $q_map_res->rewind();
50
51    $oResult = $q_map_res->next();
52    $iCurLayer = $oResult->layer;
53    $oLayer = $map->GetLayer($iCurLayer);
54    $dbfname = $map->shapepath . $oLayer->data . ".dbf";

I think it's really bombing on line 48 b/c if I comment out 49, my error
says line51. I think I must be missing some error trapping routine around
line 48, although I don't understand why it isn't returning a value.

For further ref, here's the layer definition from the map file...

LAYER
  NAME "Employee"
  DESCRIPTION "Location Codes"
  TYPE Polygon
  STATUS DEFAULT
  DATA ml4
    CLASSITEM CODE
      CLASS
        EXPRESSION ''
        COLOR 255 0 0
        OUTLINECOLOR 0 0 0
     END  # CLASS
  TOLERANCE 0
  HEADER "CODE"
  QUERYITEM "Code"
  QUERY
    EXPRESSION /1|2|3/
    TEMPLATE "ttt"
  END
END  # LAYER

TIA!

Chip




More information about the mapserver-users mailing list