root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / impl / buffer / fmap / ConstantDistanceBufferVisitor.java @ 12947
History | View | Annotate | Download (4.81 KB)
1 |
/*
|
---|---|
2 |
* Created on 02-feb-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: ConstantDistanceBufferVisitor.java 12947 2007-08-07 15:09:22Z azabala $
|
47 |
* $Log$
|
48 |
* Revision 1.6 2007-08-07 15:09:22 azabala
|
49 |
* changes to remove UnitUtils' andami dependencies
|
50 |
*
|
51 |
* Revision 1.5 2007/03/06 16:47:58 caballero
|
52 |
* Exceptions
|
53 |
*
|
54 |
* Revision 1.4 2006/09/15 10:42:54 caballero
|
55 |
* extensibilidad de documentos
|
56 |
*
|
57 |
* Revision 1.3 2006/08/29 07:21:09 cesar
|
58 |
* Rename com.iver.cit.gvsig.fmap.Fmap class to com.iver.cit.gvsig.fmap.MapContext
|
59 |
*
|
60 |
* Revision 1.2 2006/06/29 17:31:47 azabala
|
61 |
* Uses UnitUtils
|
62 |
*
|
63 |
* Revision 1.1 2006/06/20 18:20:45 azabala
|
64 |
* first version in cvs
|
65 |
*
|
66 |
* Revision 1.2 2006/06/02 18:20:33 azabala
|
67 |
* limpieza de imports
|
68 |
*
|
69 |
* Revision 1.1 2006/05/24 21:14:41 azabala
|
70 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
|
71 |
*
|
72 |
* Revision 1.8 2006/05/01 19:18:09 azabala
|
73 |
* revisi?n general del buffer (a?adidos anillos concentricos, buffers interiores y exteriores, etc)
|
74 |
*
|
75 |
* Revision 1.7 2006/03/28 16:27:16 azabala
|
76 |
* *** empty log message ***
|
77 |
*
|
78 |
* Revision 1.6 2006/03/07 21:01:33 azabala
|
79 |
* *** empty log message ***
|
80 |
*
|
81 |
* Revision 1.5 2006/03/06 19:48:39 azabala
|
82 |
* *** empty log message ***
|
83 |
*
|
84 |
* Revision 1.3 2006/03/05 19:57:05 azabala
|
85 |
* *** empty log message ***
|
86 |
*
|
87 |
* Revision 1.2 2006/02/20 19:44:21 azabala
|
88 |
* *** empty log message ***
|
89 |
*
|
90 |
* Revision 1.1 2006/02/17 16:31:38 azabala
|
91 |
* *** empty log message ***
|
92 |
*
|
93 |
* Revision 1.3 2006/02/12 21:02:58 azabala
|
94 |
* *** empty log message ***
|
95 |
*
|
96 |
* Revision 1.2 2006/02/09 16:01:06 azabala
|
97 |
* First version in CVS
|
98 |
*
|
99 |
* Revision 1.1 2006/02/02 19:46:51 azabala
|
100 |
* First version in CVS
|
101 |
*
|
102 |
*
|
103 |
*/
|
104 |
package com.iver.cit.gvsig.geoprocess.impl.buffer.fmap; |
105 |
|
106 |
import com.iver.cit.gvsig.exceptions.visitors.StartVisitorException; |
107 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
108 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
109 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
110 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
111 |
import com.iver.cit.gvsig.geoprocess.core.fmap.GeoprocessException; |
112 |
import com.iver.cit.gvsig.geoprocess.core.util.UnitUtils; |
113 |
import org.cresques.cts.IProjection; |
114 |
|
115 |
/**
|
116 |
* This FeatureVisitor computes buffers and saves
|
117 |
* it to a new FLayer.
|
118 |
* All IFeature of this Layer will have the same buffer
|
119 |
* distance.
|
120 |
*
|
121 |
* @author azabala
|
122 |
*
|
123 |
*/
|
124 |
public class ConstantDistanceBufferVisitor extends BufferVisitor { |
125 |
/**
|
126 |
* buffer distance to use
|
127 |
*/
|
128 |
private double distance; |
129 |
|
130 |
/**
|
131 |
* View projection (allow to convert, if needed, coordinates when working
|
132 |
* with not projected (geographics) CRS's)
|
133 |
*/
|
134 |
private IProjection projection;
|
135 |
private int distanceUnits; |
136 |
private int mapUnits; |
137 |
/**
|
138 |
* Constructor
|
139 |
* @param distance buffer distance to use
|
140 |
* @param viewProj TODO
|
141 |
* @param mapUnits
|
142 |
* @param distanceUnits
|
143 |
* @throws GeoprocessException
|
144 |
*/
|
145 |
public ConstantDistanceBufferVisitor(double distance, IProjection viewProj, int distanceUnits, int mapUnits) throws GeoprocessException{ |
146 |
this.distance = distance;
|
147 |
this.projection = viewProj;
|
148 |
this.distanceUnits = distanceUnits;
|
149 |
this.mapUnits = mapUnits;
|
150 |
} |
151 |
|
152 |
public void stop(FLayer layer) throws VisitorException { |
153 |
//we must flush JTS processors
|
154 |
resultsProcessor.finish(); |
155 |
} |
156 |
/**
|
157 |
* This FeatureVisitor only work with Vectorial
|
158 |
* Layers
|
159 |
*/
|
160 |
public boolean start(FLayer layer) throws StartVisitorException { |
161 |
if(layer instanceof FLyrVect){ |
162 |
return true; |
163 |
}else
|
164 |
return false; |
165 |
} |
166 |
|
167 |
public double getBufferDistance(IGeometry g, int index) { |
168 |
//first: pass the user entry to internal units
|
169 |
return UnitUtils.getInInternalUnits(distance, projection, distanceUnits, mapUnits);
|
170 |
} |
171 |
|
172 |
|
173 |
|
174 |
public String getProcessDescription() { |
175 |
return "Computing buffers with constant distances"; |
176 |
} |
177 |
|
178 |
} |
179 |
|
180 |
|