Skip to content

Commit

Permalink
Merge pull request #48 from t-kurasawa/issue/47
Browse files Browse the repository at this point in the history
Issue/47
  • Loading branch information
t-kurasawa authored Feb 19, 2022
2 parents cb1d36d + 6bb8a2a commit d9b6514
Show file tree
Hide file tree
Showing 43 changed files with 134,064 additions and 20,393 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,4 @@ node_modules/
.yarn-integrity

# dotenv environment variables file
.env

# Localhost SSL 証明書
.pem
.env
4 changes: 2 additions & 2 deletions backend/batch/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.vscode
.DS_Store
data_files
dim-lock.json
dim-lock.json
transform_files/*
21 changes: 21 additions & 0 deletions backend/batch/dim-lib/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 ryo-ma

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
136 changes: 136 additions & 0 deletions backend/batch/dim-lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# dim

Data Installation Manager: Manage the open data in your project like a package
manager.

![8bket-vzuiv](https://user-images.githubusercontent.com/6661165/148486923-a29f6ea5-ecbc-4d69-9f40-66bed34e3f99.gif)

Execute all required installations by sharing dim.json.

![r30y7-wcbx7](https://user-images.githubusercontent.com/6661165/148490980-c1ae8195-a3fd-430f-aa10-c11c7cf1fd64.gif)

# Usage

## Install the dim

Donwload the dim from binary files.

[aarch64-apple-darwin](https://github.com/ryo-ma/dim/raw/main/bin/aarch64-apple-darwin/dim)

[x86_64-apple-darwin](https://github.com/ryo-ma/dim/raw/main/bin/x86_64-apple-darwin/dim)

[x86_64-pc-windows-msvc](https://github.com/ryo-ma/dim/raw/main/bin/x86_64-pc-windows-msvc/dim.exe)

[x86_64-unknown-linux-gnu](https://github.com/ryo-ma/dim/raw/main/bin/x86_64-unknown-linux-gnu/dim)

or

```
deno install --unstable --allow-read --allow-write --allow-run --allow-net dim.ts
```



## Setup the project

```
dim init
```

## Install a data

```
dim install [url] -n [name]
```

## Upgrade the dim version

```
dim upgrade
```

# Commands

## Init

```
dim init
```

## Install

```
dim install [url] -n [name]
```

### Preprocess unzip

```
dim install [url] -p unzip
```

### Preprocess encoding-

```
dim install [url] -p encoding-utf-8
```

### Preprocess xlsx-to-csv

```
dim install [url] -p xlsx-to-csv
```

### Preprocess custom command

You can specify a custom command after **"CMD:"**.


```
dim install [url] -p CMD:******
```

The file path will be passed as an argument at the end of the specified command.

```
dim install [url] -p "CMD:python ./tests/test_custom_command.py"
```

Command to be executed during preprocessing.

```
python ./tests/test_custom_command.py ./data_files/***/***.xx
```


## Uninstall

```
dim uninstall [url]
```

## List

```
dim list
```

### Simple List

```
dim list -s
```

## Update

```
dim update [name or url]
```



## Help

```
dim help
```
7 changes: 0 additions & 7 deletions backend/batch/dim.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
"encoding-utf-8"
]
},
{
"url": "https://www.opendata.metro.tokyo.lg.jp/soumu/130001_evacuation_area.csv",
"name": "東京都総務局_東京都防災マップ避難所・避難場所_東京都防災マップ避難場所一覧データ",
"preprocesses": [
"encoding-utf-8"
]
},
{
"url": "https://code4fukui.github.io/tokyobichikunavi/csv/stockpile_list.csv",
"name": "東京備蓄ナビ_福井備蓄ナビ_MIT_License",
Expand Down
29 changes: 4 additions & 25 deletions backend/batch/functions/openDataConvert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,6 @@ import csvtojson from 'csvtojson'

const openDataConvert = async () => {

/**
* 避難場所
*/
const evacuationArea = {
"避難場所_名称": "string",
"地方公共団体コード": "number",
"都道府県": "string",
"指定区市町村名": "string",
"住所": "string",
"緯度":"number",
"経度": "number",
}

const evacuationAreaJson = await csvtojson({
colParser: evacuationArea,
checkType:true
}).fromFile(path.join(__dirname, `../data_files/www.opendata.metro.tokyo.lg.jp/soumu/130001_evacuation_area.csv`));

fs.writeFileSync(
path.join(__dirname, "../../../frontend/src/__mock__/data/evacuationArea.json"),
JSON.stringify(evacuationAreaJson)
);

/**
* 避難所
*/
Expand All @@ -48,10 +25,12 @@ const openDataConvert = async () => {
fs.writeFileSync(
path.join(__dirname, "../../../frontend/src/__mock__/data/evacuationCenter.json"),
JSON.stringify(evacuationCenterJson)
);
);


//防災備蓄品種類
/**
* 防災備蓄品種類
*/
const stockpileType = {
"id": "number",
"item_ja": "string",
Expand Down
Loading

0 comments on commit d9b6514

Please sign in to comment.