CirclingWind: eliminate attributes min_vector, max_vector
[xcsoar.git] / src / Projection / WindowProjection.cpp
blob610608eea28834a0c9b69c3887d37d60538227ae
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "WindowProjection.hpp"
26 bool
27 WindowProjection::GeoVisible(const GeoPoint &loc) const
29 return screenbounds_latlon.IsInside(loc);
32 bool
33 WindowProjection::GeoToScreenIfVisible(const GeoPoint &loc, RasterPoint &sc) const
35 if (GeoVisible(loc)) {
36 sc = GeoToScreen(loc);
37 return ScreenVisible(sc);
40 return false;
43 bool
44 WindowProjection::ScreenVisible(const RasterPoint &P) const
46 assert(screen_size_initialised);
48 return P.x >= 0 && (unsigned)P.x < screen_width &&
49 P.y >= 0 && (unsigned)P.y < screen_height;
52 void
53 WindowProjection::SetScaleFromRadius(fixed radius)
55 SetScale(fixed(GetMinScreenDistance()) / (radius * 2));
58 fixed
59 WindowProjection::GetMapScale() const
61 return DistancePixelsToMeters(GetMapResolutionFactor());
64 fixed
65 WindowProjection::GetScreenDistanceMeters() const
67 return DistancePixelsToMeters(GetScreenDistance());
70 GeoPoint
71 WindowProjection::GetGeoScreenCenter() const
73 return ScreenToGeo(GetScreenWidth() / 2, GetScreenHeight() / 2);
76 void
77 WindowProjection::UpdateScreenBounds()
79 assert(screen_size_initialised);
81 if (!IsValid())
82 return;
84 GeoBounds sb(ScreenToGeo(0, 0));
85 sb.Extend(ScreenToGeo(screen_width, 0));
86 sb.Extend(ScreenToGeo(screen_width, screen_height));
87 sb.Extend(ScreenToGeo(0, screen_height));
89 screenbounds_latlon = sb;