Fantastic, actually, the one line _Update Selection Set OBJ = Centroid(OBJ)_
is all I needed.

I was doing all the update of centroid just so I could create an object at
that point by converting that pline to a point, the initial line object is
very disposable in this case, I simply need to identify (with an object) the
halfway point between these simple two node polylines.

Thanks for the great help Peter, looks like I was going about this little
mbx using the bloatware method.

"Why use one line of code, when the same thing can be accomplished with 17
lines!!!"   ;)
Sub KeepItSimpleStupid
END Sub

David






-----Original Message-----
From: Peter Horsbøll Møller [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 16, 2005 1:23 AM
To: David Reid; MapInfo-L
Subject: RE: [Mapinfo-l] Create a point object at centroid


Dave,

You can use the SelectionInfo(SEL_INFO_TABLENAME) to find the nameof the
base table that your selection has selected records from.

You can actually do this using just two statement:

Update Selection Set OBJ = Centroid(OBJ)
Commit Table SelectionInfo(SEL_INFO_TABLENAME)

This will replace the current object(s) on the records in selection with a
point (here the centroid)

If you also need to update the columns with the X and Y, you should do this
before the other:
Update Selection Set XCOORD = CentroidX(OBJ), YCOORD = CentroidY(OBJ)
Update Selection Set OBJ = Centroid(OBJ)
Commit Table SelectionInfo(SEL_INFO_TABLENAME)

But it is not necessary to update columns with coordinates just to alter the
object.

Also be aware that this will actual replace the existing objects, and there
is no easy way back here. So you might consider making a copy of the
original table before updating the objects, or maybe insert the centroid
into another table.

Peter Horsbøll Møller
GIS Developer
Geographical Information & IT

COWI A/S
Odensevej 95
5260 Odense S.
Denmark

Tel   + 45 6311 4900
Dir   +45 6311 4908
Mob +45 5156 1045
Fax  + 45 6311 4949
E-mail [EMAIL PROTECTED]
http://www.cowi.dk



From: [EMAIL PROTECTED] on behalf of David Reid
Sent: Wed 16-Nov-05 07:40
To: MapInfo-L
Subject: [Mapinfo-l] Create a point object at centroid


Greetings List,

I'm trying to do a simple little routine here to mark the centroid of a
single section line (two node line) with a point object. I get to the point
of saving the active table then creating the point within it, but I don't
want to have to specify the table name (ie, I want this to work on any table
I have, all have the same two columns described below).



  Update Selection Set XCORD = CentroidX(Obj) 'Returns the xcoord of the
object
  Update Selection Set YCORD = CentroidY(Obj) 'Returns the yccord of the
object
  Delete Object From Selection 'Deletes only the graphic line object leaving
data

I presume that just as if you use the menu option to "Create Points", the
table must be saved first before you can insert an object at the centroid
from above. From here I'm a little stumped....

  Commit [currently_active_table] 'Save the table currently being edited
  Update [currently_active_table] 'Update currently active table
  Set obj = CreatePoint(xcord, ycord) 'Create a point object only for the
record updated previously



I may be going about this all wrong, or perhaps I will need to create a
temporary table from the selected object and work from it????

Would appreciate any help here.

Thanks,
Dave

--
Outgoing mail is certified Virus Free
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.2/170 - Release Date: 11/15/2005



_______________________________________________
Mapinfo-l mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l





--

Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.2/170 - Release Date: 11/15/2005

-- 
Outgoing mail is certified Virus Free
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.2/170 - Release Date: 11/15/2005
 


_______________________________________________
Mapinfo-l mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to