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