jhu.htmExamples
Class intersect

java.lang.Object
  |
  +--jhu.htmExamples.intersect

public class intersect
extends java.lang.Object

This example code demonstrates the intersection functionality of the SpatialIndex. It can be invoked by

java jhu.htmExamples.intersect level savelevel domainfile [-b]

where

level     : the level depth to build the index (2 - 14)
savelevel : the level depth to keep index in memory (recommended 2 - 6)
domainfile: file containing a domain
[-b]      : return result as bitlist instead of a list of id's.

The level and savelevel just indicate the index depth. The -b switch might speed up things for depths up to 7 with large-area domains. Domain files:

A domain is a set of convexes, connected by logical OR. A convex is a set of constraints, connected by logical AND. A constraint specifies a cap on the unit sphere by specifying a vector 'a' and a distance 'd' from the origin. 's' is the opening angle defining the cap.

Example: positive distance a = (1,0,0), d = 0.5, s = 60 degrees

.                   ____
.                ---    ---
.               /        /|\
.              /        / |=\
.             |        /  |==|     this side is in the convex.
.            |        /\s |===|
.            |------------|---| -> direction a
.            |        \   |===|
.             |        \  |==|
.              \        \ |=/
.               \        \|/
.                ---____---
.
.
.                     <-d-> is positive (s < 90)

Example: negative distance a = (-1,0,0), d = -0.5, s = 120 degrees

.                   ____
.                ---====---
.  this side is /========/|\
.  in the      /========/=| \
.  convex     |==== s__/==|  |
.            |===== / /===|   |
.  dir. a <- |------------|---|  'hole' in the sphere
.            |========\===|   |
.             |========\==|  |
.              \========\=| /
.               \========\|/
.                ---____---
.

A constraint is represented in the file as a set of 4 floatingpoint numbers x y z d where a=(x,y,z). Example:

1 0 0 0.5

A convex is the area defined by several constraints on the sphere that is common to all constraints. Of course such an area has to be convex.

A convex in the file is defined by a number (number of constraints in the convex) followed by as many convexes (each on one line.) Example:

4
0.5 0.707107 0.5 0.58077530122080200
0.5 0.707107 0.5 0.84077530122080200
-0.5 -0.907107 0.3  -0.87530122080200
0.2 -0.907107 0.3  -0.77530122080200

A domain is an accumulation of convexes. A domain in the domainfile is represented by a number (number of convexes) followed by that many convexes. A domainfile may only contain one domain. It may contain comment lines, starting with #. Special Identifiers

The domain file accepts several special convex identifiers to read in special formats. These identifiers must come as a single comment line before the data, and no additional comments are allowed These are

#TRIANGLE			- the next three lines are triangle corners
#TRIANGLE_RADEC		- same, given in ra/dec
#RECTANGLE			- the next four lines are rectangle corners
#RECTANGLE_RADEC		- same, given in ra/dec
#CONVEX			- read convex in default format
#CONVEX_RADEC		- read the convex in ra/dec format
Examples of a domain files:

Example 1:

#DOMAIN
1
#CONVEX
3
0.5 0.707107 0.5 0.58077530122080200
0.5 0.5 0.707107 0.63480775301220802
0.707107 -0.5 0.5 0.8480775301220802

Example 2:

#DOMAIN
2
#CONVEX
4
0 0 1 0.3
-1 -3 -5 -0.97
5 -3 -10 -0.97
2 2 -5 -0.97
#CONVEX_RADEC
1
25.23 -55.9 0.99

Example 3:

#DOMAIN
1
#RECTANGLE_RADEC
54 29
54 30
55 29
55 30

Example 4:

#DOMAIN
1
#TRIANGLE
0 0 1
0 0.9 0.9
0.9 0 0.9

Example of a run of intersect:

%intersect 4 2 example1
OUTPUT:
#DOMAIN
1
#CONVEX
3
0.707107 -0.5 0.5 0.848078
0.5 0.5 0.707107 0.634808
0.5 0.707107 0.5 0.580775
intersection done in 0.01 sec
List of full nodes : 
3088:N00100  0,45 -8.04156,40.3737 0,39.375
3090:N00102  0,33.75 0,39.375 -7.43146,34.7373
3091:N00103  -7.43146,34.7373 0,39.375 -8.04156,40.3737
3097:N00121  0,33.75 -6.91598,28.9693 0,28.125
3101:N00131  0,33.75 -7.43146,34.7373 -6.91598,28.9693
3296:N03200  0,45 -9.34287,48.9681 -8.04156,40.3737
List of partial nodes : 
3076:N00010 0,22.5 -6.02366,17.0658 0,16.875
3079:N00013 -5.84825,11.415 0,16.875 -6.02366,17.0658
3089:N00101 -15,35.2644 -7.43146,34.7373 -8.04156,40.3737
3096:N00120 0,22.5 0,28.125 -6.56686,23.3217
3098:N00122 -13.2015,23.867 -6.56686,23.3217 -6.91598,28.9693
3099:N00123 -6.91598,28.9693 -6.56686,23.3217 0,28.125
3100:N00130 -13.2015,23.867 -6.91598,28.9693 -14.0498,29.5687
3102:N00132 -15,35.2644 -14.0498,29.5687 -7.43146,34.7373
3103:N00133 -7.43146,34.7373 -14.0498,29.5687 -6.91598,28.9693
3128:N00320 0,22.5 -6.56686,23.3217 -6.02366,17.0658
3168:N01200 0,45 0,50.625 -9.34287,48.9681
3169:N01201 0,56.25 -10.566,54.5745 0,50.625
3170:N01202 -20.1039,52.0619 -9.34287,48.9681 -10.566,54.5745
3171:N01203 -10.566,54.5745 -9.34287,48.9681 0,50.625
3180:N01230 -27.301,62.9135 -23.1655,57.5378 -12.2711,60.2863
3181:N01231 -20.1039,52.0619 -10.566,54.5745 -23.1655,57.5378
3182:N01232 0,56.25 -12.2711,60.2863 -10.566,54.5745
3183:N01233 -10.566,54.5745 -12.2711,60.2863 -23.1655,57.5378
3297:N03201 -20.1039,52.0619 -17.1921,43.691 -9.34287,48.9681
3298:N03202 -15,35.2644 -8.04156,40.3737 -17.1921,43.691
3299:N03203 -17.1921,43.691 -8.04156,40.3737 -9.34287,48.9681
3920:N31100 0,45 9.34287,48.9681 0,50.625
4000:N32200 0,45 0,39.375 8.04156,40.3737
4001:N32201 0,33.75 7.43146,34.7373 0,39.375
4003:N32203 7.43146,34.7373 8.04156,40.3737 0,39.375
4004:N32210 0,22.5 6.56686,23.3217 0,28.125
4006:N32212 0,33.75 0,28.125 6.91598,28.9693
4007:N32213 6.91598,28.9693 0,28.125 6.56686,23.3217
4014:N32232 0,33.75 6.91598,28.9693 7.43146,34.7373
4032:N33000 0,45 8.04156,40.3737 9.34287,48.9681

Author:
Peter Kunszt

Constructor Summary
intersect()
           
 
Method Summary
(package private) static void doBits(SpatialIndex index, SpatialDomain domain)
          do bitlist intersection
(package private) static void doList(SpatialIndex index, SpatialDomain domain)
          do list intersection
(package private) static void main(java.lang.String[] argv)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

intersect

public intersect()
Method Detail

main

static void main(java.lang.String[] argv)
          throws java.lang.Exception

doBits

static void doBits(SpatialIndex index,
                   SpatialDomain domain)
do bitlist intersection

doList

static void doList(SpatialIndex index,
                   SpatialDomain domain)
do list intersection