Ejemplo n.º 1
0
    def DistanceJoinQueryFlat(cls, spatialRDD: SpatialRDD,
                              queryRDD: SpatialRDD, useIndex: bool,
                              considerBoundaryIntersection: bool) -> RDD:
        """

        :param spatialRDD: SpatialRDD
        :param queryRDD: SpatialRDD
        :param useIndex: bool
        :param considerBoundaryIntersection: bool

        >> spatial_rdd =
        >> query_rdd =
        >> spatial_join_result = JoinQuery.DistanceJoinQueryFlat(spatial_rdd, query_rdd, True, True)
        >> spatial_join_result.collect()
        [GeoData(), GeoData()]
        :return:
        """

        jvm = spatialRDD._jvm
        sc = spatialRDD._sc

        spatial_join = jvm.JoinQuery.DistanceJoinQueryFlat
        srdd = spatial_join(spatialRDD._srdd, queryRDD._srdd, useIndex,
                            considerBoundaryIntersection)

        serlialized = jvm.GeoSerializerData.serializeToPython(srdd)

        return RDD(serlialized, sc, GeoSparkPickler())
Ejemplo n.º 2
0
    def SpatialRangeQuery(self, spatialRDD: SpatialRDD, rangeQueryWindow: BaseGeometry, considerBoundaryIntersection: bool, usingIndex: bool):
        """

        :param spatialRDD:
        :param rangeQueryWindow:
        :param considerBoundaryIntersection:
        :param usingIndex:
        :return:
        """

        jvm = spatialRDD._jvm
        sc = spatialRDD._sc

        jvm_geom = GeometryAdapter.create_jvm_geometry_from_base_geometry(jvm, rangeQueryWindow)

        srdd = jvm.\
            RangeQuery.SpatialRangeQuery(
            spatialRDD._srdd,
            jvm_geom,
            considerBoundaryIntersection,
            usingIndex
        )

        serialized = JvmGeoSparkPythonConverter(jvm).translate_spatial_rdd_to_python(srdd)

        return RDD(serialized, sc, GeoSparkPickler())
Ejemplo n.º 3
0
    def SpatialJoinQueryFlat(cls, spatialRDD: SpatialRDD, queryRDD: SpatialRDD,
                             useIndex: bool,
                             considerBoundaryIntersection: bool) -> RDD:
        """
        Function takes SpatialRDD and other SpatialRDD and based on two parameters
        - useIndex
        - considerBoundaryIntersection
        creates RDD with result of Spatial Join operation. It Returns RDD[GeoData, GeoData]

        :param spatialRDD: SpatialRDD
        :param queryRDD: SpatialRDD
        :param useIndex: bool
        :param considerBoundaryIntersection: bool
        :return: RDD

        >> spatial_join_result = JoinQuery.SpatialJoinQueryFlat(
        >>      spatialRDD, queryRDD, useIndex, considerBoundaryIntersection
        >> )
        >> spatial_join_result.collect()
        [[GeoData(Polygon, ), GeoData()], [GeoData(), GeoData()], [GeoData(), GeoData()]]
        """

        jvm = spatialRDD._jvm
        sc = spatialRDD._sc

        spatial_join = jvm.JoinQuery.SpatialJoinQueryFlat
        srdd = spatial_join(spatialRDD._srdd, queryRDD._srdd, useIndex,
                            considerBoundaryIntersection)

        serlialized = jvm.GeoSerializerData.serializeToPython(srdd)

        return RDD(serlialized, sc, GeoSparkPickler())
Ejemplo n.º 4
0
    def spatialPartitionedRDD(self):
        """

        :return:
        """
        serialized_spatial_rdd = self._jvm.GeoSerializerData.serializeToPython(
            get_field(self._srdd, "spatialPartitionedRDD"))

        if not hasattr(self, "_spatial_partitioned_rdd"):
            setattr(self, "_spatial_partitioned_rdd",
                    RDD(serialized_spatial_rdd, self._sc, GeoSparkPickler()))
        else:
            self._spatial_partitioned_rdd._jrdd = serialized_spatial_rdd

        return getattr(self, "_spatial_partitioned_rdd")
Ejemplo n.º 5
0
    def getRawSpatialRDD(self):
        """

        :return:
        """

        serialized_spatial_rdd = GeoSparkPythonConverter(self._jvm).translate_spatial_rdd_to_python(self._srdd.getRawSpatialRDD())

        if not hasattr(self, "_raw_spatial_rdd"):
            RDD.saveAsObjectFile = lambda x, path: x._jrdd.saveAsObjectFile(path)
            setattr(self, "_raw_spatial_rdd", RDD(serialized_spatial_rdd, self._sc, GeoSparkPickler()))
        else:
            self._raw_spatial_rdd._jrdd = serialized_spatial_rdd

        return getattr(self, "_raw_spatial_rdd")
Ejemplo n.º 6
0
    def spatialPartitionedRDD(self):
        """

        :return:
        """
        serialized_spatial_rdd = GeoSparkPythonConverter(
            self._jvm).translate_spatial_rdd_to_python(
                get_field(self._srdd, "spatialPartitionedRDD"))

        if not hasattr(self, "_spatial_partitioned_rdd"):
            setattr(self, "_spatial_partitioned_rdd",
                    RDD(serialized_spatial_rdd, self._sc, GeoSparkPickler()))
        else:
            self._spatial_partitioned_rdd._jrdd = serialized_spatial_rdd

        return getattr(self, "_spatial_partitioned_rdd")
Ejemplo n.º 7
0
    def getRawSpatialRDD(self):
        """

        :return:
        """

        serialized_spatial_rdd = self._jvm.GeoSerializerData.serializeToPython(
            self._srdd.getRawSpatialRDD())

        if not hasattr(self, "_raw_spatial_rdd"):
            RDD.saveAsObjectFile = lambda x, path: x._jrdd.saveAsObjectFile(
                path)
            setattr(self, "_raw_spatial_rdd",
                    RDD(serialized_spatial_rdd, self._sc, GeoSparkPickler()))
        else:
            self._raw_spatial_rdd._jrdd = serialized_spatial_rdd

        return getattr(self, "_raw_spatial_rdd")
Ejemplo n.º 8
0
    def DistanceJoinQuery(cls, spatialRDD: SpatialRDD, queryRDD: SpatialRDD,
                          useIndex: bool,
                          considerBoundaryIntersection: bool) -> RDD:
        """

        :param spatialRDD: SpatialRDD
        :param queryRDD: SpatialRDD
        :param useIndex: bool
        :param considerBoundaryIntersection: bool
        :return:
        """

        jvm = spatialRDD._jvm
        sc = spatialRDD._sc
        srdd = jvm.JoinQuery.DistanceJoinQuery(spatialRDD._srdd,
                                               queryRDD._srdd, useIndex,
                                               considerBoundaryIntersection)
        serlialized = jvm.GeoSerializerData.serializeToPythonHashSet(srdd)

        return RDD(serlialized, sc, GeoSparkPickler())
Ejemplo n.º 9
0
    def spatialJoin(cls, queryWindowRDD: SpatialRDD, objectRDD: SpatialRDD,
                    joinParams: JoinParams) -> RDD:
        """

        :param queryWindowRDD: SpatialRDD
        :param objectRDD: SpatialRDD
        :param joinParams: JoinParams
        :return:
        """

        jvm = queryWindowRDD._jvm
        sc = queryWindowRDD._sc

        jvm_join_params = joinParams.jvm_instance(jvm)

        srdd = jvm.JoinQuery.spatialJoin(queryWindowRDD._srdd, objectRDD._srdd,
                                         jvm_join_params)

        serlialized = jvm.GeoSerializerData.serializeToPython(srdd)

        return RDD(serlialized, sc, GeoSparkPickler())
Ejemplo n.º 10
0
    def spatialJoin(cls, queryWindowRDD: SpatialRDD, objectRDD: SpatialRDD,
                    joinParams: JoinParams) -> RDD:
        """

        :param queryWindowRDD: SpatialRDD
        :param objectRDD: SpatialRDD
        :param joinParams: JoinParams
        :return:
        """

        jvm = queryWindowRDD._jvm
        sc = queryWindowRDD._sc

        jvm_join_params = joinParams.jvm_instance(jvm)

        srdd = jvm.JoinQuery.spatialJoin(queryWindowRDD._srdd, objectRDD._srdd,
                                         jvm_join_params)
        serialized = JvmGeoSparkPythonConverter(jvm).\
            translate_spatial_pair_rdd_to_python(srdd)

        return RDD(serialized, sc, GeoSparkPickler())
Ejemplo n.º 11
0
    def DistanceJoinQuery(cls, spatialRDD: SpatialRDD, queryRDD: SpatialRDD,
                          useIndex: bool,
                          considerBoundaryIntersection: bool) -> RDD:
        """

        :param spatialRDD: SpatialRDD
        :param queryRDD: SpatialRDD
        :param useIndex: bool
        :param considerBoundaryIntersection: bool
        :return:
        """

        jvm = spatialRDD._jvm
        sc = spatialRDD._sc
        srdd = jvm.JoinQuery.DistanceJoinQuery(spatialRDD._srdd,
                                               queryRDD._srdd, useIndex,
                                               considerBoundaryIntersection)
        serialized = JvmGeoSparkPythonConverter(jvm).\
            translate_spatial_pair_rdd_with_hashset_to_python(srdd)

        return RDD(serialized, sc, GeoSparkPickler())