From: Jong L. <jon...@ya...> - 2007-08-24 18:06:21
|
Jody,=0A=0AThank you for your answer. I will contact some authors to find o= ut more...=0A=0A- Jong=0A=0A----- Original Message ----=0AFrom: Jody Garnet= t <jga...@re...>=0ATo: Jong Lee <jon...@ya...>; geotools-= users <geo...@li...>; Simone <sim...@gm...= m>; Martin Desruisseaux <mar...@ge...>; Andrea Aime <and= rea...@al...>; Alessio Fabiani <ale...@gm...>=0ASent= : Thursday, August 23, 2007 5:01:16 PM=0ASubject: Re: Geotools question abo= ut raster rendering=0A=0AI am afraid I do not know much about raster suppor= t; I know it was slow =0Ain GeoTools 2.2 and I tell everyone to upgrade to = 2.3 or better :-) So =0Ayou are on the right track ...=0A=0AYou can try con= tacting the module maintainer for the ArcGrid format (you =0Acan check in t= he pom.xml file in your source download).=0A=0AAre you sure your ArcGrid fi= le has color? I would suspect that green was =0Achosen as the default color= and your arcgrid ascii file is single band? =0AI think the mapping of data= into colors is the work of a =0ARasterSymbolizer (part of a Style) which y= ou would have to supply.=0A=0ALooking at your example you *did* supply a ra= ster symbolizer. Have you =0Atried stepping through the code to see if your= symbolizer is applied? I =0Ahad a horrible time upgrading the uDig raster = rendering code to GeoTools =0A2.4 (the "new" GridCoverageRenderer does not = have good javadocs.=0A=0AI would check the @author tag on that file and sta= rt sending email). =0ASimone, Martin, Andrea and Alessio are listed - these= are the people =0Abest able to help.=0A=0AJody=0A=0A> Dear Jody Garnett,= =0A>=0A> I posted a message about my problem, but nobody answered. So, I a= m sending you a message about this issues. I believe that you might know ab= out this matter.=0A>=0A> The following is the message I posted:=0A> ----=0A= > I used geotools 2.2.0 for rendering raster (ESRI ArcGrid Ascii file).=0A>= Now, I am upgrading to geotools 2.3.3 (or 2.3.4). Then, JMapPane=0A> disp= lays the raster with one color (green). I don't know what I am=0A> doing w= rong. The following is the code. Please help me out.=0A>=0A>=0A>=0A> = mapPane =3D new JMapPane();=0A>=0A>=0A> GTRenderer renderer =3D = new StreamingRenderer();=0A>=0A>=0A>=0A> mapPane.setRenderer( rende= rer );=0A>=0A>=0A> mapPane.setSize( 400, 400 );=0A>=0A>=0A> = // context =3D new DefaultMapContext( DefaultGeographicCRS.WGS84 );= =0A>=0A>=0A> context =3D new DefaultMapContext();=0A>=0A>=0A>=0A> = setTitle( "raster test" );=0A>=0A>=0A> addWindowListener( ne= w WindowAdapter() {=0A>=0A>=0A> public void windowClosing( Wind= owEvent e )=0A> {=0A>=0A>=0A> System.exit( 0 );= =0A>=0A>=0A> }=0A>=0A>=0A> } );=0A>=0A>=0A>=0A> = this.setBounds( 20, 20, 450, 450 );=0A>=0A>=0A> mapPane.setContext= ( context );=0A>=0A>=0A> getContentPane().add( mapPane );=0A>=0A>= =0A> setVisible( true );=0A>=0A>=0A>=0A> File f =3D new Fil= e( "D:\\works\\test.asc" );=0A>=0A>=0A> ArcGridReader reader =3D ne= w ArcGridReader( f );=0A>=0A>=0A>=0A> GridCoverage gcDem =3D reader= .read( null );=0A>=0A>=0A> StyleBuilder sb =3D new StyleBuilder();= =0A>=0A>=0A>=0A> ColorMap cm =3D sb.createColorMap( new String[] { = "0.5",=0A> "0.7" }, new double[] { 0.5, 0.7 }, new Color[] { new Color( 255= , 0, 0=0A> ),=0A>=0A>=0A> new Color( 255, 255, 255 ) }, Col= orMap.TYPE_RAMP );=0A>=0A>=0A> RasterSymbolizer rsDem =3D sb.create= RasterSymbolizer( cm, 1 );=0A>=0A>=0A> Style demStyle =3D sb.create= Style( rsDem );=0A>=0A>=0A>=0A> context.addLayer( gcDem, demStyle )= ;=0A>=0A>=0A>=0A> DirectPosition lowerCorner =3D gcDem.getEnvelope(= ).getLowerCorner();=0A>=0A>=0A> DirectPosition upperCorner =3D gcDe= m.getEnvelope().getUpperCorner();=0A>=0A>=0A> Coordinate lowerCoord= =3D new Coordinate( lowerCorner.getCoordinates()[0], lowerCorner.getCoordi= nates()[1] );=0A>=0A>=0A> Coordinate upperCoord =3D new Coordinate(= upperCorner.getCoordinates()[0], upperCorner.getCoordinates()[1] );=0A>=0A= >=0A> Envelope envelope =3D new Envelope( lowerCoord, upperCoord );= =0A>=0A>=0A>=0A> mapPane.setMapArea( envelope );=0A>=0A>=0A> = mapPane.repaint();=0A>=0A>=0A> ----=0A>=0A> Thank you for your help in ad= vance.=0A>=0A>=0A>=0A> - Jong=0A>=0A>=0A>=0A>=0A> =0A=0A=0A=0A |