Revision 13570
trunk/extensions/extPublish/src/com/iver/cit/gvsig/publish/model/WMStyleInfo.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.publish.model; |
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2006-11-22 09:51:01 jvhigon |
|
47 |
* reafactoring del ServiceInfo en marcha ... |
|
48 |
* |
|
49 |
* Revision 1.2 2006/11/17 11:53:34 jvhigon |
|
50 |
* AƱado estructura del servicio WFS y WCS |
|
51 |
* |
|
52 |
* Revision 1.1 2006/11/17 09:48:36 jvhigon |
|
53 |
* Modelo de servicios OGC |
|
54 |
* |
|
55 |
* |
|
56 |
*/ |
|
57 |
/** |
|
58 |
* Represents a OGC-WMS-1.1.1 layer style. |
|
59 |
* |
|
60 |
* @author Jos? Vicente Hig?n (higon_jos@gva.es) |
|
61 |
*/ |
|
62 |
public class WMStyleInfo { |
|
63 |
private String name = null; |
|
64 |
|
|
65 |
public String getName() { |
|
66 |
return name; |
|
67 |
} |
|
68 |
|
|
69 |
public void setName(String name) { |
|
70 |
this.name = name; |
|
71 |
} |
|
72 |
} |
trunk/extensions/extPublish/src/com/iver/cit/gvsig/publish/model/LayerInfo.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.publish.model; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.ListIterator; |
|
6 |
|
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
8 |
* |
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
10 |
* |
|
11 |
* This program is free software; you can redistribute it and/or |
|
12 |
* modify it under the terms of the GNU General Public License |
|
13 |
* as published by the Free Software Foundation; either version 2 |
|
14 |
* of the License, or (at your option) any later version. |
|
15 |
* |
|
16 |
* This program is distributed in the hope that it will be useful, |
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
* GNU General Public License for more details. |
|
20 |
* |
|
21 |
* You should have received a copy of the GNU General Public License |
|
22 |
* along with this program; if not, write to the Free Software |
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
24 |
* |
|
25 |
* For more information, contact: |
|
26 |
* |
|
27 |
* Generalitat Valenciana |
|
28 |
* Conselleria d'Infraestructures i Transport |
|
29 |
* Av. Blasco Ib??ez, 50 |
|
30 |
* 46010 VALENCIA |
|
31 |
* SPAIN |
|
32 |
* |
|
33 |
* +34 963862235 |
|
34 |
* gvsig@gva.es |
|
35 |
* www.gvsig.gva.es |
|
36 |
* |
|
37 |
* or |
|
38 |
* |
|
39 |
* IVER T.I. S.A |
|
40 |
* Salamanca 50 |
|
41 |
* 46005 Valencia |
|
42 |
* Spain |
|
43 |
* |
|
44 |
* +34 963163400 |
|
45 |
* dac@iver.es |
|
46 |
*/ |
|
47 |
/* CVS MESSAGES: |
|
48 |
* |
|
49 |
* $Id$ |
|
50 |
* $Log$ |
|
51 |
* Revision 1.2 2006-11-22 12:49:10 jorpiell |
|
52 |
* Subidos algunos cambios para ver las capas en forma de ?rbol |
|
53 |
* |
|
54 |
* Revision 1.1 2006/11/22 09:51:01 jvhigon |
|
55 |
* reafactoring del ServiceInfo en marcha ... |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
/** |
|
60 |
* @author Jos? Vicente Hig?n (higon_jos@gva.es) |
|
61 |
*/ |
|
62 |
public class LayerInfo { |
|
63 |
private String name = null; |
|
64 |
private String title = null; |
|
65 |
private String abstrac = null; |
|
66 |
private Rectangle2D extent = null; |
|
67 |
private String srs = null; |
|
68 |
private ArrayList layerList = null; |
|
69 |
|
|
70 |
public LayerInfo() { |
|
71 |
layerList = new ArrayList(); |
|
72 |
} |
|
73 |
|
|
74 |
public String getAbstrac() { |
|
75 |
return abstrac; |
|
76 |
} |
|
77 |
|
|
78 |
public void setAbstrac(String abstrac) { |
|
79 |
this.abstrac = abstrac; |
|
80 |
} |
|
81 |
public Rectangle2D getExtent() { |
|
82 |
return extent; |
|
83 |
} |
|
84 |
public void setExtent(Rectangle2D extent) { |
|
85 |
this.extent = extent; |
|
86 |
} |
|
87 |
public String getName() { |
|
88 |
return name; |
|
89 |
} |
|
90 |
public void setName(String name) { |
|
91 |
this.name = name; |
|
92 |
} |
|
93 |
public String getSrs() { |
|
94 |
return srs; |
|
95 |
} |
|
96 |
public void setSrs(String srs) { |
|
97 |
this.srs = srs; |
|
98 |
} |
|
99 |
public String getTitle() { |
|
100 |
return title; |
|
101 |
} |
|
102 |
public void setTitle(String title) { |
|
103 |
this.title = title; |
|
104 |
} |
|
105 |
|
|
106 |
public ArrayList getLayerList() { |
|
107 |
return layerList; |
|
108 |
} |
|
109 |
|
|
110 |
public boolean addLayer(LayerInfo o) { |
|
111 |
return layerList.add(o); |
|
112 |
} |
|
113 |
|
|
114 |
public LayerInfo getLayer(int index) { |
|
115 |
return (LayerInfo) layerList.get(index); |
|
116 |
} |
|
117 |
|
|
118 |
public ListIterator layerListIterator() { |
|
119 |
return layerList.listIterator(); |
|
120 |
} |
|
121 |
|
|
122 |
public Object setLayer(int index, Object element) { |
|
123 |
return layerList.set(index, element); |
|
124 |
} |
|
125 |
|
|
126 |
public int layerListSize() { |
|
127 |
return layerList.size(); |
|
128 |
} |
|
129 |
|
|
130 |
public String toString(){ |
|
131 |
return name; |
|
132 |
} |
|
133 |
} |
trunk/extensions/extPublish/src/com/iver/cit/gvsig/publish/model/ServiceInfo.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.publish.model; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.ListIterator; |
|
6 |
|
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
8 |
* |
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
10 |
* |
|
11 |
* This program is free software; you can redistribute it and/or |
|
12 |
* modify it under the terms of the GNU General Public License |
|
13 |
* as published by the Free Software Foundation; either version 2 |
|
14 |
* of the License, or (at your option) any later version. |
|
15 |
* |
|
16 |
* This program is distributed in the hope that it will be useful, |
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
* GNU General Public License for more details. |
|
20 |
* |
|
21 |
* You should have received a copy of the GNU General Public License |
|
22 |
* along with this program; if not, write to the Free Software |
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
24 |
* |
|
25 |
* For more information, contact: |
|
26 |
* |
|
27 |
* Generalitat Valenciana |
|
28 |
* Conselleria d'Infraestructures i Transport |
|
29 |
* Av. Blasco Ib??ez, 50 |
|
30 |
* 46010 VALENCIA |
|
31 |
* SPAIN |
|
32 |
* |
|
33 |
* +34 963862235 |
|
34 |
* gvsig@gva.es |
|
35 |
* www.gvsig.gva.es |
|
36 |
* |
|
37 |
* or |
|
38 |
* |
|
39 |
* IVER T.I. S.A |
|
40 |
* Salamanca 50 |
|
41 |
* 46005 Valencia |
|
42 |
* Spain |
|
43 |
* |
|
44 |
* +34 963163400 |
|
45 |
* dac@iver.es |
|
46 |
*/ |
|
47 |
/* CVS MESSAGES: |
|
48 |
* |
|
49 |
* $Id$ |
|
50 |
* $Log$ |
|
51 |
* Revision 1.1 2006-11-22 09:51:01 jvhigon |
|
52 |
* reafactoring del ServiceInfo en marcha ... |
|
53 |
* |
|
54 |
* Revision 1.3 2006/11/17 13:40:18 jorpiell |
|
55 |
* A?adido el nuevo panel donde se muestran las capas |
|
56 |
* |
|
57 |
* Revision 1.1 2006/11/17 09:48:36 jvhigon |
|
58 |
* Modelo de servicios OGC |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
/** |
|
63 |
* Represents a OGC service |
|
64 |
* @author Jos? Vicente Hig?n (higon_jos@gva.es) |
|
65 |
*/ |
|
66 |
public abstract class ServiceInfo { |
|
67 |
String ows_name = null; |
|
68 |
String ows_title = null; |
|
69 |
String ows_abstract = null; |
|
70 |
String ows_onlineresource = null; |
|
71 |
Rectangle2D ows_extent = null; |
|
72 |
ArrayList layerList = null; |
|
73 |
private String ows_SRS = null; |
|
74 |
|
|
75 |
public ServiceInfo() { |
|
76 |
layerList = new ArrayList(); |
|
77 |
} |
|
78 |
|
|
79 |
public String getOws_SRS() { |
|
80 |
return ows_SRS; |
|
81 |
} |
|
82 |
|
|
83 |
public void setOws_SRS(String ows_SRS) { |
|
84 |
this.ows_SRS = ows_SRS; |
|
85 |
} |
|
86 |
|
|
87 |
public ArrayList getLayerList() { |
|
88 |
return layerList; |
|
89 |
} |
|
90 |
|
|
91 |
public void setLayerList(ArrayList children) { |
|
92 |
this.layerList = children; |
|
93 |
} |
|
94 |
|
|
95 |
public String getOws_abstract() { |
|
96 |
return ows_abstract; |
|
97 |
} |
|
98 |
|
|
99 |
public void setOws_abstract(String ows_abstract) { |
|
100 |
this.ows_abstract = ows_abstract; |
|
101 |
} |
|
102 |
|
|
103 |
public Rectangle2D getOws_extent() { |
|
104 |
return ows_extent; |
|
105 |
} |
|
106 |
|
|
107 |
public void setOws_extent(Rectangle2D ows_extent) { |
|
108 |
this.ows_extent = ows_extent; |
|
109 |
} |
|
110 |
|
|
111 |
public String getOws_name() { |
|
112 |
return ows_name; |
|
113 |
} |
|
114 |
|
|
115 |
public void setOws_name(String ows_name) { |
|
116 |
this.ows_name = ows_name; |
|
117 |
} |
|
118 |
|
|
119 |
public String getOws_onlineresource() { |
|
120 |
return ows_onlineresource; |
|
121 |
} |
|
122 |
|
|
123 |
public void setOws_onlineresource(String ows_onlineresource) { |
|
124 |
this.ows_onlineresource = ows_onlineresource; |
|
125 |
} |
|
126 |
|
|
127 |
public String getOws_title() { |
|
128 |
return ows_title; |
|
129 |
} |
|
130 |
|
|
131 |
public void setOws_title(String ows_title) { |
|
132 |
this.ows_title = ows_title; |
|
133 |
} |
|
134 |
|
|
135 |
public String toString(){ |
|
136 |
return getOws_name() + " "; |
|
137 |
} |
|
138 |
|
|
139 |
public boolean addLayer(LayerInfo o) { |
|
140 |
return layerList.add(o); |
|
141 |
} |
|
142 |
|
|
143 |
public LayerInfo getLayer(int index) { |
|
144 |
return (LayerInfo) layerList.get(index); |
|
145 |
} |
|
146 |
|
|
147 |
public ListIterator layerListIterator() { |
|
148 |
return layerList.listIterator(); |
|
149 |
} |
|
150 |
|
|
151 |
public Object setLayer(int index, Object element) { |
|
152 |
return layerList.set(index, element); |
|
153 |
} |
|
154 |
|
|
155 |
public int layerListSize() { |
|
156 |
return layerList.size(); |
|
157 |
} |
|
158 |
|
|
159 |
} |
trunk/extensions/extPublish/src/com/iver/cit/gvsig/publish/gui/panelServices/LayerTreeModel.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.publish.gui.panelServices; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import javax.swing.event.TreeModelListener; |
|
6 |
import javax.swing.tree.TreeModel; |
|
7 |
import javax.swing.tree.TreePath; |
|
8 |
|
|
9 |
import com.iver.cit.gvsig.publish.model.LayerInfo; |
|
10 |
import com.iver.cit.gvsig.publish.model.ServiceInfo; |
|
11 |
|
|
12 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
13 |
* |
|
14 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
15 |
* |
|
16 |
* This program is free software; you can redistribute it and/or |
|
17 |
* modify it under the terms of the GNU General Public License |
|
18 |
* as published by the Free Software Foundation; either version 2 |
|
19 |
* of the License, or (at your option) any later version. |
|
20 |
* |
|
21 |
* This program is distributed in the hope that it will be useful, |
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24 |
* GNU General Public License for more details. |
|
25 |
* |
|
26 |
* You should have received a copy of the GNU General Public License |
|
27 |
* along with this program; if not, write to the Free Software |
|
28 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
29 |
* |
|
30 |
* For more information, contact: |
|
31 |
* |
|
32 |
* Generalitat Valenciana |
|
33 |
* Conselleria d'Infraestructures i Transport |
|
34 |
* Av. Blasco Ib??ez, 50 |
|
35 |
* 46010 VALENCIA |
|
36 |
* SPAIN |
|
37 |
* |
|
38 |
* +34 963862235 |
|
39 |
* gvsig@gva.es |
|
40 |
* www.gvsig.gva.es |
|
41 |
* |
|
42 |
* or |
|
43 |
* |
|
44 |
* IVER T.I. S.A |
|
45 |
* Salamanca 50 |
|
46 |
* 46005 Valencia |
|
47 |
* Spain |
|
48 |
* |
|
49 |
* +34 963163400 |
|
50 |
* dac@iver.es |
|
51 |
*/ |
|
52 |
/* CVS MESSAGES: |
|
53 |
* |
|
54 |
* $Id$ |
|
55 |
* $Log$ |
|
56 |
* Revision 1.1 2006-11-22 15:57:03 jorpiell |
|
57 |
* Se ha ajustado el interfaz de usuario |
|
58 |
* |
|
59 |
* Revision 1.2 2006/11/22 12:48:21 jorpiell |
|
60 |
* Subidos algunos cambios para ver las capas en forma de ?rbol |
|
61 |
* |
|
62 |
* Revision 1.1 2006/11/17 13:43:45 jorpiell |
|
63 |
* A?adido el nuevo panel donde se muestran las capas |
|
64 |
* |
|
65 |
* |
|
66 |
*/ |
|
67 |
/** |
|
68 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
69 |
*/ |
|
70 |
public class LayerTreeModel implements TreeModel{ |
|
71 |
private ServiceInfo root = null; |
|
72 |
|
|
73 |
public LayerTreeModel(ServiceInfo root) { |
|
74 |
super(); |
|
75 |
this.root = root; |
|
76 |
} |
|
77 |
|
|
78 |
public Object getRoot() { |
|
79 |
return root; |
|
80 |
} |
|
81 |
|
|
82 |
public int getChildCount(Object arg0) { |
|
83 |
if (arg0 instanceof ServiceInfo){ |
|
84 |
return ((ServiceInfo)arg0).getLayerList().size(); |
|
85 |
}else{ |
|
86 |
return ((LayerInfo)arg0).getLayerList().size(); |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
public boolean isLeaf(Object arg0) { |
|
91 |
if (arg0 instanceof ServiceInfo){ |
|
92 |
if (((ServiceInfo)arg0).getLayerList().size() == 0){ |
|
93 |
return true; |
|
94 |
} |
|
95 |
}else{ |
|
96 |
if (((LayerInfo)arg0).getLayerList().size() == 0){ |
|
97 |
return true; |
|
98 |
} |
|
99 |
} |
|
100 |
return false; |
|
101 |
} |
|
102 |
|
|
103 |
public void addTreeModelListener(TreeModelListener arg0) { |
|
104 |
// TODO Auto-generated method stub |
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
public void removeTreeModelListener(TreeModelListener arg0) { |
|
109 |
// TODO Auto-generated method stub |
|
110 |
|
|
111 |
} |
|
112 |
|
|
113 |
public Object getChild(Object arg0, int i) { |
|
114 |
if (arg0 instanceof ServiceInfo){ |
|
115 |
return ((ServiceInfo)arg0).getLayerList().get(i); |
|
116 |
}else{ |
|
117 |
return ((LayerInfo)arg0).getLayerList().get(i); |
|
118 |
} |
|
119 |
|
|
120 |
} |
|
121 |
|
|
122 |
public int getIndexOfChild(Object arg0, Object arg1) { |
|
123 |
ArrayList children; |
|
124 |
if (arg0 instanceof ServiceInfo){ |
|
125 |
children = ((ServiceInfo)arg0).getLayerList(); |
|
126 |
}else{ |
|
127 |
children = ((LayerInfo)arg0).getLayerList(); |
|
128 |
} |
|
129 |
for (int i=0 ; i<children.size() ;i++){ |
|
130 |
if (children.get(i).equals(arg1)){ |
|
131 |
return i; |
|
132 |
} |
|
133 |
} |
|
134 |
return -1; |
|
135 |
} |
|
136 |
|
|
137 |
public void valueForPathChanged(TreePath arg0, Object arg1) { |
|
138 |
|
|
139 |
} |
|
140 |
|
|
141 |
} |
branches/v10/extensions/extPublish/src-test/com/iver/cit/gvsig/publish/util/test_LocalResourcesTestUtilities.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Iba?ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/** |
|
42 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es) |
|
43 |
*/ |
|
44 |
package com.iver.cit.gvsig.publish.util; |
|
45 |
|
|
46 |
import java.io.File; |
|
47 |
import java.net.URL; |
|
48 |
|
|
49 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
50 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
51 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
52 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
53 |
|
|
54 |
import junit.framework.TestCase; |
|
55 |
|
|
56 |
public class test_LocalResourcesTestUtilities extends TestCase { |
|
57 |
private LocalResourcesTestUtilities util = null; |
|
58 |
protected void setUp() throws Exception { |
|
59 |
super.setUp(); |
|
60 |
File f = null; |
|
61 |
//gets absolute path |
|
62 |
URL url = this.getClass().getResource("../resources"); |
|
63 |
if (url == null) |
|
64 |
throw new Exception("Can't find resources directory"); |
|
65 |
f = new File(url.getFile()); |
|
66 |
if (!f.exists()) |
|
67 |
throw new Exception("Can't find resources dir"); |
|
68 |
|
|
69 |
//gets a new view from the utilities |
|
70 |
util = new LocalResourcesTestUtilities(f.getAbsolutePath()); |
|
71 |
//create database |
|
72 |
//System.err.println("Creating database publish"); |
|
73 |
//this.util.createDBPostGIS(); |
|
74 |
} |
|
75 |
|
|
76 |
protected void tearDown() throws Exception { |
|
77 |
super.tearDown(); |
|
78 |
//delete database |
|
79 |
//System.err.println("Deleting database publish"); |
|
80 |
//this.util.dropDBPostGIS(); |
|
81 |
} |
|
82 |
|
|
83 |
public void test_layerPostGIS(){ |
|
84 |
//get postGIS layer |
|
85 |
//System.err.println("Getting postGIS layer"); |
|
86 |
//this.util.getLayerPostGIS(); |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
public void test_layerShp(){ |
|
91 |
System.err.println("Getting shapefiles"); |
|
92 |
FLayer line = null; |
|
93 |
FLayer point = null; |
|
94 |
FLayer polygon = null; |
|
95 |
line = this.util.getShapeLine(); |
|
96 |
this.assertNotNull(line); |
|
97 |
point = this.util.getShapePoint(); |
|
98 |
this.assertNotNull(point); |
|
99 |
polygon = this.util.getShapePolygon(); |
|
100 |
this.assertNotNull(polygon); |
|
101 |
//testing source |
|
102 |
this.assertNotNull(((FLyrVect)line).getSource()); |
|
103 |
this.assertNotNull(((FLyrVect)point).getSource()); |
|
104 |
this.assertNotNull(((FLyrVect)polygon).getSource()); |
|
105 |
} |
|
106 |
|
|
107 |
public void test_layerECW(){ |
|
108 |
System.err.println("Getting ECW"); |
|
109 |
this.util.getLayerECW(); |
|
110 |
} |
|
111 |
|
|
112 |
public void test_GroupView(){ |
|
113 |
System.err.println("Getting GroupedLayer"); |
|
114 |
this.util.getGroupView(); |
|
115 |
} |
|
116 |
|
|
117 |
} |
|
0 | 118 |
branches/v10/extensions/extPublish/src-test/com/iver/cit/gvsig/publish/util/LocalResourcesTestUtilities.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Iba?ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/** |
|
42 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es) |
|
43 |
*/ |
|
44 |
package com.iver.cit.gvsig.publish.util; |
|
45 |
|
|
46 |
|
|
47 |
import java.io.BufferedReader; |
|
48 |
import java.io.File; |
|
49 |
import java.io.FileNotFoundException; |
|
50 |
import java.io.FileReader; |
|
51 |
import java.io.IOException; |
|
52 |
import java.io.InputStream; |
|
53 |
import java.io.InputStreamReader; |
|
54 |
import java.net.URL; |
|
55 |
import java.sql.Connection; |
|
56 |
import java.sql.DriverManager; |
|
57 |
import java.sql.SQLException; |
|
58 |
import java.sql.Statement; |
|
59 |
import java.util.ArrayList; |
|
60 |
|
|
61 |
import org.cresques.cts.IProjection; |
|
62 |
|
|
63 |
import com.hardcode.driverManager.Driver; |
|
64 |
import com.hardcode.gdbms.engine.values.Value; |
|
65 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
66 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
67 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
68 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
69 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
70 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
71 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
72 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
|
73 |
import com.iver.cit.gvsig.fmap.drivers.ConcreteMemoryDriver; |
|
74 |
import com.iver.cit.gvsig.fmap.drivers.ConnectionFactory; |
|
75 |
import com.iver.cit.gvsig.fmap.drivers.DBException; |
|
76 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
|
77 |
import com.iver.cit.gvsig.fmap.drivers.IConnection; |
|
78 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
|
79 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
|
80 |
import com.iver.cit.gvsig.fmap.drivers.jdbc.postgis.PostGisDriver; |
|
81 |
import com.iver.cit.gvsig.fmap.drivers.raster.CmsRasterDriver; |
|
82 |
import com.iver.cit.gvsig.fmap.drivers.shp.IndexedShpDriver; |
|
83 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
84 |
import com.iver.cit.gvsig.fmap.layers.FLayerFileVectorial; |
|
85 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
86 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster; |
|
87 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
88 |
import com.iver.cit.gvsig.project.Project; |
|
89 |
import com.iver.cit.gvsig.project.ProjectFactory; |
|
90 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
|
91 |
|
|
92 |
/** |
|
93 |
* This class represents a factory which can make gvSIG objects like a project, |
|
94 |
* a view, a layer, ... |
|
95 |
* This class is useful to do tests |
|
96 |
* |
|
97 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es) |
|
98 |
* |
|
99 |
*/ |
|
100 |
public class LocalResourcesTestUtilities { |
|
101 |
|
|
102 |
private String basePath = null; |
|
103 |
|
|
104 |
/** |
|
105 |
* Constructor: gets absolute path to resources directory |
|
106 |
* @throws Exception |
|
107 |
*/ |
|
108 |
|
|
109 |
public LocalResourcesTestUtilities(String basePath){ |
|
110 |
this.basePath = basePath; |
|
111 |
//Load the drivers |
|
112 |
LayerFactory.setDriversPath("../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers"); |
|
113 |
//LayerFactory.setDriversPath("/home/jvhigon/eclipse/workspace-v10/_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers/"); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Creates a project |
|
118 |
*/ |
|
119 |
public Project getProject(){ |
|
120 |
Project gvProj = ProjectFactory.createProject(); |
|
121 |
gvProj.setOwner("test_project_owner"); |
|
122 |
gvProj.setName("test_project_name"); |
|
123 |
return gvProj; |
|
124 |
} |
|
125 |
/** |
|
126 |
* Creates a basic view with one layer |
|
127 |
*/ |
|
128 |
public ProjectView getBasicView(){ |
|
129 |
ProjectView gvView = new ProjectView(); |
|
130 |
ViewPort viewPort = new ViewPort(CRSFactory.getCRS("EPSG:23031")); |
|
131 |
MapContext mapContext = new MapContext(viewPort); |
|
132 |
mapContext.getLayers().addLayer(getLayerBasic()); |
|
133 |
gvView.setMapContext(mapContext); |
|
134 |
gvView.setComment("test_view_comment"); |
|
135 |
gvView.setCreationDate("07/07/07 13:30"); |
|
136 |
gvView.setName("test_view_name"); |
|
137 |
gvView.setOwner("test_view_owner"); |
|
138 |
return gvView; |
|
139 |
} |
|
140 |
/** |
|
141 |
* Creates a basic view with two layers |
|
142 |
*/ |
|
143 |
public ProjectView getBasic2layersView(){ |
|
144 |
ProjectView gvView = new ProjectView(); |
|
145 |
ViewPort viewPort = new ViewPort(CRSFactory.getCRS("EPSG:23031")); |
|
146 |
MapContext mapContext = new MapContext(viewPort); |
|
147 |
mapContext.getLayers().addLayer(getLayerBasic()); |
|
148 |
mapContext.getLayers().addLayer(getShapeLine()); |
|
149 |
gvView.setMapContext(mapContext); |
|
150 |
gvView.setComment("test_view_comment"); |
|
151 |
gvView.setCreationDate("07/07/07 13:30"); |
|
152 |
gvView.setName("test_view_name"); |
|
153 |
gvView.setOwner("test_view_owner"); |
|
154 |
return gvView; |
|
155 |
} |
|
156 |
/** |
|
157 |
* Creates a View with a simple layer and a nested layers |
|
158 |
* @return |
|
159 |
*/ |
|
160 |
public ProjectView getGroupView(){ |
|
161 |
ProjectView view = this.getBasicView(); |
|
162 |
MapContext map = view.getMapContext(); |
|
163 |
map.getLayers().addLayer(this.getGroupLayer(map)); |
|
164 |
return view; |
|
165 |
} |
|
166 |
/** |
|
167 |
* Creates a grouped layer |
|
168 |
*/ |
|
169 |
public FLayers getGroupLayer(MapContext mapCtxt){ |
|
170 |
FLayers layers = null; |
|
171 |
layers = new FLayers(mapCtxt, null); |
|
172 |
layers.setName("test_grouped_layer"); |
|
173 |
layers.addLayer(this.getShapeLine()); |
|
174 |
layers.addLayer(this.getShapePoint()); |
|
175 |
return layers; |
|
176 |
} |
|
177 |
/** |
|
178 |
* Creates a vectorial layer with two geometries |
|
179 |
*/ |
|
180 |
private FLayer getLayerBasic() { |
|
181 |
// DRIVER DEFINITION (SHAPE TYPE AND FIELDS) |
|
182 |
ConcreteMemoryDriver driver = new ConcreteMemoryDriver(); |
|
183 |
driver.setShapeType(FShape.POLYGON); |
|
184 |
|
|
185 |
ArrayList arrayFields = new ArrayList(); |
|
186 |
arrayFields.add("ID"); |
|
187 |
arrayFields.add("NOMBRE"); |
|
188 |
arrayFields.add("POBLACION"); |
|
189 |
Value[] auxRow = new Value[3]; |
|
190 |
|
|
191 |
driver.getTableModel().setColumnIdentifiers(arrayFields.toArray()); |
|
192 |
|
|
193 |
// ATRIBUTES |
|
194 |
auxRow[0] = ValueFactory.createValue(0); |
|
195 |
auxRow[1] = ValueFactory.createValue("Valencia"); |
|
196 |
auxRow[2] = ValueFactory.createValue(200000); |
|
197 |
|
|
198 |
// GEOMETRY 1 DEFINITION |
|
199 |
GeneralPathX gp1 = new GeneralPathX(); |
|
200 |
gp1.moveTo(20,80); |
|
201 |
gp1.lineTo(80,60); |
|
202 |
gp1.lineTo(100, 140); |
|
203 |
|
|
204 |
FShape pol1 = new FPolygon2D(gp1); |
|
205 |
driver.addShape(pol1, auxRow); |
|
206 |
|
|
207 |
auxRow[0] = ValueFactory.createValue(1); |
|
208 |
auxRow[1] = ValueFactory.createValue("Madrid"); |
|
209 |
auxRow[2] = ValueFactory.createValue(300000); |
|
210 |
|
|
211 |
// GEOMETRY 2 DEFINITION |
|
212 |
GeneralPathX gp2 = new GeneralPathX(); |
|
213 |
gp2.moveTo(100,100); |
|
214 |
gp2.lineTo(110,100); |
|
215 |
gp2.lineTo(110,110); |
|
216 |
gp2.lineTo(100,110); |
|
217 |
gp2.lineTo(100,100); |
|
218 |
|
|
219 |
FShape pol2 = new FPolygon2D(gp2); |
|
220 |
driver.addShape(pol2, auxRow); |
|
221 |
|
|
222 |
// CREATE AND ADD LAYER |
|
223 |
FLayer lyr; |
|
224 |
String layerName = "basic_layer"; |
|
225 |
|
|
226 |
IProjection proj = CRSFactory.getCRS("EPSG:23030"); |
|
227 |
|
|
228 |
lyr = LayerFactory.createLayer(layerName,driver, proj); |
|
229 |
return lyr; |
|
230 |
} |
|
231 |
/** |
|
232 |
* creates a shapefile |
|
233 |
* @return |
|
234 |
*/ |
|
235 |
public FLayer getShapePoint(){ |
|
236 |
String name = "shp_point"; |
|
237 |
String fileName = this.basePath + "/shp_point.shp"; |
|
238 |
String driverName = "gvSIG shp driver"; |
|
239 |
IProjection proj = CRSFactory.getCRS("EPSG:23030"); |
|
240 |
FLayer lyr = null; |
|
241 |
try { |
|
242 |
lyr = LayerFactory.createLayer(name, driverName, new File(fileName), proj); |
|
243 |
} catch (DriverException e) { |
|
244 |
// TODO Auto-generated catch block |
|
245 |
e.printStackTrace(); |
|
246 |
} |
|
247 |
return (FLayer)lyr; |
|
248 |
} |
|
249 |
|
|
250 |
public FLayer getShapeLine(){ |
|
251 |
String name = "shp_line"; |
|
252 |
String fileName = this.basePath + "/shp_line.shp"; |
|
253 |
String driverName = "gvSIG shp driver"; |
|
254 |
IProjection proj = CRSFactory.getCRS("EPSG:23030"); |
|
255 |
FLayer lyr = null; |
|
256 |
try { |
|
257 |
lyr = LayerFactory.createLayer(name, driverName, new File(fileName), proj); |
|
258 |
} catch (DriverException e) { |
|
259 |
// TODO Auto-generated catch block |
|
260 |
e.printStackTrace(); |
|
261 |
} |
|
262 |
return (FLayer)lyr; |
|
263 |
} |
|
264 |
/** |
|
265 |
* creates a shape of polygons |
|
266 |
* @throws Exception |
|
267 |
*/ |
|
268 |
public FLayer getShapePolygon(){ |
|
269 |
String name = "shp_polygon"; |
|
270 |
String fileName = this.basePath + "/shp_polygon.shp"; |
|
271 |
String driverName = "gvSIG shp driver"; |
|
272 |
IProjection proj = CRSFactory.getCRS("EPSG:23030"); |
|
273 |
FLayer lyr = null; |
|
274 |
try { |
|
275 |
lyr = LayerFactory.createLayer(name, driverName, new File(fileName), proj); |
|
276 |
|
|
277 |
} catch (DriverException e) { |
|
278 |
// TODO Auto-generated catch block |
|
279 |
e.printStackTrace(); |
|
280 |
} |
|
281 |
return (FLayer)lyr; |
|
282 |
} |
|
283 |
/** |
|
284 |
* creates a test layer postGIS |
|
285 |
*/ |
|
286 |
public FLayer getLayerPostGIS(){ |
|
287 |
try { |
|
288 |
Class.forName("org.postgresql.Driver"); |
|
289 |
} catch (ClassNotFoundException e1) { |
|
290 |
// TODO Auto-generated catch block |
|
291 |
e1.printStackTrace(); |
|
292 |
} |
|
293 |
String dbURL = "jdbc:postgresql://localhost:5432/publish"; |
|
294 |
String user = "postgres"; |
|
295 |
String pwd = "xxx"; |
|
296 |
String layerName = "sql_polygon"; |
|
297 |
String fidField = "gid"; |
|
298 |
//String sFields = (String) args.get((String) "FIELDS"); |
|
299 |
//String[] fields = sFields.split(","); |
|
300 |
String[] fields = {"gid", "area", "perimeter", "nucleos_", "nucleos_id", "cod_ent", "cod_ine", "nombre", "municipio", "cod_mun"}; |
|
301 |
String geomField = "the_geom"; |
|
302 |
String tableName = "sql_polygon"; |
|
303 |
String whereClause = ""; |
|
304 |
|
|
305 |
IConnection conn; |
|
306 |
try { |
|
307 |
conn = ConnectionFactory.createConnection(dbURL, user, pwd); |
|
308 |
} catch (DBException e) { |
|
309 |
e.printStackTrace(); |
|
310 |
return null; |
|
311 |
} |
|
312 |
|
|
313 |
DBLayerDefinition lyrDef = new DBLayerDefinition(); |
|
314 |
lyrDef.setName(layerName); |
|
315 |
lyrDef.setTableName(tableName); |
|
316 |
lyrDef.setWhereClause(whereClause); |
|
317 |
lyrDef.setFieldNames(fields); |
|
318 |
lyrDef.setFieldGeometry(geomField); |
|
319 |
lyrDef.setFieldID(fidField); |
|
320 |
|
|
321 |
PostGisDriver pgd = new PostGisDriver(); |
|
322 |
try { |
|
323 |
pgd.setData(conn, lyrDef); |
|
324 |
} catch (DBException e) { |
|
325 |
// TODO Auto-generated catch block |
|
326 |
e.printStackTrace(); |
|
327 |
} |
|
328 |
|
|
329 |
return LayerFactory.createDBLayer(pgd, layerName, CRSFactory.getCRS("EPSG:23030")); |
|
330 |
|
|
331 |
} |
|
332 |
/** |
|
333 |
* Creates a Raster Layer from a ECW |
|
334 |
*/ |
|
335 |
public FLayer getLayerECW(){ |
|
336 |
//RasterDriver driv = new CmsRasterDriver(); |
|
337 |
String name = "orto_ecw"; |
|
338 |
String fileName = this.basePath + "/orto.ecw"; |
|
339 |
String driverName = "gvSIG Image Driver"; |
|
340 |
FLayer lyr=null; |
|
341 |
IProjection proj = CRSFactory.getCRS("EPSG:23030"); |
|
342 |
//Driver driver = LayerFactory.getDM().getDriver("gvSIG Image Driver"); |
|
343 |
try { |
|
344 |
//lyr = LayerFactory.createLayer(name, (RasterDriver)driver, new File(fileName), proj); |
|
345 |
lyr = LayerFactory.createLayer(name, driverName, new File(fileName), proj); |
|
346 |
} catch (DriverException e) { |
|
347 |
// TODO Auto-generated catch block |
|
348 |
e.printStackTrace(); |
|
349 |
} |
|
350 |
return lyr; |
|
351 |
} |
|
352 |
|
|
353 |
/** |
|
354 |
* Create DB PostGIS (publish) |
|
355 |
* Preconditions: |
|
356 |
* - exists commands createdb, psql |
|
357 |
* - you don't need password to connect with postgres |
|
358 |
*/ |
|
359 |
public void createDBPostGIS(){ |
|
360 |
try { |
|
361 |
BufferedReader br = null; |
|
362 |
String line = null; |
|
363 |
String[] commands = null; |
|
364 |
Process child = null; |
|
365 |
// Creates the database |
|
366 |
commands = new String[]{"createdb", "-U", "postgres", "publish"}; |
|
367 |
child = Runtime.getRuntime().exec(commands); |
|
368 |
//Show output |
|
369 |
br = new BufferedReader(new InputStreamReader(child.getErrorStream())); |
|
370 |
line = br.readLine(); |
|
371 |
while (line != null){ |
|
372 |
System.out.println(line); |
|
373 |
line = br.readLine(); |
|
374 |
} |
|
375 |
// adds plpgsql support |
|
376 |
commands = new String[]{"createlang", "-U", "postgres", "plpgsql", "publish"}; |
|
377 |
child = Runtime.getRuntime().exec(commands); |
|
378 |
//Show output |
|
379 |
br = new BufferedReader(new InputStreamReader(child.getErrorStream())); |
|
380 |
line = br.readLine(); |
|
381 |
while (line != null){ |
|
382 |
System.out.println(line); |
|
383 |
line = br.readLine(); |
|
384 |
} |
|
385 |
|
|
386 |
//load lwpostgis.sql |
|
387 |
commands = new String[]{"psql", "-U", "postgres", "-d", "publish", "-f", this.basePath + "/lwpostgis.sql"}; |
|
388 |
child = Runtime.getRuntime().exec(commands); |
|
389 |
//Show output |
|
390 |
br = new BufferedReader(new InputStreamReader(child.getErrorStream())); |
|
391 |
line = br.readLine(); |
|
392 |
while (line != null){ |
|
393 |
System.out.println(line); |
|
394 |
line = br.readLine(); |
|
395 |
} |
|
396 |
//load spatial_ref_sys.sql |
|
397 |
System.out.println("Loading spatial_ref_sys.sql"); |
|
398 |
commands = new String[]{"psql", "-U", "postgres", "-d", "publish", "-f", this.basePath + "/spatial_ref_sys.sql"}; |
|
399 |
child = Runtime.getRuntime().exec(commands); |
|
400 |
//Show output |
|
401 |
br = new BufferedReader(new InputStreamReader(child.getErrorStream())); |
|
402 |
line = br.readLine(); |
|
403 |
while (line != null){ |
|
404 |
System.out.println(line); |
|
405 |
line = br.readLine(); |
|
406 |
} |
|
407 |
|
|
408 |
} catch (IOException e) { |
|
409 |
e.printStackTrace(); |
|
410 |
} |
|
411 |
//Load a table |
|
412 |
this.loadTablePostGIS(); |
|
413 |
} |
|
414 |
/** |
|
415 |
* Drop DB PostGIS (publish) |
|
416 |
*/ |
|
417 |
public void dropDBPostGIS(){ |
|
418 |
try { |
|
419 |
BufferedReader br = null; |
|
420 |
String line = null; |
|
421 |
|
|
422 |
// Execute a command with an argument that contains a space |
|
423 |
String[] commands = new String[]{"dropdb", "-U", "postgres", "publish"}; |
|
424 |
Process child = Runtime.getRuntime().exec(commands); |
|
425 |
//Show output |
|
426 |
br = new BufferedReader(new InputStreamReader(child.getErrorStream())); |
|
427 |
line = br.readLine(); |
|
428 |
while (line != null){ |
|
429 |
System.out.println(line); |
|
430 |
line = br.readLine(); |
|
431 |
} |
|
432 |
} catch (IOException e) { |
|
433 |
e.printStackTrace(); |
|
434 |
} |
|
435 |
|
|
436 |
} |
|
437 |
/** |
|
438 |
* Load a table (resources/sql_polygon.sql) into the database |
|
439 |
*/ |
|
440 |
private void loadTablePostGIS(){ |
|
441 |
try { |
|
442 |
BufferedReader br = null; |
|
443 |
String line = null; |
|
444 |
String[] commands = new String[]{"psql", "-U", "postgres", "-d", "publish", "-f", this.basePath + "/sql_polygon.sql"}; |
|
445 |
Process child = Runtime.getRuntime().exec(commands); |
|
446 |
//Show output |
|
447 |
br = new BufferedReader(new InputStreamReader(child.getErrorStream())); |
|
448 |
line = br.readLine(); |
|
449 |
while (line != null){ |
|
450 |
System.out.println(line); |
|
451 |
line = br.readLine(); |
|
452 |
} |
|
453 |
} catch (IOException e) { |
|
454 |
e.printStackTrace(); |
|
455 |
} |
|
456 |
|
|
457 |
} |
|
458 |
} |
|
0 | 459 |
branches/v10/extensions/extPublish/src-test/com/iver/cit/gvsig/publish/infoProject/AllTests.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Iba?ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/** |
|
42 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es) |
|
43 |
*/ |
|
44 |
package com.iver.cit.gvsig.publish.infoProject; |
|
45 |
|
|
46 |
import junit.framework.Test; |
|
47 |
import junit.framework.TestSuite; |
|
48 |
|
|
49 |
public class AllTests { |
|
50 |
|
|
51 |
public static Test suite() { |
|
52 |
TestSuite suite = new TestSuite( |
|
53 |
"Test for com.iver.cit.gvsig.publish.localResources"); |
|
54 |
//$JUnit-BEGIN$ |
|
55 |
suite.addTestSuite(Test_queryProject.class); |
|
56 |
suite.addTestSuite(Test_queryView.class); |
|
57 |
//$JUnit-END$ |
|
58 |
return suite; |
|
59 |
} |
|
60 |
|
|
61 |
} |
|
0 | 62 |
branches/v10/extensions/extPublish/src-test/com/iver/cit/gvsig/publish/infoProject/Test_queryProject.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Iba?ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/** |
|
42 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es) |
|
43 |
*/ |
|
44 |
package com.iver.cit.gvsig.publish.infoProject; |
|
45 |
|
|
46 |
import java.io.File; |
|
47 |
import java.net.URL; |
|
48 |
|
|
49 |
import com.iver.cit.gvsig.project.Project; |
|
50 |
import com.iver.cit.gvsig.publish.infoProject.InfoFactory; |
|
51 |
import com.iver.cit.gvsig.publish.infoProject.ProjectInfo; |
|
52 |
import com.iver.cit.gvsig.publish.util.LocalResourcesTestUtilities; |
|
53 |
|
|
54 |
import junit.framework.TestCase; |
|
55 |
/** |
|
56 |
* Test of ProjectInfImpl |
|
57 |
* |
|
58 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es) |
|
59 |
* |
|
60 |
*/ |
|
61 |
public class Test_queryProject extends TestCase { |
|
62 |
//gvSIG project |
|
63 |
private Project gvProj = null; |
|
64 |
//info about project to publish |
|
65 |
private ProjectInfo prjInf = null; |
|
66 |
/** |
|
67 |
* Initialice test |
|
68 |
*/ |
|
69 |
protected void setUp() throws Exception { |
|
70 |
super.setUp(); |
|
71 |
File f = null; |
|
72 |
URL url = this.getClass().getResource("../resources"); |
|
73 |
if (url == null) |
|
74 |
throw new Exception("Can't find resources directory"); |
|
75 |
f = new File(url.getFile()); |
|
76 |
if (!f.exists()) |
|
77 |
throw new Exception("Can't find resources dir"); |
|
78 |
//get a new project from the utilities |
|
79 |
LocalResourcesTestUtilities util = new LocalResourcesTestUtilities(f.getAbsolutePath()); |
|
80 |
this.gvProj = util.getProject(); |
|
81 |
//creates a instance to get project information |
|
82 |
this.prjInf = InfoFactory.getProjectInfo(gvProj); |
|
83 |
} |
|
84 |
/** |
|
85 |
* Just before finish the test |
|
86 |
*/ |
|
87 |
protected void tearDown() throws Exception { |
|
88 |
super.tearDown(); |
|
89 |
} |
|
90 |
/** |
|
91 |
* test getName() method |
|
92 |
*/ |
|
93 |
public void test_getName(){ |
|
94 |
|
|
95 |
this.assertEquals("info project fails", "test_project_name",this.prjInf.getName()); |
|
96 |
System.out.println(this.prjInf.getName()); |
|
97 |
return; |
|
98 |
} |
|
99 |
/** |
|
100 |
* test getOwner method |
|
101 |
* |
|
102 |
*/ |
|
103 |
public void test_getOwner(){ |
|
104 |
this.assertEquals("info project fails", "test_project_owner",this.prjInf.getOwner()); |
|
105 |
System.out.println(this.prjInf.getOwner()); |
|
106 |
return; |
|
107 |
} |
|
108 |
|
|
109 |
} |
|
0 | 110 |
branches/v10/extensions/extPublish/src-test/com/iver/cit/gvsig/publish/infoProject/Test_queryDataSource.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Iba?ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.publish.infoProject; |
|
42 |
|
|
43 |
import java.io.File; |
|
44 |
import java.net.URL; |
|
45 |
|
|
46 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
47 |
import com.iver.cit.gvsig.publish.infoProject.DataSourceInfo; |
|
48 |
import com.iver.cit.gvsig.publish.infoProject.datasources.DataSourceInfoFactory; |
|
49 |
import com.iver.cit.gvsig.publish.util.LocalResourcesTestUtilities; |
|
50 |
|
|
51 |
import junit.framework.TestCase; |
|
52 |
|
|
53 |
public class Test_queryDataSource extends TestCase { |
|
54 |
private LocalResourcesTestUtilities util = null; |
|
55 |
protected void setUp() throws Exception { |
|
56 |
super.setUp(); |
|
57 |
File f = null; |
|
58 |
//gets absolute path |
|
59 |
URL url = this.getClass().getResource("../resources"); |
|
60 |
if (url == null) |
|
61 |
throw new Exception("Can't find resources directory"); |
|
62 |
f = new File(url.getFile()); |
|
63 |
if (!f.exists()) |
|
64 |
throw new Exception("Can't find resources dir"); |
|
65 |
|
|
66 |
//gets a new view from the utilities |
|
67 |
System.out.println("Getting resources from: " + f.getAbsolutePath()); |
|
68 |
util = new LocalResourcesTestUtilities(f.getAbsolutePath()); |
|
69 |
|
|
70 |
} |
|
71 |
|
|
72 |
protected void tearDown() throws Exception { |
|
73 |
super.tearDown(); |
|
74 |
} |
|
75 |
public void test_shapefile(){ |
|
76 |
FLayer layer=null; |
|
77 |
try { |
|
78 |
layer = util.getShapePolygon(); |
|
79 |
} catch (Exception e) { |
|
80 |
// TODO Auto-generated catch block |
|
81 |
e.printStackTrace(); |
|
82 |
} |
|
83 |
DataSourceInfo dts = DataSourceInfoFactory.getInstance(layer); |
|
84 |
System.err.println(dts.getName()); |
|
85 |
} |
|
86 |
|
|
87 |
} |
|
0 | 88 |
branches/v10/extensions/extPublish/src-test/com/iver/cit/gvsig/publish/infoProject/Test_queryView.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Iba?ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
package com.iver.cit.gvsig.publish.infoProject; |
|
43 |
|
|
44 |
import java.io.File; |
|
45 |
import java.net.URL; |
|
46 |
|
|
47 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
|
48 |
import com.iver.cit.gvsig.publish.infoProject.ILayerInfo; |
|
49 |
import com.iver.cit.gvsig.publish.infoProject.IViewInfo; |
|
50 |
import com.iver.cit.gvsig.publish.infoProject.InfoFactory; |
|
51 |
import com.iver.cit.gvsig.publish.infoProject.LayerInfo; |
|
52 |
import com.iver.cit.gvsig.publish.infoProject.ViewInfo; |
|
53 |
import com.iver.cit.gvsig.publish.util.LocalResourcesTestUtilities; |
|
54 |
|
|
55 |
import junit.framework.TestCase; |
|
56 |
|
|
57 |
/** |
|
58 |
* We are testing all methods of DefaultView. |
|
59 |
* |
|
60 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es) |
|
61 |
* |
|
62 |
*/ |
|
63 |
public class Test_queryView extends TestCase { |
|
64 |
//gvSIG ProjectView |
|
65 |
private ProjectView gvView = null; |
|
66 |
//information about the view to publish |
|
67 |
private IViewInfo viewInfo = null; |
|
68 |
|
|
69 |
|
|
70 |
/** |
Also available in: Unified diff