Hi Craig Poynter ,
Doing a little test on your data, I think there might be another challenge: performance. As far as I understand you want to click on the polygon, query the intersecting points and retrieve all related data stored in a table of those selected points.
Have a look below what this would look like:
var intersectedpoints = Intersects(FeatureSetByName($map,"CUMULATIVE REGIONAL ANTIBIOGRAM"), $feature)
Console("points found: " + Count(intersectedpoints));
var dct_species = {};
var dct_microbes = {};
for (var pnt in intersectedpoints) {
var specie = pnt.species;
if (HasKey(dct_species, specie)) {
dct_species[specie] += 1;
} else {
dct_species[specie] = 1;
}
var fs = FeatureSetByRelationshipName(pnt, "form_microbe_repeat");
for (var f in fs) {
var microbe = f.microbe;
if (HasKey(dct_microbes, microbe)) {
dct_microbes[microbe] += 1;
} else {
dct_microbes[microbe] = 1;
}
}
}
Console(dct_species);
Console("");
Console(dct_microbes);
var result = "Species:";
for (var s in dct_species) {
result += TextFormatting.NewLine + " - " + s + ": " + dct_species[s];
}
result += TextFormatting.NewLine + TextFormatting.NewLine + "Microbes:"
for (var m in dct_microbes) {
result += TextFormatting.NewLine + " - " + m + ": " + dct_microbes[m];
}
return result;
The result is a single string containing:
Species:
- equine: 45
Microbes:
- actinobacillus_pasteurella_sp_: 1
- blood_culture_fluid_mixed_intes: 4
- bordetella_bronchiseptica_: 2
- enterobacter_cloacae_: 3
- escherichia_coli_: 1
- escherichia_coli_mucoid_: 1
- escherichia_coli_non_haemolytic: 4
- gram_negative_cocci_coccobacill: 1
- gram_negative_coccobacilli_: 2
- gram_negative_pleomorphic_cocco: 1
- lactobacillus_sp_: 1
- pasteruella_aerogenes: 4
- pasteurella_like_organism_: 2
- staphylococcus_aureus_: 8
- staphylococcus_aureus_intermedi: 1
- staphylococcus_sp_: 1
- streptococcus_dysgalactiae_subs: 4
- streptococcus_equi_subsp_zooepi: 6
- streptococcus_sp_alpha_haemolyt: 3
- streptococcus_sp_gp_c_: 3
However, executing time is horrible, since it consults for every specie the related records. There are at least 46 requests sent to the server and that results in a horrible response time.
I think there might be another way, but let me check that first.