Skip to content

[Feature]: A plugin command that downloads a layer runs again when it lands, so it can go on with it (clip, rename, style) in the web app and, after #1170, on the desktop #1202

Closed

Description

@elpidioassinaturas

Before you start

What problem does this solve?

A plugin command can't download a service's features and then work on them in one call in the web app. After #1170 the same holds on the desktop for layer.addUrl.

The case: a data-catalogue plugin (Brazilian public data by theme, for the user's area). One click should bring the features that cross the area, clip them to the area's polygon (gp.run clip) and rename the result. On the desktop service.add {bbox} does the download and the plugin goes on. In the web app, from a command:

  • service.add refuses: "in the web app, use Home › Add › Add Data › From Service" without the capabilities (fetch_capabilities, crates/engine/src/cmd/service.rs:190), and "…From Service downloads the features" with them (service.rs:544).
  • host.fetch can't carry a layer:
    • answers are at most 2 MiB (plugin_fetch::MAX_BYTES), and the geology of one municipality (Teresina, IBGE BDiA WFS, 110 polygons) is 3.9 MB;
    • paging it is possible (8 pending fetches a call, 64 in all), but the command then holds the GeoJSON itself, and its budget (COMMAND_FUEL, 500 million) runs out building a 4 MB collection: "it ran too long and was stopped".
  • layer.addUrl answers {"pending": true} and the layer lands later, but nothing tells the plugin. The command has already returned, so the clip needs a second click, and the plugin has to tell the user to click again.

#1170 takes layer.addUrl off the frame on the desktop the same way, so after it a desktop plugin using layer.addUrl has the same gap. That is the right change for the window; this issue is about letting the command finish its work afterwards.

Proposed solution

Run the command again when what it left to the app has landed, as RustGIS already does for host.fetch:

  1. A command whose layer.addUrl (or service.add, see 3) left a download answers {"pending": true}. The bridge undoes what the call did to the project, as it does for a pending fetch.
  2. When the download lands, RustGIS runs the command again with the same parameters (Session::poll_plugin_retries). In that run the same layer.addUrl call adds the landed layer at once and answers what it added ({"layer", "features"}). The command then clips, renames or styles it, and all of it is one undo step.
  3. In the web app, service.add from a command leaves its requests to the front end the same way (the capabilities, then the features, as the From Service dialog fetches them), instead of refusing. It then answers as on the desktop in the run after they land.

Choices in this proposal

  • The same rerun as host.fetch, not a callback command. Plugins already handle pending and reruns, and the docs already describe them. A callback ("on layer landed") would need a new manifest field and state the plugin can't keep.
  • The landed download is kept for the rerun only. It is kept by its address and parameters, as host.fetch keeps answers, and dropped once the rerun has taken it (or after the host.fetch time to live). So a layer isn't added twice, and memory isn't held.
  • Scripts, gp.run and rustgis-cli don't change. They keep waiting for the layer, as fix(plugins): a plugin's layer.addUrl downloads off the frame on the desktop #1170 keeps them.
  • The limits stay those of fix(plugins): a plugin's layer.addUrl downloads off the frame on the desktop #1170 and host.fetch: 16 downloads, 8 pending, a bounded number of reruns. A plugin that needs more says so.

Estimated scope

Medium. Most of it exists already: request_url / take_url_requests (#1170), the pending-and-rerun loop of host.fetch, and the From Service dialog's off-frame download of capabilities and features. The new part is keeping the landed layer by request until the command runs again, and service.add's web path.

Alternatives considered

  • Two clicks (what the plugin does now in the web app): the first downloads, the second finds the layer "(sem recorte)" and clips it. It works, but the user has to be told to click again, and a failed download (a 502 without CORS headers, which the browser reports as a CORS error) only shows as the app's error.
  • Raising the host.fetch cap and the command budget: this moves the limit rather than removing it, and it keeps layers' GeoJSON inside the plugin.
  • A tool instead of a command (TOOL_FUEL is 30 billion): tools make no host requests, so a tool can't fetch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions