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
*************************************************************************************/
24
/*! \file TeNeighbours.h
25
This file contains structures and definitions about neighborhood
28
#ifndef __TERRALIB_INTERNAL_NEGHBOURS_H
29
#define __TERRALIB_INTERNAL_NEGHBOURS_H
32
#include "TeAttribute.h"
40
//! Attributes associated with each neighborhood of a proximity matrix
41
class TeProxMatrixAttributes
47
double _centroid_distance;
48
double _borders_length;
49
double _net_objects_distance;
50
double _net_minimum_path;
56
TeProxMatrixAttributes();
59
TeProxMatrixAttributes (const TeProxMatrixAttributes& att);
62
double Weight() {return _weight;}
65
int Slice () {return _slice;}
68
int Order() {return _order;}
70
//! Return border length
71
double BorderLength() {return _borders_length;}
73
//! Return centroid distance
74
double CentroidDistance() {return _centroid_distance;}
76
//! Return network objects distance
77
double NetworkObjectsDistance() {return _net_objects_distance;}
79
//! Return network minimum path
80
double NetworkMinimumPath () {return _net_minimum_path;}
83
void Weight(double w) {_weight = w;}
86
void Slice (int s) {_slice = s;}
89
void Order(int o) {_order = o;}
92
void BorderLength(double l) {_borders_length = l;}
94
//! Set centroid distance
95
void CentroidDistance(double d) {_centroid_distance = d;}
97
//! Set network objects distance
98
void NetworkObjectsDistance(double d) {_net_objects_distance = d;}
100
//! Set network minimum path
101
void NetworkMinimumPath (double d) {_net_minimum_path = d;}
103
//! Return the attributes as a TePropertyVector
104
TePropertyVector getProperties ();
106
//! Return if the border length was computed
107
bool WasBordersLengthComputed () {if (_borders_length == -1.0) return false; else return true;}
109
//! Return if the centroid distance was computed
110
bool WasCentroidDistanceComputed () {if (_centroid_distance == -1.0) return false; else return true;}
112
//! Return if the network objects distance was computed
113
bool WasNetworkObjectsDistanceComputed () {if (_net_objects_distance == -1.0) return false; else return true;}
115
//! Return if the network minimal path was computed
116
bool WasNetworkMinimumPathComputed () {if (_net_minimum_path == -1.0) return false; else return true;}
119
TeProxMatrixAttributes& operator= (const TeProxMatrixAttributes& att);
121
//! Comparison Operator
122
bool operator==(const TeProxMatrixAttributes& att) const;
125
virtual ~TeProxMatrixAttributes() {}
128
//! A map from a object to its attributes
129
typedef map<string, TeProxMatrixAttributes> TeNeighboursMap;
132
//! A class to representate the neighbours of a object
136
typedef pair<string, TeProxMatrixAttributes> neigh_values;
137
typedef vector<neigh_values> neigh_vector;
144
typedef neigh_vector::iterator iterator;
145
typedef neigh_vector::const_iterator const_iterator;
147
//! Empty constructor
151
TeNeighbours(const TeNeighboursMap& neigh);
154
TeNeighbours(const TeNeighbours& neigh);
156
//! Return the number of the neighbours
157
int size() const { return _neigh.size();}
159
//! Return a iterator to the begin of the neighbours
160
iterator begin() { return _neigh.begin();}
162
//! Return a iterator to the one past end of the neighbours
163
iterator end() { return _neigh.end();}
165
//! Return the n-th neighbour object_id, if n < map size.
166
string ObjectId (int n);
168
//! Return the n-th neighbour object_id, if n < map size.
169
string operator[](int n);
171
//! Return the n-th connection weight (corresponding to the n-th neighbour), if n < map size.
172
double Weight (int n);
174
//! Return the connection weight, given the neighbour object_id
175
double Weight (const string& object_id);
177
//! Return the complete set of connection attributes (corresponding to the ith neighbour), packed in a TeProxMatrixAttributes object.
178
TeProxMatrixAttributes Attributes (int n);
180
//! Return the complete set of connection attributes, given the neighbour object_id, packed in a TeProxMatrixAttributes object.
181
TeProxMatrixAttributes Attributes (const string& object_id);
183
//! Insert a new neighbour
184
bool Insert (const string& object_id, const TeProxMatrixAttributes& attr);
186
//! Remove a neighbour
187
bool Remove (const string& object_id);
190
TeNeighbours& operator= (const TeNeighbours& neigh);
192
//! Comparison Operator
193
bool operator==(const TeNeighbours& p);
196
virtual ~TeNeighbours() {}