This project is read-only.

Heads Up Display

Dec 27, 2010 at 8:53 PM

I am evaluating the DotSpatial library for a hydrographic survey package I am writing. I am very impressed with the rich featrueset provided, but I cannot see a way of rotating the entire map display. I need to be able to provide a heads up display with the ship centered on the screen and the spatial data rotating and translating accordingly.

Is this possible? If so, how would I set up the map rotation angle in code?

Thanks,

Dave

Dec 28, 2010 at 2:23 PM

So far the Map Gui is not designed with this feature built in.  You could probably accomplish this by adding a handler to the Map.Paint event.  In that event, we normally have already drawn the image from the Map.MapFrame.Buffer to the bitmap which you can then draw on top of.  In your case, what you would do is figure out your Transform matrix.  The Graphics device "g" handed to you in the Paint Event allows you to set the "Transform" matrix.  I think this is a System.Drawing.Drawing2D.Matrix object.  This is a structure, so you cannot change attributes on the existing member like g.Transform.M1 = 5.  Instead, you must do Matrix m = new Matrix(.5, 1, 3, .2, 40, 50) or whatever and then do g.Transform = m;.   Having set the transform, when you call g.DrawImage() and pass the Map.MapFrame.Buffer image it should appear rotated.  You will want to extend the back buffer using the property on the map which extends the buffer image to three times as wide and three times as tall as the map view area.  This way, even as you rotate the background image, you will not have white background when you are drawing the image at an angle.

Be aware that rotating the view like this is only half the battle.  You will not be able to take advantage of our existing Pan functionality for instance, because if you are rotated, you will be panning in the wrong direction.  You can start with the existing MapFunctionPan class, but you will have to modify it to take into account your rotation angle to make it work correctly.  The same is probably true for rectangle zoom.  If the view is rotated, you will likely be zooming into the wrong place by default, so you will have to start with the MapFunctionZoom and tweak it to account for your rotation angle.

Depending on your level of programming experience, this may be something you are willing to tackle.  If not, you might consider adding it as a feature to the issue tracker, where if it receives enough votes it might get done for free.  If not, or if you have a strict timeline, you might consider funding the addition of this feature.  Adding the feature itself may not take a lot of time, maybe just an hour of work or so, but it might take a full day worth of debugging or more to deal with the unexpected bugs that appear when using this feature.

Ted

 

Dec 28, 2010 at 2:33 PM

Thanks for the quick reply... I have already coded the graphics shell for my application - it handles rotations, etc. so that panning, zooming, screen to pixel coordinate conversions, etc. are all working. I was looking at DotSpatial because eventually I'll need GDAL support for image overlays. At this time it might be quicker for me to continue along my path rather than try to learn the whole DotSpatial model to figure out how best to insert the matrix transformation code.

Can you elaborate more on the funding suggestion?

Dec 28, 2010 at 3:00 PM

Dr. Dan Ames heads up the research and development operation, and has a team of graduate students that put in development effort on various projects.  Most of these are large scale ventures that can completely fund a graduate student for a semester, and gain the full support of that developer along with their experience working with the system to ensure that you have whatever you need.  That would normally run several thousand dollars.  However, there are also smaller scale billing setups that can be used for quick feature additions.  I think this works on a kind of hourly basis where he will send an invoice once the feature is complete.  Dan might set you up through something more like a paypal situation rather than a full ISU account driven system since formal accounts require a substantial amount of overhead to implement.  It's not clear exactly what resources he can throw at this at the moment since it's Christmas break, but he has several team members that could get this kind of feature online.  I currently bill part time through Dan on weekends, but I'm away on vacation right now, and not set up to do any programming until I get back in January.  Anyway, you can email him at dan.ames@isu.edu about the specifics of setting something up.  There are also a large number of developers associated with the project that are comfortable with DotSpatial and some of them might also be willing to code for cash.  We don't currently have a payed feature system so for now you might be able to come to an individual arrangement with a volunteer.  Maybe we need to think about coordinating a system to help facilitate development like that.  We could set it up to where the feature request is made, and a dollar amount is offered for its completion.  To protect the programmers, we would request the money up front, and hold it until the moderator deems that the terms of the request are completed satisfactorily.  If the moderators feel that the terms are met then the money could be payed to the developer, perhaps less a handling charge or something.  If not, then after a designated time, maybe 1 month or so, the money could be returned.  We have not before tried to get the financing to help the greater external developer community before, and this usually works on the basis of volunteer work, but I have seen some code for cash sites that work something like that.  Anyway, talk with Dan, and I'm sure he can get you some better information.

Ted

 

Dec 28, 2010 at 9:41 PM
"Code for cash" has a nice ring to it. So this is a great opportunity to point out (to anyone who stumbles upon this site) that there are a number of awesome programmers on the broader DotSpatial team, many of whom do private programming and who would be very happy to take contracts of any type/size. So if you have a small or large task that needs done, please post a note here and let folks respond. - Dan

On Tue, Dec 28, 2010 at 8:00 AM, shade1974 <notifications@codeplex.com> wrote:

From: shade1974

Dr. Dan Ames heads up the research and development operation, and has a team of graduate students that put in development effort on various projects. Most of these are large scale ventures that can completely fund a graduate student for a semester, and gain the full support of that developer along with their experience working with the system to ensure that you have whatever you need. That would normally run several thousand dollars. However, there are also smaller scale billing setups that can be used for quick feature additions. I think this works on a kind of hourly basis where he will send an invoice once the feature is complete. Dan might set you up through something more like a paypal situation rather than a full ISU account driven system since formal accounts require a substantial amount of overhead to implement. It's not clear exactly what resources he can throw at this at the moment since it's Christmas break, but he has several team members that could get this kind of feature online. I currently bill part time through Dan on weekends, but I'm away on vacation right now, and not set up to do any programming until I get back in January. Anyway, you can email him at dan.ames@isu.edu about the specifics of setting something up. There are also a large number of developers associated with the project that are comfortable with DotSpatial and some of them might also be willing to code for cash. We don't currently have a payed feature system so for now you might be able to come to an individual arrangement with a volunteer. Maybe we need to think about coordinating a system to help facilitate development like that. We could set it up to where the feature request is made, and a dollar amount is offered for its completion. To protect the programmers, we would request the money up front, and hold it until the moderator deems that the terms of the request are completed satisfactorily. If the moderators feel that the terms are met then the money could be payed to the developer, perhaps less a handling charge or something. If not, then after a designated time, maybe 1 month or so, the money could be returned. We have not before tried to get the financing to help the greater external developer community before, and this usually works on the basis of volunteer work, but I have seen some code for cash sites that work something like that. Anyway, talk with Dan, and I'm sure he can get you some better information.

Ted

Read the full discussion online.

To add a post to this discussion, reply to this email (DotSpatial@discussions.codeplex.com)

To start a new discussion for this project, email DotSpatial@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Daniel P. Ames, Ph.D. PE
Associate Professor, Geosciences
Idaho State University - Idaho Falls
amesdani@isu.edu
geology.isu.edu
www.mapwindow.org


Jan 5, 2011 at 4:57 AM

I would be keen to get this kind of functionality going as well though I'm not sure how much time I could allocate toward it currently...

I saw in the MW forums here that recently they had partially implemented rotation in the MW 4x project - maybe we can reference/re-use some of their work to help?

Mar 13, 2012 at 10:07 PM

Hi all,

We have been reached a point in our development where this function would be very useful.  I have had a look at the MW implementation above and see that they have included this functionality - as tidyup suggests can we reference some of their work to get this into dotspatial?  I am very much a novice (and working in vb.net) but would be happy to help out if I can.

Rob

Mar 14, 2012 at 7:37 PM

kellison would like to see a rotate map feature, too.

Mar 14, 2012 at 8:02 PM

Yep, but don't have any resources to throw at it right now.

Nov 1, 2012 at 11:48 PM
Edited Nov 2, 2012 at 12:13 AM

Hi, I am still very interested in this feature so have had a go modifying the map control in c#. I will try and tackle the map rotation first and then attack the pan functions.

I have set the map extendbuffer = true and I have added the following code to the OnPaint even in the map class which rotates the bitmap stencil about its central point c. I also have a map property called Rotation. This works ok except that it does not create a bitmap with the extended buffer i.e. it clips the edges of the original bitmap and rotates that. The result is a funny shape a higher zoom levels. Can anyone point me in the right direction.....

 

if (Rotation > 0)

{
PointF c = new PointF(stencil.Width / 2, stencil.Height / 2);
m.RotateAt(Rotation, c);
}

Nov 2, 2012 at 4:06 PM

I just use Dotspatial for some of its internal shapefile reading and gps functions at this point (I do all my own map/geo rendering) so I can't comment on specifics of how to implement this in Dotspatial exactly. However....

Having done heads up map displays a number of times in my career, I've each time ended up simply calculating the biggest rectangle necessary (based on distance from center to corner), expand out to a square of that dimensions beyond the window. Render that the background and then apply the rotation. Depending on underlying system, you might be able to optimize away unnecessary rendering outside the rotated window bounds...but I've never needed to do that to get perf I wanted.

Pan while rotated is similar. You have to calculate the bounding square around the chunk you are panning in and then render that in similar fashion. Or decide it is quicker to just redraw the entire window.

Good luck.

Nov 2, 2012 at 8:40 PM

Thanks for that. Because dotspatial is so well crafted I really want to just add a small exception to handle map rotation and leave the remainder of the classes untouched.

From what I could gather it is pretty much setup to render a bigger rectangle than what is required, I just can't quite understand how to make it do that final part (I am just starting to come to grips with c#). I think I have sorted out a method to handle panning but will need to wait till Monday to try it. So if I can extend the buffer in the on paint event I will be pretty much there I think.