vendredi 20 février 2009

Setup dvorak on Debian with Xorg without HAL / evdev bugs

Dvorak setup used to be easy to set up :

$ dpkg-reconfigure -phigh console-data
$ dpkg-reconfigure -phigh xserver-xorg

Nothing much fancier if you were used to light systems and spent most of your time in your terminals / editor.

All the general Xorg conf was located in /etc/X11/xorg.conf :

Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc104"
Option "XkbLayout" "dvorak"
EndSection


One could have setup some personal settings in .xinitrc :

$ xmodmap ~/.myxmodmaprc

(CapsLock as additional Ctrl key, and Compose key on Ctrl_L for instance)

Console setup is just as easy as before (console-setup package is just fine) but X needs a little attention.


Obfuscation



Nowadays, Xorg uses HAL/evdev to auto-magically configure the keyboard layout. However the default policy is to use a "us" layout on a buggy "evdev" model (on Linux) ...

A proper setup can be :

1. $ cp /usr/share/hal/fdi/policy/10osvendor/10-keymap.fdi /etc/hal/fdi/policy/

2. and edit accordingly :


<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.keymap">
<append key="info.callouts.add" type="strlist">hal-setup-keymap</append>
</match>

<match key="info.capabilities" contains="input.keys">
<merge key="input.xkb.rules" type="string">xorg</merge>

<merge key="input.xkb.model" type="string">keyboard</merge>
<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
string="Linux">
<merge key="input.xkb.model" type="string">pc105</merge>
</match>
<!-- force dvorak -->
<merge key="input.xkb.layout" type="string">dvorak</merge>
<merge key="input.xkb.variant" type="string" />
</match>
</device>
</deviceinfo>



3. restart HAL and X

Testing


You can test your settings :
1. stop GDM/KDM/...
2. login as user in console mode
3. edit ~/.xinitrc :

xmodmap ~/.xmodmaprc.foo &
xterm &
yourwindowmanager

4. run $ startx


Gnome and related



Gnome uses an g-app to set up various keyboard options : gnome-keyboard-properties which requires gnome-settings-daemon which requires DBus launched which is usually triggered by GDM ...
Anyway, once your basic X config is OK, you can try g-k-p and set up your keyboard. "Generic/evdev" is meant to be used accordingly with the default HAL fdi ; I chose "Generic/pc104".

Related X package : xserver-xorg-input-evdev

mercredi 4 février 2009

Utiliser le RGC IGN : csv2shp via ogr2ogr et VRT

Je me demandais ces derniers jours comment récupérer pour mes bricolages perso un jeu de test contenant l'ensemble des communes de France avec leur coordonnées géographiques ...

Déception. Le GEOFLA Communes est toujours payant, donc à défaut, je me contenterai du RGC, qui n'est fourni en revanche que sous le convivial format CSV. Les outils GDAL supporte très bien ce format et permettent de convertir assez facilement dans un format plus pratique à condition de formater proprement l'ensemble.

Récupérer le RGC sur
http://professionnels.ign.fr/ficheProduitCMS.do?idDoc=5323862

1. dézipper, renommer le ".txt" en ".csv" et éditer dans un tableur

2. déplacer les colonnes XLAMB2 et YLAMB2 en première position

3. enregistrer au format CSV avec les paramètres suivants :
- double quotes pour les champs texte
- virgule comme séparateur

4. créer le fichier VRT suivant :
<OGRVRTDataSource>
<OGRVRTLayer name="rgc_2007">
<SrcDataSource>rgc_2007.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>EPSG:27582</LayerSRS>
<GeometryField encoding="PointFromColumns" x="XLAMB2" y="YLAMB2"/>
</OGRVRTLayer>
</OGRVRTDataSource>


5. exécuter la commande :
$ ogr2ogr -f "ESRI Shapefile" rgc_2007.shp rgc_2007.vrt

Voilà :
$ ogrinfo -so rgc_2007.shp rgc_2007
INFO: Open of `rgc_2007.shp'
using driver `ESRI Shapefile' successful.
Layer name: rgc_2007
Geometry: Point
Feature Count: 36590
Extent: (509.000000, 16227.000000) - (11945.000000, 26754.000000)
Layer SRS WKT:
PROJCS["NTF (Paris) / France II (deprecated)",
GEOGCS["NTF (Paris)",
DATUM["Nouvelle_Triangulation_Francaise",
SPHEROID["Clarke_1880_IGN",6378249.2,293.4660212936269]],
PRIMEM["Paris",2.33722917],
UNIT["grad",0.01570796326794897]],
PROJECTION["Lambert_Conformal_Conic_1SP"],
PARAMETER["latitude_of_origin",52],
PARAMETER["central_meridian",0],
PARAMETER["scale_factor",0.99987742],
PARAMETER["false_easting",600000],
PARAMETER["false_northing",2200000],
UNIT["Meter",1]]
XLAMB2: String (80.0)
YLAMB2: String (80.0)
NOM: String (80.0)
DEP: String (80.0)
COM: String (80.0)
ARRD: String (80.0)
CANT: String (80.0)
ADMI: String (80.0)
POPU: String (80.0)
SURFACE: String (80.0)