Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base-layout for TIT copied from TWW #2

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions plugin/.docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG QGIS_TEST_VERSION=latest
FROM qgis/qgis:${QGIS_TEST_VERSION}

# remove QGIS apt repo to avoid signing key issues
RUN add-apt-repository -r https://qgis.org/ubuntu && \
add-apt-repository -r https://qgis.org/ubuntu-ltr

RUN apt-get update && \
apt-get -y install openjdk-8-jre curl locales postgresql-client python3-geoalchemy2 \
&& rm -rf /var/lib/apt/lists/*

RUN printf '[postgres]\ndbname=postgres\nuser=postgres\n' >> /etc/postgresql-common/pg_service.conf
RUN printf '[pg_tww]\ndbname=tww\nuser=postgres\n' >> /etc/postgresql-common/pg_service.conf

# Some defaults
ENV POSTGRES_PASSWORD=postgres
# otherwise psycopg2 cannot connect
ENV PGSERVICEFILE=/etc/postgresql-common/pg_service.conf
ENV PGSERVICE=pg_tww
ENV LANG=C.UTF-8

WORKDIR /
24 changes: 24 additions & 0 deletions plugin/.docker/run-docker-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#***************************************************************************
# -------------------
# begin : 2017-08-24
# git sha : :%H$
# copyright : (C) 2017 by OPENGIS.ch
# email : info@opengis.ch
#***************************************************************************
#
#***************************************************************************
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU General Public License as published by *
#* the Free Software Foundation; either version 2 of the License, or *
#* (at your option) any later version. *
#* *
#***************************************************************************

set -e

pushd /usr/src/plugin
DEFAULT_PARAMS='-v'
xvfb-run pytest-3 ${@:-`echo $DEFAULT_PARAMS`}
popd
4 changes: 4 additions & 0 deletions plugin/scripts/download-interlis-libs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

wget https://github.com/teksi/wastewater/archive/refs/tags/plugin-ili-libs-1.tar.gz
tar xvzf plugin-ili-libs-1.tar.gz --strip-components=1
31 changes: 31 additions & 0 deletions plugin/scripts/package-pip-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

LIBS_DIR="plugin/teksi_interlis_tool/libs"

MODELBAKER_LIBRARY=("modelbaker" "1.6.0")

PACKAGES=(
MODELBAKER_LIBRARY[@]
)

#create lib folder
mkdir -p $LIBS_DIR

for PACKAGE in ${PACKAGES[@]}; do
echo download and unpack ${!PACKAGE:0:1} with version ${!PACKAGE:1:1}
#create temp folder
mkdir -p temp
#download the wheel
pip download -v ${!PACKAGE:0:1}==${!PACKAGE:1:1} --only-binary :all: -d temp/
#unpack all the wheels found (means including dependencies)
unzip -o "temp/*.whl" -d $LIBS_DIR
#remove temp folder
rm -r temp
#set write rights to group (because qgis-plugin-ci needs it)
chmod -R g+w $LIBS_DIR
done

#create the __init__.py in libs folder
cd $LIBS_DIR
touch __init__.py
chmod g+w __init__.py
11 changes: 11 additions & 0 deletions plugin/scripts/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Arguments are passed one to one to pytest
#
# Run all tests:
# ./scripts/run-tests.sh # Run all tests
#
# Run all test starting with test_array_
# ./scripts/run-tests.sh -k test_array_

docker-compose run qgis /usr/src/plugin/.docker/run-docker-tests.sh $@
29 changes: 29 additions & 0 deletions plugin/teksi_interlis_tool/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -----------------------------------------------------------
#
# TEKSI INTERLIS Tool
# Copyright (C) 2024 TEKSI
# -----------------------------------------------------------
#
# licensed under the terms of GNU GPL 2
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# ---------------------------------------------------------------------


def classFactory(iface):
from .teksi_interlis_tool_plugin import TeksiInterlisToolPlugin

return TeksiInterlisToolPlugin(iface)
Empty file.
62 changes: 62 additions & 0 deletions plugin/teksi_interlis_tool/gui/about_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -----------------------------------------------------------
#
# Profile
# Copyright (C) 2012 Patrice Verchere
# -----------------------------------------------------------
#
# licensed under the terms of GNU GPL 2
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, print to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# ---------------------------------------------------------------------

import os

from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog

from ..utils import get_ui_class
from ..utils.plugin_utils import plugin_root_path

DIALOG_UI = get_ui_class("about_dialog.ui")


class AboutDialog(QDialog, DIALOG_UI):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.setupUi(self)

metadata_file_path = os.path.join(
os.path.abspath(os.path.join(os.path.dirname(__file__), "..")),
"metadata.txt",
)

ini_text = QSettings(metadata_file_path, QSettings.IniFormat)
version = ini_text.value("version")
name = ini_text.value("name")
description = "".join(ini_text.value("description"))
about = " ".join(ini_text.value("about"))
qgisMinimumVersion = ini_text.value("qgisMinimumVersion")

self.setWindowTitle(f"{name} - {version}")
self.titleLabel.setText(self.windowTitle())
self.descriptionLabel.setText(description)
self.aboutLabel.setText(about)
self.qgisMinimumVersionLabel.setText(qgisMinimumVersion)

self.iconLabel.setPixmap(
QPixmap(os.path.join(plugin_root_path(), "icons/teksi-abwasser-logo.svg"))
)
26 changes: 26 additions & 0 deletions plugin/teksi_interlis_tool/gui/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import qgis
from qgis.core import QgsProject

from ..tools.twwmaptooladdfeature import TwwMapToolDigitizeDrainageChannel


def geometryDigitized(fid, layer, tool):
layer.changeGeometry(fid, tool.geometry)
layer.triggerRepaint()
tool.deactivate()


def mapToolDeactivated(tool):
tool.deactivated.disconnect()
qgis.utils.plugins["teksi_interlis_tool"].iface.mapCanvas().unsetMapTool(tool)
tool.deleteLater()


def digitizeDrainageChannel(fid, layerid):
layer = QgsProject.instance().mapLayer(layerid)
layer.startEditing()
tool = TwwMapToolDigitizeDrainageChannel(qgis.utils.plugins["teksi_interlis_tool"].iface, layer)
qgis.utils.plugins["teksi_interlis_tool"].iface.mapCanvas().setMapTool(tool)
tool.geometryDigitized.connect(lambda: geometryDigitized(fid, layer, tool))
# form.window().hide()
tool.deactivated.connect(lambda: mapToolDeactivated(tool))
Loading