ThinkGeo.com    |     Documentation    |     Premium Support

Drawing Arc from SQL Server data

Dear ThinkGeo Team,

I have an inquiry about drawing Arc from SQL Server data:

I need to draw an Arc from data persisted in SQL Server database, The data is not laid out straight forward which means, I understand to draw an Arc I need three points as follow:
o Start point
o Mid-point on the Arc
o End point

The provided data into the database is as follow:
o Start point
o Circle centre point
o Radius
o End point

I am using currently SqlGeographyBuilder class, Shape I have chosen is “OpenGisGeographyType.CircularString” and the function to draw the Arc is AddCircularArc.

• I have seen on the online forums implementation of “CurvedLineShape” class under this post: Draw curve/arc (it does not help me much to achieve the result I need to achieve)

• The data persisted in the database is well organised and trusted, one more piece of information I have got in the data is arc information is Clockwise or Anti-clockwise.

Would you please direct me to what can I do to calculate the “Mid-point” on the Arc from circle centre point and radius. Or it might be another path to solve the problem away from the SqlGeographyBuilder/SqlGeometryBuilder classes.

Thank You,
Ossama

Hi Ossama,

It looks the problem you faced is a mathematics question. If I missed any point please let me know.

We don’t have existing API for that, so I think maybe you can do some search on internet for that, then build your custom function to calculate that, and use our map to render it.

Here I found some topics should be helpful.


Regards,

Ethan

Hi Ethan,

You haven’t missed any point.
Thanks for your quick and helpful reply.

Ossama

Hi Ossama,

I am glad to hear that’s helpful.

Any question please let us know.

Regards,

Ethan

Hi Ethan,

I got a question about LineShape intersecting a circle,
Things I know are as follow:

  • Centre point of the circle
  • Radius of the circle
  • Line starting point is the same as centre point.
  • I know mid point inside the circle
    I can draw a line from the centre of the circle to the mid point I know, my question is I need to extend the line length in the same direction of the mid point, I found an API called ScaleUp, but it lengthen the line in both direction, what I need is fix the starting point of the line which is the centre of the circle and then extend of stretch the line from the other end (mid point) until it intersect with the circle.
    I hope I explained the requirements clearly, I can elaborate more if what I have typed is not clear.

Thank You,
Ossama

Hi Ossama,

I don’t think we have an API is suitable your scenario.

The ScaleUp is get the same shape in different scale, I don’t think it’s so well for implement the target.

I think you still need to calculate the endpoint by math, you know the start point, mid-point, you can quickly get the end point coordinates.
Xend = Xstart + (Xmid - Xstart);
Yend = Ystart + (Ymid - Ystart);

And you can build a new line shape based on the startPoint and endPoint, then use our API intersects to calculate the intersection point.

If I misunderstand it please let me know, wish that’s helpful.

Regards,

Ethan

Hi Ethan,

Thanks for your idea, I haven’t had the chance to implement it yet but I am pretty sure it will work fine as usual.
I will update you with the outcome of course.

Thank you,
Ossama

Hi Ossama,

Any question please let us know.

Regards,

Ethan

Hi Ethan,

I was recently with your assistance able to draw manual shapes including multiple Arcs, now I need to edit them, I found there is an “EditInteractiveOverLay” layer to work with Editing shapes.
I have extended the “EditInteractiveOverLay” class and it worked well in fact, so I can draw a shape and then edit it and drag its vertices and then end edit and it redraw the shape on TrackInteractiveOverLay" layer, up to this point all good.
I realise when I extended the “EditInteractiveOverLay” class , I lost the Editing Capability as per below:
winformsMap1.EditOverlay.CanAddVertex = true;
winformsMap1.EditOverlay.CanDrag = true;
winformsMap1.EditOverlay.CanRemoveVertex = true;
winformsMap1.EditOverlay.CanResize = true;
winformsMap1.EditOverlay.CanRotate = true;
winformsMap1.EditOverlay.CalculateAllControlPoints();

selectVerticesEditInteractiveOverlay = ((ThinkGeoWinForm.SelectVerticesEditInteractiveOverlay)winformsMap1.EditOverlay);
This line in specific throw an exception "Unable to cast object of type ‘ThinkGeo.MapSuite.Desktop Edition.Edit Interactive Overlay’ to type 'ThinkGeoWinForm.selectVerticesEditInteractiveOverlay "

How Can I retain all the above capabilities while extending the “EditInteractiveOverLay” class.
I hope I have made my question clear, if not I can rephrase it and re-send it.

Thank You,
Ossama Abdelmalak

Hi Again Ethan,

Another question I need your help with please.
How can I calculate the angle from true north between 2 points the centre point and the start point of the curve.

Thank You,
Ossama Abdelmalak

Hi Ossama,

From the exception information, it looks you try to convert our EditInteractiveOverlay to your custom class, I am not sure whether the SelectVerticesEditInteractiveOverlay is its subclass, but you should want to make sure the winformsMap1.EditOverlay is the subclass instance but not the base class instance, please check that.

And for your 2nd question, if you have pint A(x1, y1) and point B(x2, y2), you can find the 3rd point C(x1, y2) [x1 < x2, y1 < y2], then you can get the right triangle and calculate the angle by special theorem.

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,

Thanks for your replies.
Concerning drawing Manual Shapes, I need to clarify the following:
I need to draw Multi Arcs shape , which I have been able to achieve, the shape is drawn by collecting multiple basic geometries, that means I use mouse click to determine my centrepoint and when clicking again I draw a straight line between centrepoint and last clicked point and if need to draw an Arc, I click on the middle of the mouse and then draw the Arc centred around the centrepoint I started with, I can draw clockwise Arc and Anti Clockwise, I will end up with a multi Arcs Polygon collection of Lines some of them straight lines and others are Curved Lines.
My problem now, I need to edit this shape including Arcs and straight lines, what I have done is I put that Multi Arcs Polygons into one Shape of type “MultiLineshape” and then into a feature and then added it to EditInteractiveOverLay , it draws it in the Edit mode exactly the same as I have stored it except that Arcs are not editable, editing an Arc for me is to be able to resize it or drag it or rotate it, but I seems I cant do that with manually drawn Arcs.

Happy Easter and have a good long weekend.

Thank You,
Ossama

Hi Ossama,

Thanks for your detail description, I think I understand your requirement, but I think maybe our EditInteractiveOverLay cannot directly works well for Arc, because the arc is not the base shape in our map.

If you saved it as Polygon or line, it can be edit like polygon shape or line shape. You need to implement that by custom code, if you have any detail tech problem please let us know or show us simple sample, our developer can look into it and see whether we can provide any assistant.

Regards,

Ethan

Hi Ethan,

Thanks for your concise and clear reply, it would be fantastic if you can show me they way of how to think of editing the Arc using custom code, if you got any sample that would be very helpful.
I believe I can find my way if you guys help me with the tool secrets.

Thank You,
Ossama

Hi Ossama,

I think our developer would like to think about this problem based on your currently progress, a simple sample contains the part you have implemented code should be helpful. If you don’t have it and require a complete project which had implemented this new function, the support team maybe cannot work for it, you should want to contact your sales to get professional service.

Regards,

Ethan

Hi Ethan,

I will explain what I have understand by custom code, and if you find I am on the right track please let me know.
I have created a custom shape class which inherit from BaseShape and I have used this custom shape class to draw the Arc.
If as you stated “EditInteractiveOverLay cannot directly works well for Arc” , so create a class inherit from EditInteractiveOverLay and then I can extend its methods, is that what you meant by custom code, Am I on the right track ?
Thank You,
Ossama Abdelmalak

Hi Ossama,

I guess edit the Arc is very complex before you find a way about how to edit it.

For example, our default edit is based on control point, it contains drag&add&delete base operations. And for the entire shape we support drag&resize&rotate.

If that’s an Arc now, how you want to edit it? You should don’t want only support the base operation, you should want to modify the chord length or radian, but you don’t want to make the control point be modified, for make that works, you need to override many functions I think, and I am not sure whether you can implement what you want.

So the first question is how you want to edit an Arc in our map, and then you can start work for that by override the functions, that’s why I think you should wrote some custom code and then we can discuss based on that.

Regards,

Ethan