/** * Transforms a RangetSet in an array of long. * * @param rangeSet rangeSet * @return an array of pixels at a given order */ public static long[] decodeRangeSet(final RangeSet rangeSet) { assert rangeSet != null; long[] pixels = new long[(int) rangeSet.nval()]; RangeSet.ValueIterator valueIter = rangeSet.valueIterator(); int i = 0; while (valueIter.hasNext()) { pixels[i] = valueIter.next(); i++; } return pixels; }
@Override protected final void drawPixels(final Graphics2D graphic2D, final Color color) { graphic2D.setPaint(color); try { final RangeSet.ValueIterator iter = this.range.valueIterator(); while (iter.hasNext()) { final long pixel = iter.next(); drawHealpixPolygon(graphic2D, getHealpixBase(), pixel, getCoordinateTransformation()); } } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); } }
/** * Returns a hierarchical index of a cone. * * @param index Healpix index * @param shape cone * @return the pixel numbers as a hierarchical index * @throws Exception Healpix Exception */ protected static HealpixMoc computeConeIndex(final HealpixIndex index, final Shape shape) throws Exception { final HealpixMoc moc = new HealpixMoc(); final Cone cone = (Cone) shape; final RangeSet rangeSet = index.queryDiscInclusive(cone.getCenter(), cone.getRadius(), TYPICAL_CHOICE_FACT); final RangeSet.ValueIterator valueIter = rangeSet.valueIterator(); while (valueIter.hasNext()) { final long pixNest = valueIter.next(); moc.add(new MocCell(index.getOrder(), pixNest)); } return moc; }
/** * Returns a hierarchical index of a polygon. * * <p>When the polygon is clockwise, the index is computed on this polygon.<br> * When the polygon is counterclockwised, the index is computed on the complement of this polygon * * @param index Healpix index * @param shape polygon * @return the HealpixMoc; * @throws Exception Healpix Exception */ protected static HealpixMoc computePolygonIndex(final HealpixIndex index, final Shape shape) throws Exception { RangeSet rangeSet; HealpixMoc moc = new HealpixMoc(); Polygon polygon = (Polygon) shape; final Resampling resample = new Resampling(polygon); polygon = resample.processResampling(); final List<Polygon> polygons = polygon.triangulate(); rangeSet = new RangeSet(); for (Polygon p : polygons) { final RangeSet rangeSetTmp = new RangeSet(rangeSet); rangeSet.setToUnion(rangeSetTmp, computePolygon(p.getPoints(), index)); } final RangeSet.ValueIterator valueIter = rangeSet.valueIterator(); while (valueIter.hasNext()) { moc.add(new MocCell(index.getOrder(), valueIter.next())); } if (polygon.isClockwised()) { moc = moc.complement(); } return moc; }