-
Notifications
You must be signed in to change notification settings - Fork 982
/
AbstractPolyPlainShape.java
40 lines (30 loc) · 1.68 KB
/
AbstractPolyPlainShape.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.nocrala.tools.gis.data.esri.shapefile.shape.shapes;
import org.nocrala.tools.gis.data.esri.shapefile.ValidationPreferences;
import org.nocrala.tools.gis.data.esri.shapefile.exception.InvalidShapeFileException;
import org.nocrala.tools.gis.data.esri.shapefile.shape.Const;
import org.nocrala.tools.gis.data.esri.shapefile.shape.ShapeHeader;
import org.nocrala.tools.gis.data.esri.shapefile.shape.ShapeType;
import java.io.IOException;
import java.io.InputStream;
public abstract class AbstractPolyPlainShape extends AbstractPolyShape {
private static final int BASE_CONTENT_LENGTH = (4 + 8 * 4 + 4 + 4) / 2;
public AbstractPolyPlainShape(final ShapeHeader shapeHeader,
final ShapeType shapeType, final InputStream is,
final ValidationPreferences rules) throws IOException,
InvalidShapeFileException {
super(shapeHeader, shapeType, is, rules);
if (!rules.isAllowBadContentLength()) {
int expectedLength = BASE_CONTENT_LENGTH //
+ (this.numberOfParts * (4)) / 2 //
+ (this.numberOfPoints * (8 * 2)) / 2;
if (this.header.getContentLength() != expectedLength) {
throw new InvalidShapeFileException("Invalid " + getShapeTypeName()
+ " shape header's content length. " + "Expected " + expectedLength
+ " 16-bit words (for " + this.numberOfParts + " parts and "
+ this.numberOfPoints + " points)" + " but found "
+ this.header.getContentLength() + ". " + Const.PREFERENCES);
}
}
}
// Getters
}