Re: [Geotools-gt2-users] Transform Screen to Lat/Long Posible error in UserManual
I've already done what I wanted to do: Transform among screen coordinates and world coordinates (and back) using the code: -- AffineTransform world2screen = RendererUtilities.worldToScreenTransform(mapContext.getLayerBounds(), new Rectangle(panelMap.getWidth(), panelMap.getHeight())); AffineTransform screen2world = world2screen.createInverse(); Point2D pointScreen = screen2world.transform(pointScreenAbsolute, null); -- I understand that the whole manual page is focused to explain the last point[1] and if I read the whole page to the end I understand that the first example is to show users the _not so_ right way to get x,y axis. But If a programmer that is beginning with GeoTools (like me) read there howto get screen to world coordinates he will end thinking Oh shit I don't know how to get this variable, this method params do not match and stop reading. And if he finally get the transform he will end with Long/Lat in UTM and ignorant in how to transform UTM to Long/Lat in a geographic coordinate system (spherical coordinate system) in degrees (If you know the answer to this question please please send it to me). With this I'm trying to explain why I think that the _working_ examples in the user manual are very important, and if the example is vague because is only a waypoint to explain another thing I think (always IMHO, I thank you guys infinitely for the great work of creating GeoTools) that a link to a working example must be provided. If you show me the user manual guidelines I will be glad to document carefully the things I achieve in the progress of my project. Thanks! [1] http://docs.codehaus.org/display/GEOTDOC/04+What+Axis+is +X#04WhatAxisisX-LookinguptherightAxis On jue, 2008-01-17 at 18:49 -0800, Jody Garnett wrote: Can we chat for a second about what you are wanting out of this example? Having a look at it this is an example of the referencing module; so the point of the page is to ask people to trust (and use!) the coordinate reference system metadata. Rather than just assuming new Point2D( position.getOrdinate( 0 ), position.getOrdinate( 1 ) ). Do you actually want to transform screen to Lat/Long? data - is unknown world - is this Lat/Long for you screen - is based on the view port model or some kind of world2screen transformation used by the renderer Jody I'm going to try fixing the example after dinner. On Thu, January 17, 2008 17:48, Jody Garnett wrote: I have updated that page with your code example: http://docs.codehaus.org/display/GEOTDOC/04+What+Axis+is+X Were you able to spot the error in the original instructions or should I just remove them? -- Diego Fdez. Durán [EMAIL PROTECTED] | http://www.goedi.net GPG : 925C 9A21 7A11 3B13 6E43 50DB F579 D119 90D2 66BB signature.asc Description: Esta parte del mensaje está firmada digitalmente - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
[Geotools-gt2-users] geotiff, overviews and alpha channel
Hi all. I am processing images by GDAL (warp, then gdaladdo) to geotiff with alpha channel. When are images drawn by StreamingRenderer there are 2 problems: 1] I think that for rendering should be used overview with resolution better than result resolution - if exist. But it seems that overview with nearest resolution (even worse than result) is sometimes used. Is this problem solved here: http://www.nabble.com/VALUE_OVERVIEW_POLICY-in-Hints-td14516886.html ? Is there any workaround for GT 2.3.X? 2] I have images with white background - so also edge pixels are white. After gdalwarp there is fully transparent space around original image. Also overviews have fully white borders (I checked it by viewer). But after rendering there is gray border. It seems that interpolation takes in account also pixels which are transparent (and have black RGB value). When zoom is big enough to use original file then gray border disappear. Is there possibility to choose kind of interpolation? Are used different algorithms for overviews and original image? Setting hints for StreamingRenderer doesn't help. Thank you in advance! Best regards Jaroslav Kubos -- Ing. Jaroslav Kubos Amberg Engineering a.s. Ptasinskeho 10 602 00 Brno Czech Republic Phone: +420 541 432 659 Email: [EMAIL PROTECTED]- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
[Geotools-gt2-users] imagemosaic and geotiffs
Hi all I would like to render image by StreamingRenderer composed from: - colored background - N layers * geotiffs in one layer are composed (setOverlap(LATEST_ON_TOP ) of RasterSymbolizer?) with opacity 1 * each layer prepared in previous step has opacity * so result is composed from all layers I guess that for one layer of MapContext composed from multiple geotiffs I need ImageMosaic. Right? If there is other solution I would prefer it. E.g. add more instances of GeoTiffReader to layer. I have geotiffs with overviews and tiles. Is this used when image is part of ImageMosaic? My geotiffs can differ in resolution and/or pixel size in real coords. Is this a problem? Performance? What I should set to .property file to field Levels? Smallest value of pixel size from set? Best regards Jaroslav Kubos -- Ing. Jaroslav Kubos Amberg Engineering a.s. Ptasinskeho 10 602 00 Brno Czech Republic Phone: +420 541 432 659 Email: [EMAIL PROTECTED]- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
[Geotools-gt2-users] geotiff, overviews and alpha channel
Hi all. I am processing images by GDAL (warp, then gdaladdo) to geotiff with alpha channel. When are images drawn by StreamingRenderer there are 2 problems: 1] I think that for rendering should be used overview with resolution better than result resolution - if exist. But it seems that overview with nearest resolution (even worse than result) is sometimes used. Is this problem solved here: http://www.nabble.com/VALUE_OVERVIEW_POLICY-in-Hints-td14516886.html ? Is there any workaround for GT 2.3.X? 2] I have images with white background - so also edge pixels are white. After gdalwarp there is fully transparent space around original image. Also overviews have fully white borders (I checked it by viewer). But after rendering there is gray border. It seems that interpolation takes in account also pixels which are transparent (and have black RGB value). When zoom is big enough to use original file then gray border disappear. Is there possibility to choose kind of interpolation? Are used different algorithms for overviews and original image? Setting hints for StreamingRenderer doesn't help. Thank you in advance! Best regards Jaroslav Kubos -- Ing. Jaroslav Kubos Amberg Engineering a.s. Ptasinskeho 10 602 00 Brno Czech Republic Phone: +420 541 432 659 Email: [EMAIL PROTECTED]- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
[Geotools-gt2-users] JAI on IBM AIX
Hello all, I have to set up a Geotools based application on an IBM AIX environment that uses A Websphere application server. Therefore the operating system is AIX 64 bit and it uses a IBM Virtual Machine. Do you know if I can find a JAI implementation for AIX? That is, a version with hardware acceleration, such as in Windows or Linux O.S.. If it does not exist, I will have to install pure java implementation. Do you think that Geotools will slow down significantly? Thank you in advance. Best regards Manuele - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] imagemosaic and geotiffs
On vie, 2008-01-18 at 12:58 +0100, [EMAIL PROTECTED] wrote: Hi all I would like to render image by StreamingRenderer composed from: - colored background - N layers * geotiffs in one layer are composed (setOverlap(LATEST_ON_TOP ) of RasterSymbolizer?) with opacity 1 * each layer prepared in previous step has opacity * so result is composed from all layers I guess that for one layer of MapContext composed from multiple geotiffs I need ImageMosaic. Right? If there is other solution I would prefer it. E.g. add more instances of GeoTiffReader to layer. Can't you create one MapLayer with each GeoTiffReader/ImageMosaicReader so the StreamingRenderer can select only the rectangle that must be drawn? I have geotiffs with overviews and tiles. Is this used when image is part of ImageMosaic? Yes, if you have geotiffs with internal tiling the performance will be better (512x512 is enough). Zoom levels must be set in the LevelsNum field of .properties file (in theory, If've never used it yet) My geotiffs can differ in resolution and/or pixel size in real coords. Is this a problem? Performance? What I should set to .property file to field Levels? Smallest value of pixel size from set? Absolutes pixel size values from geotiff image file (All files in the mosaic must have same resolution); gdalinfo file.tif returns: Pixel Size = (4.71237289430,-4.71237289433) in the .properties you must write: Levels=4.71237289430,4.71237289433 Hope this helps. Best regards Jaroslav Kubos -- Ing. Jaroslav Kubos Amberg Engineering a.s. Ptasinskeho 10 602 00 Brno Czech Republic Phone: +420 541 432 659 Email: [EMAIL PROTECTED] - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users -- Diego Fdez. Durán [EMAIL PROTECTED] | http://www.goedi.net GPG : 925C 9A21 7A11 3B13 6E43 50DB F579 D119 90D2 66BB signature.asc Description: Esta parte del mensaje está firmada digitalmente - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
[Geotools-gt2-users] User manual: Draw points selecting the right axis
If rewrite the example code so I can transform among screen and world coordinates and back in a cleaner way, and fix many syntax errors in the example. I'm waiting for your comments :) -- CODE // Class vars private AffineTransform world2screen; private AffineTransform screen2world; private panelMap // Extends from JPanel. The map is drawn over it // overwriting paintComponent. private void updateTransforms() { try { world2screen = RendererUtilities.worldToScreenTransform(mapContext.getLayerBounds(), new Rectangle(panelMap.getWidth(), panelMap.getHeight())); screen2world = world2screen.createInverse(); } catch (IOException ex) { } catch (NoninvertibleTransformException ex) { } } /* * point has the point coordinates in world UTM coordinate reference * system. */ private void drawPoint(Graphics g, DirectPosition point) { final int X = indexOfX(point.getCoordinateReferenceSystem()); final int Y = indexOfY(point.getCoordinateReferenceSystem()); Point pointWorld = new Point((int) point.getOrdinate(X), (int) point.getOrdinate(Y)); Point2D pointScreen = world2screen.transform(pointWorld, null); int ovalSize = 20; Color colorPrevious = g.getColor(); // Save previous color g.setColor(Color.BLACK);// Point color g.fillOval((int) (pointScreen.getX() - ovalSize / 2), (int) (pointScreen.getY() - ovalSize / 2), ovalSize, ovalSize); g.setColor(colorPrevious); // Restore color } private int indexOfX(CoordinateReferenceSystem crs) { SetAxisDirection up = new HashSetAxisDirection(); up.add(AxisDirection.DISPLAY_LEFT); up.add(AxisDirection.EAST); up.add(AxisDirection.GEOCENTRIC_X); up.add(AxisDirection.COLUMN_POSITIVE); return indexOf(crs, up); } private int indexOfY(CoordinateReferenceSystem crs) { SetAxisDirection up = new HashSetAxisDirection(); up.add(AxisDirection.DISPLAY_UP); up.add(AxisDirection.NORTH); up.add(AxisDirection.GEOCENTRIC_Y); up.add(AxisDirection.ROW_POSITIVE); return indexOf(crs, up); } private int indexOf(CoordinateReferenceSystem crs, SetAxisDirection direction) { CoordinateSystem cs = crs.getCoordinateSystem(); for (int index = 0; index cs.getDimension(); index++) { CoordinateSystemAxis axis = cs.getAxis(index); if (direction.contains(axis.getDirection())) { return index; } } return -1; } -- END CODE [1] http://docs.codehaus.org/display/GEOTDOC/04+What+Axis+is +X#04WhatAxisisX-LookinguptherightAxis -- Diego Fdez. Durán [EMAIL PROTECTED] | http://www.goedi.net GPG : 925C 9A21 7A11 3B13 6E43 50DB F579 D119 90D2 66BB signature.asc Description: Esta parte del mensaje está firmada digitalmente - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Splitting LineStrings at their intersection
Hi Chris, Sorry, its been a busy week and I have not had time to keep up with your questions. Its not immediately evident to me what is wrong with your code. I would have to debug it over on my end. You said your data is a shapefile with a few thousands rows in it? If there are no licensing or confidentiality issues is there any chance i can get my hands on it? that way i could test over here. If so, please send the location of the shapefile (you can in a private email if you wish). Also the most recent version of all your code. -justin Chris wrote: Sorry, it is me again but I'm still stuck with the same problem: I tried the following Coordinate[] c = new Coordinate[]{(l1.getStartPoint()).getCoordinate(), p.getCoordinate()}; LineString l1a = new LineString(new CoordinateArraySequence(c), new GeometryFactory(new PrecisionModel( PrecisionModel.maximumPreciseValue), 4326)); l1_sub.add(l1a); if(!l1.covers(l1a)) System.out.println(Error: a); But this did not improve anything (Still prints Error: a). Hence, in the following of my routine, I trying to see which sub_part of l1 is having an intersection with l2, it happens (more than 1000 times for my shapefile) that I can find any l1 sub_part intersecting l2. To detect the intersection, I'm using the following code: int k = 0; while (k l1_sub.size() !((LineString) l1_sub.get(k)).intersects(l2)) { ++k; } if(k = l1_sub.size()) { System.out.println(error); } I hope someone can help me with this, because of this, my graph is not perfectly connected and this is kinda annoying. This is the last problem in my project... thanks in advance. P.S: I forgot to mention in my previous mail that p in the intersection point between l1 and another linestring l2. On Jan 15, 2008 2:12 AM, Chris [EMAIL PROTECTED] wrote: Could you tell me what is wrong with this part of code? Coordinate[] c = new Coordinate[]{(l1.getStartPoint()).getCoordinate(), p.getCoordinate()}; LineString l1a = new LineString(new CoordinateArraySequence(c), new GeometryFactory()); l1_sub.add(l1a); if(!l1.covers(l1a)) System.out.println(Error: a); It displays Error: a. Because of this, it happens that none of the subparts of l1 intersects with l2 :( Regards, Chris. !DSPAM:4007,4790fcb4143341804284693! -- Justin Deoliveira The Open Planning Project http://topp.openplans.org - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] JAI on IBM AIX
Ciao Manuele, I don't think you'll be able to find a prebuilt version of either jai or imageio native that fits your platform. The source code for media lib and codec lib is not OS hence there is no way to build it on your own. About using pure java JAI and ImageIO and performance slowdown, it really depends on what you are using geotools for. If you are warping and/or scaling images that could be a problem. If not you should not notice any slowdown. Feedback on what your experience is would be much appreciated. Thx, Simone. On Jan 18, 2008 4:59 PM, Manuele Ventoruzzo [EMAIL PROTECTED] wrote: Hello all, I have to set up a Geotools based application on an IBM AIX environment that uses A Websphere application server. Therefore the operating system is AIX 64 bit and it uses a IBM Virtual Machine. Do you know if I can find a JAI implementation for AIX? That is, a version with hardware acceleration, such as in Windows or Linux O.S.. If it does not exist, I will have to install pure java implementation. Do you think that Geotools will slow down significantly? Thank you in advance. Best regards Manuele - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users -- --- Eng. Simone Giannecchini President /CEO GeoSolutions S.A.S. Via Carignoni 51 55041 Camaiore (LU) Italy phone: +39 0584983027 fax: +39 0584983027 mob:+39 333 8128928 http://www.geo-solutions.it --- - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Splitting LineStrings at their intersection
Sorry, it is me again but I'm still stuck with the same problem: I tried the following Coordinate[] c = new Coordinate[]{(l1.getStartPoint()).getCoordinate(), p.getCoordinate()}; LineString l1a = new LineString(new CoordinateArraySequence(c), new GeometryFactory(new PrecisionModel( PrecisionModel.maximumPreciseValue), 4326)); l1_sub.add(l1a); if(!l1.covers(l1a)) System.out.println(Error: a); But this did not improve anything (Still prints Error: a). Hence, in the following of my routine, I trying to see which sub_part of l1 is having an intersection with l2, it happens (more than 1000 times for my shapefile) that I can find any l1 sub_part intersecting l2. To detect the intersection, I'm using the following code: int k = 0; while (k l1_sub.size() !((LineString) l1_sub.get(k)).intersects(l2)) { ++k; } if(k = l1_sub.size()) { System.out.println(error); } I hope someone can help me with this, because of this, my graph is not perfectly connected and this is kinda annoying. This is the last problem in my project... thanks in advance. P.S: I forgot to mention in my previous mail that p in the intersection point between l1 and another linestring l2. On Jan 15, 2008 2:12 AM, Chris [EMAIL PROTECTED] wrote: Could you tell me what is wrong with this part of code? Coordinate[] c = new Coordinate[]{(l1.getStartPoint()).getCoordinate(), p.getCoordinate()}; LineString l1a = new LineString(new CoordinateArraySequence(c), new GeometryFactory()); l1_sub.add(l1a); if(!l1.covers(l1a)) System.out.println(Error: a); It displays Error: a. Because of this, it happens that none of the subparts of l1 intersects with l2 :( Regards, Chris. private static VectorLineString splitLines(VectorLineString lines) { Quadtree index = new Quadtree(); // Fill Spatial Index for (int i = 0; i lines.size(); ++i) { LineString l = (LineString) lines.get(i); index.insert(l.getEnvelopeInternal(), l); } // Detect intersection and cut the lines VectorLineString l1_sub = new VectorLineString(); int imax = lines.size(); for (int i = 0; i imax; ++i) { LineString l1 = (LineString) lines.get(i); List close_lines = index.query(l1.getEnvelopeInternal()); for (int j = 0; j close_lines.size(); ++j) { LineString l2 = (LineString) close_lines.get(j); Geometry gc = l1.intersection(l2); if (gc.getNumGeometries() 0) { // Intersection Point p; try { p = (Point) gc.getGeometryN(0); } catch (Exception e) { continue; } if (!l2.getStartPoint().getCoordinate().equals2D(p.getCoordinate()) !l2.getEndPoint().getCoordinate().equals2D(p.getCoordinate())) { Coordinate[] c = new Coordinate[]{(l2.getStartPoint()).getCoordinate(), p.getCoordinate()}; LineString l2a = new LineString(new CoordinateArraySequence(c), new GeometryFactory(new PrecisionModel(PrecisionModel.maximumPreciseValue), 4326)); c = new Coordinate[]{p.getCoordinate(), (l2.getEndPoint()).getCoordinate()}; LineString l2b = new LineString(new CoordinateArraySequence(c), new GeometryFactory(new PrecisionModel(PrecisionModel.maximumPreciseValue), 4326)); // Update spatial index index.remove(l2.getEnvelopeInternal(), l2); index.insert(l2a.getEnvelopeInternal(), l2a); index.insert(l2b.getEnvelopeInternal(), l2b); } if (l1_sub.size() == 0) { if (!l1.getStartPoint().getCoordinate().equals2D(p.getCoordinate()) !l1.getEndPoint().getCoordinate().equals2D(p.getCoordinate())) { Coordinate[] c = new Coordinate[]{(l1.getStartPoint()).getCoordinate(), p.getCoordinate()}; LineString l1a = new LineString(new CoordinateArraySequence(c), new GeometryFactory(new PrecisionModel(PrecisionModel.maximumPreciseValue), 4326)); l1_sub.add(l1a); c = new Coordinate[]{p.getCoordinate(), (l1.getEndPoint()).getCoordinate()}; LineString l1b = new LineString(new CoordinateArraySequence(c), new GeometryFactory(new PrecisionModel(PrecisionModel.maximumPreciseValue), 4326)); l1_sub.add(l1b); } } else { // l1 was already cut out int k = 0; while (k l1_sub.size() !((LineString) l1_sub.get(k)).intersects(l2)) { ++k; }