Statistics
| Revision:

root / trunk / libraries / libTopology / src / org / gvsig / topology / TopologyError.java @ 13821

History | View | Annotate | Download (4.45 KB)

1
/*
2
 * Created on 07-sep-2007
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
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.
12
 *
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.
17
 *
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.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
 *
46
 * $Id: 
47
 * $Log: 
48
 *
49
 */
50
package org.gvsig.topology;
51

    
52
import com.iver.cit.gvsig.fmap.core.DefaultFeature;
53
import com.iver.cit.gvsig.fmap.core.IFeature;
54
import com.iver.cit.gvsig.fmap.core.IGeometry;
55

    
56

    
57
/**
58
 *Error produced when one or many features ?
59
 *violates a topology rule.
60
 */
61
public class TopologyError extends DefaultFeature {
62
 
63
        /**
64
         *rule which has been violated
65
         */
66
        private AbstractTopologyRule violatedRule;
67
         
68
        /**
69
         *features of the source layer that
70
         *violates the rule (if the rule is a self-rule,
71
         *the error will only have source layer features)
72
         *
73
         *Although we are validating one only feature a time, in self reflexive
74
         *rules it could cause errors with many features (a feature overlaps with
75
         *other features of the same layer)
76
         */
77
        private IFeature[] sourceLyrFeatures;
78
         
79
        /**
80
         *features of the destination layer
81
         *that violate the rule (only in rules between
82
         *two layers)
83
         */
84
        private IFeature[] destinationLyrFeatures;
85
         
86
        /**
87
         * Flag that marks if this error is allowed
88
         * (it has been marked as an exception)
89
         */
90
        private boolean exception;
91
        
92
        /**
93
         * Geometry that defines the topology error
94
         */
95
        private IGeometry errorGeometry;
96
        
97
        
98
        /**
99
         * Constructor
100
         * @param geometry geometry of the error
101
         * @param errorFid unique identifier for this error in the error container
102
         * (topology)
103
         * 
104
         * @param violatedRule topology rule that this error violates
105
         * 
106
         * @param sourceLyrFeatures features of the origin layer in the rule
107
         * that violates the rule
108
         * 
109
         * @param destinationLyrFeatures features of the destination layer in the rule
110
         * that violates the rule
111
         */
112
        public TopologyError(IGeometry geometry, 
113
                                            String errorFid,
114
                                            AbstractTopologyRule violatedRule,
115
                                            IFeature[] sourceLyrFeatures, 
116
                                            IFeature[] destinationLyrFeatures){
117
                super(geometry, null, errorFid);
118
                this.exception = false;
119
                this.violatedRule = violatedRule;
120
                this.sourceLyrFeatures = sourceLyrFeatures;
121
                this.destinationLyrFeatures = destinationLyrFeatures;
122
        }
123
        
124
        public TopologyError(IGeometry geometry,
125
                                                 AbstractTopologyRule violatedRule,
126
                                                 IFeature[] sourceLyrFeatures){
127
                super(geometry, null, null);
128
                this.violatedRule = violatedRule;
129
                this.sourceLyrFeatures = sourceLyrFeatures;
130
        }
131
         
132
        public void setViolatedRule(AbstractTopologyRule violatedRule) {
133
                this.violatedRule = violatedRule;
134
        }
135
         
136
        public AbstractTopologyRule getViolatedRule() {
137
                return violatedRule;
138
        }
139
         
140
        public void setSourceLyrFeatures(IFeature[] sourceLyrFeatures) {
141
                this.sourceLyrFeatures =sourceLyrFeatures;
142
        }
143
         
144
        public IFeature[] getSourceLyrFeatures() {
145
                return sourceLyrFeatures;
146
        }
147
         
148
        public void setDestinationLyrFeatures(IFeature[] destinationLyrFeatures) {
149
                this.destinationLyrFeatures = destinationLyrFeatures;
150
        }
151
         
152
        public IFeature[] getDestinationLyrFeatures() {
153
                return destinationLyrFeatures;
154
        }
155
         
156
        /**
157
         *Ruturns the type of geometry of the error
158
         */
159
        public int getShapeType() {
160
                return errorGeometry.getGeometryType();
161
        }
162
         
163
        public void setException(boolean exception) {
164
                this.exception = exception;
165
        }
166
         
167
        public boolean isException() {
168
                return exception;
169
        }
170

    
171
        public IGeometry getGeometry() {
172
                return errorGeometry;
173
        }
174

    
175
        public void setGeometry(IGeometry geom) {
176
                this.errorGeometry = geom;
177
        }
178

    
179
}
180