MapWindow Developer Team : MapWindow Discussion Forum
Hello, a small modification for consideration. ZoomToLayer function in ocx doesn't show the whole layer if layer's width is much bigger then it's height (ResizeBehavior =rbModern). For rbIntuitive the situation is opposite - not all height is displayed. Here is code which fixes it.
[Modification] CalculateVisibleExtents function
Posted by: Sergei ()
Date: June 24, 2009 12:08PM

Hello,
a small modification for consideration. ZoomToLayer function in ocx doesn't show the whole layer if layer's width is much bigger then it's height (ResizeBehavior =rbModern). For rbIntuitive the situation is opposite - not all height is displayed. Here is code which fixes it.
New optional parameter added - MapSizeChanged. It’s false by default and true only in CMapView::OnSize event. So resize behaviours aren’t used if we just want to set new extents to the map without resizing it.
Also I add a new resize behaviour.

Thanks.

void CMapView::CalculateVisibleExtents( Extent e, bool LogPrev, bool MapSizeChanged )

//…

if (!MapSizeChanged)
// size of control is the same, we need just to apply new extents
{
	// make extents larger if needed
	if (m_viewHeight!=0 && m_viewWidth !=0 && xrange !=0 && yrange !=0)
	{	double ratio;
		ratio = (double)m_viewWidth/(double)m_viewHeight)/(xrange/yrange);
		if (ratio > 1 )
		{	xrange *= ratio;
			right = left + xrange;
		}
		else if (ratio < 1)
		{	yrange *= (1/ratio);	
			bottom = top - yrange;
		}
	}
}
	else
	// size of control has changed; we need to calculate new extents (old code)

//…

// Additional resize behaviour; upper left corner of map is fixed
if (rbMapResizeBehavior == rbKeepScale)
{   
	//sizeOption is "keep scale", no scale adjustments for both axes
         if (m_pixelPerProjectionX == 0 || m_pixelPerProjectionY == 0)
	{	xextent = xrange;
		yextent = yrange;
	}
	else
	{	xextent = m_viewWidth/m_pixelPerProjectionX;
		yextent = m_viewHeight/m_pixelPerProjectionY;
	}
}

//…
left = left - xadjust;
right = left + xextent;
bottom = bottom - yadjust;
if (rbMapResizeBehavior == rbKeepScale)
	bottom = top - yextent;
else
	top = bottom + yextent;	

Options: ReplyQuote
Re: [Modification] CalculateVisibleExtents function
Posted by: cmichaelis ()
Date: June 24, 2009 04:10PM

Hi Sergei,

I appreciate all these fixes you're suggesting. Would you be interested in getting commit rights to the MapWindow repository? If so, just send me an e-mail at cmichaelis (at) happysquirrel.com and I'll get you set up.

Cheers,
--Chris

Options: ReplyQuote
Re: [Modification] CalculateVisibleExtents function
Posted by: Sergei ()
Date: July 22, 2009 08:30AM

Additional changes after the problem with "centering" reported by pbduda (see [bugs.mapwindow.org]).
ratio = ((double)m_viewWidth/(double)m_viewHeight)/(xrange/yrange);
if (ratio > 1 )
{	
	//right = left + xrange * ratio
	left = left - xrange * (ratio - 1)/2;
	right = left + xrange * (ratio);
	xrange *= ratio;
}
else if (ratio < 1)
{	
	//bottom = top - yrange;
	top = top + yrange * ((1/ratio) - 1)/2;
	bottom = top - yrange * (1/ratio);
	yrange *= (1/ratio);	
}

Options: ReplyQuote
Re: [Modification] CalculateVisibleExtents function
Posted by: pmeems ()
Date: July 23, 2009 01:38AM

Sergei,

Thanks for fixing this.

If you add text like 'This commit fixes bug #1234' to your SVN log it will automagically added to Mantis as well and change the status to fixed.

--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group

Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.

---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS

Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl

*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn

Options: ReplyQuote
Re: [Modification] CalculateVisibleExtents function
Posted by: Sergei ()
Date: July 23, 2009 03:06AM

Paul,
I also customized zooming with mouse wheel in MapWindow. I didn't announce it here. Your thoughts about it are welcomed. Same kind of zooming can be implemented for MouseUp event for ZoomIn and ZoomOut mode (in ocx).

Also it'd be good to introduce customizations from ocx to MapWindow to catch possible errors as early as possible:
- rbKeepScale resize behaviour;
- Map.UseSeamlessPan property.
I'm not sure I can do it the right way.

You may contact me (lsu at mail dot by) on problems with ocx, as I'd like to improve both the library and my cpp skills.

Regards Sergei

Options: ReplyQuote
Re: [Modification] CalculateVisibleExtents function
Posted by: pmeems ()
Date: July 23, 2009 01:51PM

Chris M. knows the most about the ocx. He can also discuss your proposed enhancements with you.
I don't know anything about C++ so I stick with the rest of MapWindow, enough bugs for me there ;)

Later today I'll commit the weekly build and patch, but I can't test your mouse wheel enhancement because I don't have a mouse wheel. I use a vertical mouse (Anir).

If you need any suggestions about bug fixes or enhancement requests just look at the roadmap in Mantis. I try to keep it up-to-date as much as possible.

Thanks for all your work.

Paul

--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group

Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.

---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS

Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl

*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: