Skip to content

Commit

Permalink
avoided computing geo-transform repeatedly (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
edisonguo authored May 23, 2020
1 parent 06dcfa8 commit 54729e2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions processor/tile_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (gi *GeoRasterGRPC) Run(varList []string, verbose bool) {
var connPool []*grpc.ClientConn
var projWKT string
var cLimiter *ConcLimiter
var geot []float64

accumMetrics := &pb.WorkerMetrics{}

Expand Down Expand Up @@ -135,6 +136,8 @@ func (gi *GeoRasterGRPC) Run(varList []string, verbose bool) {
C.OSRDestroySpatialReference(hSRS)

cLimiter = NewConcLimiter(g0.GrpcConcLimit * len(connPool))

geot = BBox2Geot(g0.Width, g0.Height, g0.BBox)
}

if g0.GrpcTileXSize > 0.0 || g0.GrpcTileYSize > 0.0 {
Expand Down Expand Up @@ -212,7 +215,7 @@ func (gi *GeoRasterGRPC) Run(varList []string, verbose bool) {
go func(g *GeoTileGranule, idx int) {
defer wgRpc.Done()
defer cLimiter.Decrease()
r, err := getRPCRaster(gi.Context, g, projWKT, connPool[idx%len(connPool)])
r, err := getRPCRaster(gi.Context, g, projWKT, geot, connPool[idx%len(connPool)])
if err != nil {
gi.sendError(err)
r = &pb.Result{Raster: &pb.Raster{Data: make([]uint8, g.Width*g.Height), RasterType: "Byte", NoData: -1.}}
Expand Down Expand Up @@ -314,9 +317,8 @@ func getDataSize(dataType string) (int, error) {
}
}

func getRPCRaster(ctx context.Context, g *GeoTileGranule, projWKT string, conn *grpc.ClientConn) (*pb.Result, error) {
func getRPCRaster(ctx context.Context, g *GeoTileGranule, projWKT string, geot []float64, conn *grpc.ClientConn) (*pb.Result, error) {
c := pb.NewGDALClient(conn)
geot := BBox2Geot(g.Width, g.Height, g.BBox)
granule := &pb.GeoRPCGranule{Operation: "warp", Height: int32(g.Height), Width: int32(g.Width), Path: g.Path, DstSRS: projWKT, DstGeot: geot, Bands: []int32{int32(g.BandIdx)}}
if g.GeoLocation != nil {
granule.GeoLocOpts = []string{
Expand Down

0 comments on commit 54729e2

Please sign in to comment.