SectorZone: add attribute arc_boundary
[xcsoar.git] / src / Engine / Task / ObservationZones / SectorZone.cpp
blob4117e04d9acad1331bba7116f4f142ed6c7157c0
1 /* Copyright_License {
3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "SectorZone.hpp"
24 #include "Boundary.hpp"
25 #include "Geo/GeoVector.hpp"
27 OZBoundary
28 SectorZone::GetBoundary() const
30 OZBoundary boundary;
32 if (arc_boundary)
33 boundary.GenerateArcExcluding(GetReference(), GetRadius(),
34 GetStartRadial(), GetEndRadial());
36 boundary.push_front(GetSectorEnd());
37 boundary.push_front(GetSectorStart());
38 boundary.push_front(GetReference());
40 return boundary;
43 fixed
44 SectorZone::ScoreAdjustment() const
46 return fixed(0);
49 void
50 SectorZone::UpdateSector()
52 sector_start = GeoVector(GetRadius(), start_radial).EndPoint(GetReference());
53 sector_end = GeoVector(GetRadius(), end_radial).EndPoint(GetReference());
56 bool
57 SectorZone::IsInSector(const GeoPoint &location) const
59 GeoVector f(GetReference(), location);
61 return f.distance <= GetRadius() && IsAngleInSector(f.bearing);
64 void
65 SectorZone::SetStartRadial(const Angle x)
67 start_radial = x;
68 UpdateSector();
71 void
72 SectorZone::SetEndRadial(const Angle x)
74 end_radial = x;
75 UpdateSector();
78 bool
79 SectorZone::IsAngleInSector(const Angle b) const
81 // Quit early if we have a full circle
82 if ((end_radial - start_radial).AsBearing() <= Angle::FullCircle() / 512)
83 return true;
85 return b.Between(start_radial, end_radial);
88 bool
89 SectorZone::Equals(const ObservationZonePoint &other) const
91 const SectorZone &z = (const SectorZone &)other;
93 return CylinderZone::Equals(other) &&
94 start_radial == z.GetStartRadial() &&
95 end_radial == z.GetEndRadial();