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
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]) )
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
def deserialize(self, datum): geom = GeometryFactory.geometry_from_bytes(datum) return geom
def serialize(self, obj): return GeometryFactory.to_bytes(obj)
def serialize(self, obj): from geo_pyspark.sql.geometry import GeometryFactory return GeometryFactory.to_bytes(obj)
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"]