goTo method

Future<void> goTo(
  1. int offset
)

Moves the reader to the specified byte offset in the file. Mind that:

  • it's your responsibility to ensure the offset corresponds to the actual beginning of a shape struct
  • once you call this, reading with hasNext/next on sparse shapefiles will be broken (we don't know anymore at which shape we are)

Implementation

Future<void> goTo(int offset) async {
  disableShxUsage();
  if (randomAccessEnabled) {
    await positionBufferForOffset(buffer, offset);

    int oldRecordOffset = recordEnd;
    recordEnd = offset;
    try {
      await hasNextCheck(
          false); // don't check for next logical record equality
    } catch (ioe) {
      recordEnd = oldRecordOffset;
      rethrow;
    }
  } else {
    throw StateError("Random Access not enabled");
  }
}