|
||||
[Chameleon] Item QueryRene Teniere TENIERER@gov.ns.caThu, 29 Jan 2004 14:23:11 -0400
|
Hi Paul, The code is very logical and makes sense, it will cycle through the database and make the match, however, I think there is something wrong with having ms_newShapeFileObj(), It is overwriting my original shapefile with a new one, because there are no shapes in it. The numshapes count is 0. Should I be using getShape() instead?? Here is the PHP code: Rene $szPMS = ""; if (isset($this->moURLArray["PMS"])) $szPMS = $this->moURLArray["PMS"]; if ($szPMS > 0 && is_numeric($szPMS)) { $hDB = dbase_open('d:/gis_data/juan/juan_indx.dbf',0); $nRecs = dbase_numrecords($hDB); error_log("Number of Records: ".$nRecs); $nIndex = -1; //-1 means not found for ($i=0; $i<=$nRecs; $i++) { $aRec = dbase_get_record_with_names($hDB,$i); $aResult = $aRec['MAPSHEET']; error_log("Search criteria: ".$szPMS); error_log("Line ".$i." of text from the Database: ".$aResult); if (strcasecmp($aResult,$szPMS) == 0) { //Found a match $nIndex = $i; error_log("Match Found, Index: ".$nIndex); break; } } dbase_close($hDB); if($nIndex>=0) { //Open the shapefile $oShapeFile = ms_newShapeFileObj('d:/gis_data/juan/juan_indx.shp',MS_SHP_POLYGON); $nShapes = $oShapeFile->numshapes; Error_Log("Number of shapes: ".$nShapes); if($nShapes < $nIndex) { //Not enough shapes Error_Log("Not Enough Shapes in ".$oShapeFile); } else { $oRect=$oShapeFile->getExtent($nIndex); $myMinX = $oRect->minx; $myMinY = $oRect->miny; $myMaxX = $oRect->maxx; $myMaxY = $oRect->maxy; Error_Log("Min X: ".$myMinX); Error_Log("Min Y: ".$myMinY); Error_Log("Max X: ".$myMaxX); Error_Log("Max Y: ".$myMaxY); $oMap->setExtent($myMinX,$myMinY,$myMaxX,$myMaxY); } } else { //Report no records } $oShapeFile->free(); } >>> 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. |
MapTools.org -- Hosted by DM Solutions Group |