root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / impl / convexhull / fmap / ScalableUnionVisitor.java @ 12949
History | View | Annotate | Download (3.7 KB)
1 | 5918 | azabala | /*
|
---|---|---|---|
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$
|
||
47 | * $Log$
|
||
48 | 12949 | azabala | * 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 | 10626 | caballero | * Exceptions
|
53 | *
|
||
54 | * Revision 1.1 2006/06/20 18:20:45 azabala
|
||
55 | 5918 | azabala | * 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 | 10626 | caballero | import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException; |
80 | import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
||
81 | 5918 | azabala | import com.iver.cit.gvsig.fmap.core.IGeometry; |
82 | import com.iver.cit.gvsig.geoprocess.core.fmap.XTypes; |
||
83 | 12949 | azabala | import com.iver.cit.gvsig.geoprocess.core.util.JTSFacade; |
84 | 5918 | azabala | 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 | 12949 | azabala | //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 | 5918 | azabala | |
100 | 12949 | azabala | |
101 | public ScalableUnionVisitor(int geometryType){ |
||
102 | super();
|
||
103 | this.geometryType = geometryType;
|
||
104 | } |
||
105 | |||
106 | |||
107 | 10626 | caballero | public void visit(IGeometry g, int index) throws VisitorException, ProcessVisitorException { |
108 | 5918 | azabala | if(g == null) |
109 | return;
|
||
110 | |||
111 | 12949 | azabala | /*
|
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 | 5918 | azabala | 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 | 12949 | azabala | |
133 | geometry = JTSFacade.union(geoms, geometryType); |
||
134 | 5918 | azabala | } |
135 | } |
||
136 | } |