root / branches / v10 / extensions / extPublish / src-test / org / gvsig / remoteservices / conf / mapserver / test / Test.java @ 13570
History | View | Annotate | Download (10.7 KB)
1 |
package org.gvsig.remoteservices.conf.mapserver.test; |
---|---|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 |
*
|
4 |
* Copyright (C) 2004-2006 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: Test.java 13570 2007-09-06 15:40:28Z jvhigon $
|
45 |
* $Log$
|
46 |
* Revision 1.1.2.1 2007-09-06 15:40:27 jvhigon
|
47 |
* Primer commit.
|
48 |
*
|
49 |
* Revision 1.6.2.1 2006/11/15 04:11:03 jjdelcerro
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.6 2006/11/13 08:25:03 dagilgon
|
53 |
* a?adidas "etiquetas" CLASS (completada) y JOIN
|
54 |
*
|
55 |
* Revision 1.5 2006/10/05 13:22:23 jvhigon
|
56 |
* Debido al refactor del nobre en la libreria de maapserver y geoserver. Mapserver --> MapserverConfig
|
57 |
*
|
58 |
* Revision 1.4 2006/09/19 00:30:31 luisw2
|
59 |
* Soporte para WCS en mapserver. Pendiente de verificar que va
|
60 |
*
|
61 |
* Revision 1.3 2006/09/18 08:42:06 dagilgon
|
62 |
* A?adido test de leyend para capas shape
|
63 |
*
|
64 |
* Revision 1.2 2006/09/11 08:26:27 luisw2
|
65 |
* Preferences Dialog ...
|
66 |
*
|
67 |
* Revision 1.1 2006/09/07 19:26:01 luisw2
|
68 |
* Preparing to publicate with 'time'
|
69 |
*
|
70 |
* Revision 1.10 2006/09/07 18:11:06 luisw2
|
71 |
* Adding Time to mapserver ...
|
72 |
*
|
73 |
* Revision 1.9 2006/09/07 11:19:40 jvhigon
|
74 |
* A?adido soporte para multiples class en una layer, y para layer sdentro de layer
|
75 |
*
|
76 |
* Revision 1.8 2006/09/01 06:59:00 luisw2
|
77 |
* Headers mofification
|
78 |
*
|
79 |
* Revision 1.2 2006/09/01 02:30:09 luisw2
|
80 |
* *** empty log message ***
|
81 |
*
|
82 |
*/
|
83 |
|
84 |
import java.awt.Dimension; |
85 |
|
86 |
import org.gvsig.remoteservices.conf.mapserver.MapServerConfiguration; |
87 |
import org.gvsig.remoteservices.conf.mapserver.MapServerConfiguration.RGB; |
88 |
|
89 |
public class Test { |
90 |
public static void main(String args[]) { |
91 |
testShpMap(); |
92 |
//testPostGisMap();
|
93 |
//testRasterMap();
|
94 |
//testWFSCanada();
|
95 |
} |
96 |
|
97 |
static void testShpMap() { |
98 |
String mapFileName = null;//"home/david/wms.map"; |
99 |
MapServerConfiguration.ConfigFile map = new MapServerConfiguration.ConfigFile();
|
100 |
map.mapName = "TEST_MAPSERVER";
|
101 |
map.mapStatus = "ON";
|
102 |
map.mapUnits = "METERS";
|
103 |
map.mapShapePath = "/home/david/cv300/";
|
104 |
map.mapcrs = new MapServerConfiguration.CRS("EPSG:23030",true); |
105 |
map.setExtent(638610.4375,4222780,789330,4484662.5); |
106 |
|
107 |
MapServerConfiguration.Legend leyenda= new MapServerConfiguration.Legend();
|
108 |
leyenda.imagecolor = new RGB(122,255,122); |
109 |
leyenda.outlinecolor = new RGB(255,255,255); |
110 |
//leyenda.interlace = null;
|
111 |
//leyenda.legendlabel = null;
|
112 |
//leyenda.position = null;
|
113 |
//leyenda.keysize = null;
|
114 |
//leyenda.keyspacing = null;
|
115 |
//leyenda.postlabelcache = null;
|
116 |
leyenda.status = "ON";
|
117 |
//leyenda.template = null;
|
118 |
//leyenda.transparent = null;
|
119 |
map.leyenda = leyenda; |
120 |
|
121 |
MapServerConfiguration.WebMap web = new MapServerConfiguration.WebMap();
|
122 |
web.imagepath = "/var/tmp/";
|
123 |
web.imageurl = "/var/tmp/";
|
124 |
web.metadata = new MapServerConfiguration.MetadataWeb();
|
125 |
web.metadata.crs = new MapServerConfiguration.CRS("EPSG:23030",false); |
126 |
web.metadata.title = "test shape";
|
127 |
web.metadata.onlineresource = "http://localhost/mapserver/mapserv?map=/etc/mapserver/wms.map";
|
128 |
map.www = web; |
129 |
|
130 |
MapServerConfiguration.ShpLayer capa = new MapServerConfiguration.ShpLayer();
|
131 |
MapServerConfiguration.MapClass clase = new MapServerConfiguration.MapClass("autopistas"); |
132 |
capa.name = "autopistas";
|
133 |
capa.title = "Autopistas de la GV";
|
134 |
capa.type="LINE";
|
135 |
capa.data="autopistas";
|
136 |
capa.extent = null;
|
137 |
capa.addClass(clase); |
138 |
clase.estilo = new MapServerConfiguration.StyleMap(
|
139 |
new MapServerConfiguration.RGB(120,120,120),new MapServerConfiguration.RGB(200,255,0)); |
140 |
capa.metadata=new MapServerConfiguration.MetadataLayer();
|
141 |
capa.metadata.setExtent(638610.4375,4222780,789330,4484662.5); |
142 |
capa.metadata.title="Autopistas gv";
|
143 |
capa.layercrs= new MapServerConfiguration.CRS("EPSG:23030",true); |
144 |
map.add(capa); |
145 |
|
146 |
map.generate(mapFileName); |
147 |
//map.generate();
|
148 |
} |
149 |
|
150 |
static void testPostGisMap(){ |
151 |
String mapFileName = "/etc/mapserver/wms.map"; |
152 |
MapServerConfiguration.ConfigFile map = new MapServerConfiguration.ConfigFile();
|
153 |
map.mapName= "TEST_MAPSERVER_POSTGIS";
|
154 |
map.mapStatus="ON";
|
155 |
map.mapUnits="METERS";
|
156 |
map.mapShapePath = "/home/david/cv300/";
|
157 |
map.mapcrs= new MapServerConfiguration.CRS("EPSG:23030",true); |
158 |
map.setExtent(638610.4375,4222780,789330,4484662.5); |
159 |
|
160 |
MapServerConfiguration.WebMap web = new MapServerConfiguration.WebMap();
|
161 |
web.imagepath="/var/tmp/";
|
162 |
web.imageurl="/var/tmp/";
|
163 |
web.metadata = new MapServerConfiguration.MetadataWeb();
|
164 |
web.metadata.crs = new MapServerConfiguration.CRS("EPSG:23030",false); |
165 |
web.metadata.title="test shape";
|
166 |
web.metadata.onlineresource="http://localhost/mapserver/mapserv?map=/etc/mapserver/wms.map";
|
167 |
map.www=web; |
168 |
|
169 |
MapServerConfiguration.PostgisLayer capa = new MapServerConfiguration.PostgisLayer();
|
170 |
MapServerConfiguration.MapClass clase = new MapServerConfiguration.MapClass("autopistas"); |
171 |
capa.name = "autopistas";
|
172 |
capa.title = "Autopistas de la GV";
|
173 |
capa.type="LINE";
|
174 |
capa.data="autopistas";
|
175 |
capa.extent = null;
|
176 |
capa.addClass(clase); |
177 |
clase.estilo = new MapServerConfiguration.StyleMap(
|
178 |
new MapServerConfiguration.RGB(120,120,120),new MapServerConfiguration.RGB(200,255,0)); |
179 |
capa.metadata=new MapServerConfiguration.MetadataLayer();
|
180 |
capa.metadata.setExtent(638610.4375,4222780,789330,4484662.5); |
181 |
capa.metadata.title="Autopistas gv";
|
182 |
capa.layercrs= new MapServerConfiguration.CRS("EPSG:23030",true); |
183 |
capa.setConnParams("david", "chkdsk", "localhost", "betel", "5432"); |
184 |
capa.tabla = "autopistas";
|
185 |
capa.data = "the_geom from "+capa.tabla;
|
186 |
capa.addClass(clase); |
187 |
map.add(capa); |
188 |
|
189 |
map.generate(mapFileName); |
190 |
//map.generate();
|
191 |
|
192 |
|
193 |
} |
194 |
|
195 |
static void testRasterMap(){ |
196 |
String mapFileName = null; //"/etc/mapserver/wms.map"; |
197 |
MapServerConfiguration.ConfigFile map = new MapServerConfiguration.ConfigFile();
|
198 |
map.mapName= "TEST_MAPSERVER_RASTER";
|
199 |
map.mapStatus="ON";
|
200 |
map.mapUnits="METERS";
|
201 |
map.mapShapePath = "/home/david/cv300/";
|
202 |
map.mapcrs= new MapServerConfiguration.CRS("EPSG:23030",true); |
203 |
map.setExtent(395000,97000,429000,160000); |
204 |
|
205 |
MapServerConfiguration.WebMap web = new MapServerConfiguration.WebMap();
|
206 |
web.imagepath="/var/tmp/";
|
207 |
web.imageurl="/var/tmp/";
|
208 |
web.metadata=new MapServerConfiguration.MetadataWeb();
|
209 |
web.metadata.crs= new MapServerConfiguration.CRS("EPSG:23030",false); |
210 |
web.metadata.title="test raster";
|
211 |
web.metadata.onlineresource="http://localhost/mapserver/mapserv?map=/etc/mapserver/wms.map";
|
212 |
map.www=web; |
213 |
|
214 |
MapServerConfiguration.RasterLayer capa = new MapServerConfiguration.RasterLayer();
|
215 |
MapServerConfiguration.MapClass clase = new MapServerConfiguration.MapClass("raster"); |
216 |
capa.name = "raster";
|
217 |
capa.title = "raster de la GV";
|
218 |
capa.type="RASTER";
|
219 |
capa.data="foto.tif";
|
220 |
capa.extent = null;
|
221 |
capa.addClass(clase); |
222 |
clase.estilo = new MapServerConfiguration.StyleMap(
|
223 |
new MapServerConfiguration.RGB(120,120,120),new MapServerConfiguration.RGB(200,255,0)); |
224 |
capa.metadata=new MapServerConfiguration.MetadataLayer();
|
225 |
capa.metadata.setExtent(395000,97000,429000,160000); |
226 |
capa.metadata.title="raster gv";
|
227 |
capa.layercrs= new MapServerConfiguration.CRS("EPSG:23030",true); |
228 |
capa.addClass(clase); |
229 |
map.add(capa); |
230 |
|
231 |
map.generate(mapFileName); |
232 |
} |
233 |
|
234 |
/*public void addAutopistas(DoMap map) {
|
235 |
DoMap.MapClass clase = new DoMap.MapClass("autopistas");
|
236 |
clase.estilo = new DoMap.StyleMap(
|
237 |
new RGB(120,120,120),new RGB(200,255,0));
|
238 |
|
239 |
DoMap.ShpLayer capa = new DoMap.ShpLayer();
|
240 |
capa.name = "autopistas";
|
241 |
capa.title = "Autopistas de la GV";
|
242 |
capa.type="LINE";
|
243 |
capa.data="autopistas";
|
244 |
capa.extent = null;
|
245 |
capa.layerClass = clase;
|
246 |
capa.metadata=new DoMap.MetadataLayer();
|
247 |
capa.metadata.setExtent(638610.4375,4222780,789330,4484662.5);
|
248 |
capa.metadata.metalayertitle="Autopistas gv";
|
249 |
capa.layercrs= new ToMap.CRS("EPSG:23030",true);
|
250 |
map.layers.add(capa);
|
251 |
}
|
252 |
*/
|
253 |
/**
|
254 |
* Generates a WMS .map file
|
255 |
*/
|
256 |
|
257 |
public static void testWFSCanada() { |
258 |
String mapFileName = null; //"data/wfs.map"; |
259 |
MapServerConfiguration.ConfigFile map = new MapServerConfiguration.ConfigFile();
|
260 |
map.mapName = "TEST_WFS_MAPSERVER";
|
261 |
map.mapStatus = "ON";
|
262 |
map.mapUnits = "METERS";
|
263 |
map.mapShapePath = "../data";
|
264 |
map.mapcrs= new MapServerConfiguration.CRS("EPSG:23030",true); |
265 |
map.symbolset = "../etc/symbols.sym";
|
266 |
map.fontset = "../etc/fonts.txt";
|
267 |
map.mapSize = new Dimension(400,300); |
268 |
map.imageColor = new MapServerConfiguration.RGB(255,255,255); |
269 |
map.setExtent(-2200000d,-712631d,3072800d,3840000d); |
270 |
|
271 |
MapServerConfiguration.WebMap web = new MapServerConfiguration.WebMap();
|
272 |
web.imagepath = "/ms4w/tmp/ms_tmp/";
|
273 |
web.imageurl = "/ms_tmp/";
|
274 |
web.metadata = new MapServerConfiguration.MetadataWeb();
|
275 |
web.metadata.setServiceAsWFS(); |
276 |
web.metadata.crs = new MapServerConfiguration.CRS("EPSG:42304 EPSG:42101 EPSG:4269 EPSG:4326", false); |
277 |
web.metadata.title = "GMap WFS Demo Server";
|
278 |
web.metadata.onlineresource = "http://127.0.0.1/cgi-bin/mapserv.exe?";
|
279 |
web.metadata.ows_schemas_location = "http://ogc.dmsolutions.ca";
|
280 |
map.www=web; |
281 |
|
282 |
map.mapcrs= new MapServerConfiguration.CRS("EPSG:42304",true); |
283 |
|
284 |
MapServerConfiguration.ShpLayer capa = new MapServerConfiguration.ShpLayer();
|
285 |
MapServerConfiguration.MapClass clase = new MapServerConfiguration.MapClass("Canada"); |
286 |
clase.estilo = new MapServerConfiguration.StyleMap(
|
287 |
new MapServerConfiguration.RGB(120,120,120),new MapServerConfiguration.RGB(200,255,0)); |
288 |
clase.template = "ttt_query.html";
|
289 |
capa.name = "province";
|
290 |
capa.type="POLYGON";
|
291 |
capa.data="province";
|
292 |
capa.layercrs = new MapServerConfiguration.CRS("epsg:42304", true); |
293 |
capa.addClass(clase); |
294 |
capa.metadata=new MapServerConfiguration.MetadataLayer();
|
295 |
capa.metadata.setServiceAsWFS(); |
296 |
capa.metadata.title = "Provinces";
|
297 |
capa.metadata.gml_include_items = "all";
|
298 |
capa.setDump(true);
|
299 |
map.add(capa); |
300 |
|
301 |
map.generate(mapFileName); |
302 |
} |
303 |
|
304 |
|
305 |
} |