Hello,
I have a problem with my JMapPane. I have an imprecision on the y axis when
I zoom in or out.
I don't have the imprecision when I pan so I suppose that's my zoom method
which doesn't work.
My application has 2 buttons. One zoom in with the center of the map and the
other zoom out with the center of the map too. I display the area every
zoom.
So i zoom in, then zoom out and zoom in. And for me the area should be the
same right?
Here my setTransform and zoom method.
The pZoomFactor is 0.5 or 2.0
[code]
// Zoom in or out
public void zoom(double pZoomFactor) {
Rectangle lPaneArea = mMapPanel.getVisibleRect();
//create a WGS84 point with the center of map
AffineTransform lScreenToWorld = mMapPanel.getScreenToWorldTransform();
mPointSrc.setLocation(lPaneArea.getCenterX(), lPaneArea.getCenterY());
lScreenToWorld.transform(mPointSrc, mCenterPoint);
double lScaleX = mMapPanel.getWorldToScreenTransform().getScaleX();
double lScaleY = mMapPanel.getWorldToScreenTransform().getScaleY();
double lNewScaleX = lScaleX * pZoomFactor;
double lNewScaleY = lScaleY * pZoomFactor;
mCorner.setLocation(mCenterPoint.getX() - 0.5d * lPaneArea.getWidth() /
lNewScaleX, mCenterPoint.getY() + 0.5d * lPaneArea.getHeight() /
lNewScaleY);
mNewMapArea.setFrameFromCenter(mCenterPoint, mCorner);
System.out.println("TSimpleZoomController.zoom()" + mNewMapArea);
mMapPanel.setDisplayArea(mNewMapArea);
}
private void setTransforms(final Envelope pEnvelope, final Rectangle
pPaintArea) {
ReferencedEnvelope lRefEnv = new ReferencedEnvelope(pEnvelope);
double lXScale = pPaintArea.getWidth() / lRefEnv.getWidth();
double lYScale = pPaintArea.getHeight() / lRefEnv.getHeight();
double lScale = Math.min(lXScale, lYScale);
double lXoff = lRefEnv.getMedian(0) * lScale -
pPaintArea.getCenterX();
double lYoff = lRefEnv.getMedian(1) * lScale +
pPaintArea.getCenterY();
mWorldToScreen.setTransform(lScale, 0, 0, -lScale, -lXoff, lYoff);
try {
mScreenToWorld = mWorldToScreen.createInverse();
} catch (NoninvertibleTransformException ex) {
ex.printStackTrace();
}
}
[/code]
Here the results :
first zoom in : TSimpleZoomController.zoom()Envelope2D[(4.8703379,
43.27600610000001), (5.02268126, 43.448857220000015)]
second zoom in : TSimpleZoomController.zoom()Envelope2D[(4.8703379,
43.27563989000002), (5.02268126, 43.448491010000026)]
This a little imprecision on the y axis but I see on the map.
Thanks for your help.
Didier CREST
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Imprecision-with-JMapPane-tp5260912p5260912.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users