Repository navigation
Replies: 1 comment
|
was supposed to be an issue |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Before you start
What problem does this solve?
A plugin can add a new data format to GeoLibre: its own reader, an Add Data
entry (
registerMenuContribution, #2850), and its own layers. What it cannotdo is receive that format when a user drops the file on the map.
Drop handling lives in
apps/geolibre-desktop/src/hooks/desktop-shell/useFileDrop.ts. It existstwice, once for the browser (
handleDrop, line 371,Fileobjects) and oncefor the Tauri native drop (
onDragDropEvent, line 129, file paths). Bothwork the same way:
geotagged photos, rasters, GeoPackage, vector files.
Every extension belongs to exactly one built-in group. Plugins cannot
register a group of their own.
The case that hits us is a
.zipfile. The core treats every.zipas azipped shapefile (
file-io/vector-loader.ts:232). Many domain formats arealso shipped as zip files. An example is agricultural machine data in
ISO 11783-10 (ISOXML), where the file is
TASKDATA.zipand holdsTASKDATA.XMLplus binary logs. When a user drops it, GeoLibre shows thedrop overlay and then fails in the shapefile path. The plugin that can read
the file never sees it. On desktop, the drop arrives as a Tauri native event
and not as a DOM
dropevent, so a plugin cannot intercept it with alistener either.
This is not specific to one format. Any plugin that reads a format the core
does not know runs into the same problem, for example:
TASKDATA.zip, either zipped or as an unzippedTASKDATAfolder(our plugin,
isoxml-taskdata)(vendor display exports, AgGateway ADAPT data)
Proposed solution
Add a plugin-registrable file handler, in the same style as the existing
registries (
registerMenuContribution,registerRightPanel,registerToolbarMenu,registerFloatingPanel):How the drop handling would use it:
handler gets the files that match its
extensions, in registrationorder, and claims what it recognises. Claimed files are removed from the
drop.
any change.
For extensions that no built-in group uses, the order makes no difference.
It only matters where a plugin and the core share an extension, such as
.zip. There,claimdecides by content.Built-in behaviour stays the same when no plugin registers a handler, and
also when a handler claims nothing. A shapefile zip still loads as a
shapefile, because an ISOXML handler only claims archives that contain
TASKDATA.XML.DroppedFilehides the difference between a browserFileand a Tauri path.That keeps one handler working on web and desktop. The existing
readLocalFileBytes/Filesplit inuseFileDrop.tsalready does thisinternally.
Security: a handler runs inside a plugin that is already installed and
already trusted. The new API only gives that plugin files the user dropped
on purpose. The existing gates stay in place:
layout=viewerand adeployment without
data:addstill block every drop before any handlerruns.
Same registry for data URLs (follow-up PR)
Data loaded by URL, through
?data=or the embedaddDatacommand, has thesame gap.
fetchRemoteDatainapps/geolibre-desktop/src/lib/data-url.ts(line 384) downloads the file and recognises a zip by extension, content
type or the
PKsignature. It then assumes that any zip contains GeoJSONfiles. A
TASKDATA.ziptherefore fails with "The ZIP archive does notcontain any GeoJSON files", although an installed plugin could read it.
This matters for hosts that embed GeoLibre and hand it files from their own
backend.
Proposal for a second PR, using the same registry:
step, the registered handlers are offered the downloaded file with the
same
claimcall: name, size and, for a zip, the entry list. The firsthandler that claims it opens it. Without a claim, everything stays as
today.
dataTypehint skips detection. Today it only acceptslidar(line 8). A handler could register its own hint name, e.g.
dataType=isoxml. When a URL carries that hint, GeoLibre passes the filestraight to that handler without running
claim. This helps with URLsthat have no extension, such as signed or API endpoints, and with files
that more than one handler could claim. The hint is an override, not the
normal way: a URL without a hint is still recognised automatically.
The first PR would cover drag and drop only, with the API shaped so that
the URL path can reuse it without changes.
Estimated scope
Small to medium:
packages/plugins/src, followingmenu-contribution-registry.tsuseFileDrop.ts; bothalready split the dropped files into groups, so this is one more group
file-io/shapefile-zip.tsdocs/plugin-api.md, andtests
The change only adds behaviour.
Alternatives considered
This is our workaround today. It works, but users drop files on the map,
not on a panel. The app-wide overlay also covers the plugin panel during
a drag, so the panel drop area is hard to reach.
droplistener in the plugin. This does not work on desktop,because the Tauri native drop never becomes a DOM event. In the browser
it would race with the shell's own handler.
domain formats such as ISOXML belong in plugins.
manifest. This is simpler, but
.zipis ambiguous, so the core wouldstill need to look inside the archive. The
extensionspre-filter plusclaimcovers both cases and keepsclaimfrom being called for files ahandler can never take.
If this direction is welcome, I'm happy to send a PR. The plugin that needs
the hook already exists, so I can test the change against it.
All reactions