Statistics
| Revision:

root / org.gvsig.gpe / library / trunk / org.gvsig.gpe / org.gvsig.gpe.exportto / org.gvsig.gpe.exportto.kml / src / main / java / org / gvsig / gpe / exportto / kml / ExporttoKMLProvider.java @ 527

History | View | Annotate | Download (3.28 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.gpe.exportto.kml;
25

    
26
import org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28

    
29
import org.gvsig.exportto.ExporttoService;
30
import org.gvsig.exportto.swing.prov.file.AbstractExporttoFileProvider;
31
import org.gvsig.exportto.swing.spi.ExporttoSwingProvider;
32
import org.gvsig.exportto.swing.spi.ExporttoSwingProviderPanel;
33
import org.gvsig.fmap.dal.feature.FeatureStore;
34
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
35
import org.gvsig.gpe.exportto.kml.panel.KMLOptionsPanel;
36
import org.gvsig.tools.service.spi.ProviderServices;
37

    
38
/**
39
 * Exporto provider which gets Exporto from a file.
40
 *
41
 * @author gvSIG Team
42
 * @version $Id$
43
 */
44
public class ExporttoKMLProvider extends AbstractExporttoFileProvider implements
45
    ExporttoSwingProvider {
46

    
47
    private FLyrVect vectorLayer = null;
48
    private KMLOptionsPanel optPanel = null;
49

    
50
    /**
51
     *
52
     * Constructor.
53
     */
54
    public ExporttoKMLProvider(
55
        ProviderServices providerServices,
56
        FLyrVect vlayer) {
57

    
58
        super(
59
            providerServices,
60
            vlayer.getFeatureStore(),
61
            getTargetProjection(vlayer));
62

    
63
        vectorLayer = vlayer;
64

    
65
        IProjection viewProj = getTargetProjection(vlayer);
66
        boolean viewIs4326 = (viewProj.getAbrev().compareToIgnoreCase("epsg:4326") == 0);
67
        optPanel = new KMLOptionsPanel(vlayer.isLabeled(), !viewIs4326);
68
    }
69

    
70
    private static IProjection getTargetProjection(FLyrVect vlayer) {
71
        ICoordTrans ct = vlayer.getCoordTrans();
72
        if (ct == null) {
73
            return vlayer.getProjection();
74
        } else {
75
            return ct.getPDest();
76
        }
77
    }
78

    
79
    public ExporttoService createExporttoService() {
80
        return new ExporttoKMLService(
81
            selectFileOptionPanel.getSelectedFile(),
82
            featureStore,
83
            vectorLayer,
84
            optPanel.getLongFormat(),
85
            optPanel.useLabels(),
86
            optPanel.useBalloons(),
87
            optPanel.mustReprojectToEpsg4326());
88
    }
89

    
90
    public int getPanelCount() {
91
        return 2;
92
    }
93

    
94
    public ExporttoSwingProviderPanel getPanelAt(int index) {
95
        switch (index) {
96
        case 0:
97
            return optPanel;
98
        case 1:
99
            return selectFileOptionPanel;
100
        }
101
        return null;
102
    }
103

    
104
    @Override
105
    public boolean needsPanelTargetProjection(){
106
        return false;
107
    }
108
}
109

    
110