Revision 47359

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/searchPostProcess/distinctOn/STIntersectionAggregateOperation.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.fmap.dal.swing.impl.searchPostProcess.distinctOn;
7

  
8
//    public static void selfRegister(){
9

  
10
import java.util.List;
11
import org.gvsig.fmap.dal.DataTypes;
12
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
13
import org.gvsig.fmap.geom.Geometry;
14
import static org.gvsig.tools.dynobject.DynField.RELATION_TYPE_NONE;
15

  
16

  
17
 public class STIntersectionAggregateOperation extends AbstractAggregateOperation {
18
    
19
    public static class SumAggregateOperationFactory implements AggregateOperationFactory{
20

  
21
        public static final String NAME = "ST_Intersection";
22

  
23
        @Override
24
        public String getName() {
25
            return NAME;
26
        }
27

  
28
        @Override
29
        public AggregateOperation create(Object... os) {
30
            return new STIntersectionAggregateOperation();
31
        }
32

  
33
        @Override
34
        public boolean isApplicable(Object... value) {
35
            return Geometry.class.isAssignableFrom((Class<?>) value[0]);
36
        }
37
        
38
    }
39
    
40
    Geometry geom;
41

  
42
    public STIntersectionAggregateOperation() {
43
        this.geom = null;
44
    }
45

  
46
    @Override
47
    public boolean isApplicable(Object... value) {
48
        return value[0] instanceof Geometry;
49
    }
50

  
51
    @Override
52
    public void reset() {
53
        this.geom = null;
54
    }
55

  
56
    @Override
57
    public void perform(Object value) {
58
        try {
59
            if (value == null) {
60
                return;
61
            }
62
            if( geom == null ) {
63
                geom = (Geometry)value;
64
                return;
65
            }
66
            geom = geom.intersection((Geometry) value);
67
        } catch (Exception ex) {
68
            throw new RuntimeException("",ex);
69
        }
70
    }
71

  
72
    @Override
73
    public Object getValue() {
74
        return this.geom;
75
    }
76

  
77
    @Override
78
    public void fixAttributeDescriptor(EditableFeatureAttributeDescriptor descriptor) {
79
        super.fixAttributeDescriptor(descriptor);
80
        
81
//        descriptor.setDataType(DataTypes.GEOMETRY);
82
//        descriptor.setGeometryType(Geometry.TYPES.POLYGON, Geometry.SUBTYPES.GEOM2D);
83

  
84
        descriptor.setRelationType(RELATION_TYPE_NONE);
85
        descriptor.getForeingKey().clean();
86
        descriptor.setAvailableValues((List)null);
87

  
88
    }
89
    
90
    
91
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/searchPostProcess/distinctOn/STConvexHullAggregateOperation.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.fmap.dal.swing.impl.searchPostProcess.distinctOn;
7

  
8
//    public static void selfRegister(){
9

  
10
import java.util.List;
11
import org.gvsig.fmap.dal.DataTypes;
12
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
13
import org.gvsig.fmap.geom.Geometry;
14
import org.gvsig.fmap.geom.GeometryUtils;
15
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
16
import org.gvsig.fmap.geom.primitive.Primitive;
17
import static org.gvsig.tools.dynobject.DynField.RELATION_TYPE_NONE;
18

  
19

  
20
 public class STConvexHullAggregateOperation extends AbstractAggregateOperation {
21
    
22
    public static class SumAggregateOperationFactory implements AggregateOperationFactory{
23

  
24
        public static final String NAME = "ST_ConvexHull";
25

  
26
        @Override
27
        public String getName() {
28
            return NAME;
29
        }
30

  
31
        @Override
32
        public AggregateOperation create(Object... os) {
33
            return new STConvexHullAggregateOperation();
34
        }
35

  
36
        @Override
37
        public boolean isApplicable(Object... value) {
38
            return Geometry.class.isAssignableFrom((Class<?>) value[0]);
39
        }
40
        
41
    }
42
    
43
    Geometry geom;
44

  
45
    public STConvexHullAggregateOperation() {
46
        this.geom = null;
47
    }
48

  
49
    @Override
50
    public boolean isApplicable(Object... value) {
51
        return value[0] instanceof Geometry;
52
    }
53

  
54
    @Override
55
    public void reset() {
56
        this.geom = null;
57
    }
58

  
59
    @Override
60
    public void perform(Object value) {
61
        try {
62
            if (value == null) {
63
                return;
64
            }
65
            if( geom == null ) {
66
                geom = ((Geometry)value).convexHull();
67
                return;
68
            }
69
            MultiPolygon mp = GeometryUtils.createMultiPolygon(geom.getGeometryType().getSubType());
70
            mp.addPrimitive((Primitive) geom);
71
            mp.addPrimitive((Primitive) value);
72
            geom = mp.convexHull();
73
        } catch (Exception ex) {
74
            throw new RuntimeException("",ex);
75
        }
76
    }
77

  
78
    @Override
79
    public Object getValue() {
80
        return this.geom;
81
    }
82

  
83
    @Override
84
    public void fixAttributeDescriptor(EditableFeatureAttributeDescriptor descriptor) {
85
        super.fixAttributeDescriptor(descriptor);
86
        
87
        descriptor.setDataType(DataTypes.GEOMETRY);
88
        descriptor.setGeometryType(Geometry.TYPES.POLYGON, Geometry.SUBTYPES.GEOM2D);
89

  
90
        descriptor.setRelationType(RELATION_TYPE_NONE);
91
        descriptor.getForeingKey().clean();
92
        descriptor.setAvailableValues((List)null);
93

  
94
    }
95
    
96
    
97
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/searchPostProcess/distinctOn/STExtentAggregateOperation.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.fmap.dal.swing.impl.searchPostProcess.distinctOn;
7

  
8
//    public static void selfRegister(){
9

  
10
import java.util.List;
11
import org.gvsig.fmap.dal.DataTypes;
12
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
13
import org.gvsig.fmap.geom.Geometry;
14
import org.gvsig.fmap.geom.GeometryUtils;
15
import org.gvsig.fmap.geom.primitive.Envelope;
16
import static org.gvsig.tools.dynobject.DynField.RELATION_TYPE_NONE;
17

  
18

  
19
 public class STExtentAggregateOperation extends AbstractAggregateOperation {
20
    
21
    public static class SumAggregateOperationFactory implements AggregateOperationFactory{
22

  
23
        public static final String NAME = "ST_Extent";
24

  
25
        @Override
26
        public String getName() {
27
            return NAME;
28
        }
29

  
30
        @Override
31
        public AggregateOperation create(Object... os) {
32
            return new STExtentAggregateOperation();
33
        }
34

  
35
        @Override
36
        public boolean isApplicable(Object... value) {
37
            return Geometry.class.isAssignableFrom((Class<?>) value[0]);
38
        }
39
        
40
    }
41
    
42
    Envelope extent;
43

  
44
    public STExtentAggregateOperation() {
45
        this.extent = GeometryUtils.createEnvelope(Geometry.SUBTYPES.GEOM2D);
46
    }
47

  
48
    @Override
49
    public boolean isApplicable(Object... value) {
50
        return value[0] instanceof Geometry;
51
    }
52

  
53
    @Override
54
    public void reset() {
55
        this.extent.clear();
56
    }
57

  
58
    @Override
59
    public void perform(Object value) {
60
        if (value == null) {
61
            return;
62
        }
63
        this.extent.add((Geometry) value);
64
    }
65

  
66
    @Override
67
    public Object getValue() {
68
        return this.extent.getGeometry();
69
    }
70

  
71
    @Override
72
    public void fixAttributeDescriptor(EditableFeatureAttributeDescriptor descriptor) {
73
        super.fixAttributeDescriptor(descriptor);
74
        
75
        descriptor.setDataType(DataTypes.GEOMETRY);
76
        descriptor.setGeometryType(Geometry.TYPES.POLYGON, Geometry.SUBTYPES.GEOM2D);
77

  
78
        descriptor.setRelationType(RELATION_TYPE_NONE);
79
        descriptor.getForeingKey().clean();
80
        descriptor.setAvailableValues((List)null);
81

  
82
    }
83
    
84
    
85
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/searchPostProcess/distinctOn/STUnionAggregateOperation.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.fmap.dal.swing.impl.searchPostProcess.distinctOn;
7

  
8
//    public static void selfRegister(){
9

  
10
import java.util.List;
11
import org.gvsig.fmap.dal.DataTypes;
12
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
13
import org.gvsig.fmap.geom.Geometry;
14
import static org.gvsig.tools.dynobject.DynField.RELATION_TYPE_NONE;
15

  
16

  
17
 public class STUnionAggregateOperation extends AbstractAggregateOperation {
18
    
19
    public static class SumAggregateOperationFactory implements AggregateOperationFactory{
20

  
21
        public static final String NAME = "ST_Union";
22

  
23
        @Override
24
        public String getName() {
25
            return NAME;
26
        }
27

  
28
        @Override
29
        public AggregateOperation create(Object... os) {
30
            return new STUnionAggregateOperation();
31
        }
32

  
33
        @Override
34
        public boolean isApplicable(Object... value) {
35
            return Geometry.class.isAssignableFrom((Class<?>) value[0]);
36
        }
37
        
38
    }
39
    
40
    Geometry geom;
41

  
42
    public STUnionAggregateOperation() {
43
        this.geom = null;
44
    }
45

  
46
    @Override
47
    public boolean isApplicable(Object... value) {
48
        return value[0] instanceof Geometry;
49
    }
50

  
51
    @Override
52
    public void reset() {
53
        this.geom = null;
54
    }
55

  
56
    @Override
57
    public void perform(Object value) {
58
        try {
59
            if (value == null) {
60
                return;
61
            }
62
            if( geom == null ) {
63
                geom = (Geometry)value;
64
                return;
65
            }
66
            geom = geom.union((Geometry) value);
67
        } catch (Exception ex) {
68
            throw new RuntimeException("",ex);
69
        }
70
    }
71

  
72
    @Override
73
    public Object getValue() {
74
        return this.geom;
75
    }
76

  
77
    @Override
78
    public void fixAttributeDescriptor(EditableFeatureAttributeDescriptor descriptor) {
79
        super.fixAttributeDescriptor(descriptor);
80
        
81
//        descriptor.setDataType(DataTypes.GEOMETRY);
82
//        descriptor.setGeometryType(Geometry.TYPES.POLYGON, Geometry.SUBTYPES.GEOM2D);
83

  
84
        descriptor.setRelationType(RELATION_TYPE_NONE);
85
        descriptor.getForeingKey().clean();
86
        descriptor.setAvailableValues((List)null);
87
    }
88
    
89
    
90
}

Also available in: Unified diff