Create ellipse - initial help needed

126 views
Skip to first unread message

hendrik

unread,
May 14, 2014, 4:53:40 AM5/14/14
to mapi...@googlegroups.com
Dear List,

i am looking for a way to create an Ellipse.
I would like to do this in the following way.

1) click in Map Window to get the starting point (UTM or GK metric).

2) Then use a Dialog to insert the width and legth of the ellipse in meter and finally
the angle using the rotate function.

This all shoud be done using Mapbasic -
I wrote some Mapbasic code several years before so the implementation and further routines are available.

I only need some help to write the object creation.

Any help would be appreciated.

Thanks in Advance.

Hendrik









Thomas Bacon

unread,
May 14, 2014, 5:39:04 AM5/14/14
to mapi...@googlegroups.com

Hi Hendrik,

 

This should be pretty simple once you’ve got the width, length (height?) and rotation angle. Using the ‘Create Ellipse…’ statement you can set the bounding rectangle for which you want the ellipse to fill. Then it is just a case of rotating that object by the given angle.

 

In pseudocode (none of this is tested, but should give you an idea I hope):

 

Include "MapBasic.def"

Include "Icons.def"

 

Declare Sub Main

Declare Sub toolHandlerProc

Declare Sub ValidateDialog

 

Sub Main

 

       '// use a custom toolbutton to get the x and y coordinates of the click,

       '// specify DM_CUSTOM_POINT as the drawmode if you just want a single click

      

       Create ButtonPad "MakeEllipse" As

              ToolButton

              HelpMsg "Click a start location"

              Calling toolHandlerProc

              Icon MI_ICON_CROSSHAIR

              DrawMode DM_CUSTOM_POINT

       Title "Make Ellipse"

       Width 1

       Show

 

End Sub

 

Sub toolHandlerProc

 

Dim objEllipse as Object

Dim startX, startY, wid, leng, rotAngleDeg as Float

 

       Set Coordsys Window FrontWindow() '// be sure to set your coordinate system before any spatial commands

 

       '// get the click coordinates

       startX = CommandInfo(CMD_INFO_X)

       startY = CommandInfo(CMD_INFO_Y)

 

       Dialog

       '// get your width, length and rotation values here...

       '// probably best to add a handler on the ok button

       '// to validate input values before proceeding

       Control EDITTEXT

              Into wid

       Control EDITTEXT

              Into leng

       Control EDITTEXT

              Into rotAngleDeg

       Control OKBUTTON

              Calling ValidateDialog

 

             

       If Not CommandInfo(CMD_INFO_DLG_OK) then '// dialog not closed with OK button, get out

              Exit Sub

       End If

 

       '// create your ellipse and store into a variable

       Create Ellipse Into Variable objEllipse (startX, startY) (startX + wid, startY + leng)

      

       '// rotate your newly created object

       objEllipse = Rotate(objEllipse, rotAngleDeg)

      

       '// now add your object to a map or table or whatever you like...

 

End Sub

 

Sub ValidateDialog

      

       '// do some validation on the EDITTEXT entries

       '// if validation fails use Dialog Preserve to

       '// stop dialog from closing and prompt user

       '// to correct invalid entries

      

End Sub

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



 

Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX.  The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. 

hendrik

unread,
May 14, 2014, 6:06:06 AM5/14/14
to mapi...@googlegroups.com
Hi Thomas,
this looks great, thank you for your extended help.
Gradually I will expand my program an give a feedback.
Hendrik

Thomas Bacon

unread,
May 14, 2014, 8:31:04 AM5/14/14
to mapi...@googlegroups.com

Glad to help. Should have also mentioned there is another function you can use to rotate the object which allows you to specify the rotation anchor point:

 

RotateAtPoint( object, angle, anchor_point_object )

 

anchor_point_object is a point object around which you want to rotate your object.

 

Regards,

 Error! Filename not specified.

Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX.  The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. 

--

Reply all
Reply to author
Forward
0 new messages