Пример #1
0
 public void testQueryPolygon() throws Exception {
   System.out.println("Testing queryPolygon()");
   Pointing[] corner = new Pointing[4];
   corner[0] = new Pointing(new Vec3(1, 0.01, 0.01));
   corner[1] = new Pointing(new Vec3(1, 1, -0.3));
   corner[2] = new Pointing(new Vec3(0.01, 1, 0.01));
   corner[3] = new Pointing(new Vec3(0.01, 0.01, 1));
   RangeSet lrs = HealpixProc.queryPolygonNest(10, corner);
   assertEquals("QueryPolygon problem", lrs.nval(), 1696714);
   lrs = HealpixProc.queryPolygonInclusiveNest(10, corner, 4);
   assertEquals("QueryPolygon problem", lrs.nval(), 1700206);
   lrs = HealpixProc.queryPolygonRing(10, corner);
   assertEquals("QueryPolygon problem", lrs.nval(), 1696714);
   lrs = HealpixProc.queryPolygonInclusiveRing(10, corner, 4);
   assertEquals("QueryPolygon problem", lrs.nval(), 1700206);
 }
 /**
  * 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;
 }
Пример #3
0
 public void test_query_disc() throws Exception {
   System.out.println("Testing queryDisc() empirically");
   int omax = 17;
   Random rng = new Random(5);
   for (int o = 0; o <= omax; ++o) {
     int niter = Math.max(1, Math.min(nsamples / 1000, 100000 >> o));
     for (int m = 0; m < niter; ++m) {
       Pointing ptg = random_dir(rng);
       double rad = Math.PI * rng.nextDouble();
       RangeSet rs = HealpixProc.queryDiscRing(o, ptg, rad);
       long nval = rs.nval();
       rs = HealpixProc.queryDiscNest(o, ptg, rad);
       assertEquals("queryDisc problem 1", nval, rs.nval());
       rs = HealpixProc.queryDiscInclusiveRing(o, ptg, rad, 4);
       long nv1 = rs.nval();
       rs = HealpixProc.queryDiscInclusiveNest(o, ptg, rad, 4);
       long nv2 = rs.nval();
       assertTrue("queryDisc problem 2", nv1 >= nv2);
       assertTrue("queryDisc problem 3", nv2 >= nval);
     }
   }
 }
Пример #4
0
 public void testQueryPolygon2() throws Exception {
   System.out.println("Testing queryPolygon() empirically");
   int omax = 17;
   Random rng = new Random(5);
   for (int o = 0; o <= omax; ++o) {
     int niter = Math.max(1, Math.min(nsamples / 1000, 100000 >> o));
     for (int m = 0; m < niter; ++m) {
       Pointing[] corner = new Pointing[3];
       corner[0] = random_dir(rng);
       corner[1] = random_dir(rng);
       corner[2] = random_dir(rng);
       RangeSet rs = HealpixProc.queryPolygonRing(o, corner);
       long nval = rs.nval();
       rs = HealpixProc.queryPolygonNest(o, corner);
       assertEquals("queryPolygon problem 1", nval, rs.nval());
       rs = HealpixProc.queryPolygonInclusiveRing(o, corner, 4);
       long nv1 = rs.nval();
       rs = HealpixProc.queryPolygonInclusiveNest(o, corner, 4);
       long nv2 = rs.nval();
       assertTrue("queryPolygon problem 2", nv1 >= nv2);
       assertTrue("queryPolygon problem 3", nv2 >= nval);
     }
   }
 }