require 'voruby/stc/loader' require 'voruby/stc/coords_v1_20' include VORuby::STCcoords::V1_20 module VORuby module STCregion module V1_20 # Forward declarations class RegionType; end class Region; end class ShapeType < RegionType; end class CircleType < ShapeType; end class EllipseType < CircleType; end class SmallCircleType; end class VertexType; end class PolygonType < ShapeType; end class BoxType < ShapeType; end class SectorType < ShapeType; end class ConstraintType; end class ConvexType < ShapeType; end class ConvexHullType < ShapeType; end class SkyIndexType < ShapeType; end class UnionType < RegionType; end class Union; end class IntersectionType < RegionType; end class Intersection; end class NegationType < RegionType; end class Negation; end class AllSky; end class Circle; end class Ellipse; end class Polygon; end class Box; end class Sector; end class Convex; end class ConvexHull; end class SkyIndex; end SubstitutionGroups = { 'Region' => [Intersection, Union, Negation, AllSky, Circle, Ellipse, Polygon, Box, Sector, Convex, ConvexHull, SkyIndex] } # Region is the base type for everything. class RegionType include XML::Mapping # the fill_factor (value between 0 and 1) indicates the fraction of the region that is actually included; # possible application: large scale resource coverage areas numeric_node :fill_factor, '@fill_factor', :optional => true, :default_value => 1.0 text_node :note, '@note', :optional => true end # Head element of the Region substitution group. class Region include XML::Mapping object_node :value, '', :class => RegionType, :optional => false end # Shape is the abstract type that is the building block of regions; in real life it needs to be replaced by a concrete shape. class ShapeType object_node :unit, '@unit', :class => PosUnitType, :optional => true, :default_value => 'deg' end # Circle shape: center and radius. class CircleType # the radius of the circle numeric_node :radius, 'Radius', :optional => false # the coordinates of the circle's center object_node :center, 'Center', :class => Double2Type, :optional => false end # Ellipse shape: adds semi-minor axis and position angle to circleType. class EllipseType # half the minor axis of the ellipse, in radius_unit numeric_node :minor_radius, 'MinorRadius', :optional => false # position angle of major axis (Radius) object_node :pos_angle, 'PosAngle', :class => PosAngleType, :optional => false end # SmallCircleType indicates in polygons that side is along small circle; with optional pole. class SmallCircleType include XML::Mapping object_node :pole, 'Pole', :class => Double2Type, :optional => true end # Vertex is a position with optional SmallCircle element; # the SmallCircle element indicates that the polygon side # formed by that vertex and its predecessor vertex is a small # circle, rather than a great circle; SmallCircle has no meaning # in Cartesian coordinates. class VertexType include XML::Mapping object_node :position, 'Position', :class => Double2Type, :optional => false object_node :small_circle, 'SmallCircle', :class => SmallCircleType, :optional => true end # Polygon: one or more vertices; # counter-clockwise encircled area is enclosed; # sides should span less than 180 deg in each coordinate if spherical class PolygonType array_node :vertices, 'Vertex', :class => VertexType, :optional => false end # Box shape: a rectangle defined by its center and size on both dimensions; # since it is a polygon, it is redundant, but simple rectangles with great # circle sides are awkward to define in spherical coordinates. class BoxType # the coordinates of the box's center object_node :center, 'Center', :class => Double2Type, :optional => false # the lengths of the box's sides object_node :size, 'Size', :class => Double2Type, :optional => false end # A sector is the counter-clockwise area between two half-lines. class SectorType # the vertex position of the sector object_node :position, 'Position', :class => Double2Type, :optional => false # the area ccw from this position angle is included object_node :pos_angle1, 'PosAngle1', :class => PosAngleType, :optional => false # the area cw from this position angle is included object_node :pos_angle2, 'PosAngle2', :class => PosAngleType, :optional => false end # An area on the unit sphere defined by the intersection with a plane. class ConstraintType include XML::Mapping # the distance along the normal vector where the constraint plane # intersects that vector; if positive, the spherical sector on the # far side (seen from the center) is selected; if negative, the point # of intersection is in the opposite direction of the vector, resulting # in more than a hemisphere; the valid range is -1.0 to +1.0 numeric_node :offset, 'Offset', :optional => false # this needs to be a spherical coordinate vector; it is the unit vector # that is normal to the plane that forms a constraint for a convex object_node :vector, 'Vector', :class => Double3Type, :optional => false end # A convex polygon defined by one or more Constraints. class ConvexType array_node :constraints, 'Constraint', :class => ConstraintType, :optional => false end # A convex hull. class ConvexHullType array_node :points, 'Point', :class => Double3Type, :optional => false end # This is a hook for regions defined in sky indexing schemes. class SkyIndexType; end # The union of two or more regions is a region. class UnionType full_array_node :regions, 'Region/(' + STC::group_member_names(Region, SubstitutionGroups).join('|') + ')', :unmarshaller => STC::dispatch_from_element_name('VORuby::STCregion::V1_20', Proc.new{|name| "#{name}Type"}), :optional => false end class Union include XML::Mapping object_node :value, '', :class => UnionType, :optional => false end # The intersection of two or more regions is a region. class IntersectionType full_array_node :regions, 'Region/(' + STC::group_member_names(Region, SubstitutionGroups).join('|') + ')', :unmarshaller => STC::dispatch_from_element_name('VORuby::STCregion::V1_20', Proc.new{|name| "#{name}Type"}), :optional => false end class Intersection include XML::Mapping object_node :value, '', :class => IntersectionType, :optional => false end # The negation of a region is a region. class NegationType full_object_node :region, 'Region/(' + STC::group_member_names(Region, SubstitutionGroups).join('|') + ')', :unmarshaller => STC::dispatch_from_element_name('VORuby::STCregion::V1_20', Proc.new{|name| "#{name}Type"}), :optional => false end class Negation include XML::Mapping object_node :value, '', :class => NegationType, :optional => false end # AllSky is just a convenience, meaning no bounds. class AllSky include XML::Mapping object_node :value, '', :class => RegionType, :optional => false end # The circle is defined by a center and a radius. class Circle include XML::Mapping object_node :value, '', :class => CircleType, :optional => false end # Ellipse is an extension of the circle shape, with a minor axis radius and position angle. class Ellipse include XML::Mapping object_node :value, '', :class => EllipseType, :optional => false end # A polygon is a shape delineated by a list of vertices connected with lines, # great circles, or small circles; the inside of the polygon is circumscribed # counter-clockwise by the list of vertices; the polygon may be concave but not # self-intersecting; the last vertex in the list is the predecessor of the first. # For celestial coordinates it is assumed that we are looking at the sphere # from the inside, with Right Ascension increasing to the left. Sides should span # less than 180 deg in each coordinate. class Polygon include XML::Mapping object_node :value, '', :class => PolygonType, :optional => false end # A box is a rectangle; the midpoints of its sides are the endpoints of a cross # centered on the center position with arms that extend half the size for each # coordinate in both directions, and the sides are lines or great circles that # intersect the cross at its end points at right angles; the arms of the cross # are parallel to the coordinate axes at the center point. class Box include XML::Mapping object_node :value, '', :class => BoxType, :optional => false end # A sector selects the area between two half great circles or half lines meeting in a specified point. class Sector include XML::Mapping object_node :value, '', :class => SectorType, :optional => false end # A convex is defined as the intersection of one or more half-plane constraints # with the unit sphere; this may also be described as the union of one or more # convex polygons bounded by one or more constraint planes. class Convex include XML::Mapping object_node :value, '', :class => ConvexType, :optional => false end # A convex hull is the convex polygon that contains all of the specified # positions; the points have to be constrained to lie in one hemisphere. class ConvexHull include XML::Mapping object_node :value, '', :class => ConvexHullType, :optional => false end # A shape defined through a sky indexing scheme; this is really a substitutino group for concrete implementations. class SkyIndex include XML::Mapping object_node :value, '', :class => SkyIndexType, :optional => false end end end end