root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / dissolve / fmap / SingleFieldAdjacencyDissolveCriteria.java @ 5412
History | View | Annotate | Download (4.92 KB)
1 |
/*
|
---|---|
2 |
* Created on 12-may-2006
|
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: SingleFieldAdjacencyDissolveCriteria.java 5412 2006-05-24 21:15:07Z azabala $
|
47 |
* $Log$
|
48 |
* Revision 1.1 2006-05-24 21:11:14 azabala
|
49 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
|
50 |
*
|
51 |
*
|
52 |
*/
|
53 |
package com.iver.cit.gvsig.geoprocess.dissolve.fmap; |
54 |
|
55 |
import org.cresques.cts.ICoordTrans; |
56 |
|
57 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
58 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
59 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
60 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
61 |
import com.vividsolutions.jts.geom.Geometry; |
62 |
import com.vividsolutions.jts.geom.IntersectionMatrix; |
63 |
|
64 |
/**
|
65 |
* Its a SingleFieldCriteria that adds adjacency condition:
|
66 |
* once a feature has passed the single field value dissolve
|
67 |
* criteria (it has the same specified field value) it must be
|
68 |
* adjacent to the seed feature to dissolve them.
|
69 |
* @author azabala
|
70 |
*
|
71 |
*/
|
72 |
|
73 |
public class SingleFieldAdjacencyDissolveCriteria extends |
74 |
SingleFieldDissolveCriteria /*implements
|
75 |
ISpatialDissolveCriteria*/{
|
76 |
|
77 |
// private IGeometry firstGeometry;
|
78 |
//
|
79 |
// private IGeometry secondGeometry;
|
80 |
//
|
81 |
// private ICoordTrans ct;
|
82 |
/**
|
83 |
* Cached jts geometry of the dissolve 'seed'
|
84 |
*/
|
85 |
// private Geometry cachedJts;
|
86 |
//
|
87 |
// private Geometry cachedJts2;
|
88 |
|
89 |
|
90 |
public SingleFieldAdjacencyDissolveCriteria(String dissolveField, |
91 |
FLyrVect layer) throws DriverException {
|
92 |
super(dissolveField, layer);
|
93 |
} |
94 |
|
95 |
|
96 |
// public IGeometry getFirstGeometry(){
|
97 |
//// return firstGeometry;
|
98 |
// }
|
99 |
//
|
100 |
// public IGeometry getSecondGeometry(){
|
101 |
// return secondGeometry;
|
102 |
// }
|
103 |
|
104 |
|
105 |
public boolean verifyIfDissolve(int featureIndex1, int featureIndex2) { |
106 |
//first the alphanumeric criteria
|
107 |
if(super.verifyIfDissolve(featureIndex1, featureIndex2)){ |
108 |
//second the spatial criteria
|
109 |
// FIXME: Arreglar esto
|
110 |
// fetchGeometry(featureIndex1);
|
111 |
// fetchGeometry2(featureIndex2);
|
112 |
Geometry g1; |
113 |
Geometry g2; |
114 |
try {
|
115 |
g1 = layer.getSource().getShape(featureIndex1).toJTSGeometry(); |
116 |
g2 = layer.getSource().getShape(featureIndex2).toJTSGeometry(); |
117 |
} catch (DriverIOException e) {
|
118 |
return false; |
119 |
} |
120 |
return g1.intersects(g2);
|
121 |
// return cachedJts.intersects(cachedJts2);
|
122 |
|
123 |
} |
124 |
return false; |
125 |
} |
126 |
|
127 |
/**
|
128 |
* Verify if the geometry of the seed feature has been readed,
|
129 |
* and reads it if not.
|
130 |
* @param index
|
131 |
*/
|
132 |
// private void fetchGeometry(int index){
|
133 |
// if(cachedJts == null){
|
134 |
// try {
|
135 |
// firstGeometry = layer.getSource().getShape(index);
|
136 |
// if(ct != null)
|
137 |
// firstGeometry.reProject(ct);
|
138 |
// cachedJts = firstGeometry.toJTSGeometry();
|
139 |
// } catch (DriverIOException e) {
|
140 |
// // TODO Auto-generated catch block
|
141 |
// e.printStackTrace();
|
142 |
// }
|
143 |
// }
|
144 |
// }
|
145 |
|
146 |
/**
|
147 |
* Verify if the geometry of the seed feature has been readed,
|
148 |
* and reads it if not.
|
149 |
* @param index
|
150 |
*/
|
151 |
// private void fetchGeometry2(int index){
|
152 |
// if(cachedJts2 == null){
|
153 |
// try {
|
154 |
// secondGeometry = layer.getSource().getShape(index);
|
155 |
// if(ct != null)
|
156 |
// secondGeometry.reProject(ct);
|
157 |
// cachedJts2 = secondGeometry.toJTSGeometry();
|
158 |
// } catch (DriverIOException e) {
|
159 |
// // TODO Auto-generated catch block
|
160 |
// e.printStackTrace();
|
161 |
// }
|
162 |
// }
|
163 |
// }
|
164 |
|
165 |
|
166 |
public void clear() { |
167 |
super.clear();
|
168 |
// cachedJts = null;
|
169 |
|
170 |
} |
171 |
|
172 |
|
173 |
// public void setFirstGeometry(IGeometry g) {
|
174 |
// firstGeometry = g;
|
175 |
// cachedJts = firstGeometry.toJTSGeometry();
|
176 |
// }
|
177 |
|
178 |
|
179 |
// public void setSecondGeometry(IGeometry g) {
|
180 |
// secondGeometry = g;
|
181 |
// cachedJts2 = secondGeometry.toJTSGeometry();
|
182 |
// }
|
183 |
|
184 |
|
185 |
// public void setCoordTrans(ICoordTrans coordTrans) {
|
186 |
// this.ct = coordTrans;
|
187 |
// }
|
188 |
//
|
189 |
//
|
190 |
// public void setFirstJts(Geometry g) {
|
191 |
// cachedJts = g;
|
192 |
// }
|
193 |
//
|
194 |
// public Geometry getSecondJts(){
|
195 |
// return cachedJts2;
|
196 |
// }
|
197 |
|
198 |
|
199 |
// public void setSecondJts(Geometry g) {
|
200 |
// cachedJts2 = g;
|
201 |
// }
|
202 |
} |
203 |
|
204 |
|