function makeAssociations($id_min, $id_max, $is_map = false)
{
    $id = $id_min;
    while ($id <= $id_max) {
        echo "Computing associations for document {$id} ... \n";
        // if associations with areas for current doc already existed, delete them
        //$deleted = Association::deleteAllFor($id, array('dr', 'dc', 'dd', 'dm'));
        //if ($deleted) echo "Deleted $deleted already existing associations. \n";
        // compute new associations
        $areas = gisQuery::getAreasContaining($id);
        $maps = gisQuery::getMapsContaining($id);
        // perform association with these areas.
        foreach ($areas as $area) {
            switch ($area['type']) {
                case 1:
                    // range
                    $type = 'dr';
                    break;
                case 2:
                    // country
                    $type = 'dc';
                    break;
                case 3:
                    // dept
                    $type = 'dd';
                    break;
            }
            $a = new GeoAssociation();
            echo "[type={$type}] found area : " . $area['id'] . "\n";
            $a->doSaveWithValues($id, $area['id'], $type);
            // main, linked, type
            unset($a);
        }
        // perform association with these maps if current document is not a map.
        if (!$is_map) {
            foreach ($maps as $map) {
                $a = new GeoAssociation();
                echo "[type=dm] found map : " . $map['id'] . "\n";
                $a->doSaveWithValues($id, $map['id'], 'dm');
                // main, linked, type
                unset($a);
            }
        }
        $id++;
    }
}