Statistics
| Revision:

root / trunk / extensions / extPublish / src / org / gvsig / remoteservices / conf / mapserver / Test.java @ 6954

History | View | Annotate | Download (8.02 KB)

1
package org.gvsig.remoteservices.conf.mapserver;
2

    
3
import java.awt.Dimension;
4

    
5
public class Test {
6
        public static void main(String args[]) {
7
                //testShpMap();
8
                //testPostGisMap();
9
                testRasterMap();
10
                //testWFSCanada();
11
        }
12
        
13
        static void testShpMap() {
14
                String mapFileName = null; //"/etc/mapserver/wms.map";
15
                MapServer.ConfigFile map = new MapServer.ConfigFile();
16
                map.mapName = "TEST_MAPSERVER";
17
                map.mapStatus = "ON";
18
                map.mapUnits = "METERS";
19
                map.mapShapePath = "/home/david/cv300/"; 
20
                map.mapcrs = new MapServer.CRS("EPSG:23030",true);
21
                map.setExtent(638610.4375,4222780,789330,4484662.5);
22
                
23
                MapServer.WebMap web = new MapServer.WebMap();
24
                web.imagepath = "/var/tmp/";
25
                web.imageurl = "/var/tmp/";
26
                web.metadata = new MapServer.MetadataWeb();
27
                web.metadata.crs = new MapServer.CRS("EPSG:23030",false);
28
                web.metadata.title = "test shape";
29
                web.metadata.onlineresource = "http://localhost/mapserver/mapserv?map=/etc/mapserver/wms.map";
30
                map.www = web;
31
                
32
                MapServer.ShpLayer capa = new MapServer.ShpLayer();
33
                MapServer.MapClass clase = new MapServer.MapClass("autopistas");
34
                capa.name = "autopistas";
35
                capa.title = "Autopistas de la GV";
36
                capa.type="LINE";
37
                capa.data="autopistas";
38
                capa.extent = null;
39
                capa.layerClass = clase;
40
                clase.estilo = new MapServer.StyleMap(
41
                                new MapServer.RGB(120,120,120),new MapServer.RGB(200,255,0));
42
                capa.metadata=new MapServer.MetadataLayer();
43
                capa.metadata.setExtent(638610.4375,4222780,789330,4484662.5);
44
                capa.metadata.metalayertitle="Autopistas gv";
45
                capa.layercrs= new MapServer.CRS("EPSG:23030",true);
46
                map.layers.add(capa);
47
                
48
                map.generate(mapFileName);
49
                //map.generate();
50
        }
51
        
52
        static void testPostGisMap(){
53
                String mapFileName = "/etc/mapserver/wms.map";
54
                MapServer.ConfigFile map = new MapServer.ConfigFile();
55
                map.mapName= "TEST_MAPSERVER_POSTGIS";
56
                map.mapStatus="ON";
57
                map.mapUnits="METERS";
58
                map.mapShapePath = "/home/david/cv300/"; 
59
                map.mapcrs= new MapServer.CRS("EPSG:23030",true);
60
                map.setExtent(638610.4375,4222780,789330,4484662.5);
61
                
62
                MapServer.WebMap web = new MapServer.WebMap();
63
                web.imagepath="/var/tmp/";
64
                web.imageurl="/var/tmp/";
65
                web.metadata = new MapServer.MetadataWeb();
66
                web.metadata.crs = new MapServer.CRS("EPSG:23030",false);
67
                web.metadata.title="test shape";
68
                web.metadata.onlineresource="http://localhost/mapserver/mapserv?map=/etc/mapserver/wms.map";
69
                map.www=web;
70
                
71
                MapServer.PostgisLayer capa = new MapServer.PostgisLayer();
72
                MapServer.MapClass clase = new MapServer.MapClass("autopistas");
73
                capa.name = "autopistas";
74
                capa.title = "Autopistas de la GV";
75
                capa.type="LINE";
76
                capa.data="autopistas";
77
                capa.extent = null;
78
                capa.layerClass = clase;
79
                clase.estilo = new MapServer.StyleMap(
80
                                new MapServer.RGB(120,120,120),new MapServer.RGB(200,255,0));
81
                capa.metadata=new MapServer.MetadataLayer();
82
                capa.metadata.setExtent(638610.4375,4222780,789330,4484662.5);
83
                capa.metadata.metalayertitle="Autopistas gv";
84
                capa.layercrs= new MapServer.CRS("EPSG:23030",true);
85
                capa.setConnParams("david", "chkdsk", "localhost", "betel", "5432");
86
                capa.tabla = "autopistas";
87
                capa.data = "the_geom from "+capa.tabla;
88
                capa.layerClass = clase;
89
                map.layers.add(capa);
90
                
91
                map.generate(mapFileName);
92
                //map.generate();
93
                
94
                
95
        }
96
        
97
        static void testRasterMap(){
98
                String mapFileName = null; //"/etc/mapserver/wms.map";
99
                MapServer.ConfigFile map = new MapServer.ConfigFile();
100
                map.mapName= "TEST_MAPSERVER_RASTER";
101
                map.mapStatus="ON";
102
                map.mapUnits="METERS";
103
                map.mapShapePath = "/home/david/cv300/"; 
104
                map.mapcrs= new MapServer.CRS("EPSG:23030",true);
105
                map.setExtent(395000,97000,429000,160000);
106
                
107
                MapServer.WebMap web = new MapServer.WebMap();
108
                web.imagepath="/var/tmp/";
109
                web.imageurl="/var/tmp/";
110
                web.metadata=new MapServer.MetadataWeb();
111
                web.metadata.crs= new MapServer.CRS("EPSG:23030",false);
112
                web.metadata.title="test raster";
113
                web.metadata.onlineresource="http://localhost/mapserver/mapserv?map=/etc/mapserver/wms.map";
114
                map.www=web;
115
                
116
                MapServer.RasterLayer capa = new MapServer.RasterLayer();
117
                MapServer.MapClass clase = new MapServer.MapClass("raster");
118
                capa.name = "raster";
119
                capa.title = "raster de la GV";
120
                capa.type="RASTER";
121
                capa.data="foto.tif";
122
                capa.extent = null;
123
                capa.layerClass = clase;
124
                clase.estilo = new MapServer.StyleMap(
125
                                new MapServer.RGB(120,120,120),new MapServer.RGB(200,255,0));
126
                capa.metadata=new MapServer.MetadataLayer();
127
                capa.metadata.setExtent(395000,97000,429000,160000);
128
                capa.metadata.metalayertitle="raster gv";
129
                capa.layercrs= new MapServer.CRS("EPSG:23030",true);
130
                capa.layerClass = clase;
131
                map.layers.add(capa);
132
                
133
                map.generate(mapFileName);
134
        }
135
        
136
        /*public void addAutopistas(DoMap map) {
137
                DoMap.MapClass clase = new DoMap.MapClass("autopistas");
138
                clase.estilo = new DoMap.StyleMap(
139
                                new RGB(120,120,120),new RGB(200,255,0));
140
                
141
                DoMap.ShpLayer capa = new DoMap.ShpLayer();
142
                capa.name = "autopistas";
143
                capa.title = "Autopistas de la GV";
144
                capa.type="LINE";
145
                capa.data="autopistas";
146
                capa.extent = null;
147
                capa.layerClass = clase;
148
                capa.metadata=new DoMap.MetadataLayer();
149
                capa.metadata.setExtent(638610.4375,4222780,789330,4484662.5);
150
                capa.metadata.metalayertitle="Autopistas gv";
151
                capa.layercrs= new ToMap.CRS("EPSG:23030",true);
152
                map.layers.add(capa);
153
        }
154
        */
155
        /**
156
         * Generaci�n del siguiente .map (WFS)
157
         * NAME WFS_server
158
        STATUS ON
159
        SIZE 400 300
160
        SYMBOLSET ../etc/symbols.sym
161
        EXTENT -2200000 -712631 3072800 3840000
162
        UNITS METERS
163
        SHAPEPATH "../data"
164
        IMAGECOLOR 255 255 255
165
        FONTSET ../etc/fonts.txt
166
        
167
        WEB
168
          IMAGEPATH "/ms4w/tmp/ms_tmp/" 
169
          IMAGEURL "/ms_tmp/"
170
          METADATA
171
            "wfs_title"            "GMap WFS Demo Server"  ## REQUIRED
172
            "wfs_onlineresource"   "http://127.0.0.1/cgi-bin/mapserv.exe?"  ## Recommended
173
            "wfs_srs"               "EPSG:42304 EPSG:42101 EPSG:4269 EPSG:4326"  ## Recommended
174
            "ows_schemas_location" "http://ogc.dmsolutions.ca"  ## Optional
175
          END
176
        END
177
        
178
        PROJECTION
179
          "init=epsg:42304"
180
        END
181
        
182
        LAYER
183
          NAME province
184
          METADATA
185
            "wfs_title"    "Provinces" ## REQUIRED
186
            "gml_include_items" "all"  ## Optional (serves all attributes for layer)
187
          END
188
          TYPE POLYGON
189
          STATUS ON
190
          DATA province
191
          PROJECTION
192
            "init=epsg:42304"
193
          END
194
          DUMP TRUE           ## REQUIRED
195
          CLASS
196
            NAME "Canada"
197
            STYLE
198
              COLOR 200 255 0
199
              OUTLINECOLOR 120 120 120
200
            END
201
            TEMPLATE "ttt_query.html"
202
          END
203
        END # Layer
204
        
205
        END # Map File
206
         */
207
        
208
        public static void testWFSCanada() {
209
                String mapFileName = null; //"data/wfs.map";
210
                MapServer.ConfigFile map = new MapServer.ConfigFile();
211
                map.mapName = "TEST_WFS_MAPSERVER";
212
                map.mapStatus = "ON";
213
                map.mapUnits = "METERS";
214
                map.mapShapePath = "../data";         
215
                map.mapcrs= new MapServer.CRS("EPSG:23030",true);
216
                map.symbolset = "../etc/symbols.sym";
217
                map.fontset = "../etc/fonts.txt";
218
                map.mapSize = new Dimension(400,300);
219
                map.imageColor = new MapServer.RGB(255,255,255);
220
                map.setExtent(-2200000d,-712631d,3072800d,3840000d);
221
                
222
                MapServer.WebMap web = new MapServer.WebMap();
223
                web.imagepath = "/ms4w/tmp/ms_tmp/";
224
                web.imageurl = "/ms_tmp/";
225
                web.metadata = new MapServer.MetadataWeb();
226
                web.metadata.setServiceAsWFS();
227
                web.metadata.crs = new MapServer.CRS("EPSG:42304 EPSG:42101 EPSG:4269 EPSG:4326", false);
228
                web.metadata.title = "GMap WFS Demo Server";
229
                web.metadata.onlineresource = "http://127.0.0.1/cgi-bin/mapserv.exe?";
230
                web.metadata.ows_schemas_location = "http://ogc.dmsolutions.ca";
231
                map.www=web;
232
                
233
                map.mapcrs= new MapServer.CRS("EPSG:42304",true);
234

    
235
                MapServer.ShpLayer capa = new MapServer.ShpLayer();
236
                MapServer.MapClass clase = new MapServer.MapClass("Canada");
237
                clase.estilo = new MapServer.StyleMap(
238
                                new MapServer.RGB(120,120,120),new MapServer.RGB(200,255,0));
239
                clase.template = "ttt_query.html";
240
                capa.name = "province";
241
                capa.type="POLYGON";
242
                capa.data="province";
243
                capa.layercrs = new MapServer.CRS("epsg:42304", true);
244
                capa.layerClass = clase;
245
                capa.metadata=new MapServer.MetadataLayer();
246
                capa.metadata.setServiceAsWFS();
247
                capa.metadata.title = "Provinces";
248
                capa.metadata.gml_include_items = "all";
249
                capa.setDump(true);
250
                map.layers.add(capa);
251

    
252
                map.generate(mapFileName);
253
        }
254
}