<commit_before>import os
from itertools import permutations

from django.conf import settings
from PIL import Image, ImageDraw
from shapely.geometry import JOIN_STYLE

from c3nav.mapdata.utils import assert_multipolygon
from c3nav.routing.graph.point import GraphPoint
from c3nav.routing.graph.room import GraphRoom
from c3nav.routing.utils.base import get_nearest_point
from c3nav.routing.utils.draw import _ellipse_bbox, _line_coords


class GraphLevel():
    def __init__(self, graph, level):
        self.graph = graph
        self.level = level
        self.rooms = []

    def build(self):
        self.collect_rooms()
        self.create_points()

    def collect_rooms(self):
        accessibles = self.level.geometries.accessible
        accessibles = assert_multipolygon(accessibles)
        for geometry in accessibles:
            room = GraphRoom(self, geometry)
            if not room.empty:
                self.rooms.append(room)

    def create_points(self):
        for room in self.rooms:
            room.create_points()

        doors = self.level.geometries.doors
        doors = assert_multipolygon(doors)
        for door in doors:
            polygon = door.buffer(0.01, join_style=JOIN_STYLE.mitre)
            center = door.centroid
            points = []
            for room in self.rooms:
                if polygon.intersects(room.geometry):
                    nearest_point = get_nearest_point(room.clear_geometry, center)
                    point = GraphPoint(room, *nearest_point.coords[0])
                    points.append(point)
                    room.points.append(point)

            if len(points) < 2:
                print('door with <2 rooms (%d) detected!' % len(points))

            for from_point, to_point in permutations(points, 2):
                from_point.connect_to(to_point)

        levelconnectors = self.level.geometries.levelconnectors
        levelconnectors = assert_multipolygon(levelconnectors)
        for levelconnector in self.level.levelconnectors.all():
            polygon = levelconnector.geometry
            center = polygon.centroid

            for room in self.rooms:
                if not polygon.intersects(room.geometry):
                    continue

                point = center
                if not point.within(room.clear_geometry):
                    point = get_nearest_point(room.clear_geometry, point)

                point = GraphPoint(room, *point.coords[0])
                room.points.append(point)
                self.graph.add_levelconnector_point(levelconnector, point)<commit_msg>remove unneeded code<commit_after>import os
from itertools import permutations

from django.conf import settings
from PIL import Image, ImageDraw
from shapely.geometry import JOIN_STYLE

from c3nav.mapdata.utils import assert_multipolygon
from c3nav.routing.graph.point import GraphPoint
from c3nav.routing.graph.room import GraphRoom
from c3nav.routing.utils.base import get_nearest_point
from c3nav.routing.utils.draw import _ellipse_bbox, _line_coords


class GraphLevel():
    def __init__(self, graph, level):
        self.graph = graph
        self.level = level
        self.rooms = []

    def build(self):
        self.collect_rooms()
        self.create_points()

    def collect_rooms(self):
        accessibles = self.level.geometries.accessible
        accessibles = assert_multipolygon(accessibles)
        for geometry in accessibles:
            room = GraphRoom(self, geometry)
            if not room.empty:
                self.rooms.append(room)

    def create_points(self):
        for room in self.rooms:
            room.create_points()

        doors = self.level.geometries.doors
        doors = assert_multipolygon(doors)
        for door in doors:
            polygon = door.buffer(0.01, join_style=JOIN_STYLE.mitre)
            center = door.centroid
            points = []
            for room in self.rooms:
                if polygon.intersects(room.geometry):
                    nearest_point = get_nearest_point(room.clear_geometry, center)
                    point = GraphPoint(room, *nearest_point.coords[0])
                    points.append(point)
                    room.points.append(point)

            if len(points) < 2:
                print('door with <2 rooms (%d) detected!' % len(points))

            for from_point, to_point in permutations(points, 2):
                from_point.connect_to(to_point)

        for levelconnector in self.level.levelconnectors.all():
            polygon = levelconnector.geometry
            center = polygon.centroid

            for room in self.rooms:
                if not polygon.intersects(room.geometry):
                    continue

                point = center
                if not point.within(room.clear_geometry):
                    point = get_nearest_point(room.clear_geometry, point)

                point = GraphPoint(room, *point.coords[0])
                room.points.append(point)
                self.graph.add_levelconnector_point(levelconnector, point)
{'fraction_non_alphanumeric': 0.07733386075949367, 'fraction_numerical': 0.005142405063291139, 'mean_word_length': 2.1293316831683167, 'pattern_counts': {'":': 0, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1189215', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1348, 'n_words': 313}