Revision 42823
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/utils/SHPReader2D.java | ||
---|---|---|
115 | 115 |
} |
116 | 116 |
line.addVertex(p); |
117 | 117 |
} |
118 |
checkNumVerticesOfLine(line); |
|
119 |
|
|
118 | 120 |
if (multiLine != null) { |
119 | 121 |
multiLine.addCurve(line); |
120 | 122 |
return multiLine; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/utils/SHPReader2DM.java | ||
---|---|---|
120 | 120 |
} |
121 | 121 |
line.addVertex(p); |
122 | 122 |
} |
123 |
checkNumVerticesOfLine(line); |
|
124 |
|
|
123 | 125 |
if (multiLine != null) { |
124 | 126 |
multiLine.addCurve(line); |
125 | 127 |
fillM(multiLine, bb); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/utils/SHPReader3DM.java | ||
---|---|---|
124 | 124 |
} |
125 | 125 |
line.addVertex(p); |
126 | 126 |
} |
127 |
checkNumVerticesOfLine(line); |
|
128 |
|
|
127 | 129 |
if (multiLine != null) { |
128 | 130 |
multiLine.addCurve(line); |
129 | 131 |
fillZ(multiLine, bb); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/utils/AbstractSHPReader.java | ||
---|---|---|
52 | 52 |
public AbstractSHPReader(SHPStoreParameters params) { |
53 | 53 |
this.params = params; |
54 | 54 |
} |
55 |
|
|
55 |
|
|
56 | 56 |
protected class InvalidNumberOfPointsInLinearRingException extends ReadRuntimeException { |
57 | 57 |
|
58 |
private final static String MESSAGE_FORMAT = "Invalid number of points in LinearRing (found %(NumPoints) - must be 0 or >= 4).\nCheck 'Fix LinearRings' in the shape's properties of the add layer dialog to try fix it."; |
|
58 |
private final static String MESSAGE_FORMAT = "Invalid number of points in LinearRing (found %(NumPoints) - must be 0 or >= 4).\nCheck 'Fix LinearRings and LineStrings' in the shape's properties of the add layer dialog to try fix it.";
|
|
59 | 59 |
private final static String MESSAGE_KEY = "_InvalidNumberOfPointsInLinearRingException"; |
60 | 60 |
private static final long serialVersionUID = -8265770463632826027L; |
61 | 61 |
|
... | ... | |
65 | 65 |
this.getMessage(); |
66 | 66 |
} |
67 | 67 |
} |
68 |
|
|
68 |
|
|
69 |
protected class InvalidNumberOfPointsInLineStringException extends ReadRuntimeException { |
|
70 |
|
|
71 |
/** |
|
72 |
* |
|
73 |
*/ |
|
74 |
private static final long serialVersionUID = -6458824187605578665L; |
|
75 |
private final static String MESSAGE_FORMAT = "Invalid number of points in LineString (found %(NumPoints) - must be 0 or >= 2).\nCheck 'Fix LinearRings and LineStrings' in the shape's properties of the add layer dialog to try fix it."; |
|
76 |
private final static String MESSAGE_KEY = "_InvalidNumberOfPointsInLineStringException"; |
|
77 |
|
|
78 |
public InvalidNumberOfPointsInLineStringException(int numPoints) { |
|
79 |
super(MESSAGE_FORMAT, null, MESSAGE_KEY, serialVersionUID); |
|
80 |
setValue("NumPoints", numPoints); |
|
81 |
this.getMessage(); |
|
82 |
} |
|
83 |
} |
|
69 | 84 |
public void checkNumVerticesOfRing(Ring ring ) throws InvalidNumberOfPointsInLinearRingException { |
70 | 85 |
if( ring.getNumVertices()<4 ) { |
71 | 86 |
if( this.fixLinearRings() ) { |
... | ... | |
77 | 92 |
} else { |
78 | 93 |
throw new InvalidNumberOfPointsInLinearRingException(ring.getNumVertices()); |
79 | 94 |
} |
80 |
}
|
|
95 |
} |
|
81 | 96 |
} |
82 |
|
|
97 |
|
|
98 |
public void checkNumVerticesOfLine(Line line) throws InvalidNumberOfPointsInLinearRingException { |
|
99 |
if (line.getNumVertices() > 0 && line.getNumVertices() < 2) { |
|
100 |
if (this.fixLinearRings()) { |
|
101 |
Point p = line.getVertex(line.getNumVertices() - 1); |
|
102 |
while (line.getNumVertices() < 2) { |
|
103 |
p = (Point) p.cloneGeometry(); |
|
104 |
line.addVertex(p); |
|
105 |
} |
|
106 |
} else { |
|
107 |
throw new InvalidNumberOfPointsInLineStringException(line.getNumVertices()); |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
83 | 112 |
public boolean fixLinearRings() { |
84 | 113 |
return params.getFixLinearRings(); |
85 | 114 |
} |
86 |
|
|
115 |
|
|
87 | 116 |
/** |
88 | 117 |
* @param p |
89 | 118 |
* @param bb |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/resources/org/gvsig/fmap/dal/store/shp/SHPParameters.xml | ||
---|---|---|
65 | 65 |
<field order="220" name="loadCorruptGeometriesAsNull" label="Load corrupt geometries as null" type="boolean" mandatory="false" group="Advanced" defaultValue="false"> |
66 | 66 |
<description>If set, load geometries that have inconsistencies as null and not fails. The layer will be read only.</description> |
67 | 67 |
</field> |
68 |
<field order="230" name="fixLinearRings" label="Fix LinearRings" type="boolean" mandatory="false" group="Advanced" defaultValue="false"> |
|
69 |
<description>If set, fix LinearRings to minimum four vertices duplicating last vertex. The layer will be read only.</description> |
|
68 |
<field order="230" name="fixLinearRings" label="Fix LinearRings and LineString" type="boolean" mandatory="false" group="Advanced" defaultValue="false">
|
|
69 |
<description>If set, fix LinearRings to minimum four vertices and fix LineStrings to minimum two vertices duplicating last vertex. The layer will be read only.</description>
|
|
70 | 70 |
</field> |
71 | 71 |
</fields> |
72 | 72 |
</class> |
Also available in: Unified diff