/** Create a GeoPolygon using the specified points and holes, using order to determine * siding of the polygon. Much like ESRI, this method uses clockwise to indicate the space * on the same side of the shape as being inside, and counter-clockwise to indicate the * space on the opposite side as being inside. * @param pointList is a list of the GeoPoints to build an arbitrary polygon out of. If points go * clockwise from a given pole, then that pole should be within the polygon. If points go * counter-clockwise, then that pole should be outside the polygon. * @return a GeoPolygon corresponding to what was specified. */ public static GeoPolygon makeGeoPolygon(final PlanetModel planetModel, final List<GeoPoint> pointList) { return makeGeoPolygon(planetModel, pointList, null); }
holes = new ArrayList<>(description.holes.size()); for (final PolygonDescription holeDescription : description.holes) { final GeoPolygon gp = makeGeoPolygon(planetModel, holeDescription, leniencyValue); if (gp == null) { return null; final List<GeoPoint> firstFilteredPointList = filterPoints(description.points); if (firstFilteredPointList == null) { return null; final List<GeoPoint> filteredPointList = filterEdges(firstFilteredPointList, leniencyValue); final GeoPoint centerOfMass = getCenterOfMass(planetModel, filteredPointList); final Boolean isCenterOfMassInside = isInsidePolygon(centerOfMass, filteredPointList); if (isCenterOfMassInside != null) { return generateGeoPolygon(planetModel, filteredPointList, holes, centerOfMass, isCenterOfMassInside); final GeoPoint pole = pickPole(generator, planetModel, filteredPointList); final Boolean isPoleInside = isInsidePolygon(pole, filteredPointList); if (isPoleInside != null) { return generateGeoPolygon(planetModel, filteredPointList, holes, pole, isPoleInside); return makeLargeGeoPolygon(planetModel, pd);
testPointShape = convertPolygon(pointsList, shape, testPointShape, true); final GeoPoint centerOfMass = getCenterOfMass(planetModel, testPointShape.points); final GeoComplexPolygon comRval = testPointShape.createGeoComplexPolygon(planetModel, pointsList, centerOfMass); if (comRval != null) { for (int counter = 0; counter < 1000000; counter++) { final GeoPoint pole = pickPole(generator, planetModel, testPointShape.points); final GeoComplexPolygon rval = testPointShape.createGeoComplexPolygon(planetModel, pointsList, pole); if (rval != null) {
final Boolean foundIt = findConvexPolygon(planetModel, currentEdge, rval, edgeBuffer, holes, testPoint); if (foundIt == null) { return false; if (buildPolygonShape(rval, seenConcave, planetModel, if (buildPolygonShape(rval, seenConcave, planetModel, if (makeConcavePolygon(planetModel, rval, seenConcave, edgeBuffer, holes, testPoint) == false) { return false;
final List<GeoPoint> filteredPoints = filterPoints(shape.points); if (filteredPoints == null) { return testPointShape; testPointShape = convertPolygon(pointsList, hole, testPointShape, !mustBeInside);
/** Filter coplanar points. * @param noIdenticalPoints with input list of points * @param leniencyValue is the allowed distance of a point from the plane for cleanup of overly detailed polygons * @return the filtered list, or null if we can't get a legit polygon from the input. */ static List<GeoPoint> filterEdges(final List<GeoPoint> noIdenticalPoints, final double leniencyValue) { // Now, do the search needed to find a path that has no coplanarities in it. // It is important to check coplanarities using the points that are further away so the // plane is more precise. for (int i = 0; i < noIdenticalPoints.size(); i++) { //Search starting for current index. final SafePath resultPath = findSafePath(noIdenticalPoints, i, leniencyValue); if (resultPath != null && resultPath.previous != null) { // Read out result, maintaining ordering final List<GeoPoint> rval = new ArrayList<>(noIdenticalPoints.size()); resultPath.fillInList(rval); return rval; } } // No path found. This means that everything was coplanar. return null; }
final Double angle = computeAngle(polyPoint, sinLatitude, cosLatitude, sinLongitude, cosLongitude); if (angle == null) { return null; final Double lastAngle = computeAngle(polyPoints.get(0), sinLatitude, cosLatitude, sinLongitude, cosLongitude); if (lastAngle == null) { return null;
if (buildPolygonShape(rval, seenConcave, planetModel, filteredPointList, new BitSet(), 0, 1, initialPlane, holes, testPoint) == false) { buildPolygonShape(rval, seenConcave, planetModel, filteredPointList, new BitSet(), 0, 1, initialPlane, holes, null); return rval; buildPolygonShape(rval, seenConcave, planetModel, filteredPointList, new BitSet(), 0, 1, new SidedPlane(initialPlane), holes, null); return rval; } else { buildPolygonShape(rval, seenConcave, planetModel, filteredPointList, new BitSet(), 0, 1, new SidedPlane(initialPlane), holes, null); return rval;
final List<GeoPoint> firstFilteredPointList = filterPoints(pointList); if (firstFilteredPointList == null) { return null; final List<GeoPoint> filteredPointList = filterEdges(firstFilteredPointList, leniencyValue); final GeoPoint centerOfMass = getCenterOfMass(planetModel, filteredPointList); final Boolean isCenterOfMassInside = isInsidePolygon(centerOfMass, filteredPointList); if (isCenterOfMassInside != null) { return generateGeoPolygon(planetModel, filteredPointList, holes, centerOfMass, isCenterOfMassInside); final GeoPoint pole = pickPole(generator, planetModel, filteredPointList); final Boolean isPoleInside = isInsidePolygon(pole, filteredPointList); if (isPoleInside != null) { return generateGeoPolygon(planetModel, filteredPointList, holes, pole, isPoleInside); return makeLargeGeoPolygon(planetModel, description);
/** Create a GeoPolygon using the specified points and holes, using order to determine * siding of the polygon. Much like ESRI, this method uses clockwise to indicate the space * on the same side of the shape as being inside, and counter-clockwise to indicate the * space on the opposite side as being inside. * @param description describes the polygon and its associated holes. If points go * clockwise from a given pole, then that pole should be within the polygon. If points go * counter-clockwise, then that pole should be outside the polygon. * @return a GeoPolygon corresponding to what was specified, or null if a valid polygon cannot be generated * from this input. */ public static GeoPolygon makeGeoPolygon(final PlanetModel planetModel, final PolygonDescription description) { return makeGeoPolygon(planetModel, description, 0.0); }
/** Create a GeoPolygon using the specified points and holes, using order to determine * siding of the polygon. Much like ESRI, this method uses clockwise to indicate the space * on the same side of the shape as being inside, and counter-clockwise to indicate the * space on the opposite side as being inside. * @param pointList is a list of the GeoPoints to build an arbitrary polygon out of. If points go * clockwise from a given pole, then that pole should be within the polygon. If points go * counter-clockwise, then that pole should be outside the polygon. * @param holes is a list of polygons representing "holes" in the outside polygon. Holes describe the area outside * each hole as being "in set". Null == none. * @return a GeoPolygon corresponding to what was specified, or null if a valid polygon cannot be generated * from this input. */ public static GeoPolygon makeGeoPolygon(final PlanetModel planetModel, final List<GeoPoint> pointList, final List<GeoPolygon> holes) { return makeGeoPolygon(planetModel, pointList, holes, 0.0); }
@SuppressWarnings("unchecked") @Override public Shape build() { GeoPolygonFactory.PolygonDescription description = new GeoPolygonFactory.PolygonDescription(points, polyHoles); GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(planetModel, description); if (polygon == null) { throw new InvalidShapeException("Invalid polygon, all points are coplanar"); } return new Geo3dShape<>(polygon, context); }
final GeoPolygon rval = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, points, holeList);