Revision 294 org.gvsig.oracle/trunk/org.gvsig.oracle/org.gvsig.oracle.provider/src/main/java/org/gvsig/oracle/dal/expressionbuilderformatter/OracleGeometryParameter.java
OracleGeometryParameter.java | ||
---|---|---|
6 | 6 |
package org.gvsig.oracle.dal.expressionbuilderformatter; |
7 | 7 |
|
8 | 8 |
import java.text.MessageFormat; |
9 |
import java.util.Objects; |
|
9 | 10 |
import org.cresques.cts.IProjection; |
10 | 11 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
12 |
import org.gvsig.expressionevaluator.ExpressionBuilder.Constant; |
|
11 | 13 |
import static org.gvsig.expressionevaluator.ExpressionBuilder.PARAMETER_TYPE_CONSTANT; |
12 | 14 |
import static org.gvsig.expressionevaluator.ExpressionBuilder.PARAMETER_TYPE_VARIABLE; |
15 |
import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter; |
|
13 | 16 |
import org.gvsig.expressionevaluator.Formatter; |
14 | 17 |
import org.gvsig.expressionevaluator.GeometryExpressionBuilder; |
15 | 18 |
import static org.gvsig.expressionevaluator.GeometryExpressionBuilderHelper.PARAMETER_TYPE_GEOMETRY; |
16 | 19 |
import org.gvsig.fmap.dal.SQLBuilder; |
20 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
21 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
22 |
import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_FEATURE_TYPE; |
|
17 | 23 |
import org.gvsig.fmap.geom.Geometry; |
18 | 24 |
import org.gvsig.oracle.dal.OracleSQLBuilder; |
25 |
import static org.gvsig.oracle.dal.operations.OracleFetchFeatureTypeOperation.ORACLE_SRID_ATTR_TAG; |
|
19 | 26 |
|
20 | 27 |
/** |
21 | 28 |
* |
... | ... | |
67 | 74 |
return MessageFormat.format( |
68 | 75 |
"NVL2(({0}),SDO_GEOMETRY(({0}), ({1})),NULL)", |
69 | 76 |
"?", |
70 |
param.srs().toString(formatter)
|
|
77 |
getSRS(param)
|
|
71 | 78 |
); |
72 | 79 |
} |
73 | 80 |
} |
... | ... | |
75 | 82 |
} |
76 | 83 |
|
77 | 84 |
private String getSRS(GeometryExpressionBuilder.GeometryParameter param) { |
78 |
if( param.srs()!=null ) { |
|
79 |
return param.srs().toString(formatter); |
|
85 |
String oracle_srid = null; |
|
86 |
FeatureType featureType = (FeatureType) param.getProperty(PROP_FEATURE_TYPE); |
|
87 |
if (featureType != null) { |
|
88 |
if (param.srs() instanceof Constant) { |
|
89 |
FeatureAttributeDescriptor attr = featureType.getDefaultGeometryAttribute(); |
|
90 |
if (attr != null && attr.getTags().has(ORACLE_SRID_ATTR_TAG)) { |
|
91 |
oracle_srid = Objects.toString(attr.getTags().get(ORACLE_SRID_ATTR_TAG), null); |
|
92 |
return oracle_srid; |
|
93 |
} |
|
94 |
} else if (param.srs() instanceof Parameter) { |
|
95 |
Parameter srsParam = (Parameter) param.srs(); |
|
96 |
FeatureAttributeDescriptor attr = featureType.getDefaultGeometryAttribute(); |
|
97 |
if (attr != null && attr.getTags().has(ORACLE_SRID_ATTR_TAG)) { |
|
98 |
oracle_srid = Objects.toString(attr.getTags().get(ORACLE_SRID_ATTR_TAG), null); |
|
99 |
srsParam.value(oracle_srid); |
|
100 |
} |
|
101 |
} |
|
80 | 102 |
} |
103 |
|
|
104 |
if (param.srs() != null) { |
|
105 |
String srid = param.srs().toString(formatter); |
|
106 |
return srid; |
|
107 |
} |
|
81 | 108 |
IProjection proj = param.geometry().getProjection(); |
82 | 109 |
Object s = this.builder.srs_id(proj); |
83 | 110 |
if( s == null ) { |
Also available in: Unified diff