Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / GMLProjectionFactory.java @ 11622

History | View | Annotate | Download (3.13 KB)

1
package org.gvsig.gpe.gml;
2

    
3
import org.gvsig.gpe.GPEContentHandler;
4
import org.gvsig.gpe.GPEErrorHandler;
5
import org.gvsig.gpe.warnings.SrsUnknownWarning;
6

    
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
/* CVS MESSAGES:
48
 *
49
 * $Id: GMLProjectionFactory.java 11622 2007-05-14 11:23:12Z jorpiell $
50
 * $Log$
51
 * Revision 1.3  2007-05-14 11:18:51  jorpiell
52
 * ProjectionFactory updated
53
 *
54
 * Revision 1.2  2007/04/12 17:06:44  jorpiell
55
 * First GML writing tests
56
 *
57
 * Revision 1.1  2007/04/12 10:23:41  jorpiell
58
 * Add some writers and the GPEXml parser
59
 *
60
 *
61
 */
62
/**
63
 * This class is used to convert a projection written 
64
 * using the EPSG projection to the GML projection
65
 * format
66
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
67
 */
68
public class GMLProjectionFactory {
69
        
70
        /**
71
         * This method is used to get the GML spatial reference
72
         * system (srs) calculated from a GPE srs.
73
         * @param srs
74
         * GPE srs
75
         * @param errosHandler
76
         * To report errosHandler
77
         * @return
78
         * GML srs
79
         */
80
        public static String fromGPEToGML(String srs,GPEErrorHandler errosHandler){
81
                if (srs != null){
82
                        String[] parts = srs.split(":");
83
                        if (parts.length == 2){
84
                                if (parts[0].compareTo(GMLTags.SRS_EPSG_NAME) == 0){
85
                                        return GMLTags.SRS + GMLTags.SRS_EPSG + "#" + parts[1];
86
                                }
87
                        }else if(parts.length == 1){
88
                                //If the EPSG prefix is not found 
89
                                return GMLTags.SRS + GMLTags.SRS_EPSG + "#"  + parts[0];
90
                                
91
                        }
92
                }        
93
                errosHandler.addWarning(new SrsUnknownWarning(srs));
94
                return GMLTags.SRS_UNKNOWN;        
95
        }
96
        
97
        /**
98
         * This method is used to get the GPE spatial reference
99
         * system (srs) calculated from a GML srs.
100
         * @param srs
101
         * GML srs
102
         * @param errosHandler
103
         * To report errors
104
         * @return
105
         * GPE srs
106
         */
107
        public static String fromGMLToGPE(String srs,GPEErrorHandler errosHandler){
108
                if (srs != null){
109
                        String[] parts = srs.split("#");
110
                        if (parts.length == 2){
111
                                if (parts[0].compareTo(GMLTags.SRS + GMLTags.SRS_EPSG) == 0){
112
                                        return GMLTags.SRS_EPSG_NAME + ":" + parts[1];
113
                                }
114
                        }
115
                }
116
                errosHandler.addWarning(new SrsUnknownWarning(srs));
117
                return GMLTags.SRS_UNKNOWN;        
118
        }
119
}