Skip to content

feat(core): export GeoJSON, CSV ed E7 (formato del blog) - #38

Merged
ronzim merged 2 commits into
masterfrom
feat/16-geojson-csv-e7
Oct 14, 2026
Merged

ronzim merged 2 commits into
masterfrom
feat/16-geojson-csv-e7

Conversation

@ronzim

@ronzim ronzim commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Closes #16. Chiude anche l'epic dati #23 (#22, #17, #16).

Nuovi exporter (packages/core/src/exporters/)

  • GeoJSON (exportToGeoJson / toGeoJson): punti e visite diventano Point, le activity diventano LineString (dal path oppure, senza path, da start/end). Coordinate [lng, lat], proprietà kind, startTime, activityType… Opzioni includePoints / includeTimeline.
  • CSV (exportToCsv): una riga per punto, visita e punto di path. Colonne kind,timestamp,end_time,lat,lng,activity_type,accuracy,name,place_id, quoting RFC 4180, delimitatore configurabile.
  • E7 (exportToE7 / toE7Locations): { locations: [{ latitudeE7, longitudeE7, timestamp }] }, cioè il formato che si aspetta il blog (maps.js divide per 1e7). Usa i punti grezzi e i punti dei path delle activity (un punto senza timestamp prende l'inizio dell'activity), ordinati per istante. È la stessa logica dello script manuale di blog/PLAN.md §1.3, che non serve più. Le visite si possono aggiungere con includeVisits (default no, come nel blog).
  • Dispatcher exportDataset(ds, format) e exportFormatFromPath(path), condivisi da CLI e app: .kml, .geojson, .csv, .e7.json → E7, altrimenti JSON.

CLI e app

  • CLI: il formato si deduce dall'estensione, oppure si forza con --export-format json|kml|geojson|csv|e7.
  • App: nel dialog di export ci sono i filtri GeoJSON, CSV e "E7 locations" (.e7.json).

Test

  • 16 test sugli exporter e 4 test CLI. Totale 194/194 ok. tsc di core e app ok, build dell'app ok, ESLint senza nuovi warning.

Da verificare

  • Nel dialog di salvataggio, il filtro con estensione doppia e7.json non l'ho provato su Windows/macOS. In ogni caso basta chiamare il file nome.e7.json.
  • Flusso del blog: --filter-date A B --export content/<ID>.e7.json (poi rinominare in <ID>.json). Va provato su un export reale prima di aggiornare PLAN.md nel blog.

README e AGENTS.md aggiornati.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CecUKcJiSVnehcZEiXLgtk

- exportToGeoJson: point/visit come Point, activity come LineString
  (path o start/end), coordinate [lng, lat]
- exportToCsv: una riga per punto, visita e punto di path (RFC 4180)
- exportToE7: { locations: [{ latitudeE7, longitudeE7, timestamp }] }
  da punti grezzi e path delle activity, ordinato per tempo; sostituisce
  la conversione manuale del blog
- exportDataset / exportFormatFromPath: dispatcher comune a CLI e app
  (.kml, .geojson, .csv, .e7.json, altrimenti JSON)
- CLI: nuovi formati e --export-format; app: filtri nel dialog di export
- README e AGENTS.md aggiornati

Closes #16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CecUKcJiSVnehcZEiXLgtk
Copilot AI balanced review requested due to automatic review settings October 14, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It changes the public export API and the shared CLI/app export path, includes an author-flagged untested cross-platform .e7.json save-dialog behavior, and a CSV completeness gap that warrant human verification.

1 open finding
What changed in this PR

This PR extends mappit-core's export capabilities beyond JSON/KML by adding three new exporters — GeoJSON (RFC 7946), CSV (RFC 4180 quoting), and E7 (latitudeE7/longitudeE7, the format expected by the downstream travel blog). It introduces a shared format dispatcher (exportDataset + exportFormatFromPath) that both the CLI and the Electron app now use, replacing the previous inline ext === '.kml' branching. This closes issue #16 and the data epic #23, and makes the blog's manual E7 conversion step unnecessary.

Changes:

  • New exporters in packages/core/src/exporters/ (GeoJSON, CSV, E7) plus a exportDataset/exportFormatFromPath dispatcher re-exported from the barrel and index.ts.
  • CLI gains --export-format and infers the format from the file extension; the app's main process and save dialog use the shared dispatcher and offer the new formats.
  • New tests (exporter unit tests + CLI integration tests) and documentation updates in README.md / AGENTS.md.
File Description
packages/​core/​src/​exporters/​geojson-exporter.ts New GeoJSON exporter: points/visits→Point, activities→LineString with [lng,lat].
packages/​core/​src/​exporters/​csv-exporter.ts New CSV exporter with RFC 4180 quoting; one row per point/visit/path point.
packages/​core/​src/​exporters/​e7-exporter.ts New E7 exporter producing { locations: [...] } sorted by instant for the blog.
packages/​core/​src/​exporters/​index.ts Adds ExportFormat, EXPORT_FORMATS, exportFormatFromPath, and exportDataset dispatcher.
packages/​core/​src/​index.ts Re-exports the new exporters and types from the package entry point.
packages/​core/​src/​cli.ts Uses the dispatcher; adds --export-format; infers format from extension.
packages/​app/​src/​main/​index.ts Export IPC handler now delegates to the shared dispatcher.
packages/​app/​src/​renderer/​main.ts Save dialog adds GeoJSON/CSV/E7 filters.
packages/​core/​tests/​exporters/​formats.test.ts New unit tests for the three exporters and the dispatcher.
packages/​core/​tests/​cli.test.ts New CLI integration tests for the export formats.
README.md /​ AGENTS.md Documentation updated for the new formats and CLI options.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +73 to +83
} else {
for (const p of e.path) {
rows.push({
kind: 'path',
timestamp: p.timestamp ?? e.startTime,
lat: p.lat,
lng: p.lng,
activity_type: e.activityType,
});
}
}
Dalla review di Copilot sulla PR #38: prima sparivano dal CSV.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CecUKcJiSVnehcZEiXLgtk
@ronzim
ronzim merged commit 8e2c49a into master Oct 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export in GeoJSON e CSV

3 participants