Skip to content
Snippets Groups Projects
Commit d38683e1 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

wip import c+ to AMT

parent f7b891da
Branches
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ pnpm dev ...@@ -12,6 +12,7 @@ pnpm dev
After exporting the data to json files with the Rust script from `v2s-datapod`. After exporting the data to json files with the Rust script from `v2s-datapod`.
```sh ```sh
# takes about 200 seconds (4 minutes)
time npx tsx src/scripts/cesium-plus-import.ts time npx tsx src/scripts/cesium-plus-import.ts
``` ```
...@@ -20,3 +21,5 @@ You can then manually pin the cid according to the command output. ...@@ -20,3 +21,5 @@ You can then manually pin the cid according to the command output.
```sh ```sh
ipfs pin add -r bafyreie74jtf23zzz2tdgsz7axfrm4pidje43ypqn25v4gkdtfjbcj62km ipfs pin add -r bafyreie74jtf23zzz2tdgsz7axfrm4pidje43ypqn25v4gkdtfjbcj62km
``` ```
This will make easier to insert this data in any AMT or other data structure.
\ No newline at end of file
...@@ -4,7 +4,7 @@ import { Buffer } from 'buffer' ...@@ -4,7 +4,7 @@ import { Buffer } from 'buffer'
// for reference see // for reference see
// https://doc.e-is.pro/cesium-plus-pod/REST_API.html // https://doc.e-is.pro/cesium-plus-pod/REST_API.html
interface CplusProfile { export interface CplusProfile {
version: number version: number
title: string title: string
description: string description: string
......
<script setup lang="ts"> <script setup lang="ts">
import { ref, type Ref } from 'vue' import { ref, type Ref, computed } from 'vue'
import { processCesiumPlusImport } from '../cesium-plus' import { processCesiumPlusProfile, type CplusProfile } from '../cesium-plus'
import type { CID } from 'kubo-rpc-client'
const file: Ref<File | null> = ref(null) const file: Ref<File | null> = ref(null)
const sample = ref('') const sample = ref('')
const importResult: Ref<CID | null> = ref(null) const cidlist = ref('')
const MAX = 20
async function setfile(input: any) { function setfile(input: any) {
file.value = input.target.files[0] file.value = input.target.files[0]
} }
async function importCplus() { function importCplus() {
cidlist.value = ''
if (file.value) { if (file.value) {
console.log(file.value) console.log(file.value)
const reader = new FileReader() const reader = new FileReader()
reader.onload = function (event) { reader.onload = function (event) {
const obj = JSON.parse(event.target!.result as string) const obj = JSON.parse(event.target!.result as string)
console.log(obj) console.log(obj)
sample.value = JSON.stringify(obj[0], undefined, 4) sample.value = JSON.stringify(obj[0], undefined, 4)
processCesiumPlusImport(obj.slice(0, 10)).then((cid) => (importResult.value = cid)) obj
.slice(0, MAX)
.map((e: CplusProfile) => processCesiumPlusProfile(e).then((c) => (cidlist.value += c.toString() + '\n')))
} }
reader.readAsText(file.value) reader.readAsText(file.value)
} }
...@@ -28,19 +30,23 @@ async function importCplus() { ...@@ -28,19 +30,23 @@ async function importCplus() {
</script> </script>
<template> <template>
<main>
<h1>Cesium Plus</h1> <h1>Cesium Plus</h1>
<h2>Import</h2> <h2>Import from file</h2>
<p>Import data from Cesium+</p> <p>Import data from Cesium+</p>
<p> <p>
json input file: json input file:
<input type="file" @change="setfile" /> <input type="file" @change="setfile" />
<button v-on:click="importCplus">Import</button> <button v-on:click="importCplus">Import</button> (max {{ MAX }})
</p> </p>
<p>sample:</p> <details>
<summary>sample:</summary>
<pre>{{ sample }}</pre> <pre>{{ sample }}</pre>
<p>root node for import: {{ importResult }}</p> </details>
</main> <p>list of imported cids:</p>
<pre>{{ cidlist }}</pre>
<h2>Import from root cid</h2>
<p>Choose a root CID from Cesium import and the root CID of the target AMT</p>
</template> </template>
<style scoped></style> <style scoped></style>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment