def test_spatial_knn_correctness(self):
        point_rdd = PointRDD(self.sc, input_location, offset, splitter, True,
                             StorageLevel.MEMORY_ONLY, "epsg:4326",
                             "epsg:3005")
        result_no_index = KNNQuery.SpatialKnnQuery(point_rdd, query_point,
                                                   top_k, False)
        point_rdd.buildIndex(IndexType.RTREE, False)
        result_with_index = KNNQuery.SpatialKnnQuery(point_rdd, query_point,
                                                     top_k, True)

        sorted_result_no_index = sorted(
            result_no_index,
            key=lambda geo_data: distance_sorting_functions(
                geo_data, query_point))

        sorted_result_with_index = sorted(
            result_with_index,
            key=lambda geo_data: distance_sorting_functions(
                geo_data, query_point))

        difference = 0
        for x in range(top_k):
            difference += sorted_result_no_index[x].geom.distance(
                sorted_result_with_index[x].geom)

        assert difference == 0
Esempio n. 2
0
    def test_spatial_knn_query_correctness(self):
        rectangle_rdd = RectangleRDD(self.sc, inputLocation, offset, splitter,
                                     True)

        result_no_index = KNNQuery.SpatialKnnQuery(rectangle_rdd,
                                                   self.query_point,
                                                   self.top_k, False)
        rectangle_rdd.buildIndex(IndexType.RTREE, False)

        result_with_index = KNNQuery.SpatialKnnQuery(rectangle_rdd,
                                                     self.query_point,
                                                     self.top_k, True)

        sorted_result_no_index = sorted(
            result_no_index,
            key=lambda geo_data: distance_sorting_functions(
                geo_data, self.query_point))

        sorted_result_with_index = sorted(
            result_with_index,
            key=lambda geo_data: distance_sorting_functions(
                geo_data, self.query_point))

        difference = 0
        for x in range(self.top_k):
            difference += sorted_result_no_index[x].geom.distance(
                sorted_result_with_index[x].geom)

        assert difference == 0
    def test_spatial_knn_query_using_index(self):
        point_rdd = PointRDD(self.sc, input_location, offset, splitter, False)
        point_rdd.buildIndex(IndexType.RTREE, False)

        for i in range(self.loop_times):
            result = KNNQuery.SpatialKnnQuery(point_rdd, self.query_point, self.top_k, False)
            assert result.__len__() > -1
Esempio n. 4
0
    def test_spatial_knn_query(self):
        object_rdd = PointRDD(
            self.sc, point_rdd_input_location, point_rdd_offset, point_rdd_splitter, True, StorageLevel.MEMORY_ONLY
        )
        object_rdd.rawJvmSpatialRDD.persist(StorageLevel.MEMORY_ONLY)

        for _ in range(each_query_loop_times):
            result = KNNQuery.SpatialKnnQuery(object_rdd, knn_query_point, 1000, False)
Esempio n. 5
0
 def test_spatial_knn_query(self):
     line_string_rdd = LineStringRDD(self.sc, input_location, splitter,
                                     True)
     for i in range(self.loop_times):
         result = KNNQuery.SpatialKnnQuery(line_string_rdd,
                                           self.query_point, 5, False)
         assert result.__len__() > -1
         assert result[0].getUserData() is not None
Esempio n. 6
0
    def test_spatial_knn_query(self):
        point_rdd = PointRDD(self.sc, input_location, offset, splitter, False)

        for i in range(self.loop_times):
            result = KNNQuery.SpatialKnnQuery(point_rdd, self.query_point,
                                              self.top_k, False)
            assert result.__len__() > -1
            assert result[0].getUserData() is not None
Esempio n. 7
0
 def test_spatial_knn_query_using_index(self):
     polygon_rdd = PolygonRDD(self.sc, input_location, splitter, True)
     polygon_rdd.buildIndex(IndexType.RTREE, False)
     for i in range(self.loop_times):
         result = KNNQuery.SpatialKnnQuery(polygon_rdd, self.query_point,
                                           self.top_k, True)
         assert result.__len__() > -1
         assert result[0].getUserData() is not None
Esempio n. 8
0
    def test_spatial_knn_using_linestring(self):
        rectangle_rdd = RectangleRDD(self.sc, inputLocation, offset, splitter,
                                     True)

        result_no_index = KNNQuery.SpatialKnnQuery(rectangle_rdd,
                                                   self.query_line, self.top_k,
                                                   False)

        print(result_no_index)
Esempio n. 9
0
    def test_spatial_knn_query_using_index(self):
        object_rdd = PointRDD(
            self.sc, point_rdd_input_location, point_rdd_offset, point_rdd_splitter, True, StorageLevel.MEMORY_ONLY
        )
        object_rdd.buildIndex(point_rdd_index_type, False)
        object_rdd.indexedRawRDD.persist(StorageLevel.MEMORY_ONLY)

        for _ in range(each_query_loop_times):
            result = KNNQuery.SpatialKnnQuery(object_rdd, knn_query_point, 1000, True)
Esempio n. 10
0
 def test_knn_query(self):
     object_rdd = PointRDD(sparkContext=self.sc,
                           InputLocation=point_rdd_input_location,
                           Offset=point_rdd_offset,
                           splitter=point_rdd_splitter,
                           carryInputData=False)
     for i in range(each_query_loop_times):
         result = KNNQuery.SpatialKnnQuery(object_rdd, knn_query_point,
                                           1000, False)
Esempio n. 11
0
    def test_spatial_knn_query(self):
        point_rdd = PointRDD(
            self.sc, input_location, offset, splitter, True, StorageLevel.MEMORY_ONLY, "epsg:4326", "epsg:3005"
        )

        for i in range(loop_times):
            result = KNNQuery.SpatialKnnQuery(point_rdd, query_point, top_k, False)
            assert result.__len__() > 0
            assert result[0].getUserData() is not None