Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / layers / FLyrWFSFactory.java @ 8826

History | View | Annotate | Download (3.82 KB)

1
package com.iver.cit.gvsig.fmap.layers;
2

    
3
import java.awt.Component;
4
import java.net.URL;
5

    
6
import javax.swing.JOptionPane;
7

    
8
import org.apache.log4j.Logger;
9
import org.cresques.cts.IProjection;
10

    
11
import com.iver.andami.PluginServices;
12
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
13
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
14
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver;
15
import com.iver.cit.gvsig.gui.panels.WFSParamsPanel;
16
import com.iver.cit.gvsig.gui.wizards.WFSWizardData;
17
import com.iver.cit.gvsig.project.documents.view.gui.View;
18

    
19
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
20
 *
21
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
22
 *
23
 * This program is free software; you can redistribute it and/or
24
 * modify it under the terms of the GNU General Public License
25
 * as published by the Free Software Foundation; either version 2
26
 * of the License, or (at your option) any later version.
27
 *
28
 * This program is distributed in the hope that it will be useful,
29
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31
 * GNU General Public License for more details.
32
 *
33
 * You should have received a copy of the GNU General Public License
34
 * along with this program; if not, write to the Free Software
35
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
36
 *
37
 * For more information, contact:
38
 *
39
 *  Generalitat Valenciana
40
 *   Conselleria d'Infraestructures i Transport
41
 *   Av. Blasco Ib??ez, 50
42
 *   46010 VALENCIA
43
 *   SPAIN
44
 *
45
 *      +34 963862235
46
 *   gvsig@gva.es
47
 *      www.gvsig.gva.es
48
 *
49
 *    or
50
 *
51
 *   IVER T.I. S.A
52
 *   Salamanca 50
53
 *   46005 Valencia
54
 *   Spain
55
 *
56
 *   +34 963163400
57
 *   dac@iver.es
58
 */
59
/* CVS MESSAGES:
60
 *
61
 * $Id: FLyrWFSFactory.java 8826 2006-11-16 16:46:21Z jorpiell $
62
 * $Log$
63
 * Revision 1.2.2.2  2006-11-16 16:46:21  jorpiell
64
 * Asignamos el WFSAdapter en la factoria
65
 *
66
 * Revision 1.2.2.1  2006/11/15 04:11:04  jjdelcerro
67
 * *** empty log message ***
68
 *
69
 * Revision 1.2  2006/11/06 13:58:03  jorpiell
70
 * Al crear una nueva capa se declara como activa. De esa forma se pueden aplicar tantos filtros como queramos
71
 *
72
 * Revision 1.1  2006/10/31 09:38:15  jorpiell
73
 * Se ha creado una factoria para crear la capa. De ese modo no se repite c?digo desde le panel de propiedades y desde el panel de la capa
74
 *
75
 *
76
 */
77
/**
78
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
79
 */
80
public class FLyrWFSFactory {
81

    
82
        public FLyrWFS getFLyrWFS(FLayer layer, 
83
                        URL host,
84
                        String onlineResource,
85
                        FMapWFSDriver driver,
86
                        boolean loadLayer){
87
                FLyrWFS wfsLayer = (FLyrWFS)layer;
88
                wfsLayer.setHost(host);
89
                wfsLayer.setWfsDriver(driver);
90
                //Sets the WFS adapter
91
                WFSAdapter adapter = new WFSAdapter();
92
            adapter.setDriver((VectorialDriver) driver);
93
            wfsLayer.setSource(adapter);
94
                wfsLayer.setOnlineResource(onlineResource);
95
                View activeView = 
96
                        (View) PluginServices.getMDIManager().getActiveWindow();
97
                wfsLayer.setProjection(CRSFactory.getCRS(wfsLayer.getSrs()));
98
                IProjection wfsProjection = CRSFactory.getCRS(wfsLayer.getSrs());
99
                IProjection layerProjection = activeView.getMapControl().getProjection(); 
100
                if (wfsProjection != null){
101
                        if (!(wfsProjection.equals(layerProjection))){
102
                                layer.setCoordTrans(wfsProjection.getCT(layerProjection));
103
                        }
104
                }
105
                if (loadLayer){
106
                        try {
107
                                wfsLayer.load();
108
                                if (wfsLayer.getNumfeatures() == wfsLayer.getWfsDriver().getRowCount()) {
109
                                        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
110
                                                        PluginServices.getText(this,"maxFeatures_aviso"));        
111
                                }
112
                        } catch (Exception e) {
113
                                // TODO Auto-generated catch block
114
                                Logger.getLogger(getClass().getName()).error(e.getMessage());
115
                                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),
116
                                                PluginServices.getText(this,"cantLoad"));
117
                                return null;
118
                        }
119
                }
120
                wfsLayer.setActive(true);
121
                return wfsLayer;
122
        }
123

    
124
}