Revision 41439
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/Geometry.java | ||
---|---|---|
231 | 231 |
public final static String COVEREDBY = "CoveredBy"; |
232 | 232 |
} |
233 | 233 |
|
234 |
public static int BEST = 0; |
|
234 |
public interface ValidationStatus { |
|
235 |
|
|
236 |
public static final int VALID = 0; |
|
237 |
public static final int CURRUPTED = 1; |
|
238 |
public static final int UNKNOW = 2; |
|
239 |
public static final int DISCONNECTED_INTERIOR = 10; |
|
240 |
public static final int DUPLICATE_RINGS = 11; |
|
241 |
public static final int HOLE_OUTSIDE_SHELL = 12; |
|
242 |
public static final int INVALID_COORDINATE = 13; |
|
243 |
public static final int NESTED_HOLES = 14; |
|
244 |
public static final int NESTED_SHELLS = 15; |
|
245 |
public static final int RING_NOT_CLOSED = 17; |
|
246 |
public static final int RING_SELF_INTERSECTION = 18; |
|
247 |
public static final int SELF_INTERSECTION = 19; |
|
248 |
public static final int TOO_FEW_POINTS = 20; |
|
249 |
|
|
250 |
/** |
|
251 |
* True if the geoemtry are valid. |
|
252 |
* |
|
253 |
* @return true form valid geometries |
|
254 |
*/ |
|
255 |
public boolean isValid(); |
|
256 |
|
|
257 |
/** |
|
258 |
* Return the status code results of validate the geometry. |
|
259 |
* |
|
260 |
* @return validation code |
|
261 |
*/ |
|
262 |
public int getStatusCode(); |
|
263 |
|
|
264 |
/** |
|
265 |
* Return the nearest point to the problem when validate the geometry. |
|
266 |
* |
|
267 |
* If the geometry is valid, this return null. |
|
268 |
* |
|
269 |
* @return the nearest point to the problem or null. |
|
270 |
*/ |
|
271 |
public Point getProblemLocation(); |
|
272 |
|
|
273 |
/** |
|
274 |
* Return a human readable message explaining the cause of the problem. |
|
275 |
* |
|
276 |
* If the geometry is valid this is null. |
|
277 |
* |
|
278 |
* @return the message cause of the problem. |
|
279 |
*/ |
|
280 |
public String getMessage(); |
|
281 |
} |
|
282 |
|
|
283 |
public static int BEST = 0; |
|
235 | 284 |
/** |
236 | 285 |
* North. |
237 | 286 |
*/ |
... | ... | |
634 | 683 |
*/ |
635 | 684 |
public void scale(Point basePoint, double sx, double sy); |
636 | 685 |
|
686 |
/** |
|
687 |
* Check if the geometry is valid. |
|
688 |
* |
|
689 |
* @return true if the geometry is valid. |
|
690 |
*/ |
|
691 |
public boolean isValid(); |
|
637 | 692 |
|
638 |
|
|
639 |
|
|
693 |
/** |
|
694 |
* Check if the geometry is valid and returns the validation status. |
|
695 |
* |
|
696 |
* @return the ValidationStatus |
|
697 |
*/ |
|
698 |
public ValidationStatus getValidationStatus(); |
|
699 |
|
|
640 | 700 |
// |
641 | 701 |
// =============================================== |
642 | 702 |
// |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.impl/src/main/java/org/gvsig/fmap/geom/primitive/impl/DefaultNullGeometry.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
import org.cresques.cts.ICoordTrans; |
33 | 33 |
import org.gvsig.fmap.geom.handler.Handler; |
34 |
import org.gvsig.fmap.geom.impl.DefaultValidationStatus; |
|
34 | 35 |
import org.gvsig.fmap.geom.primitive.Envelope; |
35 | 36 |
import org.gvsig.fmap.geom.primitive.FShape; |
36 | 37 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
... | ... | |
43 | 44 |
* @author Vicente Caballero Navarro |
44 | 45 |
*/ |
45 | 46 |
public class DefaultNullGeometry extends AbstractPrimitive implements NullGeometry { |
46 |
private static final long serialVersionUID = 1L; |
|
47 |
private static final long serialVersionUID = -1318803244617119121L; |
|
48 |
|
|
49 |
private static final ValidationStatus validationStatus= new DefaultValidationStatus(ValidationStatus.UNKNOW, "Null-geometry is not a valid geometry."); |
|
47 | 50 |
|
48 | 51 |
/** |
49 | 52 |
* The constructor with the GeometryType like and argument |
... | ... | |
193 | 196 |
return null; |
194 | 197 |
} |
195 | 198 |
|
199 |
public boolean isValid() { |
|
200 |
return false; |
|
201 |
} |
|
202 |
|
|
203 |
public ValidationStatus getValidationStatus() { |
|
204 |
return validationStatus; |
|
205 |
} |
|
206 |
|
|
207 |
|
|
208 |
|
|
196 | 209 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.impl/src/main/java/org/gvsig/fmap/geom/primitive/impl/AbstractPrimitive.java | ||
---|---|---|
52 | 52 |
|
53 | 53 |
import com.vividsolutions.jts.geom.Coordinate; |
54 | 54 |
import com.vividsolutions.jts.geom.GeometryFactory; |
55 |
import com.vividsolutions.jts.geom.LineString; |
|
56 | 55 |
import com.vividsolutions.jts.io.WKBWriter; |
57 | 56 |
import com.vividsolutions.jts.operation.distance.DistanceOp; |
58 | 57 |
import com.vividsolutions.jts.operation.overlay.snap.GeometrySnapper; |
58 |
import com.vividsolutions.jts.operation.valid.IsValidOp; |
|
59 |
import org.gvsig.fmap.geom.impl.DefaultValidationStatus; |
|
59 | 60 |
|
60 | 61 |
|
61 | 62 |
/** |
... | ... | |
194 | 195 |
* @see org.gvsig.fmap.geom.Geometry#isSimple() |
195 | 196 |
*/ |
196 | 197 |
public boolean isSimple() { |
197 |
return true; |
|
198 |
com.vividsolutions.jts.geom.Geometry jtsgeom = this.getJTS(); |
|
199 |
return jtsgeom.isSimple(); |
|
198 | 200 |
} |
199 | 201 |
|
202 |
public boolean isValid() { |
|
203 |
com.vividsolutions.jts.geom.Geometry jtsgeom = this.getJTS(); |
|
204 |
return jtsgeom.isValid(); |
|
205 |
} |
|
206 |
|
|
207 |
public ValidationStatus getValidationStatus() { |
|
208 |
DefaultValidationStatus status = new DefaultValidationStatus(); |
|
209 |
com.vividsolutions.jts.geom.Geometry jtsgeom = null; |
|
210 |
try { |
|
211 |
jtsgeom = this.getJTS(); |
|
212 |
IsValidOp validOp = new IsValidOp(jtsgeom); |
|
213 |
status.setValidationError(validOp.getValidationError()); |
|
214 |
} catch(Exception ex) { |
|
215 |
status.setStatusCode(ValidationStatus.CURRUPTED); |
|
216 |
status.setMesage("The geometry is corrupted."); |
|
217 |
} |
|
218 |
return status; |
|
219 |
} |
|
220 |
|
|
200 | 221 |
/* |
201 | 222 |
* (non-Javadoc) |
202 | 223 |
* @see org.gvsig.fmap.geom.Geometry#invokeOperation(int, org.gvsig.fmap.geom.operation.GeometryOperationContext) |
Also available in: Unified diff