Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
fixed import on plugin package
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-penasa committed Sep 22, 2020
1 parent b721be1 commit 0952120
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 15 deletions.
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
# mappy
Creating geological maps from limits and points - proof of concept with python gis tools

The idea is to start from contacts + labelled points to obtain consistent geological maps. in this way:
This repo contains python code to generate maps starting from boundary lines and indicator points. The inverse operation is also supported.

The mappy library can be used as a standalone module for applying the transforms from python code (without QGIS).

The qgis_plugin folder contains qgismappy, a QGIS plugin that implements the GUI for the mappy python module.

**This module and plugin are experimental, please use the issue system to provide feedback**

# Requirements
The mappy python modul;e (and the QGIS plugin) makes use of several additional libraries, that must be installed opf the plugin will not work properly:

- geopandas
- topojson

# Install

## a) From repo in development mode

To install the plugin clone this repo in a dedicated user folder:

```bash
git clone https://github.com/planmap-eu/mappy.git mappy.git
```

and add the following system variable to your bashrc:

```bash
QGIS_PLUGINPATH=/path_to_folder/mappy.git/qgis_plugin/
```

In this way QGIS should be able to find the plugin (activate it from the plugin manager of QGIS)

## b) From standalone package
This repo also provides pregenerated zip packages that can be installed in qgis by using the plugin manager.

This module and QGIS plugin are used to perform the following transform, and vice-versa:

![woops, missing image](images/example.png)
6 changes: 6 additions & 0 deletions create_plugin_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

cp -vr qgis_plugin/qgismappy qgismappy
cp -vr mappy qgismappy

zip qgismappy -r qgismappy
26 changes: 16 additions & 10 deletions qgis_plugin/qgismappy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,30 @@
import os
import sys

from qgis.core import QgsMessageLog

path = os.path.dirname(os.path.abspath(__file__))

fullpath = path + " /../../"
fullpath = os.path.abspath(fullpath)
if os.path.exists(os.path.join(path, "mappy")):
sys.path.append(path)

QgsMessageLog.logMessage(fullpath, "Mappy")
else: # we are in the dev folder
fullpath = path + " /../../"
fullpath = os.path.abspath(fullpath)

# to fix, we are expecting the structure is as in the dev repo
if fullpath not in sys.path:
# print(" adding the path")
sys.path.insert(0, fullpath)

# QgsMessageLog.logMessage(fullpath, "Mappy")

# to fix, we are expecting the structure is as in the dev repo

if fullpath not in sys.path:
# print(" adding the path")
sys.path.insert(0, fullpath)

# print(" path is there- loading mappy")
import mappy
try:
import mappy
except:
raise ImportError("Cannot import mappy. This should not happen")


# noinspection PyPep8Naming
def classFactory(iface): # pylint: disable=invalid-name
Expand Down
19 changes: 16 additions & 3 deletions qgis_plugin/qgismappy/qgismappy_dockwidget_base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>402</width>
<height>460</height>
<height>466</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -18,7 +18,7 @@
<item row="0" column="1">
<widget class="QTabWidget" name="tab">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_construction">
<attribute name="title">
Expand Down Expand Up @@ -239,13 +239,26 @@
</widget>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QPushButton" name="execute">
<property name="text">
<string>Compute</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
Expand Down

0 comments on commit 0952120

Please sign in to comment.