Revision 9524 branches/piloto3d/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/gml/FMAPGeometryFactory.java
FMAPGeometryFactory.java | ||
---|---|---|
7 | 7 |
import org.apache.log4j.Logger; |
8 | 8 |
import org.gvsig.remoteClient.gml.factories.IGeometriesFactory; |
9 | 9 |
|
10 |
import com.hardcode.gdbms.engine.values.ComplexValue; |
|
10 | 11 |
import com.hardcode.gdbms.engine.values.Value; |
11 | 12 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
12 | 13 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
... | ... | |
62 | 63 |
* |
63 | 64 |
* $Id$ |
64 | 65 |
* $Log$ |
65 |
* Revision 1.1 2006-08-10 12:03:43 jorpiell |
|
66 |
* Revision 1.1.2.1 2007-01-03 15:12:33 sbayarri |
|
67 |
* v10 synch & 3D |
|
68 |
* |
|
69 |
* Revision 1.1.4.1 2006/11/15 00:08:23 jjdelcerro |
|
70 |
* *** empty log message *** |
|
71 |
* |
|
72 |
* Revision 1.2 2006/10/10 12:55:27 jorpiell |
|
73 |
* Se ha a?adido el soporte de features complejas |
|
74 |
* |
|
75 |
* Revision 1.1 2006/08/10 12:03:43 jorpiell |
|
66 | 76 |
* Se usa el nuevo driver de GML de remoteServices |
67 | 77 |
* |
68 | 78 |
* |
... | ... | |
86 | 96 |
} |
87 | 97 |
|
88 | 98 |
public Object createSimpleFeature(String element, Object geometry, ArrayList params, ArrayList values) { |
89 |
Object[] attr = null;
|
|
90 |
Value[] value = getValues(values);
|
|
91 |
IFeature feature = new DefaultFeature((IGeometry)geometry,value);
|
|
92 |
return new FeatureWithAttributes(feature,params,value);
|
|
99 |
ArrayList fmapParams = getParams((ArrayList)params.get(1));
|
|
100 |
Value[] fmapValues = getValues((ArrayList)params.get(1),(ArrayList)values.get(1));
|
|
101 |
IFeature feature = new DefaultFeature((IGeometry)geometry,fmapValues);
|
|
102 |
return new FeatureWithAttributes(feature,fmapParams,fmapValues);
|
|
93 | 103 |
} |
94 | 104 |
|
95 | 105 |
public Object createGeometry(String gmlGeometry) { |
... | ... | |
103 | 113 |
return null; |
104 | 114 |
} |
105 | 115 |
|
116 |
private ArrayList getParams(ArrayList params){ |
|
117 |
ArrayList fmapParams = new ArrayList(); |
|
118 |
for (int i=0 ; i<params.size() ; i++){ |
|
119 |
if (!(params.get(i) instanceof ArrayList)){ |
|
120 |
fmapParams.add(params.get(i)); |
|
121 |
} |
|
122 |
} |
|
123 |
return fmapParams; |
|
124 |
} |
|
125 |
|
|
126 |
private Value[] getValues(ArrayList params,ArrayList values){ |
|
127 |
int i = 0; |
|
128 |
ArrayList fmapValues = new ArrayList(); |
|
129 |
while(i<params.size()){ |
|
130 |
if ((i+1 < params.size()) && (params.get(i+1) instanceof ArrayList)){ |
|
131 |
ComplexValue value = ValueFactory.createComplexValue((String)params.get(i)); |
|
132 |
ArrayList subParams = getParams((ArrayList)params.get(i+1)); |
|
133 |
Value[] subValues = getValues((ArrayList)params.get(i+1),(ArrayList)values.get(i+1)); |
|
134 |
for (int j=0 ; j<subParams.size() ; j++){ |
|
135 |
value.put(subParams.get(j),subValues[j]); |
|
136 |
} |
|
137 |
fmapValues.add(value); |
|
138 |
i = i + 2; |
|
139 |
}else{ |
|
140 |
fmapValues.add(getValue(values.get(i))); |
|
141 |
i++; |
|
142 |
} |
|
143 |
} |
|
144 |
Value[] returnValues = new Value[fmapValues.size()]; |
|
145 |
for (int k=0 ; k<fmapValues.size() ; k++){ |
|
146 |
returnValues[k] = (Value)fmapValues.get(k); |
|
147 |
} |
|
148 |
return returnValues; |
|
149 |
} |
|
150 |
|
|
106 | 151 |
/** |
107 | 152 |
* Gets the attributes |
108 | 153 |
* @param attr |
109 | 154 |
* @return |
110 | 155 |
*/ |
111 |
private Value[] getValues(ArrayList attr) { |
|
112 |
Value[] values = new Value[attr.size()]; |
|
113 |
|
|
114 |
for (int i=0;i<attr.size();i++){ |
|
115 |
if (attr.get(i)!=null){ |
|
116 |
if (attr.get(i) instanceof Double){ |
|
117 |
values[i]=ValueFactory.createValue(((Double)attr.get(i)).doubleValue()); |
|
118 |
}else if (attr.get(i) instanceof String){ |
|
119 |
values[i]=ValueFactory.createValue(String.valueOf(attr.get(i))); |
|
120 |
}else if (attr.get(i) instanceof Long){ |
|
121 |
values[i]=ValueFactory.createValue(((Long)attr.get(i)).longValue()); |
|
122 |
}else if (attr.get(i) instanceof Integer){ |
|
123 |
values[i]=ValueFactory.createValue(((Integer)attr.get(i)).intValue()); |
|
124 |
}else if (attr.get(i) instanceof Float){ |
|
125 |
values[i]=ValueFactory.createValue(((Float)attr.get(i)).floatValue()); |
|
126 |
}else if (attr.get(i) instanceof Short){ |
|
127 |
values[i]=ValueFactory.createValue(((Short)attr.get(i)).shortValue()); |
|
128 |
}else if (attr.get(i) instanceof Boolean){ |
|
129 |
values[i]=ValueFactory.createValue(((Boolean)attr.get(i)).booleanValue()); |
|
130 |
}else if (attr.get(i) instanceof Date){ |
|
131 |
values[i]=ValueFactory.createValue(((Date)attr.get(i))); |
|
132 |
} |
|
133 |
}else{ |
|
134 |
values[i]=ValueFactory.createValue(""); |
|
135 |
} |
|
156 |
private Value getValue(Object attr) { |
|
157 |
if (attr instanceof Double){ |
|
158 |
return ValueFactory.createValue(((Double)attr).doubleValue()); |
|
159 |
}else if (attr instanceof String){ |
|
160 |
return ValueFactory.createValue(String.valueOf(attr)); |
|
161 |
}else if (attr instanceof Long){ |
|
162 |
return ValueFactory.createValue(((Long)attr).longValue()); |
|
163 |
}else if (attr instanceof Integer){ |
|
164 |
return ValueFactory.createValue(((Integer)attr).intValue()); |
|
165 |
}else if (attr instanceof Float){ |
|
166 |
return ValueFactory.createValue(((Float)attr).floatValue()); |
|
167 |
}else if (attr instanceof Short){ |
|
168 |
return ValueFactory.createValue(((Short)attr).shortValue()); |
|
169 |
}else if (attr instanceof Boolean){ |
|
170 |
return ValueFactory.createValue(((Boolean)attr).booleanValue()); |
|
171 |
}else if (attr instanceof Date){ |
|
172 |
return ValueFactory.createValue(((Date)attr)); |
|
136 | 173 |
} |
137 |
return values;
|
|
174 |
return ValueFactory.createValue(((String)""));
|
|
138 | 175 |
} |
139 | 176 |
|
140 | 177 |
public class FeatureWithAttributes{ |
Also available in: Unified diff