Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to draw a circle in MapInfo exactly 0.9Ha in area.

I've done it by working out the corresponding radius should be, drawing a circle of arbitrary size, double clicking on it and then entering the radius. Is there a tool to do this?

If there isn't a tool for this then I'm going to make one, so I have another question: how do you programmatically get the geographic coordinates of a mouseclick?

share|improve this question
    
I look forword to the solution :) . Well I found something that might be useful for you on mapbasic reference guide Chapter 10 page 759 using toolHandler with commandinfo() –  kinkajou Oct 17 '11 at 9:35
    
@Kitex Thanks for that. I'm having some problems - it's creating the circle at slightly the wrong size in slightly the wrong place! I've added it to my Github account anyway (github.com/mrchimp/JakesMapbasicToolbars). Feel free to join in! –  Mr_Chimp Oct 19 '11 at 15:37
add comment

2 Answers

up vote 6 down vote accepted

Just sue the CreateCircle method in the MapBasic window, or just put it behind a quick and dirty dialogue with all the maths worked out behind the scene

Create circle in MapBasic

CreateCircle( x, y, radius )  

x is a float value of the circle's center. 
y is a float value of the circle's center. 
radius is a float value, indicating the circle radius. 

As for capturing a mouse click, Read the MapBasic Manual especially "Create ButtonPad statement", but you'd have to write some custom code for this, a bit like this:

Use the CommandInfo() function with the CMD_INFO_X and CMD_INFO_Y parameters and you can retrieve the info from the point you click on

from here, you can bring up a dialogue/code, with which you can then add the createCircle functionality Ex.

Include "mapbasic.def"
Include "icons.def"

Declare Sub Main
Declare Sub get_map_click

Sub Main
  Alter ButtonPad "Tools" 
Add 
Separator 
ToolButton 
Icon MI_ICON_CROSSHAIR 
HelpMsg "Click on map" 
Cursor MI_CURSOR_CROSSHAIR 
DrawMode DM_CUSTOM_POINT 
Calling get_map_click 
Show

End Sub


Sub get_map_click 
    Note "x:" + Round(CommandInfo(CMD_INFO_X), 0.1) + Chr$(10) + "y:" + Round(CommandInfo(CMD_INFO_Y), 0.1) 
    'add code to create a circle to whatever layer you want
End Sub 

You'd have to click the button each time you wanted to capture a point.

EDIT

Please note, I have not written MapBasic code for a couple of three years, so please have a look at the user/reference guide before you commit this to production data or anything silly like that. I am sure this is how you'd do it, but make sure first please.

share|improve this answer
    
Thanks for the response. I have been re-tasked so probably won't get to look at this til tomorrow now. –  Mr_Chimp Oct 17 '11 at 13:14
    
@Kitex - cheers, I knew I'd forgotten something –  Hairy Oct 18 '11 at 8:09
add comment

Perhaps you can use the MapCAD tool Circle from Center and Radius/Diameter for this. For programmatically retrieving coordinates you can use the CommandInfo() function in MapBasic.

share|improve this answer
    
+1 MapCAD is good –  kinkajou Oct 17 '11 at 13:05
    
Bit expensive just for drawing a circle though! –  Mr_Chimp Oct 17 '11 at 14:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.