-
Notifications
You must be signed in to change notification settings - Fork 982
/
MultiPointZShape.java
96 lines (74 loc) · 2.81 KB
/
MultiPointZShape.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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 org.nocrala.tools.gis.data.esri.shapefile.util.ISUtil;
import java.io.IOException;
import java.io.InputStream;
/**
* Represents a MultiPointZ Shape object, as defined by the ESRI Shape file
* specification.
*/
public class MultiPointZShape extends AbstractMultiPointShape {
private static final int BASE_CONTENT_LENGTH = (4 + 8 * 4 + 4 + 8 * 2 + 8 * 2) / 2;
private double minZ;
private double maxZ;
private double[] z;
private double minM;
private double maxM;
private double[] m;
public MultiPointZShape(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 + 8 + 8)) / 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);
}
}
this.minZ = ISUtil.readLeDouble(is);
this.maxZ = ISUtil.readLeDouble(is);
this.z = new double[this.numberOfPoints];
for (int i = 0; i < this.numberOfPoints; i++) {
this.z[i] = ISUtil.readLeDouble(is);
}
this.minM = ISUtil.readLeDouble(is);
this.maxM = ISUtil.readLeDouble(is);
this.m = new double[this.numberOfPoints];
for (int i = 0; i < this.numberOfPoints; i++) {
this.m[i] = ISUtil.readLeDouble(is);
}
}
@Override
protected String getShapeTypeName() {
return "MultiPointZ";
}
// Getters
public double getMinZ() {
return minZ;
}
public double getMaxZ() {
return maxZ;
}
public double[] getZ() {
return z;
}
public double getMinM() {
return minM;
}
public double getMaxM() {
return maxM;
}
public double[] getM() {
return m;
}
}