Skip to content

Commit

Permalink
+= QGIS - kamangir/bolt#746
Browse files Browse the repository at this point in the history
  • Loading branch information
kamangir committed Jun 16, 2024
1 parent ecd15f7 commit 33e9d41
Show file tree
Hide file tree
Showing 23 changed files with 900 additions and 2 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@ AI for precise geospatial data analysis and visualization.
pip install blue-geo
```

🔷 [ukraine-timemap](#ukraine-timemap-) 🇺🇦 🔷
🔷 [QGIS](#QGIS) 🔷 [ukraine-timemap](#ukraine-timemap-) 🇺🇦 🔷

---

## QGIS

to start, generate the seed 🌱,

```bash
QGIS seed
```

and paste it in the Python Console in QGIS.

![image](https://github.com/kamangir/assets/blob/main/blue-geo/QGIS-python-console.png?raw=true)

---

Expand Down
49 changes: 49 additions & 0 deletions blue_geo/.abcli/QGIS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#! /usr/bin/env bash

export abcli_QGIS_path_profile="$HOME/Library/Application Support/QGIS/QGIS3/profiles/default"
export abcli_QGIS_path_expressions=$abcli_QGIS_path_profile/python/expressions
export abcli_QGIS_path_expressions_git=$abcli_path_git/blue-geo/blue_geo/QGIS/expressions
export abcli_QGIS_path_templates=$abcli_QGIS_path_profile/project_templates
export abcli_QGIS_path_shared=$HOME/Downloads/QGIS
export abcli_QGIS_path_server=$abcli_QGIS_path_shared/server

mkdir -p $abcli_QGIS_path_server

function QGIS() {
blue_geo_QGIS "$@"
}

# internal function to abcli_seed.
function QGIS_seed() {
# seed is NOT local
seed=$(python3 -m blue_geo.QGIS generate_seed)
}

function blue_geo_QGIS() {
local task=$(abcli_unpack_keyword $1 help)

if [ $task == "help" ]; then
abcli_show_usage "QGIS seed [screen]" \
"seed 🌱 QGIS."

blue_geo_QGIS_expressions "$@"
blue_geo_QGIS_server "$@"
return
fi

local function_name=blue_geo_QGIS_$task
if [[ $(type -t $function_name) == "function" ]]; then
$function_name "${@:2}"
return
fi

if [ "$task" == "seed" ]; then
abcli_seed QGIS "${@:2}"
return
fi

abcli_log_error "-QGIS: $task: command not found."
return 1
}

abcli_source_path - caller,suffix=/QGIS
47 changes: 47 additions & 0 deletions blue_geo/.abcli/QGIS/expressions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#! /usr/bin/env bash

function blue_geo_QGIS_expressions() {
local task=$1

if [ "$task" == help ]; then
abcli_show_usage "QGIS expressions pull" \
"pull QGIS expressions."
abcli_show_usage "QGIS expressions push [push]" \
"push QGIS expressions."

abcli_log " 📂 $abcli_QGIS_path_expressions"
abcli_log " 📂 $abcli_QGIS_path_expressions_git"
return
fi

if [[ "$task" == pull ]]; then
rsync -av \
"$abcli_QGIS_path_expressions_git/" \
"$abcli_QGIS_path_expressions/"
return
fi

if [[ "$task" == push ]]; then
local options=$2
local do_push=$(abcli_option_int "$options" push 0)

rsync -av \
--exclude='__pycache__' \
--exclude='default.py' \
--exclude='__init__.py' \
"$abcli_QGIS_path_expressions/" \
"$abcli_QGIS_path_expressions_git/"

if [[ "$do_push" == 1 ]]; then
abcli_git blue-geo push \
"$(python3 -m blue_geo version) QGIS expressions"
else
abcli_git blue-geo status ~all
fi

return
fi

abcli_log_error "-QGIS: expressions: $task: command not found."
return 1
}
34 changes: 34 additions & 0 deletions blue_geo/.abcli/QGIS/server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/env bash

function blue_geo_QGIS_serve() {
blue_geo_QGIS_server "$@"
}

function blue_geo_QGIS_server() {
local options=$1
if [ $(abcli_option_int "$options" help 0) == 1 ]; then
abcli_show_usage "QGIS serve[r] [start]" \
"start QGIS server."
return
fi

local prompt="🌐 $(blue_geo version).QGIS server ... (^C to stop)"
abcli_log $prompt

local filename
cd $abcli_QGIS_path_server
while true; do
sleep 1
for filename in *.command; do
if [ -e "$filename" ]; then
local command=$(cat $filename)
abcli_log "$filename: $command"

abcli_eval - "$command"
rm -v $filename

abcli_log $prompt
fi
done
done
}
3 changes: 3 additions & 0 deletions blue_geo/QGIS/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from blue_geo import NAME

NAME = f"{NAME}.QGIS"
28 changes: 28 additions & 0 deletions blue_geo/QGIS/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import argparse
from blue_geo.QGIS import NAME
from blue_geo import VERSION
from blue_geo.QGIS.seed import generate_seed
from blue_geo.logger import logger
from blueness.argparse.generic import sys_exit


parser = argparse.ArgumentParser(
f"python3 -m {NAME}",
description=f"{NAME}-{VERSION}",
)
parser.add_argument(
"task",
type=str,
help="generate_seed",
)
args = parser.parse_args()

success = False
if args.task == "generate_seed":
success = seed = generate_seed()
if success:
print(seed)
else:
success = None

sys_exit(logger, NAME, args.task, success)
Loading

0 comments on commit 33e9d41

Please sign in to comment.