Hello
I am trying to use an Arcade -expression to create house number labels for building polygons downloaded from OpenStreetMap. OSM has the building number in "Tags" -field among several other tags. I have been trying multiple approaches where I pick the phrase "housenumber" and then return any characters after that before the closing marker.
I guess the closest I got was to Split the text but I get an error when trying to return arrays other than [0].
The "housenumber" -tag is not always the last tag so counting characters from the end does not work.
Here's how the original "Tags" -field looks like
"osm_uid"=>"38239", "building"=>"terrace", "osm_user"=>"Daeron", "way_area"=>"1.26619e-07", "addr:street"=>"Kantakyläntie", "osm_version"=>"4", "osm_changeset"=>"13506017", "osm_timestamp"=>"2012-10-15T13:31:04Z", "addr:housenumber"=>"7"
What I would like to label is just the
7
The house number can be anything between 1 and 5 characters such as "13-15"
Solved! Go to Solution.
Hi jussi.lehtonenesri-fi-esridist ,
Have a look at this Arcade example taking as input a static string, but it should work point it to the tag field:
var tag = '"osm_uid"=>"38239", "building"=>"terrace", "osm_user"=>"Daeron", "way_area"=>"1.26619e-07", "addr:street"=>"Kantakyläntie", "osm_version"=>"4", "osm_changeset"=>"13506017", "osm_timestamp"=>"2012-10-15T13:31:04Z", "addr:housenumber"=>"13-15","someotherdata"=>"oops"';
var index1 = Find("addr:housenumber", tag);
if (index1 > -1) {
var index2 = Find("=>", tag, index1);
var index3 = Find(",", tag, index2);
if (index3 == -1) {
// last data in string
var housenumber = Right(tag, Count(tag)-index2-2);
var housenumber = Replace(housenumber, '"', '');
return housenumber;
} else {
// there is data after the housenumber
var housenumber = Mid(tag, index2+2, index3-index2-2);
var housenumber = Replace(housenumber, '"', '');
return housenumber;
}
} else {
return "";
}
Hi jussi.lehtonenesri-fi-esridist ,
Have a look at this Arcade example taking as input a static string, but it should work point it to the tag field:
var tag = '"osm_uid"=>"38239", "building"=>"terrace", "osm_user"=>"Daeron", "way_area"=>"1.26619e-07", "addr:street"=>"Kantakyläntie", "osm_version"=>"4", "osm_changeset"=>"13506017", "osm_timestamp"=>"2012-10-15T13:31:04Z", "addr:housenumber"=>"13-15","someotherdata"=>"oops"';
var index1 = Find("addr:housenumber", tag);
if (index1 > -1) {
var index2 = Find("=>", tag, index1);
var index3 = Find(",", tag, index2);
if (index3 == -1) {
// last data in string
var housenumber = Right(tag, Count(tag)-index2-2);
var housenumber = Replace(housenumber, '"', '');
return housenumber;
} else {
// there is data after the housenumber
var housenumber = Mid(tag, index2+2, index3-index2-2);
var housenumber = Replace(housenumber, '"', '');
return housenumber;
}
} else {
return "";
}
Works perfectly, when pointing to the field. Thanks Xander Bakker