Technique

How-to run QGIS 2 and QGIS 3 at the same time in Archlinux or Manjaro

Geomatips - jeu, 05/10/2018 - 09:50

Since QGIS 3 was released, it's a nice and very pleasant upgrade. Unfortunately some plugins I use does still not work with Qgis 3 due to python upgrade from version 2 to 3.
It's possible to upgrade with tools like 2to3 (If interested, I suggest to watch Heikki Vesanto blog : https://gisforthought.com/updating-a-plugin-from-qgis-2-to-qgis-3/ ) but some plugins needs time to debug.

That's why, it's interesting during migration to have Qgis 2 and 3 at the same time in one computer. It's also possible to run Qgis 2 and 3 at the same time due to profile migration. They are not sharing same preferences folder so you are not breaking anything.
It's possible to have Qgis 2 and 3 running at the time with different way like Conda or Docker. But it's lightest to run it natively.

Archlinux/Manjaro is the Linux distribution I use. It have in my opinion a powerfull little thing called AUR (Arch User Repository) which automate installation of software. Furthermore, if you don't happy with compilation parameters and want a custom value added parameters you could modify it by editing a file named PKGBUILD. Archlinux based linux system is a rolling release and now qgis package move from AUR to official package, version 3 is available today. There is still a qgis-ltr version in AUR, version 2.18.19, but this package needs building. As explain before it's not difficult because everything is automated but at this time qgis package is in conflict with qgis-ltr package. So you have only choice to have qgis or qgis-ltr installed, not both.

Let's just edit PKGBUILD and we will be able to have both packages installed.

1) Download PKGBUILD : 

 a) Auto download with yaourt :
From command line just run
yaourt -S qgis-ltr Then you will be prompt to edit file or not

 b) Download from AUR :
Go here : https://aur.archlinux.org/packages/qgis-ltr/
On the right side there is View PKGBUILD, download it


2) Edit PKGBUILD : 

We need to modify this file to install in different directory. Like INSTALL file from qgis github repository, I installed qgis-ltr in my home

We need to modify these lines :

line 36 : (disable conflicts check between these 2 packages)
from
conflicts=("$_pkgname")It becomes
conflicts=("")
line 64 : (change installed directory with cmake option)
from
-DCMAKE_INSTALL_PREFIX=/usr \
to
-DCMAKE_INSTALL_PREFIX=${HOME}/apps \
line 93 to 108 : (comment by adding # in front or remove these lines)


3) Build package : 

  a) With yaourt :

At the end of editing PKGBUILD, it will continue alone.


  b) If you download PKGBUILD:

In directory where you download PKGBUILD, run

makepkg   from command line and wait.


4) Install package : 

  a) With yaourt :

You will be asked to install or not generated package

  b) If you download PKGBUILD:

pacman -U qgis*.pkg.tar.xz
5) Run qgis 2 : 

Open a terminal and launch these commands :

export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HOME}/apps/lib"cd ${HOME}/apps/bin
./qgis6) Automate qgis 2 launcher :

Edit file in /usr/local/bin :

nano /usr/local/bin/qgis2
Put this in it :

#!/bin/bash
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HOME}/apps/lib"
cd ${HOME}/apps/bin
./qgis
Save and close.
Make it executable :

chmod +x /usr/local/bin/qgis2
Now you could just type in terminal to run Qgis2 :
qgis2


NOTE : Overview of modified PKGBUILD. Available for download here :  https://github.com/giscan/QGIS2_Archlinux

# Maintainer: Doug Newgard
# Contributor: SaultDon
# Contributor: Lantald < lantald at gmx.com >
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org
# Contributor: Gerardo Exequiel Pozzi
# Contributor: Eric Forgeot < http://esclinux.tk >

# Globe Plugin and Map Server are disabled in cmake by default.
# Uncomment them in the build() portion if you'd like them enabled.
# You will also need to install osgearth-qt4 or fcgi, respectively, before building.

pkgname=qgis-ltr
_pkgname=${pkgname//-ltr}
pkgver=2.18.19
pkgrel=1
pkgdesc='Geographic Information System (GIS) that supports vector, raster & database formats; Long Term Release'
url='https://qgis.org/'
license=('GPL')
arch=('i686' 'x86_64')
depends=('expat' 'gcc-libs' 'gdal' 'geos' 'glibc' 'libspatialite' 'postgresql-libs' 'proj'
         'qt4' 'qca-qt4' 'qjson' 'qscintilla-qt4' 'qwt-qt4' 'qwtpolar-qt4' 'spatialindex' 'sqlite'
         'python2' 'python2-httplib2' 'python2-future' 'python2-qscintilla-qt4' 'python2-sip' 'python2-six')
makedepends=('cmake' 'gsl' 'perl' 'txt2tags')
optdepends=('gpsbabel: GPS Tool plugin'
            'gsl: Georeferencer plugin'
            'python2-gdal: DB Manager plugin; Processing plugin'
            'python2-jinja: MetaSearch plugin'
            'python2-owslib: MetaSearch plugin'
            'python2-psycopg2: DB Manager plugin; Processing plugin'
            'python2-pygments: MetaSearch plugin; DB Manager plugin'
            'python2-pyspatialite: DB Manager plugin; Processing plugin'
            'python2-yaml: Processing plugin'
            'saga-gis-ltr: Saga processing tools')
provides=("$_pkgname=$pkgver")
conflicts=("")
source=("https://qgis.org/downloads/$_pkgname-$pkgver.tar.bz2")
md5sums=('49a5d6803974f1adefe98ed9af55db1e')

prepare() {
  cd $_pkgname-$pkgver

  # Make sure we find the -qt4 versions of qwt and qwtpolar
  sed -i '/QWT_LIBRARY_NAMES/ s/qwt /qwt-qt4 /' cmake/FindQwt.cmake
  sed -i '/PATH_SUFFIXES/ s/qwt$/&-qt4/;/LIBRARY NAMES/ s/qwtpolar/&-qt4/' cmake/FindQwtPolar.cmake

  # Fix references to "python"
  sed -i 's/\(env \|\/usr\/bin\/\)python$/&2/' $(find . -iname "*.py")

  # Remove mime types already defined by freedesktop.org
  sed -e '/type="image\/tiff"/,/<\/mime-type>/d' \
      -e '/type="image\/jpeg"/,/<\/mime-type>/d' \
      -e '/type="image\/jp2"/,/<\/mime-type>/d' \
      -e '/type="application\/x-adobe-mif"/,/<\/mime-type>/d' \
      -i debian/qgis.xml

  [[ -d build ]] || mkdir build
}

build() {
  cd $_pkgname-$pkgver/build

  cmake -G "Unix Makefiles" ../ \
    -DCMAKE_INSTALL_PREFIX=${HOME}/apps \
    -DQGIS_MANUAL_SUBDIR=share/man \
    -DENABLE_TESTS=FALSE \
    -DWITH_QTWEBKIT=FALSE \
    -DWITH_INTERNAL_QWTPOLAR=FALSE \
    -DWITH_INTERNAL_{MARKUPSAFE,OWSLIB,DATEUTIL,PYTZ,YAML,NOSE2,SIX,FUTURE}=FALSE \
#    -DWITH_SERVER=TRUE \
#    -DWITH_GLOBE=TRUE

  make

  # Rebuild srs database, QGIS distributes an old, buggy one
  LD_LIBRARY_PATH="$PWD/output/lib/" make synccrsdb
  mv /tmp/srs.db ../resources/
}

package() {
  cd $_pkgname-$pkgver/build

  # Add optional deps based on selected or autodetected options
  [[ -n "$(sed -n '/^GRASS_PREFIX:/  s/.*=//p' CMakeCache.txt)" ]]      && optdepends+=('grass6: GRASS6 plugin')
  [[ -n "$(sed -n '/^GRASS_PREFIX7:/ s/.*=//p' CMakeCache.txt)" ]]      && optdepends+=('grass: GRASS7 plugin')
  [[ "$(sed -n '/^WITH_SERVER:/ s/.*=//p' CMakeCache.txt)" == "TRUE" ]] && optdepends+=('fcgi: Map Server')
  [[ "$(sed -n '/^WITH_GLOBE:/  s/.*=//p' CMakeCache.txt)" == "TRUE" ]] && optdepends+=('osgearth-qt4: Globe plugin')

  make DESTDIR="$pkgdir" install

  cd "$srcdir/$_pkgname-$pkgver"

  # install desktop files and icons
#  install -Dm644 debian/{qgis,qbrowser}.desktop -t "$pkgdir/usr/share/applications/"
#  for _icon in qgis-icon{,-16x16,-60x60} qbrowser-icon{,-60x60}; do
#    local _resolution="${_icon##*-}"; [[ "$_resolution" == "icon" ]] && _resolution="512x512"
#    install -Dm644 images/icons/$_icon.png "$pkgdir/usr/share/icons/hicolor/$_resolution/apps/${_icon%%-*}.png"
#  done
#  for _prog in qgis qbrowser; do
#    install -Dm644 images/icons/${_prog}_icon.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/#$_prog.svg"
#  done

#  install mime information and icons
#  install -Dm644 debian/qgis.xml -t "$pkgdir/usr/share/mime/packages/"
#  install -Dm644 images/icons/qgis-mime-icon.png "$pkgdir/usr/share/icons/hicolor/128x128/mimetypes/qgis-mime.png"
#  for _type in asc ddf dem dt0 dxf gml img mime mldata qgs qlr qml qpt shp sqlite; do
#    install -Dm644 images/icons/qgis_${_type}_icon.svg "$pkgdir/usr/share/icons/hicolor/scalable/#mimetypes/qgis-$_type.svg"
#  done


  # compile python files, since the cmake option doesn't seem to account for DESTDIR
  python2 -m compileall -q "$pkgdir"
}
Catégories: Technique

Resume script back from hibernation with systemd for wifi problem

Geomatips - dim, 04/29/2018 - 16:58
I wrote a simple article which I found in my own opinion usefull ! I still need user manual when I use systemd and I still remember init.d command :-/

Since systemd, I am in an annoying situation when my desktop computer come back from hibernation :
- Network is unresponsive, Network Manager icon on mate desktop show a disable network,
- Command line on desktop and tty are working but you could send a command but never get this command sending to system. It's like freezing but system is still here !

The only workaround in a first time is to detach my TP-LINK TL-WN722N and to reconnect it. No error message in logs about chipset of this usb wifi device which is from Atheros and uses ath9k driver.

Next step to debug is to simulate behaviour but the only thing what I can do is disable ath9k driver before hibernation and renabling them after resume.
For those how wanted to know commands are like that :
Before hibernation disable modules :
rmmod ath9k_htc
rmmod ath9k_common
rmmod ath9k_hw
rmmod ath

And after resume enable modules : 
modprobe ath
modprobe ath9k
modprobe ath9k_hw
modprobe ath9k_common
modprobe ath9k_htc

To do that automatically, it's easy to use pm-utils but since systemd, pm-utils is not working and we have to use systemd scripts.

So here is my working script with this driver :

Edit in
nano /usr/lib/systemd/system-sleep/wifi_hibernate_resume.shAnd put this :

#!/bin/sh
case $1/$2 in
  pre/*)
    rmmod ath9k_htc
    rmmod ath9k_common
    rmmod ath9k_hw
    rmmod ath
    ;;
  post/*)
     modprobe ath
     modprobe ath9k
     modprobe ath9k_hw
     modprobe ath9k_common
     modprobe ath9k_htc
    ;;
esac


Then make it executable with :

chmod +x /usr/lib/systemd/system-sleep/wifi_hibernate_resume.sh
No need to reboot, it works directly.
Catégories: Technique

Additions to the MapFish Protocol

Eric Lemoine - sam, 04/18/2009 - 23:55

We recently added new stuff to the MapFish Protocol.

As a refresher, let’s first take a look at what the MapFish Protocol had before the new additions.

(Note that you’d need the JSONovich FireFox extension to see the output of the examples given below in your web browser.)

Geographic query params

  • box={x1},{y1},{x2},{y2}: the features within the specified bounding box
  • geometry={geojson_string}: the features within the specified geometry
  • lon={lon}&lat={lat}&tolerance={tol}: the features within the specified tolerance of the specified lon/lat

Examples:

Limiting and Sorting

  • limit={num}: the maximum number of features returned
  • offset={num}: the number of features to skip
  • order_by={field_name}: the name of the field to use to order the features
  • dir=ASC|DESC: the ordering direction

Examples:

The new params

  • no_geom=true|false: so that the returned feature has no geometry (“geometry”: null)
  • attrs={field1}[,{field2},...]: to restrict the list of properties returned in the features
  • queryable={field1}[,{field2},...]: the names of the feature fields that can be queried
  • {field}__{query_op}={value}: filter expression, field must be in the list of fields specified by queryable, query_op is one of “eq”, “ne”, “lt, “le”, “gt”, “ge”, “like”, “ilike”

And now an example combining all the new parameters:

The above query returns a GeoJSON representation of the summits whose names include “col” and whose elevations are greater than or equal to 3500. The returned features have no geometry and their attributes include “name” and “elevation” only.

Not including the geometry in the features makes the parsing in the browser much faster, so for cases where the geometries aren’t needed this is a big win.

Credits for the “queryable={field}&{field}__{query_op}={value}” syntax goes to FeatureServer!


Catégories: Technique

Secure TileCache With Pylons and Repoze

Eric Lemoine - dim, 02/15/2009 - 19:14

This post shows how one can secure TileCache with Pylons and Repoze.

In a Pylons application one can run a WSGI application from within a controller action. Here is a simple example:

class MainController(BaseController) def action(self, environ, start_response): return wsgiApp(environ, start_response)

TileCache is commonly run from within mod_python. TileCache can also be run as a WSGI application, therefore it can be run from within the controller action of a Pylons application. Here’s how:

from TileCache.Service import wsgiApp class MainController(BaseController) def tilecache(self, environ, start_response): return wsgiApp(environ, start_response)

Pretty cool… But it gets really interesting when repoze.what is added to the picture. For those who don’t know repoze.what, repoze.what is an authorization framework for WSGI applications. repoze.what now provides a Pylons plugin, making it easy to protect controllers and controller actions in a Pylons application. Here’s how our tilecache action can be protected:

from TileCache.Service import wsgiApp from repoze.what.predicates import has_permission from repoze.what.plugins.pylonshq import ActionProtector class MainController(BaseController) @ActionProtector(has_permission('tilecache')) def tilecache(self, environ, start_response): return wsgiApp(environ, start_response)

With the above, anyone who tries to access /tilecache will have to be granted the tilecache permission. Otherwise, authorization will be denied.

TileCache is secured!

People often want finer-grained authorization, like give certain users access to certain layers. With Pylons’ routing system this can be easily and elegantly achieved using repoze.what, I will show that in a later post.


Catégories: Technique

S'abonner à OSGeo-fr agrégateur - Technique