From: Jody G. <jga...@re...> - 2006-11-28 18:09:02
|
HI Mr Govardhan: I understand that sample code is *needed* by a library - and you are correct in asking on the user list: in talking to Jesse he told me of a Render Utilities class that helps with transforms .... http://javadoc.geotools.fr/2.2/org/geotools/renderer/lite/RendererUtilities.html I have not looked at this class before either -- their is a worldToScreenTransform( mapExtent, paintArea) method that returns a Transform. AffineTransform world2screen = RendererUtilities.worldToScreenTransform( mapExtent, imageArea ); From there you can call transform.createInverse() to get a transform going from screen to world ... AffineTransform screen2world = world2screen.createInverse(); And then finally we need to take your points x and y and transform them: Point2D screen = new Point2D( x, y ); Point2D world = screen2world.transform( ptSrc, null ); This world point should be something useful in your data set. The mapExtent you will need to figure out from the code you used to generate the image, and the imageArea is the size of your image I expect. Give that a go - and get back to me; if it still does not work I will try and spend my coffee break on it. Jody > Dear Jody Garnett, > Thank you for the info, but I am very new to this kind of operation, I > am having tough time to > do this, inverse, can I get some sample code which can give me some > push to do the same. > > > Best Regards > Govardhan > > > ----- Original Message ----- From: "Jody Garnett" > <jga...@re...> > To: "Govardhan" <gov...@co...> > Cc: <geo...@li...> > Sent: Sunday, November 26, 2006 7:10 AM > Subject: Re: [Geotools-gt2-users] NEED TO convert the image coordinate > to Map coordinate > > >> Trying to think - you got an affine transform. >> >> So you need to get the transform.inverse() and then use that to >> "back-project" the screen coordinate - what pops out should be in the >> Map coordinate system. >> >> Cheers, >> Jody >>> Hi All, >>> I am using streamingRenderer and created a jpg image of the Map, >>> now I am able to bring this map on the browser. >>> When I click on the Map, I get x,y any where between 0-640 (w) and >>> 0-480 (h), but now I need to convert this clicked point >>> to Map coordinate point, so that I can bring that clicked point to >>> the center of the map in my next image generation. >>> PLEASE Help me in doing this, I am having really very hard time to >>> achieve this. >>> I am able to zoomin and zoomout by changing the zoomfactor in >>> AffineTransform , but Not able to bring the center of the map >>> where user is click on the image. >>> Best Regards >>> Govardhan >>> Congruence Software Solutions Pvt Ltd >>> KusumPrakash Arcade, site no:9 >>> 1st Main, SanjayNagar >>> Bangalore-94 >>> (O) 001-91-41674163 >>> (V) 678-248-2437 >>> (M) 001-91-9980036996 >>> http://www.congruence.co.in >>> ------------------------------------------------------------------------ >>> >>> >>> ------------------------------------------------------------------------- >>> >>> Take Surveys. Earn Cash. Influence the Future of IT >>> Join SourceForge.net's Techsay panel and you'll get the chance to >>> share your >>> opinions on IT & business topics through brief surveys - and earn cash >>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >>> >>> ------------------------------------------------------------------------ >>> >>> >>> _______________________________________________ >>> Geotools-gt2-users mailing list >>> Geo...@li... >>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>> >> > > |