Title: RE: MI Nodes in Polylines
You cannot use

nNumNodes = ObjectInfo(bObject, OBJ_INFO_NPNTS)

as the upper boundary for the loop where you extarct the nodes x and y. The statement

Xcoord = ObjectNodeX(bObject,1, nCntr) 

will create an error if a polyline contains more than one segment and nCntr becomes > than the number of nodes in segment one. You have to create a double loop to "read" the nodes segment by segment. See corrections in original message.

 

Jacques Paris

e-mail                alternate
     [EMAIL PROTECTED]   [EMAIL PROTECTED]

paris PC Consult (mainly MapInfo app.)
     www.total.net/~rparis/gisproducts.htm


       

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Scott Hall
Sent: June 8, 2000 11:08 AM
To: 'Possberg, Hendrik (Fa. Microm)'
Cc: '[EMAIL PROTECTED]'
Subject: RE: MI Nodes in Polylines

> 1. Is it possible to get the number  of nodes in a Polyline?

Getting the number of nodes for a pline is found through ObjectInfo.

Dim bObject As Object
Dim nNumNodes As Integer
[Jacques Paris] Dim nCntr as integer 
bObject = PolylineTable.Obj

[Jacques Paris]  the following line will give you the total number of points in all segments 

nNumNodes = ObjectInfo(bObject, OBJ_INFO_NPNTS)

> 2. in the next step I would like to get the coordinates for all the nodes which are  > building a polyline.

Use the ObjectNodeX and ObjectNodeY commands to grab the x and y coordinates of the nodes.  You can use a counter to loop thru the polyline node by node.  It would also be helpful to check for plineness - ObjectInfo(bObject, OBJ_INFO_TYPE) - before the loop as I have found MapBasic to be a little tipsy with ObjectNode and a regular old line.

Dim Xcoord As Float
Dim Ycoord As Floa

[Jacques Paris] Dim nseg, j as smallint

nseg=objectinfo(bOject,21)        '21 or obj_info_npolygons

for j=1 to nesg

nNumNodes= objectinfo(bObject,21+j)

For nCntr = 1 To nNumNodes
        Xcoord = ObjectNodeX(bObject,  , 21+ nCntr )
        Ycoord = ObjectNodeY(bObject,  j , 21+ nCntr )
Next           
[Jacques Paris] Next 

Reply via email to