package com.github.cadouthat.geojava;

public class GeoPolygon {
    //
}

@@ -32,16 +32,202 @@
 ojava;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0A/**%0A * Represents an enclosed area on Earth's surface, defined by a sequence of points connected by arcs%0A */%0A
 public c
@@ -248,13 +248,2018 @@
 n %7B%0A
+%0A
     /
-/
+**%0A     * Any point known to be outside the polygon, used as the destination for even-odd intersection tests,%0A     * defaults to the North Pole%0A     */%0A    GeoPoint externalReference = new GeoPoint(90, 0);%0A%0A    /**%0A     * Vertices of the polygon in sequence around the perimeter, the last will be connected to the first to%0A     * form a complete loop. Must contain at least 3 vertices to define a valid polygon.%0A     */%0A    List%3CGeoPoint%3E vertices;%0A%0A    public GeoPolygon() %7B%0A        this.vertices = new ArrayList%3C%3E();%0A    %7D%0A%0A    public GeoPolygon(List%3CGeoPoint%3E vertices) %7B%0A        this.vertices = new ArrayList%3C%3E(vertices);%0A    %7D%0A%0A    public GeoPolygon(GeoPoint... vertices) %7B%0A        this(Arrays.asList(vertices));%0A    %7D%0A%0A    public void setExternalReference(GeoPoint externalReference) %7B%0A        this.externalReference = externalReference;%0A    %7D%0A%0A    /**%0A     * @return true if the given point lies inside the polygon%0A     */%0A    public boolean contains(GeoPoint point) %7B%0A        // Fewer than 3 vertices do not define a polygon and cannot contain anything%0A        if (vertices.size() %3C 0) return false;%0A%0A        // The arc between the point and external reference will be used for testing%0A        GeoArc pointArc = new GeoArc(point, externalReference);%0A%0A        // Count the number of intersections with edges%0A        int intersections = 0;%0A%0A        for (int i = 0; i %3C vertices.size(); i++) %7B%0A            // Check each arc between adjacent vertices%0A            GeoPoint vertex1 = vertices.get(i);%0A            GeoPoint vertex2 = (i %3E 0) ? vertices.get(i - 1) : vertices.get(vertices.size() - 1);%0A            GeoArc vertexArc = new GeoArc(vertex1, vertex2);%0A%0A            // Location of intersection doesn't matter, only the presence of intersection%0A            if (pointArc.intersect(vertexArc) != null) %7B%0A                intersections++;%0A            %7D%0A        %7D%0A%0A        // The point is considered inside the polygon if the number of intersections is odd%0A        return (intersections %25 2) %3E 0;%0A    %7D
 %0A%7D%0A

Implement GeoPolygon with containment test