Revision 35199

View differences:

branches/dal_time_support/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/IntersectsTimeAndEnvelopeEvaluator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
9
 * of the License, or (at your option) any later version.
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.
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.
20
 *
21
 */
22
package org.gvsig.fmap.mapcontext.layers.vectorial;
23

  
24
import org.cresques.cts.IProjection;
25

  
26
import org.gvsig.fmap.dal.feature.Feature;
27
import org.gvsig.fmap.dal.feature.FeatureType;
28
import org.gvsig.fmap.geom.primitive.Envelope;
29
import org.gvsig.timesupport.Time;
30
import org.gvsig.tools.evaluator.EvaluatorData;
31
import org.gvsig.tools.evaluator.EvaluatorException;
32

  
33

  
34
/**
35
 * @author gvSIG Team
36
 * @version $Id$
37
 *
38
 */
39
public class IntersectsTimeAndEnvelopeEvaluator extends IntersectsEnvelopeEvaluator {
40
    private Time time;
41
    private String timeName;
42
   
43
    public IntersectsTimeAndEnvelopeEvaluator(Envelope envelope, Time time,
44
        IProjection envelopeProjection, FeatureType featureType, String geomName, String timeName) {
45
        super(envelope, envelopeProjection, featureType, geomName);  
46
        this.time = time;
47
        this.timeName = timeName;
48
    }
49

  
50
    public Object evaluate(EvaluatorData data) throws EvaluatorException {
51
       if (((Boolean)super.evaluate(data)).booleanValue()){
52
           Feature feature = ((Feature) data.getContextValue("feature"));
53
           return new Boolean(time.intersects((Time)feature.get(timeName)));
54
       }
55
       return new Boolean(false);
56
    }
57

  
58
    public String getName() {       
59
        return "intersets with tima and envelope";
60
    }
61

  
62
    public String getSQL() {
63
        // TODO add the time filter!!!
64
        return super.getSQL();
65
    }
66
}
branches/dal_time_support/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/IntersectsTimeEvaluator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
9
 * of the License, or (at your option) any later version.
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.
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.
20
 *
21
 */
22
package org.gvsig.fmap.mapcontext.layers.vectorial;
23

  
24
import org.gvsig.fmap.dal.feature.Feature;
25
import org.gvsig.timesupport.Time;
26
import org.gvsig.tools.evaluator.AbstractEvaluator;
27
import org.gvsig.tools.evaluator.EvaluatorData;
28
import org.gvsig.tools.evaluator.EvaluatorException;
29

  
30

  
31
/**
32
 * @author gvSIG Team
33
 * @version $Id$
34
 *
35
 */
36
public class IntersectsTimeEvaluator extends AbstractEvaluator {
37
    private Time time;
38
    private String timeAttributeName;
39
   
40
    public IntersectsTimeEvaluator(Time time, String timeAttributeName) {
41
        super();  
42
        this.time = time;
43
        this.timeAttributeName = timeAttributeName;
44
    }
45

  
46
    public Object evaluate(EvaluatorData data) throws EvaluatorException {
47
        Feature feature = ((Feature) data.getContextValue("feature"));
48
        return new Boolean(time.intersects((Time)feature.get(timeAttributeName)));       
49
    }
50

  
51
    public String getName() {       
52
        return "intersets with time";
53
    }
54

  
55
    public String getSQL() {
56
        // TODO add the time filter!!!
57
        return super.getSQL();
58
    }
59
}
0 60

  

Also available in: Unified diff