Revision 35771

View differences:

branches/dal_time_support/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVect.java
111 111
import org.gvsig.tools.persistence.PersistenceManager;
112 112
import org.gvsig.tools.persistence.PersistentState;
113 113
import org.gvsig.tools.persistence.exception.PersistenceException;
114
import org.gvsig.tools.persistence.exception.PersistenceRuntimeException;
114 115
import org.gvsig.tools.task.Cancellable;
115 116

  
116 117
/**
......
578 579
     * @throws ReadException
579 580
     */
580 581
    public int getShapeType() throws ReadException {
581
        if (typeShape == -1) {
582
            FeatureType featureType;
583
            try {
584
                featureType =
585
                    (((FeatureStore) getDataStore()).getDefaultFeatureType());
586
            } catch (DataException e) {
587
                throw new ReadException(getName(), e);
588
            }
589
            int indexGeom = featureType.getDefaultGeometryAttributeIndex();
590
            typeShape =
591
                featureType.getAttributeDescriptor(indexGeom).getGeometryType();
592
        }
593
        return typeShape;
582
    	if (typeShape == -1) {
583
    		FeatureType featureType = null;
584
    		try {
585
    			if( getDataStore()!=null ){
586
    				featureType =
587
    					(((FeatureStore) getDataStore()).getDefaultFeatureType());
588
    			}
589
    		} catch (DataException e) {
590
    			throw new ReadException(getName(), e);
591
    		}
592
    		if( featureType!=null ){
593
    			int indexGeom = featureType.getDefaultGeometryAttributeIndex();
594
    			typeShape =
595
    				featureType.getAttributeDescriptor(indexGeom).getGeometryType();
596
    		}
597
    	}
598
    	return typeShape;
594 599
    }
595 600

  
596 601
    public void saveToState(PersistentState state) throws PersistenceException {
......
661 666
    public void loadFromState(PersistentState state) throws PersistenceException {
662 667

  
663 668
        super.loadFromState(state);
664

  
665
        DataStore store = (DataStore) state.get("featureStore");
669
        DataStore store = null;
666 670
        try {
671
        	store = (DataStore) state.get("featureStore");
672
        } catch (PersistenceRuntimeException e) {
673
			this.setAvailable(false);
674
			return;
675
		}
676
        try {
667 677
            this.setDataStore(store);
668 678
        } catch (LoadLayerException e) {
669 679
            throw new PersistenceException("While loading FLyrVect from state.",
......
1002 1012
    public void reload() throws ReloadLayerException {
1003 1013
        super.reload();
1004 1014
        try {
1005
            DataManager dataManager = DALLocator.getDataManager();
1006
            DataStoreParameters storeParameters;
1007

  
1008
            storeParameters = getFeatureStore().getParameters();
1009

  
1010
            DataStore dataStore = dataManager.createStore(storeParameters);
1011
            setDataStore(dataStore);
1012 1015
            getFeatureStore().refresh();
1013 1016
        } catch (Exception e) {
1014 1017
            throw new ReloadLayerException(getName(), e);
1015 1018
        }
1016
        // try {
1017
        // this.source.getDriver().reload();
1018
        // if (this.getLegend() == null) {
1019
        // if (this.getRecordset().getDriver() instanceof WithDefaultLegend) {
1020
        // WithDefaultLegend aux = (WithDefaultLegend)
1021
        // this.getRecordset().getDriver();
1022
        // this.setLegend((IVectorLegend) aux.getDefaultLegend());
1023
        // this.setLabelingStrategy(aux.getDefaultLabelingStrategy());
1024
        // } else {
1025
        // this.setLegend(LegendFactory.createSingleSymbolLegend(
1026
        // this.getShapeType()));
1027
        // }
1028
        // }
1029
        //
1030
        // } catch (LegendLayerException e) {
1031
        // this.setAvailable(false);
1032
        // throw new ReloadLayerException(getName(),e);
1033
        // } catch (ReadException e) {
1034
        // this.setAvailable(false);
1035
        // throw new ReloadLayerException(getName(),e);
1036
        // }
1037

  
1038 1019
    }
1039 1020

  
1040 1021
    protected void setLoadSelection(Object xml) {
......
1305 1286

  
1306 1287
    }
1307 1288

  
1289
    /**
1290
     * It return the {@link FeatureSet} that intersects with the envelope.
1291
     * @param envelope
1292
     *          envelope that defines the area for the query.
1293
     * @param featureType
1294
     *          only the features with this feature type are used in
1295
     *          the query.    
1296
     * @return
1297
     *          the set of features that intersect with the envelope.
1298
     * @throws DataException
1299
     */
1308 1300
    public FeatureSet queryByEnvelope(Envelope envelope, FeatureType featureType) throws DataException {
1309 1301
        return queryByEnvelope(envelope, featureType, null);
1310 1302
    }
1311 1303

  
1304
    /**
1305
     * It return the {@link FeatureSet} that intersects with the envelope.
1306
     * @param envelope
1307
     *          envelope that defines the area for the query.
1308
     * @param featureType
1309
     *          only the features with this feature type are used in
1310
     *          the query.
1311
     * @param names
1312
     *          the feature attributes that have to be checked.
1313
     * @return
1314
     *          the set of features that intersect with the envelope.
1315
     * @throws DataException
1316
     */
1312 1317
    public FeatureSet queryByEnvelope(Envelope envelope,
1313 1318
        FeatureType featureType,
1314 1319
        String[] names) throws DataException {
......
1322 1327
        String geomName =
1323 1328
            featureStore.getDefaultFeatureType()
1324 1329
            .getDefaultGeometryAttributeName();
1325
        ContainsEnvelopeEvaluator iee =
1326
            new ContainsEnvelopeEvaluator(envelope,
1330
        IntersectsGeometryEvaluator iee =
1331
            new IntersectsGeometryEvaluator(envelope.getGeometry(),
1327 1332
                getMapContext().getViewPort().getProjection(),
1328 1333
                featureStore.getDefaultFeatureType(),
1329 1334
                geomName);
......
1351 1356

  
1352 1357
    public DynObjectSet getInfo(org.gvsig.fmap.geom.primitive.Point p,
1353 1358
        double tolerance) throws LoadLayerException, DataException {
1354
        return queryByPoint(p,tolerance, getFeatureStore().getDefaultFeatureType()).getDynObjectSet(true);
1359
        return queryByPoint(p,tolerance, getFeatureStore().getDefaultFeatureType()).getDynObjectSet(false);
1355 1360
    }
1356 1361
    
1357 1362
    public void legendCleared(LegendClearEvent event) {

Also available in: Unified diff