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