<commit_before>import os
import unittest

from ott.otp_client.transit_index.routes import Routes
from ott.otp_client.transit_index.stops import Stops
from ott.utils.geo.bbox import BBox
from ott.utils.geo.point import Point

from .base import *


class TiTestGeo(unittest.TestCase):
    """ test gtsdb trimet queries via geom junk"""
    db = None
    DO_PG = False

    def setUp(self):
        # import pdb; pdb.set_trace()
        if TiTestGeo.db is None:
            from .tests_ti import TiTest
            if TiTest.DO_PG:
                self.DO_PG = True
                self.db = get_pg_db(TiTest.PG_URL, 'trimet')

    def test_bbox_stops(self):
        if self.DO_PG:
            bbox = BBox(min_lat=45.530, max_lat=45.535, min_lon=-122.665, max_lon=-122.667)
            stops = Stops.bbox_stops(self.db.session, bbox)
            self.assertTrue(len(stops) > 5)

    def test_point_stops(self):
        if self.DO_PG:
            point = Point(x=-122.6664, y=45.53)
            stops = Stops.nearest_stops(self.db.session, point)
            self.assertTrue(len(stops) > 5)<commit_msg>improve the distance query for trimet stops<commit_after>import os
import unittest

from ott.otp_client.transit_index.routes import Routes
from ott.otp_client.transit_index.stops import Stops
from ott.utils.geo.bbox import BBox
from ott.utils.geo.point import Point

from .base import *


class TiTestGeo(unittest.TestCase):
    """ test gtsdb trimet queries via geom junk"""
    db = None
    DO_PG = False

    def setUp(self):
        # import pdb; pdb.set_trace()
        if TiTestGeo.db is None:
            from .tests_ti import TiTest
            if TiTest.DO_PG:
                self.DO_PG = True
                self.db = get_pg_db(TiTest.PG_URL, 'trimet')

    def test_bbox_stops(self):
        if self.DO_PG:
            bbox = BBox(min_lat=45.530, max_lat=45.535, min_lon=-122.665, max_lon=-122.667)
            stops = Stops.bbox_stops(self.db.session, bbox)
            self.assertTrue(len(stops) > 5)

    def test_point_stops(self):
        if self.DO_PG:
            #import pdb; pdb.set_trace()
            point = Point(x=-122.6664, y=45.53)
            stops = Stops.nearest_stops(self.db.session, point)
            self.assertTrue(len(stops) > 5)
            self.assertTrue(stops[0].get('dist') > 1 and stops[0].get('dist') < 100)
{'fraction_non_alphanumeric': 0.10629251700680271, 'fraction_numerical': 0.03231292517006803, 'mean_word_length': 2.385611510791367, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '3935835', 'n_tokens_mistral': 879, 'n_tokens_neox': 830, 'n_words': 177}