svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / gml / GMLUtils.java @ 6433
History | View | Annotate | Download (4.17 KB)
1 | 6433 | jorpiell | package com.iver.cit.gvsig.fmap.drivers.gml; |
---|---|---|---|
2 | |||
3 | import java.util.Date; |
||
4 | import java.util.Hashtable; |
||
5 | |||
6 | import org.geotools.feature.type.GeometricAttributeType; |
||
7 | |||
8 | import com.hardcode.gdbms.engine.values.Value; |
||
9 | import com.hardcode.gdbms.engine.values.ValueFactory; |
||
10 | import com.vividsolutions.jts.geom.Geometry; |
||
11 | import com.vividsolutions.jts.geom.GeometryCollection; |
||
12 | import com.vividsolutions.jts.geom.LineString; |
||
13 | import com.vividsolutions.jts.geom.MultiLineString; |
||
14 | import com.vividsolutions.jts.geom.MultiPoint; |
||
15 | import com.vividsolutions.jts.geom.MultiPolygon; |
||
16 | import com.vividsolutions.jts.geom.Point; |
||
17 | import com.vividsolutions.jts.geom.Polygon; |
||
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$
|
||
62 | * $Log$
|
||
63 | * Revision 1.1 2006-07-19 12:29:39 jorpiell
|
||
64 | * A?adido el driver de GML
|
||
65 | *
|
||
66 | *
|
||
67 | */
|
||
68 | /**
|
||
69 | * Some utils to manage GML
|
||
70 | *
|
||
71 | * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
||
72 | */
|
||
73 | public class GMLUtils { |
||
74 | |||
75 | public static Value[] getValues(Object[] attr) { |
||
76 | Value[] values = null; |
||
77 | if (attr.length - 1 > 0){ |
||
78 | values = new Value[attr.length - 1]; |
||
79 | }else{
|
||
80 | values = new Value[0]; |
||
81 | } |
||
82 | for (int i=1;i<attr.length;i++){ |
||
83 | if (attr[i]!=null){ |
||
84 | if (attr[i] instanceof Double){ |
||
85 | values[i-1]=ValueFactory.createValue(((Double)attr[i]).doubleValue()); |
||
86 | }else if (attr[i] instanceof String){ |
||
87 | values[i-1]=ValueFactory.createValue(String.valueOf(attr[i])); |
||
88 | }else if (attr[i] instanceof Long){ |
||
89 | values[i-1]=ValueFactory.createValue(((Long)attr[i]).longValue()); |
||
90 | }else if (attr[i] instanceof Integer){ |
||
91 | values[i-1]=ValueFactory.createValue(((Integer)attr[i]).intValue()); |
||
92 | }else if (attr[i] instanceof Float){ |
||
93 | values[i-1]=ValueFactory.createValue(((Float)attr[i]).floatValue()); |
||
94 | }else if (attr[i] instanceof Short){ |
||
95 | values[i-1]=ValueFactory.createValue(((Short)attr[i]).shortValue()); |
||
96 | }else if (attr[i] instanceof Boolean){ |
||
97 | values[i-1]=ValueFactory.createValue(((Boolean)attr[i]).booleanValue()); |
||
98 | }else if (attr[i] instanceof Date){ |
||
99 | values[i-1]=ValueFactory.createValue(((Date)attr[i])); |
||
100 | } |
||
101 | }else{
|
||
102 | values[i-1]=ValueFactory.createValue(""); |
||
103 | } |
||
104 | } |
||
105 | return values;
|
||
106 | } |
||
107 | /**
|
||
108 | * It return true is the attributeType is a geometry
|
||
109 | * @param attributeType
|
||
110 | * Type to compare
|
||
111 | * @return
|
||
112 | */
|
||
113 | public static boolean isGeometry(String attributeType){ |
||
114 | if (attributeType == null){ |
||
115 | return false; |
||
116 | } |
||
117 | |||
118 | if (attributeType.compareTo("gml:GeometryPropertyType") == 0){ |
||
119 | return true; |
||
120 | } |
||
121 | if (attributeType.compareTo("gml:MultiLineStringPropertyType") == 0){ |
||
122 | return true; |
||
123 | } |
||
124 | if (attributeType.compareTo("gml:PointPropertyType") == 0){ |
||
125 | return true; |
||
126 | } |
||
127 | if (attributeType.compareTo("gml:MultiPointPropertyType") == 0){ |
||
128 | return true; |
||
129 | } |
||
130 | if (attributeType.compareTo("gml:MultiPolygonPropertyType") == 0){ |
||
131 | return true; |
||
132 | } |
||
133 | return false; |
||
134 | } |
||
135 | |||
136 | /**
|
||
137 | * It return true is the attributeType is a geometry
|
||
138 | * @param attributeType
|
||
139 | * Type to compare
|
||
140 | * @return
|
||
141 | */
|
||
142 | public static boolean isGeometry(Class attributeType){ |
||
143 | return Geometry.class.isAssignableFrom(attributeType);
|
||
144 | } |
||
145 | |||
146 | |||
147 | |||
148 | |||
149 | } |