1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 #include "Polyline.h"
20 
21 namespace OpenXcom
22 {
23 
24 /**
25  * Initializes the polyline with arrays to store each point's coordinates.
26  * @param points Number of points.
27  */
Polyline(int points)28 Polyline::Polyline(int points) : _points(points)
29 {
30 	_lat = new double[points];
31 	_lon = new double[points];
32 }
33 
34 /**
35  * Deletes the arrays from memory.
36  */
~Polyline()37 Polyline::~Polyline()
38 {
39 	delete[] _lat;
40 	delete[] _lon;
41 }
42 
43 /**
44  * Returns the latitude (X) of a given point.
45  * @param i Point number (0-max).
46  * @return Point's latitude.
47  */
getLatitude(int i) const48 double Polyline::getLatitude(int i) const
49 {
50 	return _lat[i];
51 }
52 
53 /**
54  * Changes the latitude of a given point.
55  * @param i Point number (0-max).
56  * @param lat Point's latitude.
57  */
setLatitude(int i,double lat)58 void Polyline::setLatitude(int i, double lat)
59 {
60 	_lat[i] = lat;
61 }
62 
63 /**
64  * Returns the longitude (Y) of a given point.
65  * @param i Point number (0-max).
66  * @return Point's longitude.
67  */
getLongitude(int i) const68 double Polyline::getLongitude(int i) const
69 {
70 	return _lon[i];
71 }
72 
73 /**
74  * Changes the latitude of a given point.
75  * @param i Point number (0-max).
76  * @param lon Point's longitude.
77  */
setLongitude(int i,double lon)78 void Polyline::setLongitude(int i, double lon)
79 {
80 	_lon[i] = lon;
81 }
82 
83 /**
84  * Returns the number of points (vertexes) that make up the polyline.
85  * @return Number of points.
86  */
getPoints() const87 int Polyline::getPoints() const
88 {
89 	return _points;
90 }
91 
92 }
93