Thanks for reaching out.
ConversionService.Run sometimes chooses the wrong converter for archives with overlapping contents (e.g., .kmz files with .kml inside), fails to detect File Geodatabase in ZIPs, and rejects .geojsonseq inputs. This breaks orchestration and affects all further logic.
Symptoms
- .kmz inputs are dispatched to Kml instead of Kmz.
- ZIPs containing *.gdb folder (typical File Geodatabase) are not detected.
- Single file .geojsonseq returns “Unknown input file type”.
- Archives containing .json are ambiguous (GeoJSON vs EsriJSON vs TopoJSON vs GeoJSONSeq).
Root Causes
- Non-deterministic archive detection with overlapping requirements (e.g., both Kml and Kmz match .kml).
- FGDB detection relies on Path.GetExtension(entry) and misses folder-based .gdb layout inside ZIPs.
- JSON detection is gated by ext.EndsWith("json"), which misses .geojsonseq.
- Archive JSON detection relies on extensions, not content sniffing.
Exact Fix (Drop-in Code)
What this adds:
Deterministic archive resolution with outer extension bias (.kmz → Kmz).
- FGDB detection via folder segments (*.gdb/…) and marker extensions (e.g., .gdbtable).
- A JSON family extension set and content sniffing (file + archive stream).
- .geojsonseq support.
- Better messages for missing extensions, and optional directory handling for .gdb folders.
**
1) Update ConversionService (archive detection & single-file JSON)
**notes 01.txt
2) Add helper to open archive entry as a stream
This lets you sniff JSON content inside ZIPs without extracting.
If you prefer full extraction to tempFolderPath instead of on-demand streams, you can skip this helper and extract the JSON entry then sniff the file. Streaming is faster and cleaner for large archives.
Tests (prove the fix)
Add these to your tests project (using the same FakeFactory/FakeConverter pattern you have).
[Fact(DisplayName = RunDetectsGeoJs.txt
Expected Outcomes (after fix)
- .kmz archives are always dispatched to Kmz, even if they contain only .kml.
- ZIPs with *.gdb/… folder or FGDB markers are correctly dispatched to Gdb.
- .geojsonseq single files are recognized and dispatched to GeoJsonSeq.
- Archives containing JSON are sniffed to the precise JSON type and dispatched accordingly.
- Unknown/no-extension inputs produce clear, friendly error messages. If a failure persists inside a converter (e.g., Aspose parsing errors), the orchestration will correctly report a failure—those are converter/library issues, not detection/dispatch. Notes / Best Practices
- Keep ConverterFactory.TryCreate(key, out conv) implemented for all keys you dispatch: GeoJson, EsriJson, TopoJson, GeoJsonSeq, Kmz, Gdb, Shapefile, etc.
- Consider adding a CancellationToken to converter calls for large inputs.
- JsonFormatDetector should support file and stream sniffing for GeoJSON/EsriJSON/TopoJSON/GeoJSONSeq.
If the issue has been resolved, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.