-﻿-- ENVELOPE.sql
+-- ENVELOPE.sql
 --
 -- Authors:     Felix Kunde <fkunde@virtualcitysystems.de>
 --              Claus Nagel <cnagel@virtualcitysystems.de>
 --
 -- Copyright:   (c) 2012-2015  Chair of Geoinformatics,
---                             Technische Universitaet Muenchen, Germany
+--                             Technische Universitt Mnchen, Germany
 --                             http://www.gis.bv.tum.de
 --
 -------------------------------------------------------------------------------
 -- About:
--- This script provides functions to get an object's envelope (a diagonal cutting plane
--- inside a 3D bounding box).
+-- This script provides functions to calculate an object's envelope 
+-- (a diagonal cutting plane inside a 3D bounding box) and to store
+-- the result in the ENVELOPE column of CITYOBJECT
 --
 -------------------------------------------------------------------------------
 --

CREATE OR REPLACE FUNCTION citydb_pkg.get_envelope_cityobjectgroup(
  co_id INTEGER, 
  set_envelope INTEGER DEFAULT 0,
  get_member_envelopes INTEGER DEFAULT 1,
  schema_name VARCHAR DEFAULT 'citydb'
  ) RETURNS GEOMETRY AS
$$

  query TEXT;
  envelope GEOMETRY;
BEGIN
  IF calc_member_envelopes <> 0 THEN
    EXECUTE format(
      'WITH collect_geom AS (
         -- cityobjectgroup geometry
