Pre-filling parameters with values from data tables

Hello,

I have 6 parameters; the first 2 are a list of options whose values come from a data table.

These data tables have columns corresponding to xmin, ymin, xmax, ymax (bounding box).

<section name="bbox_crs" title="Bounding box and CRS">
 <param name="country" type="select" label="country" help="chose a country from the list of countries" optional="true">
  <options from_data_table="countries">
   <column name="value" index="0"/>
   <column name="name" index="1"/>
  </options>
 </param>
 <param name="region" type="select" label="region" help="chose a region from the list of regions" optional="true">
  <options from_data_table="regions">
   <column name="value" index="0"/>
   <column name="name" index="1"/>
   <filter type="param_value" ref="country" column="2"/>
  </options>
 </param>
 <param name="authority" type="text" label="CRS authority" help="examples: EPSG, OGC, ESRI, IAU" optional="true"/>
 <param name="code" type="text" label="CRS code" help="CRS code"  optional="true"/>
 <section name="CRSBboxWGS84" title="Bounding Box" expanded="true">
  <param name="xmin" type="float" label="Minimum X"/>
  <param name="ymin" type="float" label="Minimum Y"/>
  <param name="xmax" type="float" label="Maximum X"/>
  <param name="ymax" type="float" label="Maximum Y"/>
 </section>
</section>

What I want is that when a region is selected, the bounding box parameters are updated to the bounding box of the region. When a country is selected but no region is selected, the bounding box is updated to the bounding box of the country.

I think it’s possible to do that, but I don’t know which way is better. Is it possible to do that in XML only or is another script file necessary?

The only recommended approach I know of is via param options filtering as described here:

but you seem to be aware of this possibility already.

Assuming coordinates are stored in the regions and countries data tables you could add them as separate parameters through extra from_data_table selects that you, effectively filter down to a single item (the coordinates stored with the selected country/region). There wouldn’t be much to select for the user, but this way they could learn about the coordinatess.

You could then make the bounding box section params optional, and in the command section, you would take care that any custom coordinates take precedence over region values over country values.

Obviously, I’ve tested none of this and there might be issues I’m overlooking, but maybe these are somewhat useful ideas?

2 Likes

Thanks you @wm75 it’s an interesting solution!

It’s actually easier than I thought because the country and region parameters are optional. I don’t think it’s useful to see the bounding of the selected country/region.

I will use a conditional block to ask if the user wants a custom bounding box; if so, only the bounding box parameters appear; if not, the selected country will appear. An other condition asks the user if they need a region. If so, the region’s bounding box will be selected; if not, the country’s bounding box will be selected.

1 Like