ThinkGeo.com    |     Documentation    |     Premium Support

Why do Layers need to be manually opened

Quick question, why isnt Layer Open/Close handled internally? There are already checks on every function, so why not just handle it internally (keep layers open when already open, and open / close them when closed)? And maybe add a variable to set to turn this handling on / off?

Auto-opening and auto-closing inside every API sounds convenient, but it has some real downsides:

  • It hides expensive work behind methods that look cheap. OpenCore/CloseCore may involve file handles, database connections, indexes, projections, caches, etc.
  • It hurts batching. A common pattern is to open once, perform many operations, then close once. Auto open/close on every call would add unnecessary churn.
  • It makes failures harder to reason about. A call that looks like a simple getter can suddenly fail because it implicitly tried to open underlying resources.
  • It increases API complexity and test surface. An on/off flag would create two behavior modes for every layer API and raise backward-compatibility questions.

I hope that makes sense.

1 Like