queryBypoint problem - Please help

Ruggero Valentinotti valruggero at LIBERO.IT
Sun Feb 13 03:54:31 EST 2005


Nagu Govind wrote:

> Hi,
> Iam using MapScript.
> I want to find out the State and District name using latiudes and
> longitudes. My .dbf file has the following fields
> 1.Dst_ID
> 2.District
> 3. State
>
> I want to get this info corresponding to my lat and long.
>
> My map file layer is like this
> ---------------------
> MAP
>  NAME "ind"
>  SIZE 500 500
>  STATUS ON
>  SYMBOLSET "maps/symbols/examples.sym"
>  EXTENT 67 5 99 40
>
>  SHAPEPATH "maps/data/"
>
>     PROJECTION
>   "proj=latlong"
>   "datum=NAD83"
>     END
>
>  WEB
>   IMAGEPATH "maps/tmp/"
>   IMAGEURL "maps/ <http://nagaraj:9000/maps/tmp/>"
>   TEMPLATE  'maps/myind.html'
>  END
>
> QUERYMAP
>   STATUS ON
>   STYLE SELECTED
>   COLOR 255 255 0
>  END
>
>  LAYER
>   NAME "Ind"
>   TYPE POLYGON
>   STATUS ON
>   DATA "ind_ds"
>   PROJECTION
>    "proj=latlong"
>    "ellps=GRS80"
>   END
>   CLASS
>    NAME "IND MAP"
>    OUTLINECOLOR 0 0 0
>    COLOR 255 255 0
>    SYMBOL dash-long
>    STATUS ON
>   END
>   TEMPLATE ind_query.html
>  END
>
> END
> -----------------------
>
> And Iam calling Query by point as folows
>
> $point = ms_newpointObj();
> $point->setXY($lon,$lat);
> $layer1 = $map->getLayerByName('Ind');
> if($layer1->queryBypoint($point,MS_SINGLE,$buffer) == MS_SUCCESS){
>  echo "Success : $buffer";
> }
>
> Iam getting this warning message
> Warning: [MapServer Error]: msQueryByPoint(): No matching record(s)
> found.
>
> Iam new to mapserver & I really dont know whether this is the right
> method to get the info from the dbf file. Iam having only one polygon
> layer. Do i need to have another layer for quering.?.
> Please tell me where Iam going wrong.
>
> The concepts of layers are also not much clear to me. Regarding
> Mapscript and Map File , reference documents are there but I could not
> find any elaborate examples or application notes.
>  Please tell me where i can find them.
>
> I also could not find any good samples similar to my requirement.
>
> Some one please help me.
>
> Regards
> vdharan
>
>
>
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Yahoo! Mail
> <http://us.rd.yahoo.com/mail_us/taglines/virus/*http://promotions.yahoo.com/new_mail/static/protection.html>
> - Helps protect you from nasty viruses.

Hi Nagu,
you need METADATA keyword in Layer class:

 LAYER
  NAME "Ind"
  TYPE POLYGON
  STATUS ON
  METADATA
    "DESCRIPTION" "My layer ind"
    "RESULT_FIELDS" "DISTRICT STATE"
  END
  DATA "ind_ds"
  PROJECTION
   "proj=latlong"
   "ellps=GRS80"
  END
  CLASS
   NAME "IND MAP"
   OUTLINECOLOR 0 0 0
   COLOR 255 255 0
   SYMBOL dash-long
   STATUS ON
  END
  TEMPLATE ind_query.html
 END


And then use Use '@' to avoid warning if query found nothing
            @$layer1->queryBypoint($point,MS_SINGLE,$buffer);


Hope this help

ruggero




--
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

       /\              Ruggero Valentinotti
      //\\  /\         Studio Tecnico Ambientale Forestale
     ///\\\//\\        Frazione Tozzaga  - Via alle Pozze, 2
    ////\\\\/\\\       38022 CALDES (TN) - Italy
   /////\\\\\\\\\
       ||////\\\\\     http://digilander.libero.it/valruggero/
  _____||___||_____    E-mail: valruggero at libero.it



More information about the mapserver-users mailing list