[Mapserver-users] Nearly there! "Inline shapes" Was: Unique? Was: mapscript - queryByPoint help, simple Q

poff poff at sixbit.org
Fri Aug 29 12:51:10 EDT 2003


Hello All,

Thanks for your help, I've been making progress!

Basically I now get results with queryByPoint, it's getting at them which 
is puzzling me (different question now).

I have a layer with points drawn from a database, such as:

	$line = ms_newLineObj();
      	$line->add($oPoint);
      	$shp=ms_newShapeObj(MS_SHAPE_POINT);
      	$shp->add($line);
      	$shp->{text}="hll";
      	$shp->{index}="99";
      	$uLayer->addFeature($shp);

The ulayer has no data, just a symbol for each point.

Now I have a problem when I get the shapefile back from the results:

	$uLayer->open($map->shapepath);
	
	$oRes=$uLayer->getResult(0);

	// this next bit gives an error

	$oShape = $uLayer->getShape($oRes->tileindex,$oRes->shapeindex);

"Error in msLayerGetShape(): Cannot retrieve inline shapes randomly."

However if I use another layer, the layer with all the shapedata, I get a 
lovely array with all the shapefile data, built into the shapefile. 
Corresponding to the click.

If I do 
addFeature($shp) to the main layer, it gives me the same error. It seems 
whatever layer I addFeature to it gives the error.

Only, I need to get at the $shp data above (I really need the $shp->{index} 
part to get back the data from the database);

Do you have any ideas?

It's so close! I can almost taste that index ;)

Again a BIG thank you for helping me so far.

P

On Fri, Aug 29, 2003 at 
09:50:10AM +0000, Eric Bridger wrote:
> Sorry you're having so much trouble. I do perl mapscript queryByPoint
> extensively.  Have you tried looking att the GMap PHP demo php source?
> It will show you how to do everything with PHP mapscript.
> 
> http://www2.dmsolutions.ca/gmap/gmap75.phtml
> 
> E.g the following code is wrong:
> 
> > $my_point = ms_newpointObj();
> > $my_point->setXY($_REQUEST["mapa_x"],$_REQUEST["mapa_y"]
> 
> $_REQUEST["mapa_x"] and "mapa_y" are the pixel coordinates of your mouse
> click. You need to first transform them to geographic coordinates.  The
> gmap75.php file contains a function: GMapPix2Geo() which does this.
> 
> Here's a perl example:
> sub get_click {
>     my ($q, $map) = @_;
>     my @current_extent = ();
>     my($x_map, $y_map) = (0,0);
> 
>     if($q->param('img.x') && $q->param('imgext')) { # Make sure we got a
> click
>         @current_extent = split(' ', $q->param('imgext'));
>         my $click_x = $q->param('img.x');
>         my $click_y = $q->param('img.y');
>         my $x_pct = ($click_x / $map->{width});
>         my $y_pct = 1 - ($click_y / $map->{height});
> 
>         $x_map = $current_extent[0] + ( ($current_extent[2] -
> $current_extent[0]) * $x_pct);
>         $y_map = $current_extent[1] + ( ($current_extent[3] -
> $current_extent[1]) * $y_pct);
>     }
>     return ($x_map, $y_map);
> }
> 
> 
> 
> On Fri, 2003-08-29 at 12:08, poff wrote:
> > Hello
> > 
> > I know everyone is busy - and thanks a lot for your help.
> > 
> > Only, does _no-one_ use querbypoint with php mapscript?
> > 
> > It's a great feature if I could get it working, and definitely something to 
> > go in Wiki someday!
> > 
> > Thanks
> > 
> > P
>  
> > 
> 
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users

-- 
poff at sixbit.org
SDF Public Access UNIX System - http://sdf.lonestar.org

Please do not carbon copy replies to me



More information about the mapserver-users mailing list