code: def _validate_metadata(metadata):
      """Validate geo metadata.
      Must not be empty, and must contain the structure specified above.
  
      Raises ValueError if metadata is not valid.
  
      Parameters
      ----------
      metadata : dict
      """
  
      if not metadata:
          raise ValueError(
              "Missing or malformed geo metadata in Parquet/Feather file"
          )
  
      # version was schema_version in 0.1.0
      version = metadata.get("version", metadata.get("schema_version"))
      if not version:
          raise ValueError(
              "'geo' metadata in Parquet/Feather file is missing required key: "
              "'version'"
          )
  
      required_keys = ("primary_column", "columns")
      for key in required_keys:
          if metadata.get(key, None) is None:
              raise ValueError(
                  "'geo' metadata in Parquet/Feather file is missing required key: "
                  "'{key}'".format(key=key)
              )
  
      if not isinstance(metadata["columns"], dict):
          raise ValueError("'columns' in 'geo' metadata must be a dict")
  
      # Validate that geometry columns have required metadata and values
      # leaving out "geometry_type" for compatibility with 0.1
      required_col_keys = ("encoding",)
      for col, column_metadata in metadata["columns"].items():
          for key in required_col_keys:
              if key not in column_metadata:
                  raise ValueError(
                      "'geo' metadata in Parquet/Feather file is missing required key "
                      "'{key}' for column '{col}'".format(
                          key=key, col=col
                      )
                  )
  
          if column_metadata["encoding"] != "WKB":
              raise ValueError(
                  "Only WKB geometry encoding is supported"
              )
  
          if column_metadata.get("edges", "planar") == "spherical":
              warnings.warn(
                  f"The geo metadata indicate that column '{col}' has spherical edges, "
                  "but because GeoPandas currently does not support spherical "
                  "geometry, it ignores this metadata and will interpret the edges of "
                  "the geometries as planar.",
                  UserWarning,
                  stacklevel=4,
              )
  
imports: from packaging.version import Version
  import json
  import warnings
  import numpy
  from pandas import DataFrame, Series
  from geopandas._compat import import_optional_dependency
  from geopandas.array import from_wkb
  from geopandas import GeoDataFrame
  import geopandas
  from .file import _expand_user
label_desc: Use image node_id 7 for calling a global function with example usage: _validate_metadata(metadata) without return types