Revision 32213 branches/v2_0_0_prep/extensions/org.gvsig.oracle/src/org/gvsig/fmap/dal/store/oracle/OracleUtils.java
OracleUtils.java | ||
---|---|---|
74 | 74 |
import org.gvsig.fmap.geom.aggregate.impl.MultiPoint2DZ; |
75 | 75 |
import org.gvsig.fmap.geom.complex.Complex; |
76 | 76 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
77 |
import org.gvsig.fmap.geom.impl.DefaultGeometryManager; |
|
77 | 78 |
import org.gvsig.fmap.geom.primitive.Curve; |
78 | 79 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
80 |
import org.gvsig.fmap.geom.primitive.NullGeometry; |
|
79 | 81 |
import org.gvsig.fmap.geom.primitive.Point; |
80 | 82 |
import org.gvsig.fmap.geom.primitive.Primitive; |
81 | 83 |
import org.gvsig.fmap.geom.primitive.Surface; |
82 | 84 |
import org.gvsig.fmap.geom.primitive.impl.Circle2D; |
83 | 85 |
import org.gvsig.fmap.geom.primitive.impl.Curve2DZ; |
86 |
// import org.gvsig.fmap.geom.primitive.impl.DefaultNullGeometry; |
|
87 |
import org.gvsig.fmap.geom.primitive.impl.DefaultNullGeometry; |
|
84 | 88 |
import org.gvsig.fmap.geom.primitive.impl.Point2DZ; |
85 | 89 |
import org.gvsig.fmap.geom.primitive.impl.Surface2D; |
86 | 90 |
import org.gvsig.fmap.geom.primitive.impl.Surface2DZ; |
91 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
92 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
87 | 93 |
import org.gvsig.oracle.utils.LineString3D; |
94 |
import org.gvsig.tools.ToolsLocator; |
|
88 | 95 |
|
89 | 96 |
import com.vividsolutions.jts.algorithm.CGAlgorithms; |
90 | 97 |
import com.vividsolutions.jts.geom.Coordinate; |
... | ... | |
176 | 183 |
surface.setGeneralPath(gpx); |
177 | 184 |
for (int i = 0; i < z.size(); i++) { |
178 | 185 |
surface |
179 |
.setCoordinateAt(i, 3, ((Double) z.get(i))
|
|
186 |
.setCoordinateAt(i, 2, ((Double) z.get(i))
|
|
180 | 187 |
.doubleValue()); |
181 | 188 |
} |
182 | 189 |
return surface; |
... | ... | |
185 | 192 |
Geometry.SUBTYPES.GEOM2DZ); |
186 | 193 |
curve.setGeneralPath(gpx); |
187 | 194 |
for (int i = 0; i < z.size(); i++) { |
188 |
curve.setCoordinateAt(i, 3, ((Double) z.get(i)).doubleValue());
|
|
195 |
curve.setCoordinateAt(i, 2, ((Double) z.get(i)).doubleValue());
|
|
189 | 196 |
} |
190 | 197 |
return curve; |
191 | 198 |
} |
... | ... | |
2084 | 2091 |
/** |
2085 | 2092 |
* Utility method to deal with oracle coordinate arrays. |
2086 | 2093 |
*/ |
2087 |
public static ARRAY getDevelopedOrdsArray(ARRAY ords) { |
|
2094 |
public static ARRAY getDevelopedOrdsArray(ARRAY ords, int dim) {
|
|
2088 | 2095 |
ARRAY _resp = null; |
2089 | 2096 |
|
2090 | 2097 |
try { |
2091 |
Datum[] resp = new Datum[10]; |
|
2098 |
int n = 5*2; // dim = 2, ignored parameter dim |
|
2099 |
Datum[] resp = new Datum[n]; |
|
2092 | 2100 |
Datum[] corners = ords.getOracleArray(); |
2093 | 2101 |
|
2094 |
// x |
|
2095 |
resp[0] = corners[0]; |
|
2096 |
resp[2] = corners[2]; |
|
2097 |
resp[4] = corners[2]; |
|
2098 |
resp[6] = corners[0]; |
|
2099 |
resp[8] = corners[0]; |
|
2100 |
|
|
2101 |
// y |
|
2102 |
resp[1] = corners[1]; |
|
2103 |
resp[3] = corners[1]; |
|
2104 |
resp[5] = corners[3]; |
|
2105 |
resp[7] = corners[3]; |
|
2106 |
resp[9] = corners[1]; |
|
2102 |
for (int i=0; i<5; i++) { |
|
2103 |
resp[i*2] = ((i==2) || (i==3)) ? corners[dim] : corners[0]; |
|
2104 |
} |
|
2105 |
for (int i=0; i<5; i++) { |
|
2106 |
resp[1+i*2] = ((i==2) || (i==3)) ? corners[dim+1] : corners[1]; |
|
2107 |
} |
|
2107 | 2108 |
_resp = new ARRAY(ords.getDescriptor(), ords |
2108 | 2109 |
.getInternalConnection(), resp); |
2109 | 2110 |
} catch (SQLException se) { |
... | ... | |
2136 | 2137 |
infoARRAY = (ARRAY) aux[3]; |
2137 | 2138 |
ordsARRAY = (ARRAY) aux[4]; |
2138 | 2139 |
|
2139 |
if (polStructIsRectStruct(infoARRAY, ordsARRAY)) { |
|
2140 |
infoARRAY = getDevelopedInfoArray(infoARRAY); |
|
2141 |
ordsARRAY = getDevelopedOrdsArray(ordsARRAY); |
|
2142 |
} |
|
2143 |
|
|
2144 | 2140 |
dims = ((NUMBER) aux[0]).intValue() / 1000; |
2145 | 2141 |
|
2146 | 2142 |
if (dims == 0) { |
2147 | 2143 |
dims = 2; |
2148 | 2144 |
} |
2149 | 2145 |
|
2146 |
if (polStructIsRectStruct(infoARRAY, ordsARRAY)) { |
|
2147 |
infoARRAY = getDevelopedInfoArray(infoARRAY); |
|
2148 |
ordsARRAY = getDevelopedOrdsArray(ordsARRAY, dims); |
|
2149 |
// rect is always 2d |
|
2150 |
dims = 2; |
|
2151 |
} |
|
2152 |
|
|
2150 | 2153 |
info_array = (Datum[]) infoARRAY.getOracleArray(); |
2151 | 2154 |
ords_array = (Datum[]) ordsARRAY.getOracleArray(); |
2152 | 2155 |
info_array_size = info_array.length / 3; |
... | ... | |
2795 | 2798 |
geom = geomManager |
2796 | 2799 |
.createSurface(gpx, Geometry.SUBTYPES.GEOM2DZ); |
2797 | 2800 |
for (int i = 0; i < z.length; i++) { |
2798 |
((Surface2DZ) geom).setCoordinateAt(i, 3, z[i]);
|
|
2801 |
((Surface2DZ) geom).setCoordinateAt(i, 2, z[i]);
|
|
2799 | 2802 |
} |
2800 | 2803 |
} |
2801 | 2804 |
} |
... | ... | |
2866 | 2869 |
double[] z = getIndBigDecimalModule(ords, 2, dim); |
2867 | 2870 |
geom = geomManager.createCurve(gpx, Geometry.SUBTYPES.GEOM2DZ); |
2868 | 2871 |
for (int i = 0; i < z.length; i++) { |
2869 |
((Curve2DZ) geom).setCoordinateAt(i, 3, z[i]);
|
|
2872 |
((Curve2DZ) geom).setCoordinateAt(i, 2, z[i]);
|
|
2870 | 2873 |
} |
2871 | 2874 |
} |
2872 | 2875 |
|
... | ... | |
2922 | 2925 |
if (no_po == 1) { |
2923 | 2926 |
geom = geomManager.createPoint(x[0], y[0], |
2924 | 2927 |
Geometry.SUBTYPES.GEOM2DZ); |
2925 |
((Point2DZ) geom).setCoordinateAt(3, z[0]);
|
|
2928 |
((Point2DZ) geom).setCoordinateAt(2, z[0]);
|
|
2926 | 2929 |
} else { |
2927 | 2930 |
geom = geomManager.create(Geometry.TYPES.MULTIPOINT, |
2928 | 2931 |
Geometry.SUBTYPES.GEOM2DZ); |
... | ... | |
2933 | 2936 |
Geometry.SUBTYPES.GEOM2DZ); |
2934 | 2937 |
pto.setX(x[i]); |
2935 | 2938 |
pto.setY(y[i]); |
2936 |
pto.setCoordinateAt(3, z[i]);
|
|
2939 |
pto.setCoordinateAt(2, z[i]);
|
|
2937 | 2940 |
((MultiPoint2DZ) geom).addPoint(pto); |
2938 | 2941 |
} |
2939 | 2942 |
} |
... | ... | |
2981 | 2984 |
Geometry.TYPES.POINT, Geometry.SUBTYPES.GEOM2DZ); |
2982 | 2985 |
point.setX(x); |
2983 | 2986 |
point.setY(y); |
2984 |
point.setCoordinateAt(3, z);
|
|
2987 |
point.setCoordinateAt(2, z);
|
|
2985 | 2988 |
geom = point; |
2986 | 2989 |
} |
2987 | 2990 |
|
... | ... | |
3812 | 3815 |
String __tablesrid, |
3813 | 3816 |
Connection _conn) { |
3814 | 3817 |
|
3815 |
GeometryManager gm = GeometryLocator.getGeometryManager(); |
|
3816 |
|
|
3817 | 3818 |
if (st == null) { |
3818 | 3819 |
Geometry aux = null; |
3819 |
try { |
|
3820 |
aux = gm.createNullGeometry(SUBTYPES.GEOM2D); |
|
3821 |
} catch (CreateGeometryException e) { |
|
3822 |
logger.error("While creating null Geometry: " + e.getMessage()); |
|
3823 |
} |
|
3820 |
aux = createNullGeometry(SUBTYPES.GEOM2D); |
|
3824 | 3821 |
return aux; |
3825 | 3822 |
} |
3826 | 3823 |
|
... | ... | |
3839 | 3836 |
} |
3840 | 3837 |
|
3841 | 3838 |
int subty = getSubTypeFromDims(dim); |
3842 |
Geometry ig = gm.createNullGeometry(subty);
|
|
3839 |
Geometry ig = createNullGeometry(subty); |
|
3843 | 3840 |
|
3844 | 3841 |
if (isActuallyACollection(the_data)) { |
3845 | 3842 |
jgtype = TYPES.AGGREGATE; |
... | ... | |
4117 | 4114 |
Iterator<Feature> it = set.iterator(); |
4118 | 4115 |
while (it.hasNext()) { |
4119 | 4116 |
Feature feat = it.next(); |
4120 |
isrs = new Integer(feat.getInt("EPSG"));
|
|
4117 |
isrs = new Integer(Math.round((float) feat.getDouble("EPSG")));
|
|
4121 | 4118 |
} |
4122 | 4119 |
} |
4123 | 4120 |
} catch (DataException e) { |
... | ... | |
4176 | 4173 |
return resp; |
4177 | 4174 |
} |
4178 | 4175 |
|
4176 |
public static Geometry createNullGeometry(int stype) { |
|
4177 |
|
|
4178 |
Geometry ig = null; |
|
4179 |
GeometryType nullgt = null;; |
|
4180 |
try { |
|
4181 |
GeometryManager gm = GeometryLocator.getGeometryManager(); |
|
4182 |
nullgt = ((DefaultGeometryManager) gm).getGeometryType(DefaultNullGeometry.class.getName()); |
|
4183 |
ig = new DefaultNullGeometry(nullgt); |
|
4184 |
} catch (GeometryTypeNotSupportedException e) { |
|
4185 |
logger.error("While creating null geom: " + e.getMessage()); |
|
4186 |
return null; |
|
4187 |
} |
|
4188 |
return ig; |
|
4189 |
|
|
4190 |
} |
|
4191 |
|
|
4179 | 4192 |
} |
Also available in: Unified diff