Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.lib / org.gvsig.exportto.lib.api / src / main / java / org / gvsig / export / spi / AbstractExportParametersGeometry.java @ 44386

History | View | Annotate | Download (4.76 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.export.spi;
7

    
8
import org.cresques.cts.ICoordTrans;
9
import org.cresques.cts.IProjection;
10
import org.gvsig.export.ExportParameters;
11
import org.gvsig.fmap.geom.GeometryLocator;
12
import org.gvsig.fmap.geom.GeometryManager;
13
import org.gvsig.fmap.geom.type.GeometryType;
14
import org.gvsig.export.ExportParametersGeometry;
15

    
16
/**
17
 *
18
 * @author jjdelcerro
19
 */
20
public abstract class AbstractExportParametersGeometry 
21
        extends AbstractExportParameters
22
        implements ExportParametersGeometry 
23
    {
24

    
25
    private IProjection contextProjection;
26
    private IProjection sourceProjection;
27
    private IProjection targetProjection;
28

    
29
    private ICoordTrans sourceTransformation;
30
    private ICoordTrans targetTransformation;
31
    
32
    private int geometryChecks;
33
    private int geometryChecksAction;
34
    private boolean tryToFixGeometry;
35
    private String geometryFieldName;
36
    private int geometryType;
37
    private int geometrySubtype;
38

    
39
    public AbstractExportParametersGeometry(ExportServiceFactory factory) {
40
        super(factory);
41
    }
42
        
43
    @Override
44
    public boolean needsSelectTargetProjection() {
45
        return true;
46
    }    
47

    
48
    @Override
49
    public void setContextProjection(IProjection projection) {
50
        this.contextProjection = projection;
51
    }
52

    
53
    @Override
54
    public IProjection getContextProjection() {
55
        return this.contextProjection;
56
    }
57

    
58
    @Override
59
    public void setSourceProjection(IProjection sourceProjection) {
60
        this.sourceProjection = sourceProjection;
61
    }
62

    
63
    @Override
64
    public IProjection getSourceProjection() {
65
        return sourceProjection;
66
    }
67

    
68
    @Override
69
    public ICoordTrans getSourceTransformation() {
70
        return sourceTransformation;
71
    }
72

    
73
    @Override
74
    public void setSourceTransformation(ICoordTrans contextTransformation) {
75
        this.sourceTransformation = contextTransformation;
76
    }
77

    
78
    @Override
79
    public void setTargetProjection(IProjection targetProjection) {
80
        this.targetProjection = targetProjection;
81
    }
82

    
83
    @Override
84
    public IProjection getTargetProjection() {
85
        if( this.targetProjection == null ) {
86
            return this.sourceProjection;
87
        }
88
        return this.targetProjection;
89
    }
90

    
91
    @Override
92
    public void setTargetTransformation(ICoordTrans transformation) {
93
        this.targetTransformation = transformation;
94
    }
95

    
96
    @Override
97
    public ICoordTrans getTargetTransformation() {
98
        return targetTransformation;
99
    }
100
    
101
    @Override
102
    public int getGeometryChecks() {
103
        return this.geometryChecks;
104
    }
105

    
106
    @Override
107
    public int getGeometryChecksAction() {
108
        return this.geometryChecksAction;
109
    }
110

    
111
    @Override
112
    public boolean getTryToFixGeometry() {
113
        return this.tryToFixGeometry;
114
    }
115

    
116
    @Override
117
    public void setGeometryChecks(int geometryChecks) {
118
        this.geometryChecks = geometryChecks;
119
    }
120

    
121
    @Override
122
    public void setGeometryChecksAction(int geometryChecksAction) {
123
        this.geometryChecksAction = geometryChecksAction;
124
    }
125

    
126
    @Override
127
    public void setTryToFixGeometry(boolean tryToFixGeometry) {
128
        this.tryToFixGeometry = tryToFixGeometry;
129
    }
130

    
131
    @Override
132
    public String getSourceGeometryFieldName() {
133
        return this.geometryFieldName;
134
    }
135

    
136
    @Override
137
    public void setSourceGeometryFieldName(String geometryFieldName) {
138
        this.geometryFieldName = geometryFieldName;
139
    }
140

    
141
    @Override
142
    public int getTargetGeometryTypeAsInt() {
143
        return geometryType;
144
    }
145

    
146
    @Override
147
    public int getTargetGeometrySubtype() {
148
        return geometrySubtype;
149
    }
150

    
151
    @Override
152
    public void setTargetGeometryType(int geometryType) {
153
        this.geometryType = geometryType;
154
    }
155

    
156
    @Override
157
    public void setTargetGeometrySubtype(int subtype) {
158
        this.geometrySubtype = subtype;
159
    }
160

    
161
    @Override
162
    public void setTargetGeometryType(GeometryType type) {
163
        this.geometryType = type.getType();
164
        this.geometrySubtype = type.getSubType();
165
    }
166

    
167
    @Override
168
    public GeometryType getTargetGeometryType() {
169
        try {
170
            GeometryManager geomManager = GeometryLocator.getGeometryManager();
171
            GeometryType type = geomManager.getGeometryType(
172
                    geometryType,
173
                    geometryType
174
            );
175
            return type;
176
        } catch (Exception ex) {
177
            throw new RuntimeException("Can't create geoemtry type from type "+geometryType+", subtype "+geometrySubtype+".", ex);
178
        }
179
    }
180

    
181
    public ExportParameters clone() throws CloneNotSupportedException {
182
        return super.clone();
183
    }
184

    
185
}