Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extPublish / src / org / gvsig / remoteservices / conf / mapserver / Test.java @ 6924

History | View | Annotate | Download (7.66 KB)

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

    
3
import java.awt.Dimension;
4

    
5
import org.gvsig.remoteservices.conf.mapserver.ToMap.RGB;
6

    
7

    
8

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

    
242
                DoMap.ShpLayer capa = new DoMap.ShpLayer();
243
                DoMap.MapClass clase = new DoMap.MapClass("Canada");
244
                clase.estilo = new DoMap.StyleMap(
245
                                new RGB(120,120,120),new RGB(200,255,0));
246
                clase.template = "ttt_query.html";
247
                capa.name = "province";
248
                capa.type="POLYGON";
249
                capa.data="province";
250
                capa.layercrs = new ToMap.CRS("epsg:42304", true);
251
                capa.layerClass = clase;
252
                capa.metadata=new DoMap.MetadataLayer();
253
                capa.metadata.setServiceAsWFS();
254
                capa.metadata.title = "Provinces";
255
                capa.metadata.gml_include_items = "all";
256
                capa.setDump(true);
257
                map.layers.add(capa);
258

    
259
                map.generate();
260
        }
261
}