Revision 52 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.circlecr/src/main/java/org/gvsig/vectorediting/lib/prov/circlecr/CircleCREditingProvider.java
CircleCREditingProvider.java | ||
---|---|---|
16 | 16 |
import org.gvsig.fmap.geom.aggregate.MultiCurve; |
17 | 17 |
import org.gvsig.fmap.geom.aggregate.MultiSurface; |
18 | 18 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
19 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
20 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
19 | 21 |
import org.gvsig.fmap.geom.primitive.Arc; |
20 | 22 |
import org.gvsig.fmap.geom.primitive.Circle; |
21 | 23 |
import org.gvsig.fmap.geom.primitive.Point; |
... | ... | |
78 | 80 |
|
79 | 81 |
} |
80 | 82 |
|
81 |
public boolean isValidValue(EditingServiceParameter param, Object value) { |
|
82 |
if (param ==center){ |
|
83 |
if (value instanceof Point) { |
|
84 |
return true; |
|
85 |
} |
|
86 |
} else if (param == radius) { |
|
87 |
if (value instanceof Point) { |
|
88 |
return true; |
|
89 |
} else if (value instanceof String) { |
|
90 |
//TODO: |
|
83 |
private void validateAndInsertValue(EditingServiceParameter param, Object value) { |
|
84 |
if (param == center) { |
|
85 |
if (value instanceof Point) { |
|
86 |
values.put(param, value); |
|
87 |
return; |
|
88 |
} |
|
89 |
} else if (param == radius) { |
|
90 |
if (value instanceof Point) { |
|
91 |
Double radiusValue = null; |
|
92 |
try { |
|
93 |
radiusValue = ((Point)value).distance((Point) values.get(center)); |
|
94 |
} catch (GeometryOperationNotSupportedException e) { |
|
95 |
logger.warn("Can't calculate the radius", e); |
|
96 |
} catch (GeometryOperationException e) { |
|
97 |
logger.warn("Can't calculate the radius", e); |
|
98 |
} |
|
99 |
if (radiusValue != null){ |
|
100 |
values.put(param, radiusValue); |
|
101 |
} |
|
102 |
} else if (value instanceof Double) { |
|
103 |
values.put(param, value); |
|
104 |
} else if (value instanceof String) { |
|
105 |
//FIXME: el string podr?a ser tambi?n un punto |
|
106 |
Double.parseDouble((String) value); |
|
107 |
values.put(param, value); |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
91 | 111 |
|
92 |
} |
|
93 |
} |
|
94 |
return false; |
|
95 |
} |
|
96 |
|
|
97 | 112 |
public List<EditingServiceParameter> getParameters() { |
98 | 113 |
List<EditingServiceParameter> list = new ArrayList<EditingServiceParameter>(); |
99 | 114 |
list.add(center); |
... | ... | |
103 | 118 |
|
104 | 119 |
public void value(Object value) { |
105 | 120 |
EditingServiceParameter param = next(); |
106 |
if (isValidValue(param, value)) { |
|
107 |
values.put(param, value); |
|
108 |
} |
|
121 |
validateAndInsertValue(param, value); |
|
109 | 122 |
} |
110 | 123 |
|
111 | 124 |
public void finish() { |
112 | 125 |
Point centerPoint = (Point) values.get(center); |
113 |
double radiusValue = ((Double)values.get(radius)).doubleValue();
|
|
126 |
double radiusValue = (Double) values.get(radius);
|
|
114 | 127 |
GeometryType storeGeomType = getGeomType(featureStore); |
115 | 128 |
Geometry geometry = null; |
116 | 129 |
if(storeGeomType.isTypeOf(SURFACE)){ |
Also available in: Unified diff