rotation of a Polyline

284 views
Skip to first unread message

Riensn

unread,
May 19, 2008, 7:54:26 AM5/19/08
to MapInfo-L
Hi all,
I think I was misunderstood in a former post. Because of that I start
a new one.

I would like to rotate a poly line and write it to a table so that I
can display it on a map.
This is what I have already:

line1: Create Pline 4 ( x1, y1 ) ( x2, y2 ) ( x3, y3 ) ( x1, y1 ) '
Creates a Polyline
line2: anchorpoint_variable = CreatePoint( x1, y1 ) ' Writes
coordinates in a the variable anchorpoint_variable

Now I dont know how to select and rotate the Polyline from line1.
I know that there is a command like this:

RotateAtPoint( object, angle, anchor_point_object )

But I dont know how to select the Polyline that I created before.

And I dont know who to write the rotated Polyline back into a table.

Your help is much appreciated!
BR
Thomas

peter_hors...@mapinfo.com

unread,
May 19, 2008, 8:06:01 AM5/19/08
to mapi...@googlegroups.com

Thomas,

If you only have this one line in the table you can just update the tables obj column with the rotate function:

fAngle = ... 'assign this some value
oRotateAroundPoint= ... 'assign this some value

Update LINE1
        Set OBJ = RotateAtPoint(OBJ, fAngle, oRotateAroundPoint)

where
fAngle is a variable holding the angle to rotate the polyline
and oRotateAroundPoint is a variable to rotate the polyline around.

Peter Horsbøll Møller
Systems Engineer, MTM Geo Informatics
Pitney Bowes MapInfo



This message may contain confidential, proprietary and/or privileged information. It is intended only for the use of the intended recipient(s). If you have received it in error, please immediately advise the sender by reply email and then delete this email message. Any disclosure, copying, distribution or use of the information contained in this email message to or by anyone other than the intended recipient is strictly prohibited. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Pitney Bowes MapInfo. Thank you.

The Pitney Bowes MapInfo entities listed below are registered in England and have their registered offices at: Minton Place, Victoria Street, Windsor, Berkshire SL4 1EG UK. Pitney Bowes MapInfo Limited: Company No. 3038694. Pitney Bowes MapInfo Business Applications Limited: Company No. 2170883. Pitney Bowes MapInfo Scotland Limited: Company No.4007670. Pitney Bowes MapInfo GDC Limited: Company No. 4480179

Riensn

unread,
May 19, 2008, 10:29:44 AM5/19/08
to MapInfo-L
Hi Peter,

many thanks this helped me a lot already but I still get some errors.
I would like to do it not only once but 10 times. I try to fetch
latitude and longitude from table "KPI_with_coord_rw" and use these
for the Poly line.
Then rotate it and Update the table.

This is exactely what I try to do:

For lauf_variable = 1 to 10 ' 10 iterations

Fetch Rec lauf_variable from KPI_with_coord_rw ' select a row,
next time the next row will be selected
lat_variable = KPI_with_coord_rw.Lat_dec ' write
latitude in variable
long_variable = KPI_with_coord_rw.Long_dec ' write
longitude in variable
ankerpunkt_variable = CreatePoint( lat_variable, long_variable ) '
write anchor point into one variable

Create Pline
4 ( lat_variable, long_variable ) ( lat_variable + 0.2,
long_variable + 0.05 ) ( lat_variable + 0.2, long_variable - 0.05 )
( lat_variable, long_variable ) ' Create Poly line


Update KPI_with_coord_rw
Set OBJ = rotateatpoint(obj, 60, ankerpunkt_variable) '
here I wanted to update the table with the new rotate Poly line... I
think this is not like it should be


Next


Unfortunately I always get this message: Rotateatpoint: Could not
fetch Object from the current row, argument 1.
Maybe I should write the rotate Polyline to different table and
display this one?

Many thanks

Thomas

peter_hors...@mapinfo.com

unread,
May 19, 2008, 3:14:13 PM5/19/08
to mapi...@googlegroups.com

Thomas,

Try this:

For lauf_variable = 1 to 10      ' 10 iterations
       Fetch Rec lauf_variable from KPI_with_coord_rw    ' select a row, next time the next row will be selected

        nRow                        = KPI_with_coord_rw.ROWID          ' Getting the rowid of the current record
       lat_variable         = KPI_with_coord_rw.Lat_dec     ' write latitude in variable
       long_variable        = KPI_with_coord_rw.Long_dec    ' write longitude in variable

         ankerpunkt_variable = CreatePoint( lat_variable, long_variable )   'write anchor point into one variable

        Create Pline
               Into Variable oPLine
                  4
                (lat_variable, long_variable)
                (lat_variable + 0.2, long_variable + 0.05)
                (lat_variable + 0.2, long_variable - 0.05)
               (lat_variable, long_variable )  


        Update KPI_with_coord_rw
                       Set OBJ = rotateatpoint(
oPLine, 60, ankerpunkt_variable)
                        Where ROWID = nRow
        'here I wanted to update the table with the new rotate Poly line... I think this is not like it should be
Next


You might also want to consider changing your For ... Next loop into a Do Until loop.
Unless you know that there always will be 10 records in the table, the Do Until is safer:

Fetch First From KPI_with_coord_rw
Do Until EOT(KPI_with_coord_rw)
        nRow                        = KPI_with_coord_rw.ROWID          ' Getting the rowid of the current record
        lat_variable         = KPI_with_coord_rw.Lat_dec     ' write latitude in variable
       long_variable        = KPI_with_coord_rw.Long_dec    ' write longitude in variable

         ankerpunkt_variable = CreatePoint( lat_variable, long_variable )   'write anchor point into one variable

        Create Pline
                 4

                (lat_variable, long_variable)
                (lat_variable + 0.2, long_variable + 0.05)
                (lat_variable + 0.2, long_variable - 0.05)
               (lat_variable, long_variable )  

                Into Variable oPLine

        Update KPI_with_coord_rw
                       Set OBJ = rotateatpoint(oPLine, 60, ankerpunkt_variable)

                        Where ROWID = nRow
        Fetch Next From KPI_with_coord_rw
Loop

And finally you should specify the coordsys before entering the loop.
I assume that the table KPI_with_coord_rw is mappable

Set CoordSys Table KPI_with_coord_rw
Fetch First From KPI_with_coord_rw
        '...

Riensn

unread,
May 20, 2008, 2:05:56 PM5/20/08
to MapInfo-L
Many thanks Peter!!

Now its perfect!!
Reply all
Reply to author
Forward
0 new messages