[Mapserver-users] Querybypoint succes GetNumResult 1 shapeindex -1 Why?
Eric Bridger
eric at gomoos.org
Fri Jun 13 04:09:35 PDT 2003
Jose,
The line below is incorrect, is not necessary and is probably
causing your problem. Try commenting it out.
You only need to re-open the shapefile if you want to retrieve the
shape. But you don't have a shape file, you have a dynamically created
feature layer. FYI the correct call if you had a shape file would have
been:
$layerObj->open($layerObj->{data});
> $layerObj->open($results);
On Thu, 2003-06-12 at 23:21, jose.quintal at cfe.gob.mx wrote:
> Of a data base of Mysql I take hold points with its coordinates x and y
> them drawing and all OK, But when doing a Querybypoint shapeindex returns
> to me -1 That I have bad?
>
> Here I keep the points in a ShapeObj object
>
> //Conectando con Mysql
> mysql_pconnect("dwa00","sist","sist") or die("No abrio el servidor");
> mysql_select_db("mapas") or die("No selecciono la Base de Datos");
>
> //Seleccionando Postes
> $sql="SELECT * from postes_Mer WHERE identificador = '$buscar' ";
> $p=mysql_query($sql) or die("Error al Ejecutar la Consulta");
>
> //Arma la consulta
>
> // get a layer object representing your pointlayer
>
> $layerObj = $map->getLayerByName("postes");
>
> // get a class object representing the first class in the layer
> $classObj = $layerObj->getClass(0);
>
> // create a new point object to hold the X Y data
> $pointObj = ms_newPointObj();
> $line = ms_newLineObj();
>
> $i=0;
> while($reg=mysql_fetch_array($p))
> {
> $a=$reg['num_campo'];
> $b=$reg['cor_x'];
> $c=$reg['cor_y'];
>
>
> $pointObj->setXY($b,$c);
> $line = ms_newLineObj();
> $line ->add($pointObj);
> $shp = ms_newShapeObj(MS_SHAPE_POINT);
>
> $shp->add($line);
> $shp->{text} = $a;
> $shp->{index} = $i;
> if($layerObj->addFeature($shp) == -1){
> echo "addFeature failed";
> }
> $point_lookup[$i] = $a;
> $i++;
> $pointObj->draw($map, $layerObj, $image, 0, $a);
>
> }
>
> Here this the code where I make the Querybypoint
>
>
> if ($info_pt == 1 )
> {
> $record = -1;
>
> $layerObj = $map->getLayerByName('postes');
> $queryresult = @$map->queryByPoint ($ptClicked,MS_SINGLE,1000);
> echo "Queryresult " . $queryresult;
> if ($queryresult == SUCCES)
>
> {
>
> $results = $layerObj->resultcache;
# remove the line below:
> $layerObj->open($results);
> $num_results = $layerObj->getNumResults();
> echo "Num resultados :" . $num_results;
> // we only expect one result.
>
> $rslt[0] = $layerObj->getResult(0);
> // this is an index into the point lookup table.
> $shapeindex[0]=$rslt[0]->shapeindex;
> $tileindex[0]=$rslt[0]->tileindex;
> echo "rsultado : " . $rslt[0];
> echo "tile : " . $tileindex[0];
> echo "shape :" . $shapeindex[0];
>
>
> }
> }
>
>
>
> Here this the definition of the Layer in the .map where I make the
> Querybypoint
>
> LAYER
> NAME "postes"
> TYPE POINT
> STATUS ON
> TOLERANCE 10
> LABELMINSCALE 10
> LABELMAXSCALE 60000
> TEMPLATE "postes.html"
> CLASS
>
> SYMBOL 'circle'
> COLOR 0 0 0
> SIZE 5
> MINSIZE 5
> MAXSIZE 5
> LABEL
> ANTIALIAS TRUE
> TYPE TRUETYPE
> FONT Arialn
> SIZE 8
> POSITION CL
> BUFFER 2
> MINDISTANCE -3
> MINFEATURESIZE -1
> COLOR 252 152 54
> PARTIALS TRUE
> FORCE FALSE
> END
>
> END
> END
>
>
>
>
> Thanks
>
>
>
>
> José Antonio Quintal Castillo
> Sistemas
> Comision Federal de Electricidad
>
> Tel 9243128 O 9243136
>
>
>
>
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
More information about the MapServer-users
mailing list