Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pages/workspace/create/file.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ const complete = computed(() =>
&& projectGroupId.value !== null
&& datasetType.value !== null
&& datasetFile.value instanceof File
&& datasetFile.value.name.endsWith('.zip')
&& (datasetFile.value.name.endsWith('.zip')
|| datasetFile.value.name.endsWith('.xml'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No .osm?

Copy link
Collaborator Author

@cyrossignol cyrossignol Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .osm extension is a little messy—OSM publishes the official planet file with the .osm extension, but other tools like JOSM may use the extension for both OSM XML and for changeset diffs (instead of .osc). We would need to peek the file to determine how to process it.

Though, I suppose the same issue exists with the .xml extension. Maybe we should shelve this until we have time to write out the validation logic.

);

function onFileChange(e) {
Expand Down
3 changes: 2 additions & 1 deletion services/import/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { OsmApiClient, OsmApiClientError, osm2osc } from '~/services/osm';
import { openTdeiPathwaysArchive, pathways2osc } from '~/services/pathways';
import { TdeiClient, TdeiClientError, TdeiConversionError } from '~/services/tdei';
import { WorkspacesClient, WorkspacesClientError } from '~/services/workspaces';
import { isMimeXml } from '~/util/xml';

const status = {
idle: 'Idle',
Expand Down Expand Up @@ -62,7 +63,7 @@ export class FileImporter {
}

async _run(data: Blob, workspace): Promise<number> {
if (workspace.type === 'osw') {
if (workspace.type === 'osw' && !isMimeXml(data.type)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a check for the mime type of a .zip file and display an error if the file is neither .zip or .xml vs. assuming anything not .xml is .zip?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense. Originally, this was "feed anything through to the converter, and let it complain if it doesn't support it", but it looks like the converter API's error messages are not helpful at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LMK if you wanna connect on wrapping this up!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(when you get back!)

this._context.status = status.convertOsm;
data = await this._tdeiClient.convertDataset(data, 'osw', 'osm', workspace.tdeiProjectGroupId);
}
Expand Down
6 changes: 6 additions & 0 deletions util/xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
const xmlParser = new DOMParser();
const xmlSerializer = new XMLSerializer();

export function isMimeXml(mimeType: string): boolean {
return mimeType === 'text/xml'
|| mimeType === 'application/xml'
|| mimeType.startsWith('application/') && mimeType.endsWith('+xml');
}

export function parse(input: string): XMLDocument {
return xmlParser.parseFromString(input, 'application/xml');
}
Expand Down