How to edit attribute of a selected shape?

Skalski Artur - askals Artur.Skalski at ACXIOM.COM
Thu Jan 26 00:04:36 PST 2006


To change an attribute of added point You have to also update a dbase file (I don't see that in your code) wihich stores all atributes of shapes in shp.file, otherwise you get nothing. And if you try to open such a file in ArcViwe it will promt taht tha file was damaged which is because dbf. file record number doesn't mach shp. file record number.
dbase.dll which is used to create and update dbf. file comes with standard distribution off all lates php binaries
 
ragards

Artur Skalski 

ACXIOM Polska
Telephone:      (+48 22) 606 11 27      Budynek Saturn
Facsimile:      (+48 22) 606 11 28      Domaniewska 41
Mobile:         (+48) 503 070 036       02-672 Warszawa
E-mail:         artur.skalski at acxiom.com 

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]On Behalf Of Xiaonan Zhang
Sent: Wednesday, January 25, 2006 6:02 PM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: [UMN_MAPSERVER-USERS] How to edit attribute of a selected shape?


Dear all,
 
I am tring to create a function which can add comment point onto layer however I got a few problems here:
1. the newly added one always overwrite the existing point so there is always only one point in that layer.
2. I can not regain the added point.
3. how to change the attribute of the added point, say there is one attribue called "Comment".
 
thanks. 
 
My code is:
 
//Create a new comment point
            $ClickGeo = ms_newPointObj();
            $ClickGeo->setXY($nClickGeoX, $nClickGeoY);
            
            //printf("ClickGeoX %f<BR>\n",$nClickGeoX); 
          //printf("ClickGeoY %f<BR>\n",$nClickGeoY);
          
          //Add it to the comments layer
          $shape = ms_newShapeObj(MS_SHAPE_POINT);
          $line = ms_newLineObj(); 
          $line->add($oClickGeo);
          $shape ->add($line);
                   
              
          $poLayer = $gpoMap->getlayerbyname(comments); //get the layer "comments"
          $poLayer->open();
          //printf("Layer Name: %f<BR>\n", $poLayer->name);
          
                  
          $poLayer-> addfeature($shape); //add the new comment point  
          
                           
          //Save the changes     
            $cmmShapefile = "../htdocs/data/comments"; 
          $objShapefile = ms_newShapeFileObj( $cmmShapefile, MS_SHP_POINT ); 
          $objShapefile->addshape($shape);
          $objShapefile->free;
           $poLayer->close(); 
          
          //Task2: Use layer->querybypoint to regain the newly added point and then change it's comment attribut 
          
          //Task2.1:get the new added comment point
                 $poLayer->querybypoint($oClickGeo, MS_SINGLE, 2); 
                 $numResults = $poLayer->getNumResults();
                 printf("Find point: %f<BR>\n", $numResults);                                 
                 $oRes = $poLayer->getResult(0); 
                 printf("tileindex: %f<BR>\n", $oRes->tileindex);
                 printf("SHAPEINDEX: %f<BR>\n", $oRes->shapeindex);                 
                $oShape = $poLayer->getShape(-1,0); //(-1,-1)
                print_r($oShape->values); //print the keys of the values array
                $comment = $oShape->Values["Comment"]; 
                printf("The comment attribute is ---: %f<BR>\n",$comment ); //display comment attribute
                
                                  

***************************************************************************
The information contained in this communication is confidential, is
intended only for the use of the recipient named above, and may be legally
privileged.

If the reader of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited.

If you have received this communication in error, please resend this
communication to the sender and delete the original message or any copy
of it from your computer system.

Thank You.
****************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060126/9a6c2e33/attachment.htm>


More information about the MapServer-users mailing list