<commit_before>import os

from django.conf import settings
from django.db.models import Max, Min
from shapely.geometry import box
from shapely.ops import cascaded_union

from c3nav.mapdata.models import Package
from c3nav.mapdata.utils.cache import cache_result


@cache_result('c3nav__mapdata__dimensions')
def get_dimensions():
    aggregate = Package.objects.all().aggregate(Max('right'), Min('left'), Max('top'), Min('bottom'))
    return (
        float(aggregate['right__max'] - aggregate['left__min']),
        float(aggregate['top__max'] - aggregate['bottom__min']),
    )


@cache_result('c3nav__mapdata__render_dimensions')
def get_render_dimensions():
    width, height = get_dimensions()
    return (width * settings.RENDER_SCALE, height * settings.RENDER_SCALE)


def get_render_path(filetype, level, mode, public):
    return os.path.join(settings.RENDER_ROOT,
                        '%s%s-level-%s.%s' % (('public-' if public else ''), mode, level, filetype))


def get_public_private_area(level):
    from c3nav.mapdata.models import AreaLocation

    width, height = get_dimensions()
    everything = box(0, 0, width, height)
    needs_permission = [location.geometry
                        for location in AreaLocation.objects.filter(routing_inclusion='needs_permission')]<commit_msg>fix bug that searched for restrictions on the wrong level<commit_after>import os

from django.conf import settings
from django.db.models import Max, Min
from shapely.geometry import box
from shapely.ops import cascaded_union

from c3nav.mapdata.models import Package
from c3nav.mapdata.utils.cache import cache_result


@cache_result('c3nav__mapdata__dimensions')
def get_dimensions():
    aggregate = Package.objects.all().aggregate(Max('right'), Min('left'), Max('top'), Min('bottom'))
    return (
        float(aggregate['right__max'] - aggregate['left__min']),
        float(aggregate['top__max'] - aggregate['bottom__min']),
    )


@cache_result('c3nav__mapdata__render_dimensions')
def get_render_dimensions():
    width, height = get_dimensions()
    return (width * settings.RENDER_SCALE, height * settings.RENDER_SCALE)


def get_render_path(filetype, level, mode, public):
    return os.path.join(settings.RENDER_ROOT,
                        '%s%s-level-%s.%s' % (('public-' if public else ''), mode, level, filetype))


def get_public_private_area(level):
    from c3nav.mapdata.models import AreaLocation

    width, height = get_dimensions()
    everything = box(0, 0, width, height)
    needs_permission = [location.geometry
                        for location in AreaLocation.objects.filter(level=level,
                                                                    routing_inclusion='needs_permission')]
{'fraction_non_alphanumeric': 0.11342846688620563, 'fraction_numerical': 0.005122575923893158, 'mean_word_length': 3.8561278863232684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4800461', 'n_tokens_mistral': 827, 'n_tokens_neox': 800, 'n_words': 181}