Revision 43040
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataManager.java | ||
---|---|---|
20 | 20 |
import org.gvsig.fmap.dal.DataStoreParameters; |
21 | 21 |
import org.gvsig.fmap.dal.DataStoreProviderFactory; |
22 | 22 |
import org.gvsig.fmap.dal.DataTypes; |
23 |
import org.gvsig.fmap.dal.ExpressionBuilder; |
|
23 | 24 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
24 | 25 |
import org.gvsig.fmap.dal.OpenErrorHandler; |
25 | 26 |
import org.gvsig.fmap.dal.Register; |
... | ... | |
36 | 37 |
import org.gvsig.fmap.dal.feature.impl.FeatureStoreFactory; |
37 | 38 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
38 | 39 |
import org.gvsig.fmap.dal.feature.paging.impl.FeaturePagingHelperImpl; |
40 |
import org.gvsig.fmap.dal.feature.spi.ExpressionBuilderBase; |
|
39 | 41 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
40 | 42 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
41 | 43 |
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider; |
... | ... | |
659 | 661 |
x = reourceLoader.getClass().getResourceAsStream(name); |
660 | 662 |
return x; |
661 | 663 |
} |
664 |
|
|
665 |
@Override |
|
666 |
public ExpressionBuilder createExpressionBuilder() { |
|
667 |
return new ExpressionBuilderBase(); |
|
668 |
} |
|
662 | 669 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataManager.java | ||
---|---|---|
382 | 382 |
public Register getServerExplorerRegister(); |
383 | 383 |
|
384 | 384 |
public Register getFeatureIndexRegister(); |
385 |
|
|
386 |
/** |
|
387 |
* Creates a default ExpressionBuilder. |
|
388 |
* |
|
389 |
* This ExpressionBuilder is not dependent on a data source, |
|
390 |
* and is not advisable to use it. |
|
391 |
* |
|
392 |
* @return the ExpressionBuilder |
|
393 |
*/ |
|
394 |
public ExpressionBuilder createExpressionBuilder(); |
|
385 | 395 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/spi/DataManagerProviderServices.java | ||
---|---|---|
29 | 29 |
import org.gvsig.fmap.dal.DataStoreFactory_v2_4; |
30 | 30 |
import org.gvsig.fmap.dal.DataStoreParameters; |
31 | 31 |
import org.gvsig.fmap.dal.DataStoreProviderFactory; |
32 |
import org.gvsig.fmap.dal.ExpressionBuilder; |
|
32 | 33 |
import org.gvsig.fmap.dal.Register; |
33 | 34 |
import org.gvsig.fmap.dal.exception.InitializeException; |
34 | 35 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
... | ... | |
147 | 148 |
* @return |
148 | 149 |
*/ |
149 | 150 |
public InputStream getResourceAsStream(Object resourcesLoader, String name); |
150 |
|
|
151 |
|
|
151 | 152 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/WithinGeometryEvaluator.java | ||
---|---|---|
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 | 44 |
|
45 |
/** |
|
46 |
* @param geometry |
|
47 |
* @param projection |
|
48 |
* @param featureType |
|
49 |
* @param geomName |
|
50 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
51 |
*/ |
|
52 |
public WithinGeometryEvaluator( |
|
53 |
Geometry geometry, |
|
54 |
IProjection projection, |
|
55 |
FeatureType featureType, |
|
56 |
String geomName |
|
57 |
) { |
|
58 |
this( |
|
59 |
geometry, |
|
60 |
projection, |
|
61 |
featureType, |
|
62 |
geomName, |
|
63 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
64 |
); |
|
65 |
} |
|
66 |
|
|
45 | 67 |
WithinGeometryEvaluator( |
46 | 68 |
Geometry geometry, |
47 | 69 |
IProjection projection, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/IntersectsEnvelopeEvaluator.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
public class IntersectsEnvelopeEvaluator extends AbstractEvaluator { |
38 | 38 |
|
39 |
private Envelope envelope; |
|
40 |
private String geomName; |
|
41 |
private boolean isDefault; |
|
42 |
private ExpressionBuilder condition; |
|
43 |
String defaultGeometryAttributeName; |
|
39 |
private final Envelope envelope; |
|
40 |
private final String geomName; |
|
41 |
private final boolean isDefault; |
|
42 |
private final String defaultGeometryAttributeName; |
|
43 |
private final IProjection projection; |
|
44 |
private final ExpressionBuilder builder; |
|
44 | 45 |
|
45 |
|
|
46 |
IntersectsEnvelopeEvaluator(Envelope envelope, |
|
47 |
IProjection envelopeProjection, FeatureType featureType, |
|
46 |
/** |
|
47 |
* @param envelope |
|
48 |
* @param envelopeProjection |
|
49 |
* @param featureType |
|
50 |
* @param geomName |
|
51 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
52 |
*/ |
|
53 |
public IntersectsEnvelopeEvaluator( |
|
54 |
Envelope envelope, |
|
55 |
IProjection envelopeProjection, |
|
56 |
FeatureType featureType, |
|
57 |
String geomName |
|
58 |
) { |
|
59 |
this( |
|
60 |
envelope, |
|
61 |
envelopeProjection, |
|
62 |
featureType, |
|
63 |
geomName, |
|
64 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
65 |
); |
|
66 |
} |
|
67 |
|
|
68 |
IntersectsEnvelopeEvaluator( |
|
69 |
Envelope envelope, |
|
70 |
IProjection envelopeProjection, |
|
71 |
FeatureType featureType, |
|
48 | 72 |
String geomName, |
49 |
ExpressionBuilder builder) { |
|
73 |
ExpressionBuilder builder |
|
74 |
) { |
|
50 | 75 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
51 | 76 |
defaultGeometryAttributeName = featureType.getDefaultGeometryAttributeName(); |
52 | 77 |
this.isDefault = defaultGeometryAttributeName.equals(geomName); |
53 | 78 |
this.envelope = envelope; |
79 |
this.projection = envelopeProjection; |
|
80 |
this.builder = builder; |
|
54 | 81 |
this.geomName = geomName; |
55 | 82 |
this.getFieldsInfo().addMatchFieldValue(geomName, envelope); |
56 |
|
|
57 |
this.condition = builder.set( |
|
58 |
builder.ST_Intersects( |
|
59 |
builder.geometry(envelope.getGeometry(), envelopeProjection), |
|
60 |
builder.ST_Envelope(builder.column(geomName)) |
|
61 |
) |
|
62 |
); |
|
63 | 83 |
} |
64 | 84 |
|
65 | 85 |
@Override |
... | ... | |
72 | 92 |
} else { |
73 | 93 |
geom = (Geometry) data.getDataValue(geomName); |
74 | 94 |
if (geom == null) { |
75 |
return Boolean.FALSE;
|
|
95 |
return false;
|
|
76 | 96 |
} |
77 | 97 |
featureEnvelope = geom.getEnvelope(); |
78 | 98 |
} |
79 | 99 |
if (envelope.intersects(featureEnvelope)) { |
80 | 100 |
return envelope.intersects(geom); |
81 | 101 |
} |
82 |
return Boolean.FALSE;
|
|
102 |
return false;
|
|
83 | 103 |
} |
84 | 104 |
|
85 | 105 |
@Override |
... | ... | |
89 | 109 |
|
90 | 110 |
@Override |
91 | 111 |
public String getSQL() { |
92 |
return this.condition.toString(); |
|
112 |
return builder.set( |
|
113 |
builder.ST_Intersects( |
|
114 |
builder.geometry(envelope.getGeometry(), this.projection), |
|
115 |
builder.ST_Envelope(builder.column(geomName)) |
|
116 |
) |
|
117 |
).toString(); |
|
93 | 118 |
} |
94 | 119 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OutGeometryEvaluator.java | ||
---|---|---|
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 | 44 |
|
45 |
/** |
|
46 |
* @param geometry |
|
47 |
* @param envelopeProjection |
|
48 |
* @param featureType |
|
49 |
* @param geomName |
|
50 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
51 |
*/ |
|
52 |
public OutGeometryEvaluator( |
|
53 |
Geometry geometry, |
|
54 |
IProjection envelopeProjection, |
|
55 |
FeatureType featureType, |
|
56 |
String geomName |
|
57 |
) { |
|
58 |
this( |
|
59 |
geometry, |
|
60 |
envelopeProjection, |
|
61 |
featureType, |
|
62 |
geomName, |
|
63 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
64 |
); |
|
65 |
} |
|
66 |
|
|
45 | 67 |
OutGeometryEvaluator( |
46 | 68 |
Geometry geometry, |
47 | 69 |
IProjection envelopeProjection, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/TouchesGeometryEvaluator.java | ||
---|---|---|
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 | 44 |
|
45 |
/** |
|
46 |
* @param geometry |
|
47 |
* @param projection |
|
48 |
* @param featureType |
|
49 |
* @param geomName |
|
50 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
51 |
*/ |
|
52 |
public TouchesGeometryEvaluator(Geometry geometry, |
|
53 |
IProjection projection, |
|
54 |
FeatureType featureType, |
|
55 |
String geomName |
|
56 |
) { |
|
57 |
this( |
|
58 |
geometry, |
|
59 |
projection, |
|
60 |
featureType, |
|
61 |
geomName, |
|
62 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
63 |
); |
|
64 |
} |
|
65 |
|
|
45 | 66 |
TouchesGeometryEvaluator(Geometry geometry, |
46 | 67 |
IProjection projection, |
47 | 68 |
FeatureType featureType, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/CrossEnvelopeEvaluator.java | ||
---|---|---|
43 | 43 |
private final ExpressionBuilder builder; |
44 | 44 |
private final IProjection projection; |
45 | 45 |
|
46 |
/** |
|
47 |
* @param envelope |
|
48 |
* @param envelopeProjection |
|
49 |
* @param featureType |
|
50 |
* @param geomName |
|
51 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
52 |
*/ |
|
53 |
public CrossEnvelopeEvaluator( |
|
54 |
Envelope envelope, |
|
55 |
IProjection envelopeProjection, |
|
56 |
FeatureType featureType, |
|
57 |
String geomName |
|
58 |
) { |
|
59 |
this( |
|
60 |
envelope, |
|
61 |
envelopeProjection, |
|
62 |
featureType, |
|
63 |
geomName, |
|
64 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
65 |
); |
|
66 |
} |
|
67 |
|
|
46 | 68 |
CrossEnvelopeEvaluator( |
47 | 69 |
Envelope envelope, |
48 | 70 |
IProjection envelopeProjection, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/ContainsGeometryEvaluator.java | ||
---|---|---|
43 | 43 |
private final ExpressionBuilder builder; |
44 | 44 |
private final IProjection projection; |
45 | 45 |
|
46 |
/** |
|
47 |
* @param geometry |
|
48 |
* @param projection |
|
49 |
* @param featureType |
|
50 |
* @param geomName |
|
51 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
52 |
*/ |
|
53 |
public ContainsGeometryEvaluator( |
|
54 |
Geometry geometry, |
|
55 |
IProjection projection, |
|
56 |
FeatureType featureType, |
|
57 |
String geomName |
|
58 |
) { |
|
59 |
this( |
|
60 |
geometry, |
|
61 |
projection, |
|
62 |
featureType, |
|
63 |
geomName, |
|
64 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
65 |
); |
|
66 |
} |
|
67 |
|
|
46 | 68 |
ContainsGeometryEvaluator( |
47 | 69 |
Geometry geometry, |
48 | 70 |
IProjection projection, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/CrossesGeometryEvaluator.java | ||
---|---|---|
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 | 44 |
|
45 |
/** |
|
46 |
* @param geometry |
|
47 |
* @param projection |
|
48 |
* @param featureType |
|
49 |
* @param geomName |
|
50 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
51 |
*/ |
|
52 |
public CrossesGeometryEvaluator( |
|
53 |
Geometry geometry, |
|
54 |
IProjection projection, |
|
55 |
FeatureType featureType, |
|
56 |
String geomName |
|
57 |
) { |
|
58 |
this( |
|
59 |
geometry, |
|
60 |
projection, |
|
61 |
featureType, |
|
62 |
geomName, |
|
63 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
64 |
); |
|
65 |
} |
|
66 |
|
|
45 | 67 |
CrossesGeometryEvaluator( |
46 | 68 |
Geometry geometry, |
47 | 69 |
IProjection projection, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/IntersectsGeometryEvaluator.java | ||
---|---|---|
28 | 28 |
import org.gvsig.fmap.dal.feature.Feature; |
29 | 29 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
30 | 30 |
import org.gvsig.fmap.dal.feature.FeatureType; |
31 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
32 | 31 |
import org.gvsig.fmap.geom.Geometry; |
33 | 32 |
import org.gvsig.tools.evaluator.AbstractEvaluator; |
34 | 33 |
import org.gvsig.tools.evaluator.EvaluatorData; |
... | ... | |
36 | 35 |
|
37 | 36 |
public class IntersectsGeometryEvaluator extends AbstractEvaluator { |
38 | 37 |
|
39 |
private String geomName; |
|
40 |
private Geometry geometry; |
|
41 |
private Geometry geometryTrans; |
|
42 |
private boolean isDefault; |
|
43 |
private ExpressionBuilder condition; |
|
38 |
private final String geomName; |
|
39 |
private final Geometry geometry; |
|
40 |
private final Geometry geometryTrans; |
|
41 |
private final boolean isDefault; |
|
42 |
private final ExpressionBuilder builder; |
|
43 |
private final IProjection projection; |
|
44 | 44 |
|
45 |
IntersectsGeometryEvaluator(Geometry geometry, |
|
46 |
IProjection projection, FeatureType featureType, |
|
45 |
/** |
|
46 |
* @param geometry |
|
47 |
* @param projection |
|
48 |
* @param featureType |
|
49 |
* @param geomName |
|
50 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
51 |
*/ |
|
52 |
public IntersectsGeometryEvaluator( |
|
53 |
Geometry geometry, |
|
54 |
IProjection projection, |
|
55 |
FeatureType featureType, |
|
56 |
String geomName |
|
57 |
) { |
|
58 |
this( |
|
59 |
geometry, |
|
60 |
projection, |
|
61 |
featureType, |
|
62 |
geomName, |
|
63 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
64 |
); |
|
65 |
} |
|
66 |
|
|
67 |
IntersectsGeometryEvaluator( |
|
68 |
Geometry geometry, |
|
69 |
IProjection projection, |
|
70 |
FeatureType featureType, |
|
47 | 71 |
String geomName, |
48 |
ExpressionBuilder builder) { |
|
72 |
ExpressionBuilder builder |
|
73 |
) { |
|
49 | 74 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
50 | 75 |
.get(geomName); |
51 | 76 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
52 | 77 |
this.geometry = geometry; |
78 |
this.projection = projection; |
|
79 |
this.builder = builder; |
|
53 | 80 |
this.geometryTrans = geometry.cloneGeometry(); |
54 | 81 |
ICoordTrans ct = null; |
55 | 82 |
|
... | ... | |
63 | 90 |
} |
64 | 91 |
this.geomName = geomName; |
65 | 92 |
this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans); |
66 |
this.condition = builder.set( |
|
67 |
builder.ST_Intersects( |
|
68 |
builder.geometry(geometry, projection), |
|
69 |
builder.column(geomName) |
|
70 |
) |
|
71 |
); |
|
72 | 93 |
} |
73 | 94 |
|
74 | 95 |
@Override |
75 | 96 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
76 | 97 |
try { |
77 |
Geometry geom ;
|
|
98 |
Geometry geom; |
|
78 | 99 |
if (isDefault) { |
79 | 100 |
Feature feature = (Feature) data.getContextValue("feature"); |
80 | 101 |
geom = feature.getDefaultGeometry(); |
... | ... | |
99 | 120 |
|
100 | 121 |
@Override |
101 | 122 |
public String getSQL() { |
102 |
return this.condition.toString(); |
|
123 |
return builder.set( |
|
124 |
builder.ST_Intersects( |
|
125 |
builder.geometry(geometry, this.projection), |
|
126 |
builder.column(geomName) |
|
127 |
) |
|
128 |
).toString(); |
|
103 | 129 |
} |
104 | 130 |
|
105 | 131 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/DisjointGeometryEvaluator.java | ||
---|---|---|
43 | 43 |
private final ExpressionBuilder builder; |
44 | 44 |
private final IProjection projection; |
45 | 45 |
|
46 |
/** |
|
47 |
* @param geometry |
|
48 |
* @param projection |
|
49 |
* @param featureType |
|
50 |
* @param geomName |
|
51 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
52 |
*/ |
|
53 |
public DisjointGeometryEvaluator( |
|
54 |
Geometry geometry, |
|
55 |
IProjection projection, |
|
56 |
FeatureType featureType, |
|
57 |
String geomName |
|
58 |
) { |
|
59 |
this( |
|
60 |
geometry, |
|
61 |
projection, |
|
62 |
featureType, |
|
63 |
geomName, |
|
64 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
65 |
); |
|
66 |
} |
|
67 |
|
|
46 | 68 |
DisjointGeometryEvaluator( |
47 | 69 |
Geometry geometry, |
48 | 70 |
IProjection projection, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/EqualsGeometryEvaluator.java | ||
---|---|---|
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 | 44 |
|
45 |
/** |
|
46 |
* @param geometry |
|
47 |
* @param projection |
|
48 |
* @param featureType |
|
49 |
* @param geomName |
|
50 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
51 |
*/ |
|
52 |
public EqualsGeometryEvaluator( |
|
53 |
Geometry geometry, |
|
54 |
IProjection projection, |
|
55 |
FeatureType featureType, |
|
56 |
String geomName |
|
57 |
) { |
|
58 |
this( |
|
59 |
geometry, |
|
60 |
projection, |
|
61 |
featureType, |
|
62 |
geomName, |
|
63 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
64 |
); |
|
65 |
} |
|
66 |
|
|
45 | 67 |
EqualsGeometryEvaluator( |
46 | 68 |
Geometry geometry, |
47 | 69 |
IProjection projection, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OverlapsGeometryEvaluator.java | ||
---|---|---|
47 | 47 |
private final ExpressionBuilder builder; |
48 | 48 |
private final IProjection projection; |
49 | 49 |
|
50 |
/** |
|
51 |
* @param geometry |
|
52 |
* @param projection |
|
53 |
* @param featureType |
|
54 |
* @param geomName |
|
55 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
56 |
*/ |
|
57 |
public OverlapsGeometryEvaluator( |
|
58 |
Geometry geometry, |
|
59 |
IProjection projection, |
|
60 |
FeatureType featureType, |
|
61 |
String geomName |
|
62 |
) { |
|
63 |
this( |
|
64 |
geometry, |
|
65 |
projection, |
|
66 |
featureType, |
|
67 |
geomName, |
|
68 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
69 |
); |
|
70 |
} |
|
71 |
|
|
50 | 72 |
OverlapsGeometryEvaluator( |
51 | 73 |
Geometry geometry, |
52 | 74 |
IProjection projection, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/SpatialEvaluatorsFactory.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.mapcontext.layers.vectorial; |
2 | 2 |
|
3 | 3 |
import org.cresques.cts.IProjection; |
4 |
import org.gvsig.fmap.dal.DALLocator; |
|
5 |
import org.gvsig.fmap.dal.DataManager; |
|
4 | 6 |
import org.gvsig.fmap.dal.exception.DataException; |
5 | 7 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
6 | 8 |
import org.gvsig.fmap.dal.feature.FeatureType; |
7 | 9 |
import org.gvsig.fmap.dal.ExpressionBuilder; |
8 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
9 | 10 |
import org.gvsig.fmap.geom.Geometry; |
10 | 11 |
import org.gvsig.fmap.geom.primitive.Envelope; |
11 | 12 |
import org.gvsig.tools.evaluator.Evaluator; |
... | ... | |
22 | 23 |
|
23 | 24 |
} |
24 | 25 |
|
26 |
public ExpressionBuilder createBuilder() { |
|
27 |
DataManager manager = DALLocator.getDataManager(); |
|
28 |
ExpressionBuilder builder = manager.createExpressionBuilder(); |
|
29 |
return builder; |
|
30 |
} |
|
31 |
|
|
25 | 32 |
public Evaluator intersects( |
26 | 33 |
Geometry geometry, |
27 | 34 |
IProjection projection, |
... | ... | |
79 | 86 |
String geomName, |
80 | 87 |
ExpressionBuilder builder |
81 | 88 |
){ |
82 |
return new ContainsEnvelopeEvaluator(envelope, projection, featureType, geomName); |
|
89 |
return new ContainsEnvelopeEvaluator(envelope, projection, featureType, geomName, builder);
|
|
83 | 90 |
} |
84 | 91 |
|
85 | 92 |
public Evaluator contains( |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/ContainsEnvelopeEvaluator.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License
|
|
8 |
* as published by the Free Software Foundation; either version 3
|
|
9 |
* of the License, or (at your option) any later version.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 | 23 |
package org.gvsig.fmap.mapcontext.layers.vectorial; |
25 | 24 |
|
26 | 25 |
import org.cresques.cts.IProjection; |
26 |
import org.gvsig.fmap.dal.ExpressionBuilder; |
|
27 | 27 |
|
28 |
import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException; |
|
29 | 28 |
import org.gvsig.fmap.dal.feature.Feature; |
30 | 29 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
31 | 30 |
import org.gvsig.fmap.dal.feature.FeatureType; |
32 | 31 |
import org.gvsig.fmap.geom.Geometry; |
33 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
34 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
35 | 32 |
import org.gvsig.fmap.geom.primitive.Envelope; |
36 | 33 |
import org.gvsig.tools.evaluator.AbstractEvaluator; |
37 | 34 |
import org.gvsig.tools.evaluator.EvaluatorData; |
... | ... | |
39 | 36 |
|
40 | 37 |
public class ContainsEnvelopeEvaluator extends AbstractEvaluator { |
41 | 38 |
|
42 |
private Envelope envelope;
|
|
43 |
private String geomName;
|
|
44 |
private Envelope envelopeTrans;
|
|
45 |
private boolean isDefault;
|
|
46 |
private String srs;
|
|
47 |
private String envelopeWKT;
|
|
39 |
private final Envelope envelope;
|
|
40 |
private final String geomName;
|
|
41 |
private final Envelope envelopeTrans;
|
|
42 |
private final boolean isDefault;
|
|
43 |
private final ExpressionBuilder builder;
|
|
44 |
private final IProjection projection;
|
|
48 | 45 |
|
49 |
ContainsEnvelopeEvaluator(Envelope envelope, |
|
50 |
IProjection envelopeProjection, FeatureType featureType, |
|
51 |
String geomName) { |
|
52 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
|
53 |
.get(geomName); |
|
54 |
|
|
55 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals( |
|
56 |
geomName); |
|
57 |
this.envelope = envelope; |
|
58 |
// this.srs = envelopeProjection.getAbrev(); |
|
59 |
// this.projection=CRSFactory.getCRS(fad.getSRS()); |
|
60 |
// this.envelopeProjection=envelopeProjection; |
|
46 |
/** |
|
47 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
48 |
* @param envelope |
|
49 |
* @param envelopeProjection |
|
50 |
* @param featureType |
|
51 |
* @param geomName |
|
52 |
*/ |
|
53 |
public ContainsEnvelopeEvaluator( |
|
54 |
Envelope envelope, |
|
55 |
IProjection envelopeProjection, |
|
56 |
FeatureType featureType, |
|
57 |
String geomName |
|
58 |
) { |
|
59 |
this( |
|
60 |
envelope, |
|
61 |
envelopeProjection, |
|
62 |
featureType, |
|
63 |
geomName, |
|
64 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
65 |
); |
|
66 |
} |
|
67 |
|
|
68 |
ContainsEnvelopeEvaluator( |
|
69 |
Envelope envelope, |
|
70 |
IProjection envelopeProjection, |
|
71 |
FeatureType featureType, |
|
72 |
String geomName, |
|
73 |
ExpressionBuilder builder |
|
74 |
) { |
|
75 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
|
76 |
.get(geomName); |
|
77 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
|
78 |
this.projection = envelopeProjection; |
|
79 |
this.builder = builder; |
|
80 |
this.envelope = envelope; |
|
81 |
// this.srs = envelopeProjection.getAbrev(); |
|
82 |
// this.projection=CRSFactory.getCRS(fad.getSRS()); |
|
83 |
// this.envelopeProjection=envelopeProjection; |
|
61 | 84 |
// ICoordTrans ct = null; |
62 | 85 |
// if (!this.srs.equals(fad.getSRS())) { // FIXME comparaci�n |
63 | 86 |
// ct = envelopeProjection.getCT(fad.getSRS()); |
... | ... | |
65 | 88 |
// if (ct != null) { |
66 | 89 |
// this.envelopeTrans = envelope.convert(ct); |
67 | 90 |
// } else { |
68 |
this.envelopeTrans = envelope;
|
|
91 |
this.envelopeTrans = envelope;
|
|
69 | 92 |
// } |
70 |
this.geomName = geomName; |
|
71 |
this.srs = envelopeProjection.getAbrev(); |
|
72 |
this.getFieldsInfo().addMatchFieldValue(geomName, envelopeTrans); |
|
93 |
this.geomName = geomName; |
|
94 |
this.getFieldsInfo().addMatchFieldValue(geomName, envelopeTrans); |
|
73 | 95 |
|
74 |
}
|
|
96 |
}
|
|
75 | 97 |
|
76 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
77 |
Envelope featureEnvelope; |
|
78 |
if (isDefault) { |
|
79 |
featureEnvelope = ((Feature) data.getContextValue("feature")) |
|
80 |
.getDefaultEnvelope(); |
|
98 |
@Override |
|
99 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
100 |
Envelope featureEnvelope; |
|
101 |
if (isDefault) { |
|
102 |
featureEnvelope = ((Feature) data.getContextValue("feature")) |
|
103 |
.getDefaultEnvelope(); |
|
81 | 104 |
|
82 |
} else {
|
|
83 |
Geometry geom = (Geometry) data.getDataValue(geomName);
|
|
84 |
if( geom == null ) {
|
|
85 |
return Boolean.FALSE;
|
|
86 |
}
|
|
87 |
featureEnvelope = geom.getEnvelope();
|
|
88 |
}
|
|
89 |
return new Boolean(envelopeTrans.contains(featureEnvelope));
|
|
90 |
}
|
|
105 |
} else {
|
|
106 |
Geometry geom = (Geometry) data.getDataValue(geomName); |
|
107 |
if (geom == null) {
|
|
108 |
return false;
|
|
109 |
} |
|
110 |
featureEnvelope = geom.getEnvelope(); |
|
111 |
}
|
|
112 |
return envelopeTrans.contains(featureEnvelope);
|
|
113 |
}
|
|
91 | 114 |
|
92 |
public String getName() { |
|
93 |
return "contains in envelope"; |
|
94 |
} |
|
115 |
@Override |
|
116 |
public String getName() { |
|
117 |
return "contains in envelope"; |
|
118 |
} |
|
95 | 119 |
|
96 |
public String getSQL() { |
|
97 |
if (envelopeWKT == null) { |
|
98 |
try { |
|
99 |
envelopeWKT = envelope.getGeometry().convertToWKT(); |
|
100 |
} catch (GeometryOperationNotSupportedException e) { |
|
101 |
throw new DataEvaluatorRuntimeException(e); |
|
102 |
} catch (GeometryOperationException e) { |
|
103 |
throw new DataEvaluatorRuntimeException(e); |
|
104 |
} |
|
105 |
} |
|
106 |
return " ST_contains(ST_GeomFromText('" + envelopeWKT + "', '" + srs |
|
107 |
+ "'), ST_envelope(" + geomName + ")) "; |
|
108 |
} |
|
120 |
@Override |
|
121 |
public String getSQL() { |
|
122 |
return this.builder.set( |
|
123 |
builder.ST_Contains( |
|
124 |
builder.envelope(envelope, projection), |
|
125 |
builder.column(geomName) |
|
126 |
) |
|
127 |
).toString(); |
|
128 |
} |
|
109 | 129 |
|
110 | 130 |
} |
Also available in: Unified diff