MapTools.org

[Chameleon] Item Query

Rene Teniere TENIERER@gov.ns.ca
Wed, 28 Jan 2004 08:51:03 -0400
Wow, that's exactly it. I appreciate the work you put in. The guys and I
here at work are still trying to wrap our heads around the architecture
of Chameleon. We've been looking up the PHP MapScript documentation to
get an idea as to variables that need to be passed to specific
functions. Can you tell me about other resources/web sites that you guys
have at DM Solutions or wherever that could make out lives easier for
programming new widgets, as opposed to bugging the user's list?

Thanks,

RT

>>> pagameba@magma.ca 2004-01-27 11:37:07 PM >>>
Rene, it is indeed possible but I am not entirely sure that I
understand 
exactly what you are trying to accomplish and what your inputs are. 
Let 
me try to outline what I think you are trying to do and how to solve
the 
issue:

Requirements:

* you have a shapefile consisting of polygons that define the extents
of 
provincial map sheets
* you want the user to be able to enter a mapsheet number and be zoomed

to that mapsheet's extents

Unknowns:

* is the shapefile included in your application?  Assume no.

Approach:

* using a copy of the LocateWidget with all inputs removed except NTS 
MapSheet, and added a Provincial Map Sheet

You need to locate the code that decides what the user wants to lookup,

and supply some code to do your lookup.  This is some code that looks 
roughly right, but I haven't tested it and I don't guarantee that it is

without typos or erroneous function names, but I think you will get the

idea.
<?php
dl( 'php_dbf.dll' );
$hDB = dbase_open( 'path-to-shapefile.dbf' );
$nRecs = dbase_numrecords( $hDB );
$nIndex = -1; //-1 means not found
for ($i=0; $i<$nRecs; $i++)
{
   $aRec = dbase_get_record_with_names( $hDB, $i );
   if (strcasecmp( $aRec['fieldname'], $szUserInput ) == 0)
   {
     //found a match
     $nIndex = $i;
     break;
   }
}
dbase_close( $hDB );

if ($nIndex >= 0)
{
   //open shapefile using mapscript
   $oShapeFile = ms_newShapeFileObj( 'path-to-shapefile.shp', 
MS_SHP_POLYGON );
   if ($oShapeFile->numshapes < $nIndex )
   {
     //oops, not enough shapes, error
   }
   else
   {
     //get the bounding box of the shape in a RectObj
     $oRect = $oShape->getExtent( $nIndex );
     $oMap->setextent( $oRect->minx, $oRect->miny, $oRect->maxx, 
$oRect->maxy );
   }
}
else
{
   //report no records
}
$oShapeFile->free();
?>

Rene Teniere wrote:

> Hi Paul,
> 
> That's very similar to what I started off with (only I used the
> LocateWidget and got rid of all the inputs except NTS Map Sheet, and
> added my own - Provincial Map Sheet). The problem comes in that there
is
> a polygon index covering the whole province containing cells
> representing specific mapsheets. I have to be able to get chameleon
to
> find the mapsheet number within the index shapefile (the MAPSHEET
item
> in the index's table) using the user inputted text (essentially an
item
> query), then once I have the map object's extents returned, I would
use
> the setextent object to see it. Is this at all possible? If I
> misunderstood you, I apologize, however, I don't think I exactly
> explained the situation properly.
> 
> Thanks,
> 
> Rene
> 
> 
> 
> 
>>>>pagameba@magma.ca 2004-01-27 2:36:20 PM >>>
> 
> Rene,
> 
> to do this in Chameleon, you create a new widget from one of the 
> existing ones that does something similar.  For instance, the Scale 
> widget does something similar (it uses an input box to allow the
user
> to 
> type in a new scale value and then zooms to that scale.  You would
make
> 
> a copy of this widget and rename stuff appropriately.
> 
> Your main work would go in the ParseURL function which is where you
> will 
> get the FORM variables that were submitted (Scale is a good example
of
> 
> this) and do something with them.  In your case, you would use the
> input 
> value to lookup the bounding box of a Map sheet and then apply those

> extents to the map object using something like 
> $this->moMapSession->oMap->setextent( $nMinX, $nMinY, $nMaxX, $nMaxY
> );
> 
> That's pretty much it.  Note that the Scale widget is just a
container
> 
> for the value, you use an UpdateMap widget to actually submit the
> page.
> 
> Cheers,
> 
> Paul
> 
> Rene Teniere wrote:
> 
> 
>>Hi All,
>>
>>Been sitting down here with the office MapServer programmer, looking
> 
> to
> 
>>create an Item Query. This goes back to the message I left yesterday
> 
> on
> 
>>having an input box for the user to input a mapsheet number and
> 
> return
> 
>>the result on the map display. In MapServer, you would just set the
>>variables and send them to MapServer for processing. The question is
> 
> how
> 
>>is this achieved through Chameleon? In fact, how does it talk to
>>mapserver? All we need to do is be able to figure out what variables
> 
> to
> 
>>set, and where to send them.
>>
>>Example: In the bounding box widget, you set the user-defined
> 
> bounding
> 
>>coordinates to the variables and them pass them
>>on:window.opener.applyBoundingBox( nMinX, nMinY, nMaxX, nMaxY ); 
>>
>>Is there anything that can help me out on figuring this stuff out?
> 
> What
> 
>>about the utils in htdocs_admin?
>>
>>Any help would be greatly appreciated
>>Rene
>>
>>Rene J.R. Teniere - BSc., D.GIS
>>GIS Technician
>>Nova Scotia Department of Natural Resources
>>Forestry Division (GIS) - Truro
>>
>>Phone: (902) 893-5655
>>Mobile: (902) 209-8956
>>_______________________________________________
>>Chameleon mailing list
>>Chameleon@lists.maptools.org 
>>http://lists.maptools.org/mailman/listinfo/chameleon 
>>
> 
> 

-- 
  -----------------------------------------------------------------
|Paul Spencer                           spencer@dmsolutions.ca    |
|-----------------------------------------------------------------|
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/| 
  -----------------------------------------------------------------



This archive was generated by Pipermail.