root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / impl / convexhull / fmap / ScalableUnionVisitor.java @ 12949
History | View | Annotate | Download (3.7 KB)
1 |
/*
|
---|---|
2 |
* Created on 03-mar-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: ScalableUnionVisitor.java 12949 2007-08-07 15:23:01Z azabala $
|
47 |
* $Log$
|
48 |
* Revision 1.3 2007-08-07 15:23:01 azabala
|
49 |
* centrilizing JTS in JTSFacade
|
50 |
*
|
51 |
* Revision 1.2 2007/03/06 16:47:58 caballero
|
52 |
* Exceptions
|
53 |
*
|
54 |
* Revision 1.1 2006/06/20 18:20:45 azabala
|
55 |
* first version in cvs
|
56 |
*
|
57 |
* Revision 1.3 2006/06/08 18:20:59 azabala
|
58 |
* modificaciones para admitir capas de shapeType MULTI
|
59 |
*
|
60 |
* Revision 1.2 2006/06/02 18:21:28 azabala
|
61 |
* *** empty log message ***
|
62 |
*
|
63 |
* Revision 1.1 2006/05/24 21:13:31 azabala
|
64 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
|
65 |
*
|
66 |
* Revision 1.2 2006/05/01 19:16:10 azabala
|
67 |
* optimizada la union mediante buffer(0)
|
68 |
*
|
69 |
* Revision 1.1 2006/03/06 19:48:39 azabala
|
70 |
* *** empty log message ***
|
71 |
*
|
72 |
* Revision 1.1 2006/03/05 19:57:48 azabala
|
73 |
* *** empty log message ***
|
74 |
*
|
75 |
*
|
76 |
*/
|
77 |
package com.iver.cit.gvsig.geoprocess.impl.convexhull.fmap; |
78 |
|
79 |
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException; |
80 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
81 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
82 |
import com.iver.cit.gvsig.geoprocess.core.fmap.XTypes; |
83 |
import com.iver.cit.gvsig.geoprocess.core.util.JTSFacade; |
84 |
import com.vividsolutions.jts.geom.Geometry; |
85 |
|
86 |
|
87 |
|
88 |
|
89 |
//TODO Este Visitor no deber?a heredar del anterior, puesto que las
|
90 |
//llamadas getJtsConvexHull() no devuelven un convex hull, sino una
|
91 |
//uni?n.
|
92 |
|
93 |
|
94 |
public class ScalableUnionVisitor extends ScalableConvexHullVisitor { |
95 |
//geometry type of the layer whose features we are going to fussion
|
96 |
//(polygon features are optimized in jts with buffer(0) trick, the
|
97 |
//nor the rest
|
98 |
int geometryType;
|
99 |
|
100 |
|
101 |
public ScalableUnionVisitor(int geometryType){ |
102 |
super();
|
103 |
this.geometryType = geometryType;
|
104 |
} |
105 |
|
106 |
|
107 |
public void visit(IGeometry g, int index) throws VisitorException, ProcessVisitorException { |
108 |
if(g == null) |
109 |
return;
|
110 |
|
111 |
/*
|
112 |
* TODO Aqu? estamos desechando aquellas geometrias cuyo tipo
|
113 |
* no es POLYGON (el tipo MULTI no aparece por ning?n lado)
|
114 |
*
|
115 |
* Se puede dar el caso de que una capa tenga polilineas cerradas,
|
116 |
* y el usuario visualmente piensa que son poligonos.
|
117 |
*
|
118 |
* Podemos considerar aqu? este caso.
|
119 |
*
|
120 |
* */
|
121 |
if(g.getGeometryType() != XTypes.POLYGON &&
|
122 |
g.getGeometryType() != XTypes.MULTI) |
123 |
return;
|
124 |
|
125 |
Geometry actualGeometry = g.toJTSGeometry(); |
126 |
if(geometry == null){ |
127 |
geometry = actualGeometry; |
128 |
}else{
|
129 |
Geometry[] geoms = new Geometry[2]; |
130 |
geoms[0] = geometry;
|
131 |
geoms[1] = actualGeometry;
|
132 |
|
133 |
geometry = JTSFacade.union(geoms, geometryType); |
134 |
} |
135 |
} |
136 |
} |
137 |
|