forked from qgispt/qgis_pt_processing_pttransform
/
Datum73MilToETR89PTTM06.py
94 lines (73 loc) · 3.67 KB
/
Datum73MilToETR89PTTM06.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# -*- coding: utf-8 -*-
"""
***************************************************************************
Datum73MilToETR89PTTM06.py
---------------------
Date : July 2014
Copyright : (C) 2014 by Alexander Bruy
Email : alexander dot bruy at gmail dot com
***************************************************************************
* *
* 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. *
* *
***************************************************************************
"""
__author__ = 'Alexander Bruy'
__date__ = 'July 2014'
__copyright__ = '(C) 2014, Alexander Bruy'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
from PyQt4.QtGui import *
from qgis.core import *
try:
from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterSelection import ParameterSelection
from processing.outputs.OutputVector import OutputVector
except:
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterSelection
from processing.core.outputs import OutputVector
from processing.tools.system import *
from processing.algs.gdal.OgrAlgorithm import OgrAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils
class Datum73MilToETR89PTTM06(OgrAlgorithm):
INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
GRID = 'GRELHAS'
GRID_OPTIONS = ['Jose Alberto Goncalves',
'Direccao Geral do Territorio']
def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/icons/pttransform.svg')
def defineCharacteristics(self):
self.name = 'From Datum 73 Militar to ETRS89-PTTM06'
self.group = 'Vector Datum Transformations'
self.addParameter(ParameterVector(self.INPUT, 'Input layer',
[ParameterVector.VECTOR_TYPE_ANY]))
self.addParameter(ParameterSelection(self.GRID, 'Ntv2 Grid to use (origin)',
self.GRID_OPTIONS))
self.addOutput(OutputVector(self.OUTPUT, 'Output layer'))
def processAlgorithm(self, progress):
inLayer = self.getParameterValue(self.INPUT)
conn = self.ogrConnectionString(inLayer)
output = self.getOutputFromName(self.OUTPUT)
outFile = output.value
arguments = ['-s_srs']
if self.getParameterValue(self.GRID) == 0:
# Jose Alberto Goncalves
arguments.append('+proj=tmerc +lat_0=39.66666666666666 '
'+lon_0=-8.131906111111112 +k=1 +x_0=200180.598 +y_0=299913.01 +ellps=intl +nadgrids=' + os.path.dirname(__file__) + '/grids/pt73_e89.gsb +wktext +units=m +no_defs')
else:
# Direccao Geral do Territorio
arguments.append('+proj=tmerc +lat_0=39.66666666666666 +lon_0=-8.131906111111112 +k=1 +x_0=200180.598 +y_0=299913.01 +ellps=intl +nadgrids=' + os.path.dirname(__file__) + '/grids/D73_ETRS89_geo.gsb +wktext +units=m +no_defs')
arguments.append('-t_srs')
arguments.append('EPSG:3763')
arguments.append('-f')
arguments.append('ESRI Shapefile')
arguments.append(outFile)
arguments.append(conn)
commands = ['ogr2ogr', GdalUtils.escapeAndJoin(arguments)]
GdalUtils.runGdal(commands, progress)