Ejemplo n.º 1
0
    def test_search_by_distance_check_limit(self):
        """
        Test to validate that solr searches by distance using several units. It will also validate
        that and exception is arisen if geodetic predicates are used against cartesian geometry

        @since 2.0.0
        @jira_ticket PYTHON-698
        @expected_result if the search distance is below the real distance only one
        name will be in the list, otherwise, two

        @test_category dse graph
        """
        # Paul Thomas Joe and George Bill Steve are 64.6923761881464 km apart
        self._assert_in_distance(
            Geo.inside(Distance(-92.46295, 44.0234, 65), GeoUnit.KILOMETERS),
            ["George Bill Steve", "Paul Thomas Joe"])

        self._assert_in_distance(
            Geo.inside(Distance(-92.46295, 44.0234, 64), GeoUnit.KILOMETERS),
            ["Paul Thomas Joe"])

        # Paul Thomas Joe and George Bill Steve are 40.19797892069464 miles apart
        self._assert_in_distance(
            Geo.inside(Distance(-92.46295, 44.0234, 41), GeoUnit.MILES),
            ["George Bill Steve", "Paul Thomas Joe"])

        self._assert_in_distance(
            Geo.inside(Distance(-92.46295, 44.0234, 40), GeoUnit.MILES),
            ["Paul Thomas Joe"])
Ejemplo n.º 2
0
 def inside(value, units=GeoUnit.DEGREES):
     """
     Search any instance of geometry inside the Distance targeted.
     :param value: A Distance to look for.
     :param units: The units for ``value``. See GeoUnit enum. (Can also
         provide an integer to use as a multiplier to convert ``value`` to
         degrees.)
     """
     return GeoP.inside(
         value=Distance(x=value.x, y=value.y, radius=value.radius * units))
Ejemplo n.º 3
0
    def test_search_by_distance(self):
        """
        Test to validate that solr searches by distance.

        @since 1.0.0
        @jira_ticket PYTHON-660
        @expected_result all names with a geo location within a 2 degree distance of -92,44 are returned

        @test_category dse graph
        """
        self._assert_in_distance(Geo.inside(Distance(-92, 44, 2)),
                                 ["Paul Thomas Joe", "George Bill Steve"])
    def test_distance_parse(self):
        """
        This test exercises the parsing logic our Distance WKT object
        @since 1.2
        @jira_ticket PYTHON-670
        @test_category dse geometric
        @expected_result We should be able to form Distance objects from properly formatted WKT strings
        """

        ds = "DISTANCE ((12, 10) 3)"
        do = Distance(12, 10, 3)
        self.assertEqual(do.x, 12)
        self.assertEqual(do.y, 10)
        self.assertEqual(do.radius, 3)
        # Test bad distance strings

        bds = "DISTANCE ((1.0 2.0))"
        with self.assertRaises(ValueError):
            bdo = Distance.from_wkt(bds)
        bps = "DISTANCE ((1.0 2.0 3.0 4.0 5.0)"
        with self.assertRaises(ValueError):
            bdo = Distance.from_wkt(bds)
Ejemplo n.º 5
0
    def test_search_by_distance_with_miles_units(self):
        """
        Test to validate that solr searches by distance.

        @since 2.0.0
        @jira_ticket PYTHON-698
        @expected_result all names with a geo location within a 70-mile radius of -92,44 are returned

        @test_category dse graph
        """
        self._assert_in_distance(
            Geo.inside(Distance(-92, 44, 70), GeoUnit.MILES),
            ["Paul Thomas Joe", "George Bill Steve"])
Ejemplo n.º 6
0
    def _test_search_by_distance_meters_units(self, schema, graphson):
        """
        Test to validate that solr searches by distance.

        @since 2.0.0
        @jira_ticket PYTHON-698
        @expected_result all names with a geo location within a 56k-meter radius of -92,44 are returned

        @test_category dse graph
        """
        self._assert_in_distance(schema, graphson,
            Geo.inside(Distance(-92, 44, 56000), GeoUnit.METERS),
            ["Paul Thomas Joe"]
        )