7 |
7 |
import java.util.ArrayList;
|
8 |
8 |
import java.util.List;
|
9 |
9 |
|
|
10 |
import org.cresques.cts.ICoordTrans;
|
|
11 |
import org.cresques.cts.IProjection;
|
10 |
12 |
import org.slf4j.LoggerFactory;
|
11 |
13 |
|
12 |
14 |
import org.gvsig.compat.print.PrintAttributes;
|
... | ... | |
21 |
23 |
import org.gvsig.fmap.geom.exception.CreateGeometryException;
|
22 |
24 |
import org.gvsig.fmap.geom.operation.GeometryOperationException;
|
23 |
25 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
|
|
26 |
import org.gvsig.fmap.geom.primitive.Envelope;
|
24 |
27 |
import org.gvsig.fmap.geom.primitive.Point;
|
25 |
28 |
import org.gvsig.fmap.mapcontext.MapContext;
|
26 |
29 |
import org.gvsig.fmap.mapcontext.ViewPort;
|
... | ... | |
158 |
161 |
fields.add(getColorField());
|
159 |
162 |
}
|
160 |
163 |
|
161 |
|
FeatureStore featureStore=layer.getFeatureStore();
|
|
164 |
FeatureStore featureStore = layer.getFeatureStore();
|
|
165 |
ICoordTrans ct = layer.getCoordTrans();
|
162 |
166 |
|
163 |
|
String geomName=featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName();
|
|
167 |
String geomName = featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName();
|
164 |
168 |
fields.add(geomName);
|
165 |
169 |
|
166 |
|
FeatureQuery featureQuery=featureStore.createFeatureQuery();
|
|
170 |
if (viewPort.getAdjustedEnvelope().contains(
|
|
171 |
layer.getFullEnvelope())) {
|
|
172 |
/*
|
|
173 |
* viewport contains layer completely
|
|
174 |
*/
|
|
175 |
set = featureStore.getFeatureSet();
|
|
176 |
} else {
|
|
177 |
/*
|
|
178 |
* view port does not contain layer completely
|
|
179 |
*/
|
|
180 |
IntersectsEnvelopeEvaluator iee = null;
|
|
181 |
|
|
182 |
IProjection data_proj = null;
|
|
183 |
Envelope env_in_store_crs = null;
|
167 |
184 |
|
168 |
|
featureQuery.setAttributeNames((String[]) fields.toArray(new String[fields.size()]));
|
169 |
|
// TODO no set filter y layer is contained totaly in viewPort
|
170 |
|
IntersectsEnvelopeEvaluator iee = new IntersectsEnvelopeEvaluator(
|
171 |
|
viewPort.getAdjustedEnvelope(),
|
172 |
|
viewPort.getProjection(),
|
173 |
|
featureStore.getDefaultFeatureType(),
|
174 |
|
geomName);
|
175 |
|
|
176 |
|
featureQuery.setFilter(iee);
|
177 |
|
set = featureStore
|
178 |
|
.getFeatureSet(featureQuery);
|
179 |
|
|
|
185 |
if (ct == null) {
|
|
186 |
env_in_store_crs = viewPort.getAdjustedEnvelope();
|
|
187 |
data_proj = viewPort.getProjection();
|
|
188 |
} else {
|
|
189 |
env_in_store_crs = viewPort.getAdjustedEnvelope().convert(
|
|
190 |
ct.getInverted());
|
|
191 |
data_proj = ct.getPOrig();
|
|
192 |
}
|
180 |
193 |
|
|
194 |
iee = new IntersectsEnvelopeEvaluator(
|
|
195 |
env_in_store_crs,
|
|
196 |
data_proj,
|
|
197 |
featureStore.getDefaultFeatureType(),
|
|
198 |
geomName);
|
|
199 |
FeatureQuery featureQuery = featureStore.createFeatureQuery();
|
|
200 |
featureQuery.setAttributeNames((String[]) fields.toArray(new String[fields.size()]));
|
|
201 |
featureQuery.setFilter(iee);
|
|
202 |
set = featureStore.getFeatureSet(featureQuery);
|
|
203 |
}
|
|
204 |
|
|
205 |
/*
|
|
206 |
* 'set' now has the features that have to be labeled
|
|
207 |
*/
|
181 |
208 |
iterator = set.fastIterator();
|
182 |
209 |
while(iterator.hasNext()){
|
183 |
210 |
if (cancel.isCanceled()){
|
... | ... | |
266 |
293 |
Geometry geom = feature.getDefaultGeometry();
|
267 |
294 |
sym.setText(feature.getString(fields.get(textPos)));
|
268 |
295 |
sym.setRotation(rotation);
|
|
296 |
|
|
297 |
if (ct != null) {
|
|
298 |
/*
|
|
299 |
* Reproject from store CRS to view CRS
|
|
300 |
*/
|
|
301 |
geom = geom.cloneGeometry();
|
|
302 |
geom.reProject(ct);
|
|
303 |
}
|
269 |
304 |
|
270 |
305 |
Point p = createLabelPoint(geom);
|
271 |
306 |
if( p != null ) {
|