Esempio n. 1
0
    def deserialize(self, datum):
        from geo_pyspark.sql.geometry import GeometryFactory
        from geo_pyspark.utils.binary_parser import BinaryParser

        bin_parser = BinaryParser(datum)
        geom = GeometryFactory.geometry_from_bytes(bin_parser)

        return geom
Esempio n. 2
0
 def __getstate__(self):
     from geo_pyspark.sql.geometry import GeometryFactory
     attributes = copy(self.__slots__)
     geom = getattr(self, attributes[0])
     return dict(
         geom=bytearray([el if el >= 0 else el + 256 for el in GeometryFactory.to_bytes(geom)]),
         userData=getattr(self, attributes[1])
     )
Esempio n. 3
0
    def _deserialize_geom(cls, bin_parser: BinaryParser) -> GeoData:
        from geo_pyspark.sql.geometry import GeometryFactory

        user_data_length = bin_parser.read_int()
        geom = GeometryFactory.geometry_from_bytes(bin_parser)
        if user_data_length > 0:
            user_data = bin_parser.read_string(user_data_length)
            geo_data = GeoData(geom=geom, userData=user_data)

        else:
            geo_data = GeoData(geom=geom, userData="")
        return geo_data
Esempio n. 4
0
    def deserialize(self, datum):
        geom = GeometryFactory.geometry_from_bytes(datum)

        return geom
Esempio n. 5
0
 def serialize(self, obj):
     return GeometryFactory.to_bytes(obj)
Esempio n. 6
0
 def serialize(self, obj):
     from geo_pyspark.sql.geometry import GeometryFactory
     return GeometryFactory.to_bytes(obj)
Esempio n. 7
0
 def __setstate__(self, attributes):
     from geo_pyspark.sql.geometry import GeometryFactory
     from geo_pyspark.utils.binary_parser import BinaryParser
     bin_parser = BinaryParser(attributes["geom"])
     self._geom = GeometryFactory.geometry_from_bytes(bin_parser)
     self._userData = attributes["userData"]