private Polygon2D(Polygon polygon, Polygon2D holes) { super(polygon.minLat, polygon.maxLat, polygon.minLon, polygon.maxLon, polygon.getPolyLats(), polygon.getPolyLons()); this.holes = holes; }
private Polygon2D(Polygon polygon, Polygon2D holes) { super(polygon.minLat, polygon.maxLat, polygon.minLon, polygon.maxLon, polygon.getPolyLats(), polygon.getPolyLons()); this.holes = holes; }
/** * Convert a list of polygons to a list of polygon descriptions. * @param polygons is the list of polygons to convert. * @return the list of polygon descriptions. */ private static List<GeoPolygonFactory.PolygonDescription> convertToDescription(final Polygon... polygons) { final List<GeoPolygonFactory.PolygonDescription> descriptions = new ArrayList<>(polygons.length); for (final Polygon polygon : polygons) { final Polygon[] theHoles = polygon.getHoles(); final List<GeoPolygonFactory.PolygonDescription> holes = convertToDescription(theHoles); // Now do the polygon itself final double[] polyLats = polygon.getPolyLats(); final double[] polyLons = polygon.getPolyLons(); // I presume the arguments have already been checked final List<GeoPoint> points = new ArrayList<>(polyLats.length-1); // We skip the last point anyway because the API requires it to be repeated, and geo3d doesn't repeat it. for (int i = 0; i < polyLats.length - 1; i++) { final int index = polyLats.length - 2 - i; points.add(new GeoPoint(PlanetModel.WGS84, fromDegrees(polyLats[index]), fromDegrees(polyLons[index]))); } descriptions.add(new GeoPolygonFactory.PolygonDescription(points, holes)); } return descriptions; }
final double[] polyLons = polygon.getPolyLons();