<span class="gmail_quote"><br><br></span><div>Hi Skalaski,</div>
<div> </div>
<div>Thanks for the code. I tried it but it didn't work. There are errors when change the db file I think. Please see my code used. Also could you please give me the code of the html input. I have to done this very soon otherwise I will not ask this.
</div>
<div>
<p> /* -------------------------------------------------------------------- */<br> /* check if it's the comment button which is pressed */<br> /* */<br>
/* -------------------------------------------------------------------- */<br> else if ($HTTP_FORM_VARS["CMD"] == "COMMENT")<br> {<br> $oPixelPos = ms_newpointobj(); // to record the click position
<br> <br> if ($HTTP_FORM_VARS["INPUT_TYPE"])<br> {<br> $szCoord = strval($HTTP_FORM_VARS["INPUT_COORD"]);<br> $szCoordType = strval($HTTP_FORM_VARS["INPUT_TYPE"]);
<br> if (strcmp($szCoordType,"auto_point") == 0)<br> {<br> $szCoordArray =explode(",", $szCoord);<br> $nClickPixX = $szCoordArray[0];<br> $nClickPixY = $szCoordArray[1];
<br> }<br> } //Get the point screen location<br> <br> <br> //Covert to geo-location<span class="q"><br> $nClickGeoX = GMapPix2Geo($nClickPixX, 0, $dfWidthPix, <br> $dfMinX, $dfMaxX, 0);
<br> $nClickGeoY = GMapPix2Geo($nClickPixY, 0, $dfHeightPix, <br> $dfMinY, $dfMaxY, 1);<br> <br></span><span class="q"> //Create a new comment point<br></span> $oClickGeo = ms_newPointObj();
<br> $oClickGeo->setXY($nClickGeoX, $nClickGeoY);
<span class="q"><br> <br> //printf("ClickGeoX %f<BR>\n",$nClickGeoX);<br> //printf("ClickGeoY %f<BR>\n",$nClickGeoY);<br> <br> //Add it to the comments layer
<br> $shape = ms_newShapeObj(MS_SHAPE_POINT);<br> $line = ms_newLineObj();<br> $line->add($oClickGeo);<br> $shape ->add($line);<br></span> //print_r($shape->values);<br>
<br> //$shape->set ($shape->values["Comment"], "neweddddd"); // change the comment attributes<br> //$shape->values["Comment"]= "neweddddd";<span class="q">
<br> <br>
<br> $poLayer = $gpoMap->getlayerbyname(comments); //get the layer "comments"<br> //$poLayer->open();<br> //printf("Layer Name: %f<BR>\n", $poLayer->name);
<br> <br></span> //change the comment attribue here<br> //$newArr= array(1,1,comment); <br> //$shape->set(values, $newArr); //error, values is not a property<span class="q"><br>
<br> $poLayer-> addfeature($shape); //add the new comment point
<br> <br> <br></span> //Task1: input the new comment<br> //Method1:Input form<br> Printf( " <br> <input TYPE='text' NAME=\"new_comment\" value='Please add you comment here!' size =80>
<br> <input TYPE='submit' value='Add'>"); </p>
<p> //end of method1 <br> <br> //Metod 2:pop up a window for user to input comments <br> <br> //Printf("The new comment is %f<BR>\n",$_GET['new_comment']);<br>
<br> <br> //Save the changes <br> //$cmmShapefile = "../htdocs/e_Salford/data/comments"; <br> $objShapefile = ms_newShapeFileObj( '../htdocs/e_Salford/data/comments', -2 );
<br> $dbname= "C:/ms4w/Apache/htdocs/e_Salford/data/comments.dbf";<span class="q"><br> $db = dbase_open($dbname, 2);<br> $nf = dbase_numfields($db);<br> $rn = dbase_numrecords ($db);
<br>
<br></span> $vatr =array("new comment here", 1) ; <br> <br> if (ereg("([0-9]+)", $HTTP_FORM_VARS["new_comment"], $vatr))<br> {<br> $def = array($vatr[0]);
<span class="q"><br> }<br> else<br> {<br> $def = array($rn+1);<br> }<br> <br></span> $objShapefile->addPoint($oClickGeo);<span class="q"><br> dbase_add_record($db, $def);
<br>
<br> dbase_close ($db);<br> <br></span> $objShapefile->free();<br> $oClickGeo->free();</p></div>
<div> </div>
<div>regards</div>
<div> </div>
<div>Jonathan<br><br> </div><div><span class="e" id="q_1091aecc1bd35e88_16">
<div><span class="gmail_quote">On 27/01/06, <b class="gmail_sendername">Skalski Artur - askals</b> <<a href="mailto:Artur.Skalski@acxiom.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Artur.Skalski@acxiom.com
</a>> wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
<div><span><font color="#0000ff" face="Arial" size="2">OK this is a part of the php code I used to add point to shp, notice to use it you have to first give an attribute value (fill a html input) which you will save in a dbf. file, than click on a map to add this point (I was using previously created blank shp. file)
</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2">ad here is the code:</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">else if ($HTTP_FORM_VARS["CMD"] == "INPUT_POINT")</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"> {<br> $nClickGeoX = GMapPix2Geo($nClickPixX, 0, $dfWidthPix, <br> $dfMinX, $dfMaxX, 0);<br> $nClickGeoY = GMapPix2Geo($nClickPixY, 0, $dfHeightPix, <br>
$dfMinY, $dfMaxY, 1);<br> <br> $oPoint = ms_newPointObj();<br> $oPoint->setXY($nClickGeoX, $nClickGeoY);</font></span></div>
<div> </div>
<div><span><font color="#0000ff" face="Arial" size="2"> $oshpfile = ms_newShapefileObj('C:\Program Files\Apache Group\Apache2\htdocs\data\siedlce\ptk', -2);</font></span></div>
<div> </div>
<div><span><font color="#0000ff" face="Arial" size="2"> $dbname = "C:/Program Files/Apache Group/Apache2/htdocs/data/siedlce/ptk.dbf";<br> </font></span></div>
<div> </div>
<div><span><font color="#0000ff" face="Arial" size="2"> $db = dbase_open ( $dbname,2);<br> <br> $nf = dbase_numfields($db);<br> $rn = dbase_numrecords ($db);</font></span></div>
<div><font color="#0000ff" face="Arial" size="2"></font> </div>
<div><span><font color="#0000ff" face="Arial" size="2"> if (ereg("([0-9]+)", $HTTP_FORM_VARS["atrybuty"], $vatr))<br> {<br> $def = array($vatr[1]);<br> }<br> else<br> {<br> $def = array($rn+1);
<br> }</font></span></div>
<div> </div>
<div><span><font color="#0000ff" face="Arial" size="2"> $oshpfile->addPoint($oPoint);<br> dbase_add_record($db, $def);</font></span></div>
<div> </div>
<div><span><font color="#0000ff" face="Arial" size="2"> dbase_close ($db);</font></span></div>
<div> </div>
<div><span><font color="#0000ff" face="Arial" size="2"> $oshpfile->free();<br> $oPoint->free();</font></span></div>
<div><span></span><span><font color="#0000ff" face="Arial" size="2">}</font></span></div>
<div><font color="#0000ff" face="Arial" size="2"></font> </div>
<div><span><font color="#0000ff" face="Arial" size="2">usig this i never had any problem with overwriting allready added points, no such thing happened</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">hope this helps</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">regards</font></span></div><span>
<p><font face="Arial CE" size="2">Artur Skalski</font> </p>
<p><b><font color="#000080" face="Arial CE" size="2">ACXIOM Polska</font></b><br><font color="#000080" face="Arial CE" size="2">Telephone: (+48 22) 606 11 27 Budynek Saturn<br>Facsimile: (+48 22) 606 11 28 Domaniewska 41
<br>Mobile: (+48) 503 070 036 02-672 Warszawa</font><font color="#000080" face="Arial CE"><br></font><font color="#000080" face="Arial CE" size="2">E-mail: <a href="mailto:artur.skalski@acxiom.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
artur.skalski@acxiom.com</a></font> </p></span>
<div><span>
<blockquote>
<div dir="ltr" align="left"><font face="Tahoma" size="2">-----Original Message-----<br><b>From:</b> Xiaonan Zhang [mailto:<a href="mailto:xnzhang11@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
xnzhang11@gmail.com</a>]<br><b>Sent:</b> Thursday, January 26, 2006 12:59 PM<br><b>To:</b> Skalski Artur - askals<br><b>Cc:</b> <a href="mailto:MAPSERVER-USERS@LISTS.UMN.EDU" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
MAPSERVER-USERS@LISTS.UMN.EDU</a><br><b>Subject:</b> Re: [UMN_MAPSERVER-USERS] How to edit attribute of a selected shape?<br><br></font></div>
<div>hi, Skalski,</div>
<div> </div>
<div>Thanks for the reply. However could you please give more information on this. Maybe an example.</div>
<div> </div>
<div>The code was working partly ok, the new point can be added, however as I said, it will overwrite the old one. It's attribute was inherited from the old one. I now want to change it's attribute and when I use $poLayer->getResult(0); there seems not point was picked up.
</div>
<div> </div>
<div>regards,</div>
<div> </div>
<div>Jonathan</div>
<div><br><br> </div>
<div><span class="gmail_quote">On 26/01/06, <b class="gmail_sendername">Skalski Artur - askals</b> <<a href="mailto:Artur.Skalski@acxiom.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Artur.Skalski@acxiom.com
</a>> wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
<div><span><font color="#0000ff" face="Arial" size="2">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.
</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2">dbase.dll which is used to create and update dbf. file comes with standard distribution off all lates php binaries</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">ragards</font></span></div>
<p><font face="Arial CE" size="2">Artur Skalski</font> </p>
<p><b><font color="#000080" face="Arial CE" size="2">ACXIOM Polska</font></b><br><font color="#000080" face="Arial CE" size="2">Telephone: (+48 22) 606 11 27 Budynek Saturn<br>Facsimile: (+48 22) 606 11 28 Domaniewska 41
<br>Mobile: (+48) 503 070 036 02-672 Warszawa</font><font color="#000080" face="Arial CE"><br></font><font color="#000080" face="Arial CE" size="2">E-mail: <a href="mailto:artur.skalski@acxiom.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
artur.skalski@acxiom.com</a></font> </p>
<div><span>
<blockquote dir="ltr" style="margin-right: 0px;">
<div dir="ltr" align="left"><font face="Tahoma" size="2">-----Original Message-----<br><b>From:</b> UMN MapServer Users List [mailto:<a href="mailto:MAPSERVER-USERS@LISTS.UMN.EDU" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
MAPSERVER-USERS@LISTS.UMN.EDU</a>]<b>On Behalf Of </b>Xiaonan Zhang<br><b>Sent:</b> Wednesday, January 25, 2006 6:02 PM<br><b>To:</b> <a href="mailto:MAPSERVER-USERS@LISTS.UMN.EDU" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
MAPSERVER-USERS@LISTS.UMN.EDU</a><br><b>Subject:</b> [UMN_MAPSERVER-USERS] How to edit attribute of a selected shape?<br><br></font></div>
<div>Dear all,</div>
<div> </div>
<div>I am tring to create a function which can add comment point onto layer however I got a few problems here:</div>
<div>1. the newly added one always overwrite the existing point so there is always only one point in that layer.</div>
<div>2. I can not regain the added point.</div>
<div>3. how to change the attribute of the added point, say there is one attribue called "Comment".</div>
<div> </div>
<div>thanks. </div>
<div> </div>
<div>My code is:</div>
<div> </div>
<div>//Create a new comment point<br> $ClickGeo = ms_newPointObj();<br> $ClickGeo->setXY($nClickGeoX, $nClickGeoY);<br> <br> //printf("ClickGeoX %f<BR>\n",$nClickGeoX);
<br> //printf("ClickGeoY %f<BR>\n",$nClickGeoY);<br> <br> //Add it to the comments layer<br> $shape = ms_newShapeObj(MS_SHAPE_POINT);<br> $line = ms_newLineObj();
<br> $line->add($oClickGeo);<br> $shape ->add($line);<br> <br> <br> $poLayer = $gpoMap->getlayerbyname(comments); //get the layer "comments"<br>
$poLayer->open();<br> //printf("Layer Name: %f<BR>\n", $poLayer->name);<br> <br> <br> $poLayer-> addfeature($shape); //add the new comment point
<br> <br> <br> //Save the changes <br> $cmmShapefile = "../htdocs/data/comments"; <br> $objShapefile = ms_newShapeFileObj( $cmmShapefile, MS_SHP_POINT );
<br> $objShapefile->addshape($shape);<br> $objShapefile->free;<br> $poLayer->close(); <br> <br> //Task2: Use layer->querybypoint to regain the newly added point and then change it's comment attribut
<br> <br> //Task2.1:get the new added comment point<br> $poLayer->querybypoint($oClickGeo, MS_SINGLE, 2); <br> $numResults = $poLayer->getNumResults();<br> printf("Find point: %f<BR>\n", $numResults);
<br> $oRes = $poLayer->getResult(0); <br> printf("tileindex: %f<BR>\n", $oRes->tileindex);<br> printf("SHAPEINDEX: %f<BR>\n", $oRes->shapeindex);
<br> $oShape = $poLayer->getShape(-1,0); //(-1,-1)<br> print_r($oShape->values); //print the keys of the values array<br> $comment = $oShape->Values["Comment"];
<br> printf("The comment attribute is ---: %f<BR>\n",$comment ); //display comment attribute<br> <br> </div></blockquote></span></div><pre>***************************************************************************
<br>The information contained in this communication is confidential, is<br>intended only for the use of the recipient named above, and may be legally<br>privileged.<br><br>If the reader of this message is not the intended recipient, you are
<br>hereby notified that any dissemination, distribution or copying of this<br>communication is strictly prohibited.<br><br>If you have received this communication in error, please resend this<br>communication to the sender and delete the original message or any copy
<br>of it from your computer system.<br><br>Thank You.<br>****************************************************************************<br></pre></blockquote></div><br></blockquote></span></div></blockquote></div><br>
</span></div>