span8
span4
的想法通过nic_ran··公布的参数值parameterfetcher选择多
当使用ParameterFetcher(或AttributeCreator/Manager)获取发布参数“Choice (Multiple)”的值时,结果是一个空格分隔的字符串。但是,当任何已发布的参数选择包含空格时,值将被双引号括起来。如果选择值中没有空格,则不将其括在引号中。这使得在FME工作空间中提取实际选择的值成为问题。
例如,如果我发布的参数选择值为:
然后ParameterFetcher返回一个属性,该属性包含一个字符串:
从这个字符串检索各个选择值不是一项简单的任务。由于分隔符的原因,AttributeSplitter将无法工作
我的建议是让访问这些值变得更容易。为此,我提出两种替代方案:
即墨市评论·
我遇到了同样的问题,找到了这个帖子。我同意@nic_ran但与此同时,下面的Python代码将完成这项工作。
我在这段代码中使用了“inClause”来保存修改后的字符串,因为我想让用户的选择成为一个数据库查询中的in子句:
#的(多个)参数的选择#两个空间构建脚印,一个空间的自行车路线featureClassLabel =”“建筑脚印”BIA“自行车路线”通道的见= " " isStartQuote = False部分字符featureClassLabel:如果角色= =””:如果不是isStartQuote: #开始引用其他isStartQuote = True继续:#结尾引号isStartQuote = False继续其他:如果isStartQuote: #寻找报价之间的空间如果性格= = ' ':将空格替换为::。It could be any characters, though else: inClause += character # default; just add the character to InClause else: inClause += character # default; just add the character to inClause # inClause now looks like this # Building::Foot::Print BIA Bike::Route Areaway inClause = inClause.replace(' ',"','") # You are free to replace the spaces now inClause = inClause.replace('::',' ') # Now replace the :: back to spaces inClause = "'%s'" % inClause print inClause # inClause now looks like this # 'Building Foot Print','BIA','Bike Route','Areaway'
要在PythonCaller中执行这段代码,首先必须从参数中创建一个属性,然后使用
def processFeature(feature): featureClassLabel = featuregetattribute ("cboFeatureClassLabel")
分享你的好点子,或者为别人的点子投票。
©2019安全亚搏在线软件公司法律