[Mapserver-dev] WMS GetFeatureInfo

Ross Elliott ross.elliott at infoterra-global.com
Wed Sep 22 12:22:55 EDT 2004


In order to get GetFeatureInfo to work with WMS as I'd expect it to I find that I need to make the following changes to mapserver. Now, am I missing something about how it is meant to work? and if not, do my changes make any sense? My changes to msQueryByPoint allow you to pick out when you are in a polygon or on a line and only want one record returned, before this I'd often get the wrong poly sent back. The change to msWMSFeatureInfo is needed to get the right point for the query rather than a point that doesn't ever seem to exist within my BBOX.

Ross Elliott
Senior Software Engineer
Infoterra Ltd
 

-----------------------------------------------------------------


mapwms.c msWMSFeatureInfo
COMMENT OUT THE FOLLOWING CODE

  // Perform the actual query
  //cellx = MS_CELLSIZE(map->extent.minx, map->extent.maxx, map->width); // note: don't adjust extent, WMS assumes incoming extent is correct
  //celly = MS_CELLSIZE(map->extent.miny, map->extent.maxy, map->height);
  //point.x = MS_IMAGE2MAP_X(point.x, map->extent.minx, cellx);
  //point.y = MS_IMAGE2MAP_Y(point.y, map->extent.maxy, celly);

------------------------------------------------------------------

mapquery.c msQueryByPoint()
CHANGE 

      d = msDistancePointToShape(&p, &shape);
      if( d <= t ) { // found one
	if(mode == MS_SINGLE) {
	  lp->resultcache->numresults = 0;
	  addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
	  lp->resultcache->bounds = shape.bounds;
	  t = d; // next one must be closer
	} else {
	  addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
	  if(lp->resultcache->numresults == 1)
	    lp->resultcache->bounds = shape.bounds;
	  else
	    msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
	}
      }
 
      msFreeShape(&shape);	
    } // next shape

TO
      int NoOfHits=0;
      d=0.0;
      if(lp->type == MS_LAYER_POLYGON || lp->type == MS_LAYER_LINE)
        NoOfHits = msIntersectPointPolygon(&p, &shape);
      else
        d = msDistancePointToShape(&p, &shape);

      if(((lp->type == MS_LAYER_LINE || lp->type == MS_LAYER_POLYGON) & NoOfHits && 0x01) || (lp->type != MS_LAYER_POLYGON & d <= t))
      {
          if(mode == MS_SINGLE) {
          lp->resultcache->numresults = 0;
          addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
          lp->resultcache->bounds = shape.bounds;
          t = d; // next one must be closer
        } else {
          addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
          if(lp->resultcache->numresults == 1)
            lp->resultcache->bounds = shape.bounds;
          else
            msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
        }
      }
 
      msFreeShape(&shape); 


The information in this e-mail and any attachment is confidential and may be privileged. If you have received this e-mail in error, please delete it immediately and destroy any copies on your system. You should not retain, copy or use this e-mail for any purpose, nor disclose all or any part of its content to any other person.
Opinions expressed in this e-mail may not be endorsed by the company and unless explicitly indicated, this e-mail shall not form part of any binding agreement.





More information about the mapserver-dev mailing list