Exemplo n.º 1
0
// DataByFilter returns a ROI Data based on a string specification of the form
// "roi:<roiname>,<uuid>". If the given string is not parsable, the "found" return value is false.
func DataByFilter(spec storage.FilterSpec) (d *Data, v dvid.VersionID, found bool, err error) {
	filterval, found := spec.GetFilterSpec("roi")
	if !found {
		return
	}
	return DataBySpec(filterval)
}
Exemplo n.º 2
0
// NewFilter returns a Filter for use with a push of key-value pairs.
func (d *Data) NewFilter(fs storage.FilterSpec) (storage.Filter, error) {
	filter := &Filter{Data: d, fs: fs}

	// if there's no filter, just use base Data send.
	roidata, roiV, roiFound, err := roi.DataByFilter(fs)
	if err != nil {
		return nil, fmt.Errorf("No filter found that was parsable (%s): %v\n", fs, err)
	}
	filter.roi = roidata
	tilespec, tilespecFound := fs.GetFilterSpec("tile")

	if (!roiFound || roidata == nil) && !tilespecFound {
		dvid.Debugf("No ROI or tile filter found for imagetile push, so using generic data push.\n")
		return nil, nil
	}
	if tilespecFound {
		filter.planes = strings.Split(tilespec, ",")
	}

	// Get the spans once from datastore.
	filter.spans, err = roidata.GetSpans(roiV)
	if err != nil {
		return nil, err
	}

	return filter, nil
}
Exemplo n.º 3
0
// ParseFilterSpec returns the specified ROI instance name and version within a FilterSpec.
// Currently, only one ROI can be specified in a FilterSpec.  Multiple ROIs should use a
// different FilterSpec like "intersect" instead of "roi".
func ParseFilterSpec(spec storage.FilterSpec) (name dvid.InstanceName, v dvid.VersionID, found bool, err error) {
	var filterval string
	filterval, found = spec.GetFilterSpec("roi")
	if !found {
		return
	}
	roispec := strings.Split(filterval, ",")
	if len(roispec) != 2 {
		err = fmt.Errorf("bad ROI spec: %s", filterval)
		return
	}
	name = dvid.InstanceName(roispec[0])
	_, v, err = datastore.MatchingUUID(roispec[1])
	return
}