Hi list,
When trying to parse a gml3 file (http://x10.b3p.nl/heeltest.gml) with geotools
2.7, it fails to correctly parse the geometry. Instead of parsing an arc (part
of a circle), it parses the whole circle. This is caused by the incorrect
method laidOutClockwise(), in the class ArcTypeBinding.
I've made a patch for this problem, which is attached. Can you review this
patch and maybe apply it?
Thanks!
Meine Toonen
Index: ArcTypeBinding.java
===================================================================
--- ArcTypeBinding.java (revision 38473)
+++ ArcTypeBinding.java (working copy)
@@ -37,6 +37,8 @@
/**
*
* @author Erik van de Pol. B3Partners BV.
+ * @author Meine Toonen. B3Partners BV.
+ * @author Matthijs Laan. B3Partners BV.
*
* @source $URL: http://svn.osgeo.org/geotools/branches/2.7.x/build/maven/javadoc/../../../modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/ArcTypeBinding.java $
*/
@@ -125,29 +127,13 @@
/**
* Returns whether the input coordinates are laid out clockwise on their corresponding circle.
- * Only works correctly if the Euclidean distance between c1 and c2 is equal to the Euclidean distance between c2 and c3.
+ * Based on a algorithm of Paul Bourke: http://debian.fmi.uni-sofia.bg/~sergei/cgsr/docs/clockwise.htm. It calculates the cross product of the 3 coordinates.
* @param c1
* @param c2
* @param c3
* @return true if input coordinates are laid out clockwise on their corresponding circle. false otherwise.
*/
protected boolean laidOutClockwise(Coordinate c1, Coordinate c2, Coordinate c3) {
- double x1 = c1.x;
- double y1 = c1.y;
- double x2 = c2.x;
- double y2 = c2.y;
- double x3 = c3.x;
- double y3 = c3.y;
-
- double midY = y1 - (y1 - y3) / 2;
-
- return (x1 < x3 && midY < y2) ||
- (x1 > x3 && midY > y2) ||
- (Double.compare(x1, x3) == 0 && (
- (y1 < y3 && x1 > x2) || // x1 == x3 == midX in this case and the case below
- (y1 > y3 && x1 < x2)
- // Double.compare(y1, y3) == 0 degenerate case omitted
- ));
+ return ((c2.x - c1.x) * (c3.y - c2.y) - (c2.y - c1.y) * (c3.x - c2.x)) < 0.0;
}
-
}------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users