From: Martin D. <mar...@no...> - 2005-03-09 10:30:02
|
Hello Gayatri Finally I had a look at the code you sent me last week (sorry for the delay). I saw many lines, but no closed shapes. It may be the reason why GeometryCollection give no output (it doesn't explains the infinite loop however). If we wants to check if a point is inside a shape, GeometryCollection need closed shapes. We can said if a point is inside a circle, or a rectangle, or a polygon. But what is "inside" a line that goes from the bottom to the top of the screen? If you means a point located right on the line, GeometryCollection will not work for this case; it assumes that line width are 0 (which is consistent with java.awt.geom.Line2D. See the 'contains' method for Line2D in J2SE javadoc). Even if a line has some width on the screen, it is often a styling issue unrelated to the width of the feature in "real world". So if I'm understanding right, you want to find which line is close to a point. If I'm understanding right, you can process as below: 1) Iterate through each geometries. 2) Get the PathIterator for current geometry. You can take the opportunity to ask for pixels coordinates if you want (through the AffineTransform argument). 3) Iterate through each lines returned by the PathIterator. 4) Use java.awt.geom.Line2D.ptLineDist(...) method in order to compute the distance between this line and yours point. 5) Select the feature when the distance is below some threshold value. Hope it help, Martin. |