getLength method

  1. @override
int getLength(
  1. dynamic geometry
)
override

Get the length of the given geometry Object in bytes not 16-bit words. This is easier to keep track of, since the ByteBuffer deals with bytes. Do not include the 8 bytes of record.

@param geometry The geometry to analyze. @return The number of bytes the shape will take up.

Implementation

@override
int getLength(dynamic geometry) {
  MultiLineString multi = geometry as MultiLineString;

  int numlines;
  int numpoints;
  int length;

  numlines = multi.getNumGeometries();
  numpoints = multi.getNumPoints();

  if (shapeType == ShapeType.ARC) {
    length = 44 + (4 * numlines) + (numpoints * 16);
  } else if (shapeType == ShapeType.ARCM) {
    length = 44 + (4 * numlines) + (numpoints * 16) + 8 + 8 + (8 * numpoints);
  } else if (shapeType == ShapeType.ARCZ) {
    length = 44 +
        (4 * numlines) +
        (numpoints * 16) +
        8 +
        8 +
        (8 * numpoints) +
        8 +
        8 +
        (8 * numpoints);
  } else {
    throw StateError("Expected ShapeType of Arc, got $shapeType");
  }

  return length;
}