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.
Could try something using the modulus operator. Will return the remainder of the division, so it is evenly divided by 5, will return 0.
if ($feature.cngmetros % 5 == 0){
return True //(or whatever value you require)
}
R_
As RhettZufelt said, calculate the remainder of the division by 5 and make your code return values only when the remainder is 0. I tried it based on RhettZufelt code:
Result: labeling only multiples of 5:
Cheers
E.,
I found the solution and it was to declare the round in the return.
result:
thanks to all of you who participated
Hi,
Actually, the round function does round and works fine. The label is not shown because you are returning the original value (see "return inpval") . You do the rounding in the condition statement and it dose pass the condition but it returns the original value. so, you need to modify ur code and return the rounded value
Cheers,
E.
Could try something using the modulus operator. Will return the remainder of the division, so it is evenly divided by 5, will return 0.
if ($feature.cngmetros % 5 == 0){
return True //(or whatever value you require)
}
R_
thanks to both of you for the help, related to this topic how could I label the pk's ending in decimal values.
Regards
As RhettZufelt said, calculate the remainder of the division by 5 and make your code return values only when the remainder is 0. I tried it based on RhettZufelt code:
Result: labeling only multiples of 5:
Cheers
E.,
thanks to both of you for the help, related to this topic how could I label the pk's ending in decimal values.
Regards
I continue with this topic... I have already managed to mark the end of the P.K., but as always the arcade solutions leave much to be desired.....
with this expression I have succeeded:
just by looking at the image you would think that it has been achieved, but not because only 2 decimals can be shown in the P.k, so the round function would be very good, but .......
surprise:
disappears, the truth that I have no idea why to put a rounding disappears the value has been used the text function in case it does something but does nothing.
someone knows why this happens.
Greetings Javier
Your parren is in the wrong place. Looks like you need to encapsulate the round function in parens, then compare != 0.
var inpval = $feature.cngmetros
if(inpval == 0 || inpval % 5 == 0 || Round(inpval % 1 != 0,2) != 0){
return inpval
}
R_
thank you for your reply.
I have tried your expression and it gives the same result, I do not understand why the round function does not round.
Regards
I found the solution and it was to declare the round in the return.
result:
thanks to all of you who participated
Sorry, should have read the question better. I just fixed the error in the round function so a label would show.
R_