Skip to main content

代码片段

过滤字段

  • 仅限制长度
def test(Contour, Shape_Length):
Contour = float(round(Contour, 2))
length = int(Shape_Length)
limt = 1000

if length >= limt:
if Contour==0:
return "流速不变"
elif Contour>0:
return "流速增大"
else:
return "流速减少"
else:
return ""
test(!Contour!, !Shape_Length!)

限制长度等值线范围

def test(Contour, Shape_Length):
Contour = float(round(Contour, 2))
length = round(Shape_Length, 2)
limt = 900
contour_limt = [0, 0.01, -0.01, 0.03, -0.03]

if length >= limt and Contour in contour_limt:
if Contour == 0:
return "流速不变"
elif Contour > 0:
return "流速增大"
else:
return "流速减少"
return ""
test(!Contour!, !Shape_Length!)

仅过滤流速变化

def test(Contour):
Contour = float(round(Contour, 2))

if Contour == 0:
return "流速不变"
elif Contour> 0:
return "流速增大"
else:
return "流速减少"

test(!Contour!)

标注相关

根据某字段显示

// 假设当前字段名称为 
// static字段,记录了三种状态
// 流速增大、流速不变、流速减小
// 就算字段为空,在length中也会显示为1,所以指定为4的才显示
function FindLabel ( [static], [Contour] )
{
tar = [static].toString()
if( tar.length == 4 ) { return [Contour] }
return "";
}
// 添加条件限制
function FindLabel ( [static], [Contour], [Shape_Length] )
{
var tar = [static].toString()
var limt = 300

if(tar != "" && [Shape_Length] >= limt) return [Contour]

return "";
}