Revision 36577
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/IGeoprocessPlugin.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 20-jun-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 |
* Revision 1.4 2007-08-13 11:50:36 jmvivo |
|
49 |
* Extraidas los htm de descripcion de las traducciones a un directorio fuera del jar |
|
50 |
* |
|
51 |
* Revision 1.3 2006/06/29 17:28:24 azabala |
|
52 |
* added comments |
|
53 |
* |
|
54 |
* Revision 1.2 2006/06/27 16:10:14 azabala |
|
55 |
* toString() added to interface to force textual representation of geoprocess plugins |
|
56 |
* |
|
57 |
* Revision 1.1 2006/06/23 19:01:58 azabala |
|
58 |
* first version in cvs |
|
59 |
* |
|
60 |
* Revision 1.1 2006/06/22 17:46:30 azabala |
|
61 |
* first version in cvs |
|
62 |
* |
|
63 |
* |
|
64 |
*/ |
|
65 |
package com.iver.cit.gvsig.geoprocess.core; |
|
66 |
|
|
67 |
import java.net.URL; |
|
68 |
|
|
69 |
import com.iver.cit.gvsig.geoprocess.core.gui.IGeoprocessUserEntries; |
|
70 |
|
|
71 |
/** |
|
72 |
Ofrece acceso a todo lo necesario para a?adir un geoproceso |
|
73 |
al geoprocessmanager: |
|
74 |
a) geoproceso en si |
|
75 |
b) panel grafico |
|
76 |
c) html descriptivo |
|
77 |
d) imagen descriptiva |
|
78 |
e) controlador, que lee las entradas de la GUI y se las |
|
79 |
pasa al geoproceso |
|
80 |
|
|
81 |
?Como podemos hacer que cuando un desarrollador externo haga una extension |
|
82 |
con nuevos geoprocesos, se cosque el GeoprocessManager? |
|
83 |
|
|
84 |
El geoprocessmanager tendr? asociada una extension, y en esta |
|
85 |
extension se construye el componente y se a?aden los geoprocesos del core |
|
86 |
(union, diferencia, etc). |
|
87 |
Adem?s, construye un punto de extension con el API ExtensionPoints (IverUtiles) |
|
88 |
|
|
89 |
En el metodo initialize() de la Extension ANDAMI del GeoprocessManager, |
|
90 |
se crear?a el punto de extension "GeoprocessManager". |
|
91 |
|
|
92 |
Si desde otro proyecto se quiere crear un geoproceso, y que se muestre en el geoprocess |
|
93 |
manager, solo habr?a que construir una extension de andami, y en su metodo initialize |
|
94 |
a?adir cada geoproceso nuevo al punto de extension. |
|
95 |
|
|
96 |
Luego, desde el GeoprocessManager, en el metodo execute() de la extension |
|
97 |
asociada ya se har?a lo siguiente: |
|
98 |
ExtensionPoint infoByPoint = (ExtensionPoint)extensionPoints.get("GeoprocessManager"); |
|
99 |
Iterator infoByPoint =infoByPoint.keySet().iterator(); |
|
100 |
while( i.hasNext() ) { |
|
101 |
String nombre = (String)i.next(); |
|
102 |
} |
|
103 |
Quiz?s sea menos elegante que el mecanismo de los drivers (con su propio |
|
104 |
classloader), pero simplifica la gesti?n. No hay que echar ning?n jar |
|
105 |
en ning?n directorio. Solo crear las extensiones Andami encargadas de registrar |
|
106 |
los nuevos geoprocesos en el punto de extension. |
|
107 |
|
|
108 |
* |
|
109 |
* @author azabala |
|
110 |
* |
|
111 |
*/ |
|
112 |
|
|
113 |
public interface IGeoprocessPlugin { |
|
114 |
public IGeoprocessUserEntries getGeoprocessPanel(); |
|
115 |
// JEditorPane htmlPane = new JEditorPane(url); |
|
116 |
// htmlPane.setPage(new URL(url)); |
|
117 |
public URL getHtmlDescription(); |
|
118 |
/** |
|
119 |
* @deprecated |
|
120 |
*/ |
|
121 |
public URL getImgDescription(); |
|
122 |
public IGeoprocessController getGpController(); |
|
123 |
/** |
|
124 |
* Gives access to the geoprocess namespace. |
|
125 |
* Namespaces are artifacts to identify geoproccesses by a path |
|
126 |
* (similar to xpath), and to organize them. |
|
127 |
* For example: |
|
128 |
* Analysis Tools/Overlay/Union |
|
129 |
* Data Management Tools/Generalization/Dissolve |
|
130 |
* Data Management Tools/Generalization/Dissolve by multiple fields |
|
131 |
* @return |
|
132 |
*/ |
|
133 |
public String getNamespace(); |
|
134 |
/** |
|
135 |
* To give a textual representation of the plugin |
|
136 |
* @return |
|
137 |
*/ |
|
138 |
public String toString(); |
|
139 |
} |
|
140 |
|
|
0 | 141 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/GeoprocessException.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 01-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$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.1 2006-05-24 21:12:16 azabala |
|
49 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
50 |
* |
|
51 |
* Revision 1.1 2006/02/12 21:03:25 azabala |
|
52 |
* *** empty log message *** |
|
53 |
* |
|
54 |
* Revision 1.1 2006/02/01 19:40:59 azabala |
|
55 |
* First version in CVS |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
60 |
/** |
|
61 |
* Exceptions throwed by geoprocesses. |
|
62 |
* @author azabala |
|
63 |
* |
|
64 |
*/ |
|
65 |
public class GeoprocessException extends Exception { |
|
66 |
|
|
67 |
private static final long serialVersionUID = -1215904736755267813L; |
|
68 |
|
|
69 |
public GeoprocessException() { |
|
70 |
super(); |
|
71 |
} |
|
72 |
|
|
73 |
public GeoprocessException(String message) { |
|
74 |
super(message); |
|
75 |
} |
|
76 |
|
|
77 |
public GeoprocessException(String message, Throwable cause) { |
|
78 |
super(message, cause); |
|
79 |
} |
|
80 |
|
|
81 |
public GeoprocessException(Throwable cause) { |
|
82 |
super(cause); |
|
83 |
|
|
84 |
} |
|
85 |
} |
|
86 |
|
|
0 | 87 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/MinFunction.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 23-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$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2006-06-20 18:19:43 azabala |
|
49 |
* refactorizaci?n para que todos los nuevos geoprocesos cuelguen del paquete impl |
|
50 |
* |
|
51 |
* Revision 1.1 2006/05/24 21:12:16 azabala |
|
52 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
53 |
* |
|
54 |
* Revision 1.1 2006/02/26 20:55:28 azabala |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
60 |
|
|
61 |
import com.hardcode.gdbms.engine.values.NumericValue; |
|
62 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
63 |
/** |
|
64 |
* Sumarization function that returns min value of |
|
65 |
* all field values. |
|
66 |
* @author azabala |
|
67 |
* |
|
68 |
*/ |
|
69 |
public class MinFunction implements SummarizationFunction { |
|
70 |
double minValue = Double.MAX_VALUE; |
|
71 |
|
|
72 |
public void process(NumericValue value) { |
|
73 |
double val = value.doubleValue(); |
|
74 |
if(minValue > val){ |
|
75 |
minValue = val; |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
public NumericValue getSumarizeValue() { |
|
80 |
if(minValue == Double.MAX_VALUE) |
|
81 |
return ValueFactory.createValue(0d); |
|
82 |
return ValueFactory.createValue(minValue); |
|
83 |
} |
|
84 |
|
|
85 |
public String toString(){ |
|
86 |
return "min"; |
|
87 |
} |
|
88 |
|
|
89 |
public void reset() { |
|
90 |
minValue = Double.MAX_VALUE; |
|
91 |
} |
|
92 |
|
|
93 |
} |
|
94 |
|
|
0 | 95 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/AbstractGeoprocessFeatureVisitor.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 06-jul-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 |
* Revision 1.2 2007-03-06 16:47:58 caballero |
|
49 |
* Exceptions |
|
50 |
* |
|
51 |
* Revision 1.1 2006/07/21 09:08:15 azabala |
|
52 |
* first version in cvs |
|
53 |
* |
|
54 |
* |
|
55 |
*/ |
|
56 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
57 |
|
|
58 |
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException; |
|
59 |
import com.iver.cit.gvsig.exceptions.visitors.StartVisitorException; |
|
60 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
61 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
62 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
63 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
|
64 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData; |
|
65 |
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor; |
|
66 |
|
|
67 |
/** |
|
68 |
* Abstract base class to all feature visitor created |
|
69 |
* for geoprocessing. |
|
70 |
* @author azabala |
|
71 |
* |
|
72 |
*/ |
|
73 |
public abstract class AbstractGeoprocessFeatureVisitor implements |
|
74 |
FeatureVisitor { |
|
75 |
/** |
|
76 |
* processes visited features. |
|
77 |
*/ |
|
78 |
FeatureProcessor featureProcessor; |
|
79 |
|
|
80 |
/** |
|
81 |
* Constructor. |
|
82 |
* It receives a FeatureProcessor to process visited features |
|
83 |
* (usually to save them) |
|
84 |
* @param processor |
|
85 |
*/ |
|
86 |
public AbstractGeoprocessFeatureVisitor(FeatureProcessor processor){ |
|
87 |
this.featureProcessor = processor; |
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 |
public abstract void visit(IGeometry g, int index) throws VisitorException, ProcessVisitorException; |
|
92 |
|
|
93 |
public abstract String getProcessDescription(); |
|
94 |
|
|
95 |
/** |
|
96 |
* finishes visitation by closing result layer writing. |
|
97 |
*/ |
|
98 |
public void stop(FLayer layer) throws VisitorException { |
|
99 |
featureProcessor.finish(); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* to start the visit process, prepares result layer. |
|
104 |
*/ |
|
105 |
public boolean start(FLayer layer) throws StartVisitorException { |
|
106 |
if (layer instanceof AlphanumericData && |
|
107 |
layer instanceof VectorialData) { |
|
108 |
this.featureProcessor.start(); |
|
109 |
return true; |
|
110 |
} |
|
111 |
return false; |
|
112 |
} |
|
113 |
|
|
114 |
|
|
115 |
} |
|
116 |
|
|
0 | 117 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/GeoprocessingResultsProcessor.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 08-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$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2007-03-06 16:47:58 caballero |
|
49 |
* Exceptions |
|
50 |
* |
|
51 |
* Revision 1.1 2006/05/24 21:12:16 azabala |
|
52 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
53 |
* |
|
54 |
* Revision 1.1 2006/02/17 16:33:46 azabala |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* Revision 1.2 2006/02/12 21:02:44 azabala |
|
58 |
* *** empty log message *** |
|
59 |
* |
|
60 |
* Revision 1.1 2006/02/09 16:00:36 azabala |
|
61 |
* First version in CVS |
|
62 |
* |
|
63 |
* |
|
64 |
*/ |
|
65 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
66 |
|
|
67 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
68 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
69 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
70 |
import com.vividsolutions.jts.geom.Geometry; |
|
71 |
|
|
72 |
public interface GeoprocessingResultsProcessor { |
|
73 |
public void processJtsGeometry(Geometry g, int index) throws VisitorException, ReadDriverException; |
|
74 |
public void finish() throws VisitorException; |
|
75 |
public void processFeature(IFeature feature) throws VisitorException; |
|
76 |
} |
|
77 |
|
|
0 | 78 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/MaxFunction.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 23-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$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.3 2007-05-24 10:35:12 caballero |
|
49 |
* Min_Value |
|
50 |
* |
|
51 |
* Revision 1.2 2006/06/20 18:19:43 azabala |
|
52 |
* refactorizaci?n para que todos los nuevos geoprocesos cuelguen del paquete impl |
|
53 |
* |
|
54 |
* Revision 1.1 2006/05/24 21:12:16 azabala |
|
55 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
56 |
* |
|
57 |
* Revision 1.1 2006/02/26 20:55:28 azabala |
|
58 |
* *** empty log message *** |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
63 |
|
|
64 |
import com.hardcode.gdbms.engine.values.NumericValue; |
|
65 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
66 |
|
|
67 |
/** |
|
68 |
* * Sumarization function that returns min value of all field values. |
|
69 |
* |
|
70 |
* @author azabala |
|
71 |
*/ |
|
72 |
public class MaxFunction implements SummarizationFunction { |
|
73 |
|
|
74 |
boolean set = false; |
|
75 |
double maxValue = 0; |
|
76 |
|
|
77 |
public void process(NumericValue value) { |
|
78 |
double val = value.doubleValue(); |
|
79 |
if (!set || maxValue < val) { |
|
80 |
maxValue = val; |
|
81 |
set= true; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
public NumericValue getSumarizeValue() { |
|
86 |
if(!set){ |
|
87 |
//process method wasnt be called |
|
88 |
return ValueFactory.createValue(0d); |
|
89 |
} |
|
90 |
return ValueFactory.createValue(maxValue); |
|
91 |
} |
|
92 |
|
|
93 |
public String toString(){ |
|
94 |
return "max"; |
|
95 |
} |
|
96 |
|
|
97 |
public void reset() { |
|
98 |
set = false; |
|
99 |
} |
|
100 |
|
|
101 |
} |
|
0 | 102 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/FeatureProcessor.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 22-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$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2007-03-06 16:47:58 caballero |
|
49 |
* Exceptions |
|
50 |
* |
|
51 |
* Revision 1.1 2006/05/24 21:12:16 azabala |
|
52 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
53 |
* |
|
54 |
* Revision 1.2 2006/03/05 20:00:09 azabala |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* Revision 1.1 2006/02/26 20:55:55 azabala |
|
58 |
* *** empty log message *** |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
63 |
|
|
64 |
import com.iver.cit.gvsig.exceptions.visitors.StartVisitorException; |
|
65 |
import com.iver.cit.gvsig.exceptions.visitors.StopVisitorException; |
|
66 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
67 |
import com.iver.cit.gvsig.fmap.core.IRow; |
|
68 |
|
|
69 |
public interface FeatureProcessor { |
|
70 |
public void processFeature(IRow feature) throws VisitorException; |
|
71 |
public void finish() throws StopVisitorException; |
|
72 |
public void start() throws StartVisitorException; |
|
73 |
} |
|
74 |
|
|
0 | 75 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/XTypes.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 07-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$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2007-08-07 15:06:12 azabala |
|
49 |
* added getNumericFields method |
|
50 |
* |
|
51 |
* Revision 1.1 2006/05/24 21:12:16 azabala |
|
52 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
53 |
* |
|
54 |
* Revision 1.4 2006/02/19 20:56:07 azabala |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* Revision 1.3 2006/02/17 16:34:00 azabala |
|
58 |
* *** empty log message *** |
|
59 |
* |
|
60 |
* Revision 1.2 2006/02/13 18:37:41 azabala |
|
61 |
* *** empty log message *** |
|
62 |
* |
|
63 |
* Revision 1.1 2006/02/09 15:59:48 azabala |
|
64 |
* First version in CVS |
|
65 |
* |
|
66 |
* |
|
67 |
*/ |
|
68 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
69 |
|
|
70 |
import java.sql.Types; |
|
71 |
import java.util.ArrayList; |
|
72 |
import java.util.Date; |
|
73 |
|
|
74 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
75 |
import com.hardcode.gdbms.engine.values.BooleanValue; |
|
76 |
import com.hardcode.gdbms.engine.values.DateValue; |
|
77 |
import com.hardcode.gdbms.engine.values.DoubleValue; |
|
78 |
import com.hardcode.gdbms.engine.values.FloatValue; |
|
79 |
import com.hardcode.gdbms.engine.values.IntValue; |
|
80 |
import com.hardcode.gdbms.engine.values.LongValue; |
|
81 |
import com.hardcode.gdbms.engine.values.StringValue; |
|
82 |
import com.hardcode.gdbms.engine.values.Value; |
|
83 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
84 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
85 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
86 |
|
|
87 |
/** |
|
88 |
* This is a similar try to com.iver.cit.gvsig.jdbc_spatial.XTypes to do a Types |
|
89 |
* management in GvSig |
|
90 |
* |
|
91 |
* @author azabala |
|
92 |
* |
|
93 |
*/ |
|
94 |
public abstract class XTypes { |
|
95 |
// Geometry types |
|
96 |
public final static int SHAPE_NULL = 0; |
|
97 |
public final static int POINT = 1; |
|
98 |
public final static int LINE = 2; |
|
99 |
public final static int POLYGON = 4; |
|
100 |
public final static int TEXT = 8; |
|
101 |
public final static int MULTI = 16; |
|
102 |
public final static int MULTIPOINT = 32; |
|
103 |
public final static int CIRCLE = 64; |
|
104 |
public final static int ARC = 128; |
|
105 |
public final static int ELLIPSE = 256; |
|
106 |
public final static int Z = 512; |
|
107 |
|
|
108 |
public static final int BIT = Types.BIT; |
|
109 |
public static final int TINYINT = Types.TINYINT; |
|
110 |
public static final int SMALLINT = Types.SMALLINT; |
|
111 |
public static final int INTEGER = Types.INTEGER; |
|
112 |
public static final int BIGINT = Types.BIGINT; |
|
113 |
public static final int FLOAT = Types.FLOAT; |
|
114 |
public static final int REAL = Types.REAL; |
|
115 |
public static final int DOUBLE = Types.DOUBLE; |
|
116 |
public static final int NUMERIC = Types.NUMERIC; |
|
117 |
public static final int DECIMAL = Types.DECIMAL; |
|
118 |
public static final int CHAR = Types.CHAR; |
|
119 |
public static final int VARCHAR = Types.VARCHAR; |
|
120 |
public static final int LONGVARCHAR = Types.LONGVARCHAR; |
|
121 |
public static final int DATE = Types.DATE; |
|
122 |
public static final int TIME = Types.TIME; |
|
123 |
public static final int TIMESTAMP = Types.TIMESTAMP; |
|
124 |
public static final int BINARY = Types.BINARY; |
|
125 |
public static final int VARBINARY = Types.VARBINARY; |
|
126 |
public static final int LONGVARBINARY = Types.LONGVARBINARY; |
|
127 |
public static final int NULL = Types.NULL; |
|
128 |
public static final int OTHER = Types.OTHER; |
|
129 |
public static final int JAVA_OBJECT = Types.JAVA_OBJECT; |
|
130 |
public static final int DISTINCT = Types.DISTINCT; |
|
131 |
public static final int STRUCT = Types.STRUCT; |
|
132 |
public static final int ARRAY = Types.ARRAY; |
|
133 |
public static final int BLOB = Types.BLOB; |
|
134 |
public static final int CLOB = Types.CLOB; |
|
135 |
public static final int REF = Types.REF; |
|
136 |
public static final int DATALINK = Types.DATALINK; |
|
137 |
public static final int BOOLEAN = Types.BOOLEAN; |
|
138 |
|
|
139 |
public static boolean isNumeric(int fieldType) { |
|
140 |
switch (fieldType) { |
|
141 |
case DOUBLE: |
|
142 |
case FLOAT: |
|
143 |
case INTEGER: |
|
144 |
case SMALLINT: |
|
145 |
case BIGINT: |
|
146 |
case NUMERIC: |
|
147 |
case REAL: |
|
148 |
case TINYINT: |
|
149 |
case DECIMAL: |
|
150 |
return true; |
|
151 |
} |
|
152 |
return false; |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* Convert an int data type in a text sql type. Is abstract because it will |
|
157 |
* be strongly dependant of sql rdbms. |
|
158 |
* |
|
159 |
* @param fieldType |
|
160 |
* @return |
|
161 |
*/ |
|
162 |
public abstract String fieldTypeToString(int fieldType); |
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
public static Object getObject(Value value, int fieldType){ |
|
167 |
Object solution = null; |
|
168 |
switch (fieldType) { |
|
169 |
case Types.VARCHAR: |
|
170 |
StringValue str = (StringValue) value; |
|
171 |
solution = str.getValue(); |
|
172 |
break; |
|
173 |
case Types.FLOAT: |
|
174 |
FloatValue fval = (FloatValue) value; |
|
175 |
solution = new Float(fval.floatValue()); |
|
176 |
break; |
|
177 |
case Types.DOUBLE: |
|
178 |
DoubleValue dval = (DoubleValue)value; |
|
179 |
solution = new Double(dval.doubleValue()); |
|
180 |
break; |
|
181 |
case Types.INTEGER: |
|
182 |
IntValue intval = (IntValue)value; |
|
183 |
solution = new Integer(intval.intValue()); |
|
184 |
break; |
|
185 |
case Types.BIGINT: |
|
186 |
LongValue lval = (LongValue) value; |
|
187 |
solution = new Long(lval.longValue()); |
|
188 |
break; |
|
189 |
case Types.BIT: |
|
190 |
BooleanValue bval = (BooleanValue) value; |
|
191 |
solution = new Boolean(bval.getValue()); |
|
192 |
break; |
|
193 |
case Types.DATE: |
|
194 |
DateValue dtval = (DateValue) value; |
|
195 |
solution = dtval.getValue(); |
|
196 |
break; |
|
197 |
} |
|
198 |
return solution; |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* Returns a Value from its data type (fieldType) and an Object with its |
|
203 |
* value |
|
204 |
* |
|
205 |
* TODO Move to ValueFactory |
|
206 |
* |
|
207 |
* @param plainObject |
|
208 |
* @param fieldType |
|
209 |
* @return |
|
210 |
*/ |
|
211 |
public static Value getValue(Object object, int fieldType) { |
|
212 |
if(object == null) |
|
213 |
return ValueFactory.createNullValue(); |
|
214 |
Value solution = null; |
|
215 |
switch (fieldType) { |
|
216 |
case Types.VARCHAR: |
|
217 |
String str = (String) object; |
|
218 |
solution = ValueFactory.createValue(str); |
|
219 |
break; |
|
220 |
case Types.FLOAT: |
|
221 |
float fval = ((Float) object).floatValue(); |
|
222 |
solution = ValueFactory.createValue(fval); |
|
223 |
break; |
|
224 |
case Types.DOUBLE: |
|
225 |
double dval = ((Double) object).doubleValue(); |
|
226 |
solution = ValueFactory.createValue(dval); |
|
227 |
break; |
|
228 |
case Types.INTEGER: |
|
229 |
int ival = ((Integer) object).intValue(); |
|
230 |
solution = ValueFactory.createValue(ival); |
|
231 |
break; |
|
232 |
case Types.BIGINT: |
|
233 |
long lval = ((Long) object).longValue(); |
|
234 |
solution = ValueFactory.createValue(lval); |
|
235 |
break; |
|
236 |
case Types.BIT: |
|
237 |
boolean bval = ((Boolean) object).booleanValue(); |
|
238 |
solution = ValueFactory.createValue(bval); |
|
239 |
break; |
|
240 |
case Types.DATE: |
|
241 |
Date dtval = (Date) object; |
|
242 |
solution = ValueFactory.createValue(dtval); |
|
243 |
break; |
|
244 |
default: |
|
245 |
solution = ValueFactory.createNullValue(); |
|
246 |
} |
|
247 |
return solution; |
|
248 |
} |
|
249 |
|
|
250 |
public static String[] getNumericFieldsNames(FLyrVect layer) { |
|
251 |
String[] solution = null; |
|
252 |
if(layer == null) |
|
253 |
return null; |
|
254 |
ArrayList list = new ArrayList(); |
|
255 |
try { |
|
256 |
SelectableDataSource recordset = layer.getRecordset(); |
|
257 |
int numFields = recordset.getFieldCount(); |
|
258 |
for (int i = 0; i < numFields; i++) { |
|
259 |
if (XTypes.isNumeric(recordset.getFieldType(i))) { |
|
260 |
list.add(recordset.getFieldName(i)); |
|
261 |
} |
|
262 |
}// for |
|
263 |
} catch (ReadDriverException e) { |
|
264 |
// TODO Auto-generated catch block |
|
265 |
e.printStackTrace(); |
|
266 |
} |
|
267 |
solution = new String[list.size()]; |
|
268 |
list.toArray(solution); |
|
269 |
return solution; |
|
270 |
} |
|
271 |
} |
|
0 | 272 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/ITwoLayersGeoprocess.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 01-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$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.1 2006-05-24 21:12:16 azabala |
|
49 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
50 |
* |
|
51 |
* Revision 1.1 2006/02/12 21:03:25 azabala |
|
52 |
* *** empty log message *** |
|
53 |
* |
|
54 |
* Revision 1.1 2006/02/01 19:40:59 azabala |
|
55 |
* First version in CVS |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
60 |
|
|
61 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
62 |
|
|
63 |
/** |
|
64 |
* Geoprocess wich operates with two layers |
|
65 |
* @author azabala |
|
66 |
* |
|
67 |
*/ |
|
68 |
public interface ITwoLayersGeoprocess extends IOneLayerGeoprocess { |
|
69 |
/** |
|
70 |
* It sets second layer geoprocess operand. |
|
71 |
* @param secondLayer |
|
72 |
*/ |
|
73 |
public void setSecondOperand(FLyrVect secondLayer); |
|
74 |
} |
|
75 |
|
|
0 | 76 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/FeaturePersisterProcessor.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 16-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$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2007-03-06 16:47:58 caballero |
|
49 |
* Exceptions |
|
50 |
* |
|
51 |
* Revision 1.1 2006/05/24 21:12:16 azabala |
|
52 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
53 |
* |
|
54 |
* Revision 1.4 2006/03/15 18:34:03 azabala |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* Revision 1.3 2006/03/14 18:32:46 fjp |
|
58 |
* Cambio con LayerDefinition para que sea compatible con la definici?n de tablas tambi?n. |
|
59 |
* |
|
60 |
* Revision 1.2 2006/02/26 20:54:52 azabala |
|
61 |
* *** empty log message *** |
|
62 |
* |
|
63 |
* Revision 1.1 2006/02/17 16:33:25 azabala |
|
64 |
* *** empty log message *** |
|
65 |
* |
|
66 |
* |
|
67 |
*/ |
|
68 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
69 |
|
|
70 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
71 |
import com.hardcode.gdbms.driver.exceptions.SchemaEditionException; |
|
72 |
import com.hardcode.gdbms.engine.values.Value; |
|
73 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
74 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
75 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
76 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
|
77 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
|
78 |
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
|
79 |
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited; |
|
80 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
|
81 |
import com.iver.cit.gvsig.fmap.edition.ISchemaManager; |
|
82 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
|
83 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
|
84 |
import com.vividsolutions.jts.geom.Geometry; |
|
85 |
/** |
|
86 |
* It saves in a persistent data store the result of an individual geoprocess. |
|
87 |
* @author azabala |
|
88 |
* |
|
89 |
|
|
90 |
* |
|
91 |
*/ |
|
92 |
public class FeaturePersisterProcessor extends GeometryPersisterProcessor { |
|
93 |
|
|
94 |
private SelectableDataSource recordset; |
|
95 |
|
|
96 |
public FeaturePersisterProcessor(ITableDefinition layerDefinition, ISchemaManager schemaManager, IWriter writer) throws SchemaEditionException, VisitorException { |
|
97 |
super(layerDefinition, schemaManager, writer); |
|
98 |
} |
|
99 |
|
|
100 |
public FeaturePersisterProcessor(ITableDefinition layerDefinition,ISchemaManager schemaManager, IWriter writer, SelectableDataSource recordset) throws SchemaEditionException, VisitorException{ |
|
101 |
this(layerDefinition, schemaManager, writer); |
|
102 |
this.recordset = recordset; |
|
103 |
} |
|
104 |
|
|
105 |
public void setSelectableDataSource(SelectableDataSource recordset){ |
|
106 |
this.recordset = recordset; |
|
107 |
} |
|
108 |
|
|
109 |
public void processJtsGeometry(Geometry g, int index) throws VisitorException, ReadDriverException { |
|
110 |
IGeometry clipGeometry = FConverter.jts_to_igeometry(g); |
|
111 |
FieldDescription[] fields = this.layerDefinition.getFieldsDesc(); |
|
112 |
Value[] attrs = new Value[fields.length]; |
|
113 |
for(int i = 0; i < fields.length; i++){ |
|
114 |
FieldDescription field = fields[i]; |
|
115 |
String attrName = field.getFieldName(); |
|
116 |
Value value = null; |
|
117 |
int fieldIndex = recordset.getFieldIndexByName(attrName); |
|
118 |
value = recordset.getFieldValue(index, fieldIndex); |
|
119 |
attrs[i] = value; |
|
120 |
}//for |
|
121 |
|
|
122 |
IFeature feature = FeatureFactory.createFeature(attrs, |
|
123 |
clipGeometry); |
|
124 |
DefaultRowEdited editedFeature = new |
|
125 |
DefaultRowEdited(feature, |
|
126 |
IRowEdited.STATUS_ADDED, index); |
|
127 |
writer.process(editedFeature); |
|
128 |
} |
|
129 |
|
|
130 |
} |
|
131 |
|
|
0 | 132 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/GeometryPersisterProcessor.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 09-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$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.4 2007-03-06 16:47:58 caballero |
|
49 |
* Exceptions |
|
50 |
* |
|
51 |
* Revision 1.3 2006/06/29 07:33:57 fjp |
|
52 |
* Cambios ISchemaManager y IFieldManager por terminar |
|
53 |
* |
|
54 |
* Revision 1.2 2006/05/31 09:10:12 fjp |
|
55 |
* Ubicaci?n de IWriter |
|
56 |
* |
|
57 |
* Revision 1.1 2006/05/24 21:12:16 azabala |
|
58 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing |
|
59 |
* |
|
60 |
* Revision 1.4 2006/05/01 19:10:09 azabala |
|
61 |
* comentario |
|
62 |
* |
|
63 |
* Revision 1.3 2006/03/14 18:32:46 fjp |
|
64 |
* Cambio con LayerDefinition para que sea compatible con la definici?n de tablas tambi?n. |
|
65 |
* |
|
66 |
* Revision 1.2 2006/02/26 20:54:52 azabala |
|
67 |
* *** empty log message *** |
|
68 |
* |
|
69 |
* Revision 1.1 2006/02/17 16:33:25 azabala |
|
70 |
* *** empty log message *** |
|
71 |
* |
|
72 |
* Revision 1.3 2006/02/13 17:52:45 azabala |
|
73 |
* *** empty log message *** |
|
74 |
* |
|
75 |
* Revision 1.2 2006/02/12 21:02:58 azabala |
|
76 |
* *** empty log message *** |
|
77 |
* |
|
78 |
* Revision 1.1 2006/02/09 16:00:36 azabala |
|
79 |
* First version in CVS |
|
80 |
* |
|
81 |
* |
|
82 |
*/ |
|
83 |
package com.iver.cit.gvsig.geoprocess.core.fmap; |
|
84 |
|
|
85 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
86 |
import com.hardcode.gdbms.driver.exceptions.SchemaEditionException; |
|
87 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
88 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
89 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
90 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
|
91 |
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
|
92 |
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited; |
|
93 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
|
94 |
import com.iver.cit.gvsig.fmap.edition.ISchemaManager; |
|
95 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
|
96 |
import com.vividsolutions.jts.geom.Geometry; |
|
97 |
/** |
|
98 |
* Persists individual buffer results in a persistent data |
|
99 |
* store |
|
100 |
* @author azabala |
|
101 |
* |
|
102 |
*/ |
|
103 |
public class GeometryPersisterProcessor implements GeoprocessingResultsProcessor { |
|
104 |
protected ITableDefinition layerDefinition; |
|
105 |
protected ISchemaManager schemaManager; |
|
106 |
protected IWriter writer; |
|
107 |
|
|
108 |
private long numProcessed = 0; |
|
109 |
|
|
110 |
public GeometryPersisterProcessor(ITableDefinition layerDefinition, |
|
111 |
ISchemaManager schemaManager, |
|
112 |
IWriter writer) throws SchemaEditionException, VisitorException{ |
|
113 |
this.layerDefinition = layerDefinition; |
|
114 |
this.schemaManager = schemaManager; |
|
115 |
this.writer = writer; |
|
116 |
this.schemaManager.createSchema(layerDefinition); |
|
117 |
this.writer.preProcess(); |
|
118 |
} |
|
119 |
//FIXME usar el atributo INDEX para leer del recordset atributos |
|
120 |
public void processJtsGeometry(Geometry g, int index) throws VisitorException, ReadDriverException { |
|
121 |
IGeometry fmapBuffer = FConverter.jts_to_igeometry(g); |
|
122 |
Object[] attrs = new Object[1]; |
|
123 |
attrs[0] = new Long(numProcessed++); |
|
124 |
IFeature feature = FeatureFactory.createFeature(attrs, |
|
125 |
fmapBuffer, |
|
126 |
layerDefinition); |
|
127 |
DefaultRowEdited editedFeature = new |
|
128 |
DefaultRowEdited(feature, |
|
129 |
IRowEdited.STATUS_ADDED, (int)numProcessed); |
|
130 |
writer.process(editedFeature); |
|
131 |
} |
|
132 |
|
|
133 |
public void finish() throws VisitorException { |
|
134 |
writer.postProcess(); |
|
135 |
} |
|
136 |
|
|
137 |
public void processFeature(IFeature feature) throws VisitorException { |
|
138 |
DefaultRowEdited editedFeature = new |
|
139 |
DefaultRowEdited(feature, |
|
140 |
IRowEdited.STATUS_ADDED, (int)numProcessed); |
|
141 |
writer.process(editedFeature); |
|
142 |
} |
|
143 |
|
|
144 |
} |
|
145 |
|
|
0 | 146 |
tags/v1_12_0_Build_1402/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/core/fmap/AbstractGeoprocess.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 16-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 |
*/ |
Also available in: Unified diff