1
/************************************************************************************
2
TerraLib - a library for developing GIS applications.
3
Copyright � 2001-2004 INPE and Tecgraf/PUC-Rio.
5
This code is part of the TerraLib library.
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
You should have received a copy of the GNU Lesser General Public
12
License along with this library.
14
The authors reassure the license terms regarding the warranties.
15
They specifically disclaim any warranties, including, but not limited to,
16
the implied warranties of merchantability and fitness for a particular purpose.
17
The library provided hereunder is on an "as is" basis, and the authors have no
18
obligation to provide maintenance, support, updates, enhancements, or modifications.
19
In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
20
indirect, special, incidental, or consequential damages arising out of the use
21
of this library and its documentation.
22
*************************************************************************************/
25
#pragma warning ( disable: 4786 )
28
#include "TeNeighbours.h"
30
TeProxMatrixAttributes::TeProxMatrixAttributes()
32
_weight = 1; //default
35
_centroid_distance = -1.0; //not computed
36
_borders_length = -1.0; //not computed
37
_net_objects_distance = -1.0; //not computed
38
_net_minimum_path= -1.0; //not computed
42
TeProxMatrixAttributes::TeProxMatrixAttributes (const TeProxMatrixAttributes& att)
44
_weight = att._weight;
47
_centroid_distance = att._centroid_distance;
48
_borders_length = att._borders_length;
49
_net_objects_distance = att._net_objects_distance;
50
_net_minimum_path = att._net_minimum_path;
55
TeProxMatrixAttributes::getProperties ()
58
TeProperty prop1; prop1.value_ = Te2String (_weight); vec.push_back ( prop1 );
59
TeProperty prop2; prop2.value_ = Te2String (_slice); vec.push_back ( prop2 );
60
TeProperty prop3; prop3.value_ = Te2String (_order); vec.push_back ( prop3 );
61
TeProperty prop4; prop4.value_ = Te2String (_borders_length); vec.push_back ( prop4 );
62
TeProperty prop5; prop5.value_ = Te2String (_centroid_distance); vec.push_back ( prop5 );
63
TeProperty prop6; prop6.value_ = Te2String (_net_objects_distance); vec.push_back ( prop6 );
64
TeProperty prop7; prop7.value_ = Te2String (_net_minimum_path); vec.push_back ( prop7 );
69
TeProxMatrixAttributes&
70
TeProxMatrixAttributes::operator= (const TeProxMatrixAttributes& att)
72
_weight = att._weight;
75
_centroid_distance = att._centroid_distance;
76
_borders_length = att._borders_length;
77
_net_objects_distance = att._net_objects_distance;
78
_net_minimum_path = att._net_minimum_path;
85
TeProxMatrixAttributes::operator==(const TeProxMatrixAttributes& att) const
87
return ((_weight == att._weight) &&
88
(_slice == att._slice) &&
89
(_order == att._order) &&
90
(_centroid_distance == att._centroid_distance) &&
91
(_borders_length == att._borders_length) &&
92
(_net_objects_distance == att._net_objects_distance) &&
93
(_net_minimum_path == att._net_minimum_path));
97
TeNeighbours::TeNeighbours(const TeNeighboursMap& neigh)
100
TeNeighboursMap::const_iterator pos = neigh.begin();
102
for (pos = neigh.begin(); pos != neigh.end(); ++pos)
103
_neigh.push_back(make_pair (pos->first, pos->second));
108
TeNeighbours::TeNeighbours (const TeNeighbours& neigh)
111
for (it = neigh._neigh.begin(); it != neigh._neigh.end(); ++it)
112
_neigh.push_back(*it);
117
TeNeighbours::ObjectId (int n)
119
if (n < (int)_neigh.size())
120
return _neigh[n].first;
130
TeNeighbours:: operator[](int n)
132
if (n < (int)_neigh.size())
133
return _neigh[n].first;
142
TeNeighbours:: Weight (int n)
144
if (n < (int)_neigh.size())
145
return _neigh[n].second.Weight();
153
TeNeighbours:: Weight (const string& object_id)
155
for (unsigned int i = 0; i< _neigh.size(); ++i) {
156
if (object_id == _neigh[i].first)
157
return _neigh[i].second.Weight();
163
TeProxMatrixAttributes
164
TeNeighbours:: Attributes (int n)
166
TeProxMatrixAttributes attr;
168
if (n < (int)_neigh.size())
169
return _neigh[n].second;
175
TeNeighbours:: operator== (const TeNeighbours& neigh)
177
if (_neigh == neigh._neigh) return true;
183
TeNeighbours::operator= (const TeNeighbours& neigh)
191
for (it = neigh._neigh.begin(); it != neigh._neigh.end(); ++it)
192
_neigh.push_back(*it);
199
TeNeighbours:: Insert (const string& object_id, const TeProxMatrixAttributes& attr)
201
for (unsigned int i = 0; i< _neigh.size(); i++) {
202
if (object_id == _neigh[i].first)
205
_neigh.push_back (make_pair (object_id, attr));
211
TeNeighbours:: Remove (const string& object_id)
213
iterator it = _neigh.begin();
214
while (it!= _neigh.end())
215
if (object_id == (*it).first)