good afternoon, everyone,
I have a webmap where I represent kilometer points every meter, I would like to be able to label those P.K every 5 meters and for that I need to use an expression in arcade, but I can't find the solution.
I am currently trying a conditional with the expression equal or default but I don't get what I am looking for.
Does anyone know what would be the expression to label those P.K every 5 meters?
Thanks to all of you who participate.
example code:
if (DefaultValue($feature.cngmetros, 0))
return Pkinicial
else (DefaultValue($feature.cngmetros, 5))
return PK5metros
else (DefaultValue($feature.cngmetros, ','))
return Pk5metros
else (DefaultValue($feature.cngmetros, '.'))
return Pk5metros
Greetings Javier
#############################ESPAÑOL##########################################
buenas tardes a todos ,
tengo un webmap donde represento puntos kilométricos cada metro, me gustaría poder etiquetar esos P.K cada 5 metros y para ello necesito utilizar un expresión en arcade, pero no encuentro la solución.
actualmente estoy intentando un condicional con la expresion equal o default pero no consigo lo que busco.
¿alguien sabe cual seria la expresion para etiquetar esos P.K cada 5 metros?
Gracias a todos lo que participeis.
ejemplo de codigo:
if (DefaultValue($feature.cngmetros, 0))
return Pkinicial
else (DefaultValue($feature.cngmetros, 5))
return PK5metros
else (DefaultValue($feature.cngmetros, ','))
return Pk5metros
else (DefaultValue($feature.cngmetros, '.'))
return Pk5metros
Saludos Javier
Solved! Go to Solution.
To find multiples of a number, you can use the modulo operator. X modulo Y means "divide X by Y and return the rest". If the modulo is zero, X is divisible by Y, so it's a multiple.
So you could do something like this:
var cngmetros = $feature.cngmetros
// if value is zero or divisible by 5
// % is the modulo operator in many languages
if(cngmetros == 0 || cngmetros % 5 == 0) {
return cngmetros
}
Hi Javier,
I'm not sure that DefaultValue is the function that you want. It evaluates the first parameter and if it finds null or an empty string it returns the second parameter.
Are you wanting to return "Pkinicial" if the value of the cngmetros field is 0 and "Pk5metros" if the value of cngmetros is a multiple of 5?
To find multiples of a number, you can use the modulo operator. X modulo Y means "divide X by Y and return the rest". If the modulo is zero, X is divisible by Y, so it's a multiple.
So you could do something like this:
var cngmetros = $feature.cngmetros
// if value is zero or divisible by 5
// % is the modulo operator in many languages
if(cngmetros == 0 || cngmetros % 5 == 0) {
return cngmetros
}