[Mapserver-users] Querybypoint succes GetNumResult 1 shapeindex -1 Why?

jose.quintal at cfe.gob.mx jose.quintal at cfe.gob.mx
Thu Jun 12 19:21:37 EDT 2003


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;
         $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








More information about the mapserver-users mailing list