From: Martin D. <mar...@te...> - 2002-06-13 10:01:34
|
Hello > In general it is more useful to get back rectangles rather than a single > shape, since searches based on rectangles are much faster on any > practical implementation I know of. Maybe, but I wonder if we should benchmark it to be sure. For example, calling "difference" many time may result in a quick explosion of the amount of rectangles. See attached figure for an example. Since Area try to do an intelligent work, it is not obvious to me that the Rectangle approach would be faster when the amount of Rectangles is big. If performance is the prime concern, than a more efficient algorithm with rectangles would be: R1 = the orange rectangle N1 = the first white rectangle N2 = the second white rectangle if (R1.contains(P) && !N1.contains(P) && !N2.contains(P)) It would probably be more efficient than if (R1.contains(P) || R2.contains(P) || R3.contains(P) || R4.contains(P) || R5.contains(P) || R6.contains(P)) If we want to implement the (R1,N1,N2) algorithm instead of the (R1,R2,R3,R4,R5,R6) one, then we are going closer to Rob architecture with his Filter (AND, OR, NOT operations, etc.). It bring us to the point Rob made some time ago, that Extends are just special kind of Filters. In anycase, my point is that Extend.difference shoud not returns an array of Extent. It should returns a single Extent instead. This single Extent may be a package-private implementation wrappind an array of other Extents, or a combinaison of AND/OR/NOT operations among the line of Rob's filters. > But you are right we do need to revisit the ogc envelope and our extent > objects, to see what simplifications we can make. As we develop more > extents this interface will mature. Two questions here: 1) Are Extent always two-dimensional? 2) Are Extent always rectangular in shape? If the answer is true for 1 and 2, then Extent is basically a java.awt.geom.Rectangle2D. If 1 is false and 2 is true, then Extent is basically a org.opengis.pt.PT_Envelope. If both 1 and 2 are false, then I see no direct equivalence. In this last case, the Extent existence is easier to justify. Regards, Martin. |