-
Notifications
You must be signed in to change notification settings - Fork 982
/
MultiPointPlainShape.java
46 lines (36 loc) · 1.74 KB
/
MultiPointPlainShape.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
41
42
43
44
45
46
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;
/**
* Represents a MultiPoint Shape object, as defined by the ESRI Shape file
* specification.
*/
public class MultiPointPlainShape extends AbstractMultiPointShape {
private static final int BASE_CONTENT_LENGTH = (4 + 8 * 4 + 4) / 2;
public MultiPointPlainShape(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.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.numberOfPoints + " points)"
+ " but found " + this.header.getContentLength() + ". "
+ Const.PREFERENCES);
}
}
}
@Override
protected String getShapeTypeName() {
return "MultiPoint";
}
}