svn-gvsig-desktop / 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 @ 47359
History | View | Annotate | Download (2.38 KB)
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 |
} |