def serialize_point(self, p: Point) -> gpb.Geometry:
        try:
            coordinate = gpb.Coordinate(x=p.x, y=p.y, z=p.z, has_z=True)
        except DimensionError:
            coordinate = gpb.Coordinate(x=p.x, y=p.y, has_z=False)

        return gpb.Geometry(type=gpb.Type.POINT, coordinates=[coordinate])
Example #2
0
    def serialize_point(self, p: Point) -> gpb.Geometry:
        try:
            coordinate = gpb.Coordinate(x=p.x, y=p.y, z=p.z)
        except shapely.errors.DimensionError:
            coordinate = gpb.Coordinate(x=p.x, y=p.y)

        return gpb.Geometry(type=gpb.Type.POINT, coordinates=[coordinate])
Example #3
0
 def create_coordinate_from_tuple(self, coordinates) -> gpb.Coordinate:
     try:
         return gpb.Coordinate(x=coordinates[0],
                               y=coordinates[1],
                               z=coordinates[2])
     except IndexError:
         return gpb.Coordinate(
             x=coordinates[0],
             y=coordinates[1],
         )