Issue Type: Bug Bug
Affects Versions: 8.5
Assignee: Unassigned
Components: geometry
Created: 20/Jan/13 5:36 AM
Description:

org.geotools.geometry.jts.GeometryBuilder - ellipse method produces erroneous results due to what is most likely a typo.

problem is with the following line, calculating centerY using the x1 and x2 variables.
double cy = Math.min(x1, x2) + ry;

this should really be:
double cy = Math.min(y1, y2) + ry;

the code of the method as it is currently implemented:

public Polygon ellipse(double x1, double y1, double x2, double y2, int nsides) {
        double rx = Math.abs(x2 - x1) / 2;
        double ry = Math.abs(y2 - y1) / 2;
        double cx = Math.min(x1, x2) + rx;
        double cy = Math.min(x1, x2) + ry;
    
        double[] ord = new double[2 * nsides + 2];
        double angInc = 2 * Math.PI / nsides;
        // create ring in CW order
        for (int i = 0; i < nsides; i++) {
            double ang = -(i * angInc);
            ord[2 * i] = cx + rx * Math.cos(ang);
            ord[2 * i + 1] = cy + ry * Math.sin(ang);
        }
        ord[2 * nsides] = ord[0];
        ord[2 * nsides + 1] = ord[1];
        return polygon(ord);
    }

  • please note that method does work for circles
Environment: N/A
GeoTools 8.5 - org.geotools.geometry.jts.GeometryBuilder
Project: GeoTools
Priority: Major Major
Reporter: ilan keshet
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to