Select to view content in your preferred language

Arcade Popup, need code review to optimize processing speed

442
2
Jump to solution
03-15-2024 09:18 AM
BrandonPrice1
Occasional Contributor

Hello,

The Arcade Popup displays two different types of popups, depending on which feature type is selected. This is the code:

var GeneralIntersect = Intersects(FeatureSetByName($map, "ZNET_Public - Zoning (Hidden from Map)"), Buffer($feature, -20, "feet"))
var SP_Intersect = Intersects(FeatureSetByName($map, "ZNET_Public - Zoning SP Category (Hidden from Map)"), Buffer($feature, -20, "feet"))
var zone_list = ''
//var zone_d =''
var zone_link = ''
var zone_area =''
var sp_zone = ''

for (var f in GeneralIntersect){
  zone_list += f.ZONE + ' '
  //zone_d = f.Z_DESC + ' Zone';
  zone_link = 'https://library.municode.com/ca/los_angeles_county/codes/code_of_ordinances?nodeId=TIT22PLZO_' + f.TITLE_22
  zone_area = Proper(f.NAME) + "-" + f.PLNG_AREA + " Planning Area"
}

for (var g in SP_Intersect){
  sp_zone = '- ' + g.PLAN_LEG
}

var revision_text = "";
if ($feature.TaxRateCity != "unincorporated") {
    revision_text += "This property is within the city of <b>" + $feature.TaxRateCity +  "</b> and is out of our jurisdiction. <br><br>Our zoning is only for the UNINCORPORATED areas of LA County. <br><br>Contact city staff for zoning info.<br><br><a href='https://file.lacounty.gov/SDSInter/lac/1043535_city_webaddress.pdf'>Incorporated LA County Cities Contact List</a>";
}
if (revision_text == "") {
    revision_text = "<a href='" + zone_link + "'><font color=#0066ff><b>" + f.Z_DESC + " Zone (" + f.Z_CATEGORY + ")↗</b></font></a><br><span style='font-size:15px;'>Specific Zone(s): " + zone_list + "<span>" + sp_zone + "</span><span title='This may or may not be the same as the zone category above.&#013;It can differ when extra numbers or letters are added to the end,&#013;or when the property is part of a specific plan. Extra numbers&#013;indicate a minimum lot size and letters indicate a combined&#013;zone.'> ⓘ</span><br><br><span style='font-size:15px;'><b><i>Main Address:</i></b><i><br>" + $feature.SitusFullAddress + "</i><br><b><i>AIN:</i></b><i> " + $feature.AIN + "</i><br><br>" + zone_area + "<br><br><a href='https://portal.assessor.lacounty.gov/parceldetail/{AIN}'><font color=#0066ff><i>Get Assessor Details for this Property↗</i></font></a><br><a href='https://rpgis.isd.lacounty.gov/Html5Viewer/index.html?viewer=GISNET_Public.GIS-NET_Public&run=UrlSearch&term={AIN}'><font color=#0066ff><i>Go to this Property in GIS-NET↗</i></font></a><br><a href='https://planning.lacounty.gov/land-use-zoning/'><font color=#0066ff><i>Learn More about Zoning↗</i></font></a><br><a href='https://outlook.office365.com/book/RegionalPlanningVirtualOnlineAppointments@lacounty.onmicrosoft.com/'><font color=#0066ff><i>Schedule an Appointment↗</i></font></a></span>";
}
return { 
                type : 'text', 
                text : "<span style=\"display: block; size: '20'; font-size: 16px; text-align: left; padding: 0.5rem; color: black; \">" + revision_text + "</span>"//this property supports html tags 
}

Popup 1

BrandonPrice1_0-1710519273798.png

Popup 2

BrandonPrice1_1-1710519381289.png

The app using the web map with this code is currently private. Is it still possible to assess if this was the best way to write this code? Or is there a way to improve so it processes faster?

-Brandon

 

1 Solution

Accepted Solutions
BrandonPrice1
Occasional Contributor

Hi Ken. Thank you. The first part which checks if the TaxRateCity is unincoporated runs a lot faster now that it runs first. The template literals make the code cleaner although may have not impacted the processing speed one way or the other. I still could not get the second half to run without using the loops in the original code so that processing time is the same. I will keep taking a look.

 

var revision_text;
if ($feature.TaxRateCity != "unincorporated") {
revision_text = `This property is within the city of <b>${$feature.TaxRateCity}</b> and is out of our jurisdiction.<br/><br/>  
Our zoning is only for the UNINCORPORATED areas of LA County.<br/><br/>Contact city staff for zoning info.<br/><br/><a href='https://file.lacounty.gov/SDSInter/lac/1043535_city_webaddress.pdf'>Incorporated LA County Cities Contact List</a>`;
} 

else {
var featBuffer = Buffer($feature, -20, "feet");
var GeneralIntersect = Intersects(FeatureSetByName($map, "ZNET_Public - Zoning (Hidden from Map)"), featBuffer);

var SP_Intersect = Intersects(FeatureSetByName($map, "ZNET_Public - Zoning SP Category (Hidden from Map)"), featBuffer);
var zone_link = ``;
//var zone_area = ``
var zone_list = ``
var sp_zone = ``

for (var f in GeneralIntersect){
zone_list += f.ZONE + ' '
//zone_d = f.Z_DESC + ' Zone';
zone_link = `https://library.municode.com/ca/los_angeles_county/codes/code_of_ordinances?nodeId=TIT22PLZO_${f.TITLE_22}`
//zone_area = `${Proper(f.NAME)}-${f.PLNG_AREA} Planning Area`
}

for (var g in SP_Intersect){
  sp_zone = `-${g.PLAN_LEG}`
}

revision_text = `<a href='${zone_link}'><font color=#0066ff><b>${f.Z_DESC} Zone (${f.Z_CATEGORY})↗</b></font></a><br><span style='font-size:15px;'>Specific Zone(s): ${zone_list} <span>- ${sp_zone}</span><span title='This may or may not be the same as the zone category above.&#013;It can differ when extra numbers or letters are added to the end,&#013;or when the property is part of a specific plan. Extra numbers&#013;indicate a minimum lot size and letters indicate a combined&#013;zone.'> ⓘ</span><br><br><span style='font-size:15px;'><b><i>Main Address:</i></b><i><br>${$feature.SitusFullAddress}</i><br>
<b><i>AIN:</i></b><i> ${$feature.AIN}</i><br><br>
${Proper(f.NAME)}-${f.PLNG_AREA} Planning Area<br><br>
<a href='https://portal.assessor.lacounty.gov/parceldetail/${$feature.AIN}'><font color=#0066ff><i>Get Assessor Details for this Property↗</i></font></a><br>
<a href='https://rpgis.isd.lacounty.gov/Html5Viewer/index.html?viewer=GISNET_Public.GIS-NET_Public&run=UrlSearch&term=${$feature.AIN}'><font color=#0066ff><i>Go to this Property in GIS-NET↗</i></font></a><br>
<a href='https://planning.lacounty.gov/land-use-zoning/'><font color=#0066ff><i>Learn More about Zoning↗</i></font></a><br>
<a href='https://outlook.office365.com/book/RegionalPlanningVirtualOnlineAppointments@lacounty.onmicrosoft.com/'><font color=#0066ff><i>Schedule an Appointment↗</i></font></a></span>`;
}

return {
  type : 'text',
  text : `<span style=\"display: block; size: '20'; font-size: 16px; text-align: left; padding: 0.5rem; color: black; \">${revision_text}</span>`
}

 

 

 

 

 

  

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

The first thing you should do is check if the TaxRateCity is unincorporated. There's no need to do the expensive buffer and intersections if isn't in your jurisdiction.

Next, you're buffering the feature twice. Only do that once.

It looks like the feature only intersect one Zoning feature and one Zoning SP category, since you're not pushing the results into an array. If so, you can just get the First item in each intersection FeatureSet instead of looping through them.

Here's my attempt at making this more efficient, also using template literals to make it easier to understand. Note, it's not tested, so it may need some tweaking.

var revision_text ;
if ($feature.TaxRateCity != "unincorporated") {
    revision_text = `This property is within the city of <b>${$feature.TaxRateCity}</b> and is out of our jurisdiction.<br/><br/>  
                    Our zoning is only for the UNINCORPORATED areas of LA County.<br/><br/>
                    Contact city staff for zoning info.<br/><br/>
                    <a href='https://file.lacounty.gov/SDSInter/lac/1043535_city_webaddress.pdf'>Incorporated LA County Cities Contact List</a>`;
} else {
  var featBuffer = Buffer($feature, -20, "feet");
  var GeneralIntersect = First(Intersects(FeatureSetByName($map, "ZNET_Public - Zoning (Hidden from Map)"), featBuffer));
  var SP_Intersect = First(Intersects(FeatureSetByName($map, "ZNET_Public - Zoning SP Category (Hidden from Map)"), featBuffer));
  var zone_link = `https://library.municode.com/ca/los_angeles_county/codes/code_of_ordinances?nodeId=TIT22PLZO_${GeneralIntersect.TITLE_22}`;
  var zone_area = `${Proper(GeneralIntersect.NAME)}-${GeneralIntersect.PLNG_AREA} Planning Area`

  revision_text = `<a href='${zone_link}'><font color=#0066ff><b>${GeneralIntersect.Z_DESC} Zone (${GeneralIntersect.Z_CATEGORY})↗</b></font></a><br>
                   <span style='font-size:15px;'>Specific Zone(s): ${GeneralIntersect.Zone} <span>- ${SP_Intersect.PLAN_LEG}</span><span title='This may or may not be the same as the zone category above.&#013;It can differ when extra numbers or letters are added to the end,&#013;or when the property is part of a specific plan. Extra numbers&#013;indicate a minimum lot size and letters indicate a combined&#013;zone.'> ⓘ</span><br><br>
                   <span style='font-size:15px;'><b><i>Main Address:</i></b><i><br>
                   ${$feature.SitusFullAddress}</i><br>
                   <b><i>AIN:</i></b><i> ${$feature.AIN}</i><br><br>
                   ${zone_area}<br><br>
                   <a href='https://portal.assessor.lacounty.gov/parceldetail/${$feature.AIN}'><font color=#0066ff><i>Get Assessor Details for this Property↗</i></font></a><br>
                   <a href='https://rpgis.isd.lacounty.gov/Html5Viewer/index.html?viewer=GISNET_Public.GIS-NET_Public&run=UrlSearch&term=${$feature.AIN}'><font color=#0066ff><i>Go to this Property in GIS-NET↗</i></font></a><br>
                   <a href='https://planning.lacounty.gov/land-use-zoning/'><font color=#0066ff><i>Learn More about Zoning↗</i></font></a><br>
                   <a href='https://outlook.office365.com/book/RegionalPlanningVirtualOnlineAppointments@lacounty.onmicrosoft.com/'><font color=#0066ff><i>Schedule an Appointment↗</i></font></a></span>`;
   
}
return { 
  type : 'text', 
  text : `<span style=\"display: block; size: '20'; font-size: 16px; text-align: left; padding: 0.5rem; color: black; \">${revision_text}</span>`
}

 

0 Kudos
BrandonPrice1
Occasional Contributor

Hi Ken. Thank you. The first part which checks if the TaxRateCity is unincoporated runs a lot faster now that it runs first. The template literals make the code cleaner although may have not impacted the processing speed one way or the other. I still could not get the second half to run without using the loops in the original code so that processing time is the same. I will keep taking a look.

 

var revision_text;
if ($feature.TaxRateCity != "unincorporated") {
revision_text = `This property is within the city of <b>${$feature.TaxRateCity}</b> and is out of our jurisdiction.<br/><br/>  
Our zoning is only for the UNINCORPORATED areas of LA County.<br/><br/>Contact city staff for zoning info.<br/><br/><a href='https://file.lacounty.gov/SDSInter/lac/1043535_city_webaddress.pdf'>Incorporated LA County Cities Contact List</a>`;
} 

else {
var featBuffer = Buffer($feature, -20, "feet");
var GeneralIntersect = Intersects(FeatureSetByName($map, "ZNET_Public - Zoning (Hidden from Map)"), featBuffer);

var SP_Intersect = Intersects(FeatureSetByName($map, "ZNET_Public - Zoning SP Category (Hidden from Map)"), featBuffer);
var zone_link = ``;
//var zone_area = ``
var zone_list = ``
var sp_zone = ``

for (var f in GeneralIntersect){
zone_list += f.ZONE + ' '
//zone_d = f.Z_DESC + ' Zone';
zone_link = `https://library.municode.com/ca/los_angeles_county/codes/code_of_ordinances?nodeId=TIT22PLZO_${f.TITLE_22}`
//zone_area = `${Proper(f.NAME)}-${f.PLNG_AREA} Planning Area`
}

for (var g in SP_Intersect){
  sp_zone = `-${g.PLAN_LEG}`
}

revision_text = `<a href='${zone_link}'><font color=#0066ff><b>${f.Z_DESC} Zone (${f.Z_CATEGORY})↗</b></font></a><br><span style='font-size:15px;'>Specific Zone(s): ${zone_list} <span>- ${sp_zone}</span><span title='This may or may not be the same as the zone category above.&#013;It can differ when extra numbers or letters are added to the end,&#013;or when the property is part of a specific plan. Extra numbers&#013;indicate a minimum lot size and letters indicate a combined&#013;zone.'> ⓘ</span><br><br><span style='font-size:15px;'><b><i>Main Address:</i></b><i><br>${$feature.SitusFullAddress}</i><br>
<b><i>AIN:</i></b><i> ${$feature.AIN}</i><br><br>
${Proper(f.NAME)}-${f.PLNG_AREA} Planning Area<br><br>
<a href='https://portal.assessor.lacounty.gov/parceldetail/${$feature.AIN}'><font color=#0066ff><i>Get Assessor Details for this Property↗</i></font></a><br>
<a href='https://rpgis.isd.lacounty.gov/Html5Viewer/index.html?viewer=GISNET_Public.GIS-NET_Public&run=UrlSearch&term=${$feature.AIN}'><font color=#0066ff><i>Go to this Property in GIS-NET↗</i></font></a><br>
<a href='https://planning.lacounty.gov/land-use-zoning/'><font color=#0066ff><i>Learn More about Zoning↗</i></font></a><br>
<a href='https://outlook.office365.com/book/RegionalPlanningVirtualOnlineAppointments@lacounty.onmicrosoft.com/'><font color=#0066ff><i>Schedule an Appointment↗</i></font></a></span>`;
}

return {
  type : 'text',
  text : `<span style=\"display: block; size: '20'; font-size: 16px; text-align: left; padding: 0.5rem; color: black; \">${revision_text}</span>`
}