Revision 5628

View differences:

trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/clip/fmap/ClipVisitor.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.2  2006-05-31 09:10:12  fjp
48
* Revision 1.3  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.2  2006/05/31 09:10:12  fjp
49 52
* Ubicaci?n de IWriter
50 53
*
51 54
* Revision 1.1  2006/05/24 21:14:07  azabala
......
146 149
	 * ignored.
147 150
	 */
148 151
	public void visit(IGeometry g, int index) throws VisitException {
152
		if(g == null)
153
			return;
149 154
		Geometry jtsGeom = g.toJTSGeometry();
150
		//first of all we check envelopes
151
//		Envelope envelope = jtsGeom.getEnvelopeInternal();
152
//		Envelope clipEnvelope = clippingConvexHull.getEnvelopeInternal();
153
//		if(!envelope.intersects(clipEnvelope))
154
//			return;
155
		
156 155
		if(!jtsGeom.getEnvelope().intersects(clippingConvexHull.getEnvelope()))
157 156
			return;
158 157
		if(jtsGeom.intersects(clippingConvexHull)){
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/clip/ClipGeoprocessController.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.2  2006-05-25 08:21:48  jmvivo
48
* Revision 1.3  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.2  2006/05/25 08:21:48  jmvivo
49 52
* A?adida peticion de confirmacion para sobreescribir el fichero de salida, si este ya existiera
50 53
*
51 54
* Revision 1.1  2006/05/24 21:14:17  azabala
......
145 148
			task2.setLayers(layers);
146 149
			MonitorableDecoratorMainFirst globalTask = new MonitorableDecoratorMainFirst(task1,
147 150
					task2);
148
			//FIXME REVISAR ESTO
149 151
			if(clippingLayer.getISpatialIndex() == null){
150 152
				final IMonitorableTask sptIdxTask = 
151 153
					geoProcessingClipPanel.askForSpatialIndexCreation(clippingLayer);
152
				PluginServices.backgroundExecution(
153
						new Runnable(){
154
					public void run() {
155
						PluginServices.
156
						cancelableBackgroundExecution(sptIdxTask);	
157
					}}
158
				);
154
				if(sptIdxTask != null){
155
					PluginServices.backgroundExecution(
156
							new Runnable(){
157
						public void run() {
158
							PluginServices.
159
							cancelableBackgroundExecution(sptIdxTask);	
160
						}}
161
					);
162
				}	
159 163
			}//if
160 164
			if (globalTask.preprocess())
161 165
				PluginServices.cancelableBackgroundExecution(globalTask);
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/convexhull/fmap/ScalableConvexHullVisitor.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2006-05-24 21:13:31  azabala
48
* Revision 1.2  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/05/24 21:13:31  azabala
49 52
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
*
51 54
* Revision 1.3  2006/03/15 18:31:06  azabala
......
96 99
	}
97 100
	
98 101
	public void visit(IGeometry g, int index) throws VisitException {
102
		if(g == null)
103
			return;
99 104
		Geometry actualGeometry = g.toJTSGeometry();
100 105
		if(geometry == null){
101 106
			geometry = actualGeometry;
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/convexhull/fmap/ScalableUnionVisitor.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2006-05-24 21:13:31  azabala
48
* Revision 1.2  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/05/24 21:13:31  azabala
49 52
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
*
51 54
* Revision 1.2  2006/05/01 19:16:10  azabala
......
77 80
public class ScalableUnionVisitor extends ScalableConvexHullVisitor {
78 81
	
79 82
	public void visit(IGeometry g, int index) throws VisitException {
83
		if(g == null)
84
			return;
80 85
		Geometry actualGeometry = g.toJTSGeometry();
81 86
		if(geometry == null){
82 87
			geometry = actualGeometry;
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/convexhull/fmap/MemoryConvexHullVisitor.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2006-05-24 21:13:31  azabala
48
* Revision 1.2  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/05/24 21:13:31  azabala
49 52
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
*
51 54
* Revision 1.2  2006/03/07 21:01:33  azabala
......
92 95
		
93 96
	}
94 97
	public void visit(IGeometry g, int index) throws VisitException {
98
		if(g == null)
99
			return;
95 100
		Geometry jtsgeo = g.toJTSGeometry();
96 101
		geometries.add(jtsgeo);
97 102
	}
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/AbstractGeoprocessController.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2006-05-24 21:12:16  azabala
48
* Revision 1.2  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/05/24 21:12:16  azabala
49 52
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
*
51 54
* Revision 1.1  2006/04/11 17:55:51  azabala
......
60 63
import com.iver.cit.gvsig.geoprocess.core.IGeoprocessController;
61 64
import com.iver.cit.gvsig.geoprocess.core.gui.IGeoprocessPanel;
62 65

  
66
/**
67
 * Abstract base class for all implementations of GeoprocessController.
68
 * <br>
69
 * A <b>GeoprocessController</b> instance reads user inputs, and builds a Geoprocess
70
 * instance with these data.
71
 * 
72
 * This abstraction is very usefull to allow the building of any GUI component
73
 * (toolbar button, dialog, extensible geoprocessing toolbox, etc.) reusing the
74
 * reading of user entries and the construction of the geoprocess instance.
75
 * 
76
 * @author azabala
77
 *
78
 */
63 79
public abstract class AbstractGeoprocessController implements
64 80
		IGeoprocessController {
65 81

  
......
84 100
		writer.initialize(definition);
85 101
		return writer;
86 102
	}
87

  
103
	
88 104
}
89 105

  
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/gui/AbstractGeoprocessPanel.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.2  2006-05-25 08:21:14  jmvivo
48
* Revision 1.3  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.2  2006/05/25 08:21:14  jmvivo
49 52
* A?adido metodo de peticion de confirmacion para sobreescribir el fichero de salida
50 53
*
51 54
* Revision 1.1  2006/05/24 21:13:09  azabala
......
157 160
	 * For those geoprocesses that needs it (NN searches) overwrite this
158 161
	 * method and use JSI RTree, or SIL RTree.
159 162
	 * 
163
	 * It returns an IMonitorableTask, a task to build the spatial
164
	 * index in background.
160 165
	 * 
161 166
	 * @param layer
162 167
	 * @return an ITask
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/dissolve/DissolveGeoprocessController.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.2  2006-05-25 08:21:48  jmvivo
48
* Revision 1.3  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.2  2006/05/25 08:21:48  jmvivo
49 52
* A?adida peticion de confirmacion para sobreescribir el fichero de salida, si este ya existiera
50 53
*
51 54
* Revision 1.1  2006/05/24 21:11:14  azabala
......
160 163
			task2.setLayers(layers);
161 164
			MonitorableDecoratorMainFirst globalTask = new MonitorableDecoratorMainFirst(task1,
162 165
					task2);
163
			if(inputLayer.getISpatialIndex() == null){
164
				final IMonitorableTask sptIdxTask = 
165
					geoProcessingDissolvePanel.askForSpatialIndexCreation(inputLayer);
166
				if(sptIdxTask != null){
167
					PluginServices.backgroundExecution(
168
							new Runnable(){
169
						public void run() {
170
							PluginServices.
171
							cancelableBackgroundExecution(sptIdxTask);	
172
						}}
173
					);
174
				}
175
			}//if
166
			//if dissolving is spatial based, checks spatial
167
			//index existency
168
			if(geoProcessingDissolvePanel.onlyAdjacentSelected()){
169
				if(inputLayer.getISpatialIndex() == null){
170
					final IMonitorableTask sptIdxTask = 
171
						geoProcessingDissolvePanel.askForSpatialIndexCreation(inputLayer);
172
					if(sptIdxTask != null){
173
						PluginServices.backgroundExecution(
174
								new Runnable(){
175
							public void run() {
176
								PluginServices.
177
								cancelableBackgroundExecution(sptIdxTask);	
178
							}}
179
						);
180
					}
181
				}//if
182
			}
176 183
			if (globalTask.preprocess())
177 184
				PluginServices.cancelableBackgroundExecution(globalTask);
178 185
		} catch (GeoprocessException e) {
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/dissolve/fmap/GenericDissolveVisitor.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2006-05-24 21:11:14  azabala
48
* Revision 1.2  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/05/24 21:11:14  azabala
49 52
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
*
51 54
* Revision 1.2  2006/03/23 21:03:45  azabala
......
143 146
	 * For each adjacent feature, put it in the Stack
144 147
	 */
145 148
	public void visit(IGeometry g, int index) throws VisitException {
149
		if(g == null)
150
			return;
146 151
		if (!dissolvedGeometries.get(index)) {
147 152
			// if we havent dissolved this feature
148 153
			Stack toDissol = new Stack();// stack for adjacent features
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/dissolve/fmap/FeatureDissolver.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.1  2006-05-24 21:11:14  azabala
48
 * Revision 1.2  2006-06-02 18:21:28  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.1  2006/05/24 21:11:14  azabala
49 52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
 *
51 54
 *
......
287 290
		}
288 291

  
289 292
		public void visit(IGeometry g, int index2) throws VisitException {
293
			if(g == null)
294
				return;
290 295
			if (verifyCancelation(cancel, va)) {
291 296
				// TODO Revisar si hay problemas por llamar a finish
292 297
				// varias veces
......
368 373
		ArrayList geometries = new ArrayList();
369 374
		//we add the 'seed' feature geometry
370 375
		IGeometry g1 = va.getShape(index1);
376
		if(g1 == null)
377
			return;
371 378
		if(ct != null)
372 379
			g1.reProject(ct);
373 380
		geometries.add(g1.toJTSGeometry());
......
436 443
		
437 444

  
438 445
		public void visit(IGeometry g, int index2) throws VisitException {
446
			if(g == null)
447
				return;
439 448
			if (verifyCancelation(cancel, va)) {
440 449
				// TODO Revisar si hay problemas por llamar a finish
441 450
				// varias veces
......
521 530
			return;
522 531
		Strategy strategy = StrategyManager.getStrategy(dissolvedLayer);	
523 532
		IGeometry g1 = va.getShape(index1);
533
		if(g1 == null)
534
			return;
524 535
		if(ct != null)
525 536
			g1.reProject(ct);
526 537
		StackEntry entry = new StackEntry();
......
597 608
	}
598 609

  
599 610
	private void dumpStack(Stack stack) {
600
		Enumeration enum = stack.elements();
611
		Enumeration e = stack.elements();
601 612
		System.out.println("#####Elementos por procesar");
602
		while(enum.hasMoreElements()){
603
			System.out.println("#######-     "+((StackEntry)enum.nextElement()).index);
613
		while(e.hasMoreElements()){
614
			System.out.println("#######-     "+((StackEntry)e.nextElement()).index);
604 615
		}
605 616
	}
606 617

  
......
610 621
	 * @param geometries
611 622
	 * @return
612 623
	 */
613
	protected Geometry union(List geometries) {
614
long t0 = System.currentTimeMillis();		
624
	protected Geometry union(List geometries) {	
615 625
		Geometry union = null;
616 626
		GeometryFactory fact = ((Geometry)geometries.
617 627
									get(0)).getFactory();
......
634 644
	protected Geometry union3(List geometries) {
635 645
		long t0 = System.currentTimeMillis();		
636 646
				Geometry union = null;
637
				GeometryFactory fact = ((Geometry)geometries.
638
											get(0)).getFactory();
639 647
				Iterator geomIt = geometries.iterator();
640 648
				while(geomIt.hasNext()){
641 649
					Geometry g = (Geometry) geomIt.next();
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/dissolve/fmap/DissolveVisitor.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.1  2006-05-24 21:11:14  azabala
48
 * Revision 1.2  2006-06-02 18:21:28  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.1  2006/05/24 21:11:14  azabala
49 52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
 *
51 54
 * Revision 1.5  2006/05/08 15:37:26  azabala
......
189 192
	 * feature, put it in the Stack
190 193
	 */
191 194
	public void visit(IGeometry g, int index) throws VisitException {
195
		if(g == null)
196
			return;
192 197
		if (!dissolvedGeometries.get(index)) {
193 198
			// if we havent dissolved this feature
194 199
			Stack toDissol = new Stack();// stack for adjacent features
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/dissolve/fmap/AlphanumericDissolveVisitor.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.1  2006-05-24 21:11:14  azabala
48
 * Revision 1.2  2006-06-02 18:21:28  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.1  2006/05/24 21:11:14  azabala
49 52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
 *
51 54
 * Revision 1.2  2006/05/08 15:37:26  azabala
......
107 110
		}
108 111
		
109 112
		public void visit(IGeometry g, int index) throws VisitException {
113
			if(g == null)
114
				return;
110 115
			if (index == feature.getIndex())
111 116
				return;
112 117
			// have we dissolved this feature yet?
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/union/UnionGeoprocessController.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.2  2006-05-25 08:21:48  jmvivo
48
* Revision 1.3  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.2  2006/05/25 08:21:48  jmvivo
49 52
* A?adida peticion de confirmacion para sobreescribir el fichero de salida, si este ya existiera
50 53
*
51 54
* Revision 1.1  2006/05/24 21:09:11  azabala
......
150 153
			if(overlayLayer.getISpatialIndex() == null){
151 154
				final IMonitorableTask sptIdxTask = 
152 155
					geoProcessingUnionPanel.askForSpatialIndexCreation(overlayLayer);
153
				PluginServices.backgroundExecution(
154
						new Runnable(){
155
					public void run() {
156
						PluginServices.
157
						cancelableBackgroundExecution(sptIdxTask);	
158
					}}
159
				);
156
				if(sptIdxTask != null){
157
					PluginServices.backgroundExecution(
158
							new Runnable(){
159
						public void run() {
160
							PluginServices.
161
							cancelableBackgroundExecution(sptIdxTask);	
162
						}}
163
					);
164
				}	
160 165
			}//if
161 166
			if (globalTask.preprocess())
162 167
				PluginServices.cancelableBackgroundExecution(globalTask);
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/difference/DifferenceGeoprocessController.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.2  2006-05-25 08:21:48  jmvivo
48
* Revision 1.3  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.2  2006/05/25 08:21:48  jmvivo
49 52
* A?adida peticion de confirmacion para sobreescribir el fichero de salida, si este ya existiera
50 53
*
51 54
* Revision 1.1  2006/05/24 21:11:50  azabala
......
154 157
			if(overlayLayer.getISpatialIndex() == null){
155 158
				final IMonitorableTask sptIdxTask = 
156 159
					geoProcessingDifferencePanel.askForSpatialIndexCreation(overlayLayer);
157
				PluginServices.backgroundExecution(
158
						new Runnable(){
159
					public void run() {
160
						PluginServices.
161
						cancelableBackgroundExecution(sptIdxTask);	
162
					}}
163
				);
160
				if(sptIdxTask != null){
161
					PluginServices.backgroundExecution(
162
							new Runnable(){
163
						public void run() {
164
							PluginServices.
165
							cancelableBackgroundExecution(sptIdxTask);	
166
						}}
167
					);
168
				}	
164 169
			}//if
165 170
			if (globalTask.preprocess())
166 171
				PluginServices.cancelableBackgroundExecution(globalTask);
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/difference/fmap/DifferenceVisitor.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.1  2006-05-24 21:11:38  azabala
48
 * Revision 1.2  2006-06-02 18:21:28  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.1  2006/05/24 21:11:38  azabala
49 52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
 *
51 54
 * Revision 1.4  2006/05/01 19:15:18  azabala
......
79 82
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
80 83
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition;
81 84
import com.iver.cit.gvsig.fmap.edition.EditionException;
82
import com.iver.cit.gvsig.fmap.layers.FBitSet;
83 85
import com.iver.cit.gvsig.fmap.layers.FLayer;
84 86
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
85 87
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
......
88 90
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor;
89 91
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy;
90 92
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException;
91
import com.iver.cit.gvsig.geoprocess.convexhull.fmap.ScalableUnionVisitor;
92 93
import com.iver.cit.gvsig.geoprocess.core.fmap.FeatureFactory;
93 94
import com.iver.cit.gvsig.geoprocess.core.fmap.FeatureProcessor;
94 95
import com.vividsolutions.jts.geom.Geometry;
95
import com.vividsolutions.jts.geom.GeometryCollection;
96 96
import com.vividsolutions.jts.geom.MultiPolygon;
97 97
import com.vividsolutions.jts.geom.Polygon;
98 98
import com.vividsolutions.jts.precision.EnhancedPrecisionOp;
......
174 174
		}
175 175

  
176 176
		public void visit(IGeometry g, int index) throws VisitException {
177
			if(g == null)
178
				return;
177 179
			if (overlayLayerSelected) {
178 180
				try {
179 181
					if (!overlayLayer.getRecordset().getSelection().get(index))
......
215 217

  
216 218
	
217 219
	public void visit(IGeometry g, final int index) throws VisitException {
220
		if(g == null)
221
			return;
218 222
		Geometry firstJts = g.toJTSGeometry();
219 223
		Geometry solution = null;
220 224
		try {
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/spatialjoin/SpatialJoinGeoprocessController.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.2  2006-05-25 08:21:48  jmvivo
48
* Revision 1.3  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.2  2006/05/25 08:21:48  jmvivo
49 52
* A?adida peticion de confirmacion para sobreescribir el fichero de salida, si este ya existiera
50 53
*
51 54
* Revision 1.1  2006/05/24 21:09:47  azabala
......
76 79
import com.iver.cit.gvsig.geoprocess.core.fmap.IGeoprocess;
77 80
import com.iver.cit.gvsig.geoprocess.core.gui.AddResultLayerTask;
78 81
import com.iver.cit.gvsig.geoprocess.core.gui.IGeoprocessPanel;
79
import com.iver.cit.gvsig.geoprocess.dissolve.gui.GeoProcessingDissolvePanel;
80 82
import com.iver.cit.gvsig.geoprocess.spatialjoin.fmap.SpatialJoinGeoprocess;
81 83
import com.iver.cit.gvsig.geoprocess.spatialjoin.gui.GeoProcessingSpatialjoinPanel;
82 84
import com.iver.utiles.swing.threads.IMonitorableTask;
......
133 135
		boolean onlySecondSelection = geoProcessingSpatialjoinPanel
134 136
				.onlySecondLayerSelected();
135 137
		boolean nearest = geoProcessingSpatialjoinPanel.isNearestSelected();
138
		
139
		
136 140
		SpatialJoinGeoprocess join = new SpatialJoinGeoprocess(inputLayer);
137 141
		join.setSecondOperand(secondLayer);
138 142
		join.setFields_sumFunctions(sumarizeFunctions);
......
166 170
			task2.setLayers(layers);
167 171
			MonitorableDecoratorMainFirst globalTask = new MonitorableDecoratorMainFirst(task1,
168 172
					task2);
169
			if(secondLayer.getISpatialIndex() == null){
170
				final IMonitorableTask sptIdxTask = 
171
					geoProcessingSpatialjoinPanel.askForSpatialIndexCreation(secondLayer);
172
				PluginServices.backgroundExecution(
173
						new Runnable(){
174
					public void run() {
175
						PluginServices.
176
						cancelableBackgroundExecution(sptIdxTask);	
177
					}}
178
				);
179
			}//if
180 173
			if (globalTask.preprocess())
181 174
				PluginServices.cancelableBackgroundExecution(globalTask);
182 175
		} catch (GeoprocessException e) {
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/spatialjoin/fmap/NearestFeatureVisitor.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2006-05-24 21:09:47  azabala
48
* Revision 1.2  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/05/24 21:09:47  azabala
49 52
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
*
51 54
* Revision 1.2  2006/03/07 21:01:33  azabala
......
88 91
	}
89 92
	
90 93
	public void visit(IGeometry g, int index) throws VisitException {
94
		if(g == null)
95
			return;
91 96
		double dist = queryGeometry.distance(g.toJTSGeometry());
92 97
		if(dist < shortestDist){
93 98
			shortestDist = dist;
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/spatialjoin/fmap/IntersectSpatialJoinVisitor.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.1  2006-05-24 21:09:47  azabala
48
 * Revision 1.2  2006-06-02 18:21:28  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.1  2006/05/24 21:09:47  azabala
49 52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
 *
51 54
 * Revision 1.4  2006/03/21 19:29:36  azabala
......
154 157
	}
155 158

  
156 159
	public void visit(IGeometry g, int index) throws VisitException {
160
		if(g == null)
161
			return;
157 162
		IFeature solution = null;
158 163
		visitor.setQueryGeometry(g.toJTSGeometry());
159 164
		try {
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/spatialjoin/fmap/NearestHeuristicSpatialJoinVisitor.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2006-05-24 21:09:47  azabala
48
* Revision 1.2  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/05/24 21:09:47  azabala
49 52
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
*
51 54
* Revision 1.1  2006/05/01 19:09:09  azabala
......
195 198
	 * target layer and taking attributes from it
196 199
	 */
197 200
	public void visit(IGeometry g, int sourceIndex) throws VisitException {
201
		if(g == null)
202
			return;
198 203
		final Geometry geometry = g.toJTSGeometry();	
199 204
		Stack stackOfEnvelopes = quadTree.getNearestEnvelopeOfIdealDimension(geometry,
200 205
				targetLayerEnv);
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/spatialjoin/fmap/NearestSpatialJoinVisitor.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.1  2006-05-24 21:09:47  azabala
48
 * Revision 1.2  2006-06-02 18:21:28  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.1  2006/05/24 21:09:47  azabala
49 52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
 *
51 54
 * Revision 1.6  2006/05/01 19:08:41  azabala
......
173 176
	 * target layer and taking attributes from it
174 177
	 */
175 178
	public void visit(IGeometry g, int sourceIndex) throws VisitException {
179
		if(g == null)
180
			return;
181
long t0 = System.currentTimeMillis();		
176 182
		lookForNearestVisitor.setQueryGeometry(g.toJTSGeometry());
177 183
		try {
178 184
			if(onlySecondLayerSelection)
......
180 186
			else
181 187
				strategy.process(lookForNearestVisitor);
182 188
			int targetIndex = lookForNearestVisitor.getNearestFeatureIndex();
189
long t1 = System.currentTimeMillis();
183 190
			IFeature joinedFeature = createFeature(g, sourceIndex, targetIndex);
191
long t2 = System.currentTimeMillis();			
184 192
			this.featureProcessor.processFeature(joinedFeature);
193
long t3 = System.currentTimeMillis();
194
System.out.println((t1-t0)+" en buscar nearest");
195
System.out.println((t2-t1)+" en build feature");
196
System.out.println((t3-t2)+" en guardar feature");
185 197
		} catch (DriverException e) {
186 198
			throw new VisitException(
187 199
					"Problemas accediendo a los datos durante un nearest spatial join");
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/spatialjoin/fmap/SpatiallyIndexedSpatialJoinVisitor.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2006-05-24 21:09:47  azabala
48
* Revision 1.2  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/05/24 21:09:47  azabala
49 52
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
*
51 54
* Revision 1.1  2006/05/02 18:58:47  azabala
......
109 112
			FLyrVect targetLayer, 
110 113
			FeatureProcessor processor) throws DriverException {
111 114
		super(sourceLayer, targetLayer, processor);
112
		initialize();
115
//		lo comentamos porque debe ser llamado externamente
116
//		initialize();
113 117
	}
114 118
	
115
	void initialize(){
119
	public void initialize(){
116 120
		ISpatialIndex spatialIndex =
117 121
			targetLayer.getISpatialIndex();
118 122
		if(spatialIndex instanceof INearestNeighbourFinder)
119 123
			nearestFinder = (INearestNeighbourFinder)spatialIndex;
120 124
		else
121
			throw new IllegalArgumentException("La segunda capa de spatial join ha de tener un ?ndice espacial de tipo RTreeSptLib para usar este visitor");
125
			throw new IllegalArgumentException("La segunda capa de spatial join ha de tener un ?ndice espacial de tipo INearestNeighbourFinder para usar este visitor");
122 126
	}
123 127
	
124 128
	
......
128 132
	 * target layer and taking attributes from it
129 133
	 */
130 134
	public void visit(IGeometry g, int sourceIndex) throws VisitException {
135
		if(g == null)
136
			return;
131 137
		try {
138
long t0 = System.currentTimeMillis();			
132 139
		//no se si el rtree har? la busqueda bien si el rectangulo
133 140
		//de busqueda no est? insertado. Hacer las pruebas (si no,
134 141
		//a?adimos ahora y borramos luego)
......
158 165
		
159 166
			joinedFeature = createFeature(g, sourceIndex, targetIndex);
160 167
			this.featureProcessor.processFeature(joinedFeature);
168
long t1 = System.currentTimeMillis();
169
System.out.println((t1-t0)+" en spatial join con indice espacial");
161 170
		} catch (DriverException e) {
162 171
			throw new VisitException("Error de driver al escribir un feature resultante de un spatial join", e);
163 172
		} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/spatialjoin/fmap/IntersectsFinderFeatureVisitor.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.1  2006-05-24 21:09:47  azabala
48
 * Revision 1.2  2006-06-02 18:21:28  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.1  2006/05/24 21:09:47  azabala
49 52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
 *
51 54
 * Revision 1.2  2006/03/07 21:01:33  azabala
......
121 124
	}
122 125

  
123 126
	public void visit(IGeometry g, int index) throws VisitException {
127
		if(g == null)
128
			return;
124 129
		if(selection != null){
125 130
			if(! selection.get(index)){
126 131
				//dont process feature because is not selected
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/spatialjoin/fmap/SpatialJoinGeoprocess.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.1  2006-05-24 21:09:47  azabala
48
 * Revision 1.2  2006-06-02 18:21:28  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.1  2006/05/24 21:09:47  azabala
49 52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
 *
51 54
 * Revision 1.10  2006/05/08 15:38:05  azabala
......
86 89

  
87 90
import com.iver.andami.PluginServices;
88 91
import com.iver.cit.gvsig.fmap.DriverException;
92
import com.iver.cit.gvsig.fmap.core.IGeometry;
89 93
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
90 94
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition;
91 95
import com.iver.cit.gvsig.fmap.edition.EditionException;
92 96
import com.iver.cit.gvsig.fmap.layers.FBitSet;
93 97
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
98
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
94 99
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy;
95 100
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager;
96 101
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException;
97 102
import com.iver.cit.gvsig.fmap.spatialindex.INearestNeighbourFinder;
98 103
import com.iver.cit.gvsig.fmap.spatialindex.ISpatialIndex;
104
import com.iver.cit.gvsig.fmap.spatialindex.RTreeJsi;
99 105
import com.iver.cit.gvsig.geoprocess.core.fmap.AbstractGeoprocess;
100 106
import com.iver.cit.gvsig.geoprocess.core.fmap.FeaturePersisterProcessor2;
101 107
import com.iver.cit.gvsig.geoprocess.core.fmap.GeoprocessException;
......
204 210
			this.nearestSpatialJoin = nearest.booleanValue();
205 211
		if(nearestSpatialJoin){
206 212
			try {
207
				ISpatialIndex spatialIndex = secondLayer.getISpatialIndex();
208
				if(spatialIndex != null && 
209
						(spatialIndex instanceof INearestNeighbourFinder))
210
				{
213
//				ISpatialIndex spatialIndex = secondLayer.getISpatialIndex();
214
//				if(spatialIndex != null && 
215
//						(spatialIndex instanceof INearestNeighbourFinder))
216
//				{
211 217
					visitor = new SpatiallyIndexedSpatialJoinVisitor(this.firstLayer, 
212 218
							this.secondLayer,
213 219
							processor);
214
				}else{
215
					
216
					visitor = new NearestSpatialJoinVisitor(this.firstLayer, 
217
							this.secondLayer,
218
							processor);
219
				}
220
//				}else{
221
//					
222
//					visitor = new NearestSpatialJoinVisitor(this.firstLayer, 
223
//							this.secondLayer,
224
//							processor);
225
//				}
220 226
			} catch (DriverException e) {
221 227
				throw new GeoprocessException("Error preparando el procesado de las capas a enlazar");
222 228
			}
......
261 267
	}
262 268

  
263 269
	public void process() throws GeoprocessException {
264
		//Comentado: esto se le debe preguntar al usuario
265
//		if(!secondLayer.isSpatiallyIndexed()){
266
//			//Revisar. Si el driver es ISpatialDB no es 
267
//			//necesario construir indice
268
//			secondLayer.createSpatialIndex();
269
//		}
270 270
		Strategy strategy =
271 271
			StrategyManager.getStrategy(firstLayer);
272 272
		
......
397 397
		}
398 398

  
399 399
		public void run() throws GeoprocessException {
400
			if(!secondLayer.isSpatiallyIndexed()){
401
				//Revisar. Si el driver es ISpatialDB no es 
402
				//necesario construir indice
403
				secondLayer.createSpatialIndex();
400
			ISpatialIndex oldSptIdx = null;
401
			if(nearestSpatialJoin){
402
				oldSptIdx = secondLayer.getISpatialIndex();
403
				if(oldSptIdx == null || ! (oldSptIdx instanceof INearestNeighbourFinder)){
404
					RTreeJsi newSptIdx = new RTreeJsi();
405
					newSptIdx.create();
406
					ReadableVectorial source = secondLayer.getSource();
407
					try {
408
						int numFeatures = source.getShapeCount();
409
						for(int i = 0; i < numFeatures; i++){
410
							IGeometry geometry = source.getShape(i);
411
							newSptIdx.insert(geometry.getBounds2D(), i);
412
						}
413
					} catch (DriverIOException e) {
414
						throw new GeoprocessException("Error intentando indexar para busqueda por mas proximo");
415
					}
416
					secondLayer.setISpatialIndex(newSptIdx);
417
				}//if oldSptIdx
418
			}//if nearest
419
			
420
			if(visitor instanceof SpatiallyIndexedSpatialJoinVisitor)
421
			{
422
				//here checks for Nearest Neighbour capabilitie
423
				((SpatiallyIndexedSpatialJoinVisitor)visitor).initialize();
404 424
			}
425
			
405 426
			Strategy strategy =
406 427
				StrategyManager.getStrategy(firstLayer);
407 428
			Strategy secondLyrStrategy =
......
419 440
					strategy.process(visitor, cancelMonitor);
420 441
				}
421 442
				
443
//				If we changed spatial index to allow Nearest Neighbour queries,
444
				//recover the old spatial index
445
				if(oldSptIdx != null)
446
					secondLayer.setISpatialIndex(oldSptIdx);
447
				
422 448
			} catch (DriverException e) {
423 449
				throw new GeoprocessException("Error al acceder a los datos durante un spatial join");
424 450
			} catch (VisitException e) {
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/merge/fmap/MergeVisitor.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2006-05-24 21:10:15  azabala
48
* Revision 1.2  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.1  2006/05/24 21:10:15  azabala
49 52
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
*
51 54
* Revision 1.5  2006/03/23 21:05:11  azabala
......
105 108
	}
106 109
	
107 110
	public void visit(IGeometry g, int index) throws VisitException {
111
		if(g == null)
112
			return;
108 113
		FieldDescription[] fields =
109 114
			definition.getFieldsDesc();
110 115
		Value[] values = new Value[fields.length];
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/intersection/fmap/IntersectVisitor.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.1  2006-05-24 21:10:40  azabala
48
 * Revision 1.2  2006-06-02 18:21:28  azabala
49
 * *** empty log message ***
50
 *
51
 * Revision 1.1  2006/05/24 21:10:40  azabala
49 52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
50 53
 *
51 54
 * Revision 1.6  2006/05/01 19:12:17  azabala
......
81 84
import com.iver.cit.gvsig.fmap.core.IFeature;
82 85
import com.iver.cit.gvsig.fmap.core.IGeometry;
83 86
import com.iver.cit.gvsig.fmap.core.v02.FConverter;
84
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
85 87
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition;
86 88
import com.iver.cit.gvsig.fmap.edition.EditionException;
87
import com.iver.cit.gvsig.fmap.layers.FBitSet;
88 89
import com.iver.cit.gvsig.fmap.layers.FLayer;
89 90
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
90 91
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
......
181 182
	}
182 183

  
183 184
	public void visit(IGeometry g, final int index) throws VisitException {
184

  
185
		if(g == null)
186
			return;
185 187
		final Geometry firstJts = g.toJTSGeometry();
186 188
		final boolean onlyOverlay = onlyOverlaySelection;
187 189
		try {
trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/intersection/IntersectionGeoprocessController.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.2  2006-05-25 08:21:48  jmvivo
48
* Revision 1.3  2006-06-02 18:21:28  azabala
49
* *** empty log message ***
50
*
51
* Revision 1.2  2006/05/25 08:21:48  jmvivo
49 52
* A?adida peticion de confirmacion para sobreescribir el fichero de salida, si este ya existiera
50 53
*
51 54
* Revision 1.1  2006/05/24 21:10:40  azabala
......
156 159
			if(overlayLayer.getISpatialIndex() == null){
157 160
				final IMonitorableTask sptIdxTask = 
158 161
					geoProcessingIntersectPanel.askForSpatialIndexCreation(overlayLayer);
159
				PluginServices.backgroundExecution(
160
						new Runnable(){
161
					public void run() {
162
						PluginServices.
163
						cancelableBackgroundExecution(sptIdxTask);	
164
					}}
165
				);
162
				if(sptIdxTask != null){
163
					PluginServices.backgroundExecution(
164
							new Runnable(){
165
						public void run() {
166
							PluginServices.
167
							cancelableBackgroundExecution(sptIdxTask);	
168
						}}
169
					);
170
				}	
166 171
			}//if
167 172
			if (globalTask.preprocess())
168 173
				PluginServices.cancelableBackgroundExecution(globalTask);

Also available in: Unified diff