37 #define G_RADIUS "GSkyRegionCircle::radius(double&)"
38 #define G_READ "GSkyRegionCircle::read(std::string&)"
39 #define G_CONTAINS "GSkyRegionCircle::contains(GSkyRegion&)"
40 #define G_OVERLAPS "GSkyRegionCircle::overlaps(GSkyRegion&)"
188 if (
this != ®ion) {
261 "A negative radius of "+
gammalib::str(radius)+
" degrees has been "
262 "specified for a circular sky region. Please specify a "
263 "non-negative radius.";
293 std::string region_def = (!substrings.empty()) ? substrings[0] :
"";
294 std::string comment = (substrings.size() > 1) ? substrings[1] :
"";
297 if (region_def.find(
"circle") == std::string::npos) {
299 "Unable to find the key word \"circle\" in provided string"
300 " \""+line+
"\". The \"circle\" key word is mandatory.";
308 size_t pos = region_def.find(
"circle(");
309 size_t end = region_def.find(
")");
310 std::string circlestring = region_def.substr(pos+7, end);
311 circlestring.erase(circlestring.find(
")"), 1);
315 if (values.size() != 3) {
317 "Invalid number of "+
gammalib::str(values.size())+
" arguments "
318 "after the \"circle\" key word in provided string \""+line+
"\". "
319 "Exactly 3 arguments are expected.";
338 if (system ==
"fk5" || system ==
"icrs") {
341 else if (system ==
"galactic") {
346 "Unsupported coordinate system \""+system+
"\" in provided string "
347 "\""+line+
"\". Only the following coordinate systems are "
348 "supported: \"fk5\", \"icrs\" and \"galactic\".";
361 pos = comment.find(
"text");
362 if (pos != std::string::npos) {
363 pos = comment.find(
"=", pos+4);
364 if (pos != std::string::npos) {
367 const std::string quotes_open =
"{'\"";
368 const std::string quotes_close =
"}'\"";
374 for (
int i = 0; i < quotes_open.size(); ++i) {
375 std::string quote_open = quotes_open.substr(i,1);
376 std::string quote_close = quotes_close.substr(i,1);
377 pos = comment.find(quote_open, pos+1);
378 if (pos != std::string::npos) {
379 end = comment.find(quote_close, pos+1);
380 if (end != std::string::npos) {
381 int length = end-pos-1;
383 m_name = comment.substr(pos+1, length);
391 std::string msg =
"Missing "+quote_open+
" following "+
392 quote_close+
" encountered after "
393 "text attribute. Please add closing "
394 "quotes to text="+quote_open+
"Name"+
395 quote_close+
" attribute.";
403 std::string msg =
"Missing quotes \" or ' or {} following "
404 "text attribute. Please specify quotes "
405 "around the names of the text, for example "
414 std::string msg =
"Missing = following text attribute. Please "
415 "specify the value for a text attribute, "
416 "for example text={Name}.";
441 result.append(
"fk5;circle(");
450 if (
m_name.length() > 0) {
451 result.append(
" # text=");
477 result.append(
"=== GSkyRegionCircle ===");
511 if (distance <=
radius()) {
535 if (reg.
type() ==
"Circle") {
553 else if (reg.
type() ==
"Rectangle") {
569 else if (reg.
type() ==
"Map") {
581 for (
int i = 0; i < indices.size(); ++i) {
600 "Cannot compare to region type \""+reg.
type()+
"\" yet.");
620 bool overlap =
false;
624 if (reg.
type() ==
"Circle") {
641 else if (reg.
type() ==
"Rectangle") {
653 else if (reg.
type() ==
"Map") {
666 "Cannot compare to region type \""+reg.
type()+
"\" yet.");
void free_members(void)
Delete class members.
std::string print(const GChatter &chatter=NORMAL) const
Print circular region.
bool contains(const std::string &str, const std::string &substring)
Checks if a substring is in a string.
double dist_deg(const GSkyDir &dir) const
Compute angular distance between sky directions in degrees.
double m_solid
Solid angle subtended by the region (sr)
Rectangular sky region class interface definition.
bool overlaps(const GSkyRegion ®) const
Checks if region is overlapping with this region.
double dec_deg(void) const
Returns Declination in degrees.
GSkyDir m_centre
Centre or reference point of the region.
void free_members(void)
Delete class members.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
void init_members(void)
Initialise class members.
const std::string & type(void) const
Return region type.
GSkyRegionCircle(void)
Void constructor.
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
void read(const std::string &line)
Read region from DS9 string.
Interface for the circular sky region class.
Interface for the rectangular sky region class.
std::string m_type
Type of the region (circle, rectangle,...)
std::string centre(const std::string &s, const int &n, const char &c= ' ')
Centre string to achieve a length of n characters.
const double & radius(void) const
Return circular region radius (in degrees)
void map(const GSkyMap &map)
Set sky map.
virtual ~GSkyRegionCircle(void)
Destructor.
const std::vector< int > & nonzero_indices(void) const
Get non-zero index vector.
Abstract interface for the sky region class.
std::string write(void) const
Write region into a string.
std::string m_name
Name of the region.
double m_radius
Radius of circular the region (degrees)
bool overlaps(const GSkyRegion ®) const
Checks if a given region is overlapping with this region.
void compute_solid_angle(void)
Compute solid angle.
virtual GSkyRegion & operator=(const GSkyRegion ®ion)
Assignment operator.
double ra_deg(void) const
Returns Right Ascension in degrees.
Interface for a sky region map.
double dec(void) const
Return circular region centre Declination.
void radec_deg(const double &ra, const double &dec)
Set equatorial sky direction (degrees)
bool overlaps(const GSkyRegion ®) const
Checks if region is overlapping with this region.
const GSkyDir & centre(void) const
Return circular region centre.
void copy_members(const GSkyRegionCircle ®ion)
Copy class members.
Sky region map class interface definition.
void lb_deg(const double &l, const double &b)
Set galactic sky direction (degrees)
bool contains(const GSkyDir &dir) const
Checks if sky direction lies within region.
GSkyDir corner(const int &index) const
Return sky direction of one corner of the rectangle.
bool operator==(const GEnergy &a, const GEnergy &b)
Energy equality operator friend.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
GSkyRegionCircle & operator=(const GSkyRegionCircle ®ion)
Assignment operator.
Circular sky region class interface definition.
bool operator!=(const GEbounds &a, const GEbounds &b)
Energy boundaries inequality operator friend.
GSkyRegionCircle * clone(void) const
Clone circular sky region.
void clear(void)
Clear instance.
double todouble(const std::string &arg)
Convert string into double precision value.
void init_members(void)
Initialise class members.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
double ra(void) const
Return circular region centre Right Ascension.