premier commit/push

This commit is contained in:
Tom LAVEILLE 2024-10-14 13:56:22 +02:00
parent c9954f295d
commit 06e259c338
42 changed files with 274 additions and 4535 deletions

8
.gitignore vendored
View File

@ -3,13 +3,13 @@
#Ignores all folders
/*
*__pycache__/
plugins.xml
#Except Plugin folders
!/CenRa_AUTOMAP/*
!/CenRa_COPIE/*
!/CenRa_FLUX/*
!/CenRa_METABASE/*
!/CenRa_POSTGIS/*
!/CenRa_SICEN/*
!/CenRa_SICEN/*
!/CenRa_AUTOMAP/*
*__pycache__*

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 286 KiB

View File

@ -1,120 +0,0 @@
<Layout worldFileMap="" name="test.qpt" printResolution="300" units="mm">
<Snapper snapToGrid="0" snapToItems="1" tolerance="5" snapToGuides="1"/>
<Grid resolution="10" offsetUnits="mm" offsetX="0" resUnits="mm" offsetY="0"/>
<PageCollection>
<symbol name="" clip_to_extent="1" type="fill" force_rhr="0" alpha="1">
<data_defined_properties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</data_defined_properties>
<layer class="SimpleFill" locked="0" enabled="1" pass="0">
<Option type="Map">
<Option name="border_width_map_unit_scale" value="3x:0,0,0,0,0,0" type="QString"/>
<Option name="color" value="255,255,255,255" type="QString"/>
<Option name="joinstyle" value="miter" type="QString"/>
<Option name="offset" value="0,0" type="QString"/>
<Option name="offset_map_unit_scale" value="3x:0,0,0,0,0,0" type="QString"/>
<Option name="offset_unit" value="MM" type="QString"/>
<Option name="outline_color" value="35,35,35,255" type="QString"/>
<Option name="outline_style" value="no" type="QString"/>
<Option name="outline_width" value="0.26" type="QString"/>
<Option name="outline_width_unit" value="MM" type="QString"/>
<Option name="style" value="solid" type="QString"/>
</Option>
<prop k="border_width_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="color" v="255,255,255,255"/>
<prop k="joinstyle" v="miter"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="35,35,35,255"/>
<prop k="outline_style" v="no"/>
<prop k="outline_width" v="0.26"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="style" v="solid"/>
<data_defined_properties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
<LayoutItem zValue="0" id="" itemRotation="0" position="0,0,mm" frame="false" templateUuid="{5c80221d-7561-455b-94fd-69a27d877679}" referencePoint="0" opacity="1" frameJoinStyle="miter" uuid="{5c80221d-7561-455b-94fd-69a27d877679}" blendMode="0" size="297,210,mm" groupUuid="" outlineWidthM="0.3,mm" positionOnPage="0,0,mm" type="65638" excludeFromExports="0" positionLock="false" background="true" visibility="1">
<FrameColor green="0" blue="0" red="0" alpha="255"/>
<BackgroundColor green="255" blue="255" red="255" alpha="255"/>
<LayoutObject>
<dataDefinedProperties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</dataDefinedProperties>
<customproperties>
<Option/>
</customproperties>
</LayoutObject>
<symbol name="" clip_to_extent="1" type="fill" force_rhr="0" alpha="1">
<data_defined_properties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</data_defined_properties>
<layer class="SimpleFill" locked="0" enabled="1" pass="0">
<Option type="Map">
<Option name="border_width_map_unit_scale" value="3x:0,0,0,0,0,0" type="QString"/>
<Option name="color" value="255,255,255,255" type="QString"/>
<Option name="joinstyle" value="miter" type="QString"/>
<Option name="offset" value="0,0" type="QString"/>
<Option name="offset_map_unit_scale" value="3x:0,0,0,0,0,0" type="QString"/>
<Option name="offset_unit" value="MM" type="QString"/>
<Option name="outline_color" value="35,35,35,255" type="QString"/>
<Option name="outline_style" value="no" type="QString"/>
<Option name="outline_width" value="0.26" type="QString"/>
<Option name="outline_width_unit" value="MM" type="QString"/>
<Option name="style" value="solid" type="QString"/>
</Option>
<prop k="border_width_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="color" v="255,255,255,255"/>
<prop k="joinstyle" v="miter"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="35,35,35,255"/>
<prop k="outline_style" v="no"/>
<prop k="outline_width" v="0.26"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="style" v="solid"/>
<data_defined_properties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
</LayoutItem>
<GuideCollection visible="1"/>
</PageCollection>
<customproperties>
<Option type="Map">
<Option name="atlasRasterFormat" value="png" type="QString"/>
<Option name="imageAntialias" value="true" type="bool"/>
<Option name="imageCropMarginBottom" value="0" type="int"/>
<Option name="imageCropMarginLeft" value="0" type="int"/>
<Option name="imageCropMarginRight" value="0" type="int"/>
<Option name="imageCropMarginTop" value="0" type="int"/>
<Option name="imageCropToContents" value="false" type="bool"/>
<Option name="singleFile" value="true" type="bool"/>
</Option>
</customproperties>
<Atlas coverageLayer="" pageNameExpression="" filterFeatures="0" filenamePattern="'output_'||@atlas_featurenumber" enabled="0" hideCoverage="0" sortFeatures="0"/>
</Layout>

View File

@ -1,120 +0,0 @@
<Layout worldFileMap="" name="test.qpt" printResolution="300" units="mm">
<Snapper snapToGrid="0" snapToItems="1" tolerance="5" snapToGuides="1"/>
<Grid resolution="10" offsetUnits="mm" offsetX="0" resUnits="mm" offsetY="0"/>
<PageCollection>
<symbol name="" clip_to_extent="1" type="fill" force_rhr="0" alpha="1">
<data_defined_properties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</data_defined_properties>
<layer class="SimpleFill" locked="0" enabled="1" pass="0">
<Option type="Map">
<Option name="border_width_map_unit_scale" value="3x:0,0,0,0,0,0" type="QString"/>
<Option name="color" value="255,255,255,255" type="QString"/>
<Option name="joinstyle" value="miter" type="QString"/>
<Option name="offset" value="0,0" type="QString"/>
<Option name="offset_map_unit_scale" value="3x:0,0,0,0,0,0" type="QString"/>
<Option name="offset_unit" value="MM" type="QString"/>
<Option name="outline_color" value="35,35,35,255" type="QString"/>
<Option name="outline_style" value="no" type="QString"/>
<Option name="outline_width" value="0.26" type="QString"/>
<Option name="outline_width_unit" value="MM" type="QString"/>
<Option name="style" value="solid" type="QString"/>
</Option>
<prop k="border_width_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="color" v="255,255,255,255"/>
<prop k="joinstyle" v="miter"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="35,35,35,255"/>
<prop k="outline_style" v="no"/>
<prop k="outline_width" v="0.26"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="style" v="solid"/>
<data_defined_properties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
<LayoutItem zValue="0" id="" itemRotation="0" position="0,0,mm" frame="false" templateUuid="{5c80221d-7561-455b-94fd-69a27d877679}" referencePoint="0" opacity="1" frameJoinStyle="miter" uuid="{5c80221d-7561-455b-94fd-69a27d877679}" blendMode="0" size="297,210,mm" groupUuid="" outlineWidthM="0.3,mm" positionOnPage="0,0,mm" type="65638" excludeFromExports="0" positionLock="false" background="true" visibility="1">
<FrameColor green="0" blue="0" red="0" alpha="255"/>
<BackgroundColor green="255" blue="255" red="255" alpha="255"/>
<LayoutObject>
<dataDefinedProperties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</dataDefinedProperties>
<customproperties>
<Option/>
</customproperties>
</LayoutObject>
<symbol name="" clip_to_extent="1" type="fill" force_rhr="0" alpha="1">
<data_defined_properties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</data_defined_properties>
<layer class="SimpleFill" locked="0" enabled="1" pass="0">
<Option type="Map">
<Option name="border_width_map_unit_scale" value="3x:0,0,0,0,0,0" type="QString"/>
<Option name="color" value="255,255,255,255" type="QString"/>
<Option name="joinstyle" value="miter" type="QString"/>
<Option name="offset" value="0,0" type="QString"/>
<Option name="offset_map_unit_scale" value="3x:0,0,0,0,0,0" type="QString"/>
<Option name="offset_unit" value="MM" type="QString"/>
<Option name="outline_color" value="35,35,35,255" type="QString"/>
<Option name="outline_style" value="no" type="QString"/>
<Option name="outline_width" value="0.26" type="QString"/>
<Option name="outline_width_unit" value="MM" type="QString"/>
<Option name="style" value="solid" type="QString"/>
</Option>
<prop k="border_width_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="color" v="255,255,255,255"/>
<prop k="joinstyle" v="miter"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="35,35,35,255"/>
<prop k="outline_style" v="no"/>
<prop k="outline_width" v="0.26"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="style" v="solid"/>
<data_defined_properties>
<Option type="Map">
<Option name="name" value="" type="QString"/>
<Option name="properties"/>
<Option name="type" value="collection" type="QString"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
</LayoutItem>
<GuideCollection visible="1"/>
</PageCollection>
<customproperties>
<Option type="Map">
<Option name="atlasRasterFormat" value="png" type="QString"/>
<Option name="imageAntialias" value="true" type="bool"/>
<Option name="imageCropMarginBottom" value="0" type="int"/>
<Option name="imageCropMarginLeft" value="0" type="int"/>
<Option name="imageCropMarginRight" value="0" type="int"/>
<Option name="imageCropMarginTop" value="0" type="int"/>
<Option name="imageCropToContents" value="false" type="bool"/>
<Option name="singleFile" value="true" type="bool"/>
</Option>
</customproperties>
<Atlas coverageLayer="" pageNameExpression="" filterFeatures="0" filenamePattern="'output_'||@atlas_featurenumber" enabled="0" hideCoverage="0" sortFeatures="0"/>
</Layout>

View File

@ -1,82 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Capa_1"
x="0px"
y="0px"
viewBox="0 0 470 470"
style="enable-background:new 0 0 470 470;"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="north-star-svgrepo-com.svg"><metadata
id="metadata41"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs39" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1017"
id="namedview37"
showgrid="false"
inkscape:zoom="0.50212766"
inkscape:cx="-58.75"
inkscape:cy="235"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="Capa_1" /><g
id="g3"
transform="matrix(0.70762712,0,0,0.70762712,73.669492,121.42372)"><path
d="m 464.37,227.737 -137.711,-35.46 55.747,-94.413 c 1.74,-2.946 1.265,-6.697 -1.155,-9.117 -2.42,-2.42 -6.169,-2.894 -9.117,-1.154 L 277.721,143.34 242.263,5.63 C 241.41,2.316 238.422,0 235,0 c -3.422,0 -6.41,2.316 -7.263,5.63 L 192.277,143.341 97.865,87.593 c -2.947,-1.742 -6.697,-1.267 -9.117,1.154 -2.419,2.42 -2.895,6.171 -1.155,9.117 L 143.34,192.277 5.63,227.737 C 2.316,228.59 0,231.578 0,235 c 0,3.422 2.316,6.41 5.63,7.263 l 137.711,35.46 -55.747,94.413 c -1.74,2.946 -1.265,6.697 1.155,9.117 1.445,1.445 3.365,2.196 5.306,2.196 1.308,0 2.625,-0.342 3.811,-1.042 l 94.413,-55.747 35.46,137.71 c 0.854,3.313 3.841,5.63 7.263,5.63 3.422,0 6.41,-2.316 7.263,-5.63 l 35.46,-137.711 94.413,55.748 c 1.187,0.701 2.503,1.042 3.811,1.042 1.94,0 3.86,-0.751 5.306,-2.196 2.419,-2.42 2.895,-6.171 1.155,-9.117 l -55.747,-94.413 137.71,-35.46 c 3.314,-0.853 5.63,-3.841 5.63,-7.263 0,-3.422 -2.319,-6.41 -5.633,-7.263 z m -176.627,60.007 23.796,-6.128 43.142,73.065 -73.065,-43.143 6.127,-23.794 z m 25.697,-22.106 c -0.035,0.009 -0.07,0.019 -0.106,0.027 l -29.473,7.59 -22.344,-22.345 c -2.929,-2.928 -7.678,-2.928 -10.606,0 -2.929,2.93 -2.929,7.678 0,10.607 l 22.344,22.344 -7.59,29.478 c -0.008,0.033 -0.018,0.065 -0.025,0.099 L 235,432.423 204.356,313.413 c -0.004,-0.016 -7.61,-29.552 -7.61,-29.552 l 87.115,-87.116 29.302,7.546 C 313.21,204.303 432.423,235 432.423,235 L 313.44,265.638 Z m -25.697,-83.382 -6.127,-23.795 73.065,-43.143 -43.142,73.064 -23.796,-6.126 z m -22.099,-25.669 c 0.004,0.016 7.61,29.552 7.61,29.552 L 235,224.393 l -38.254,-38.254 7.59,-29.478 c 0.008,-0.033 0.018,-0.065 0.025,-0.099 L 235,37.577 l 30.644,119.01 z m -83.387,25.669 -23.796,6.128 -43.142,-73.065 73.065,43.143 -6.127,23.794 z m 3.882,14.489 L 224.393,235 186.139,273.255 37.577,235 186.139,196.745 Z m -3.882,90.999 6.127,23.795 -73.065,43.143 43.142,-73.064 23.796,6.126 z"
id="path5"
inkscape:connector-curvature="0" /></g><g
id="g7"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g9"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g11"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g13"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g15"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g17"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g19"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g21"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g23"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g25"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g27"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g29"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g31"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g33"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><g
id="g35"
transform="matrix(0.70762712,0,0,0.70762712,77.669492,133.42372)" /><path
inkscape:connector-curvature="0"
class="st0"
d="m 230.3366,69.68989 20.38,33.826 c 0.404,0.673 0.717,1.188 0.953,1.59 0.487,0.002 1.12,0.004 1.805,0.004 l 20.004,0 c 0.557,0 1.027,-0.471 1.027,-1.028 l 0,-76.944 c 0,-0.557 -0.472,-1.027 -1.027,-1.027 l -20.004,0 c -0.555,0 -1.025,0.471 -1.025,1.027 l 0,33.553 c 0,2.979 -1.948,3.13 -2.338,3.13 -0.958,0 -1.803,-0.599 -2.518,-1.78 l -20.378,-33.826 c -0.498,-0.825 -0.852,-1.429 -1.104,-1.882 -0.4,-0.02 -0.956,-0.036 -1.655,-0.036 l -20.003,0 c -0.557,0 -1.027,0.47 -1.027,1.027 l 0,76.945 c 0,0.557 0.471,1.027 1.027,1.027 l 20.001,0 c 0.557,0 1.027,-0.47 1.027,-1.027 l 0,-33.229 c 0,-2.979 1.948,-3.129 2.338,-3.129 0.959,-10e-4 1.805,0.599 2.517,1.779 z"
id="path9" /></svg>

Before

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -1,47 +0,0 @@
<svg viewBox="0 0 61.06 96.62" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(-1.438 30.744)">
<g fill="none" stroke="param(outline)">
<path d="m61 35c0 16.02-12.984 29-29 29-16.02 0-29-12.984-29-29 0-16.02 12.984-29 29-29 16.02 0 29 12.984 29 29z" stroke-width="3"/>
<path d="m55 35c0 12.979-10.521 23.5-23.5 23.5-12.979 0-23.5-10.521-23.5-23.5 0-12.979 10.521-23.5 23.5-23.5 12.979 0 23.5 10.521 23.5 23.5z" stroke-width=".497" transform="matrix(1.01148 0 0 .99988 -.089 .004)"/>
<path d="m32 35v-32" stroke-width=".25"/>
</g>
<path d="m32-9.453l28.938 73.826-29-29-29 29z" fill="param(fill)" stroke="param(outline)" stroke-width="3"/>
<path d="m32-9.453l29 73.45-29-29-29 29z" fill="none" stroke="param(outline)" stroke-linecap="square"/>
<text fill="param(fill)" font-family="OPEN SANS" font-size="40" letter-spacing="0" line-height="125%" word-spacing="0" x="22.71" y="-10.854">
<tspan font-family="Adobe Heiti Std R" font-size="26" x="22.71" y="-10.854">N</tspan>
</text>
</g>
<g fill="none" stroke="param(outline)" stroke-width=".25" transform="translate(0 -3.829)">
<path d="m4 92.82l6.74-3.891"/>
<path d="m4.603 90.7l10.397-6"/>
<path d="m3 95.17l4-2.309"/>
<path d="m5.442 88.45l13.856-8"/>
<path d="m12 72.26l18.686-10.812"/>
<path d="m14.593 65.45l16.09-9.291"/>
<path d="m15.343 63.24l15.343-8.858"/>
<path d="m16.877 60.58l13.809-7.972"/>
<path d="m17.511 58.45l13.174-7.606"/>
<path d="m18.412 56.15l12.274-7.087"/>
<path d="m19 54.04l11.427-6.597"/>
<path d="m20 51.757l10.822-6.311"/>
<path d="m20.826 49.45l9.86-5.693"/>
<path d="m21.48 47.3l9.206-5.315"/>
<path d="m23 44.647l7.686-4.437"/>
<path d="m23.744 42.45l6.928-4"/>
<path d="m24.549 40.21l6.137-3.543"/>
<path d="m25 38.18l5.686-3.283"/>
<path d="m26.663 35.446l4.02-2.323"/>
<path d="m27.617 33.12l3.069-1.772"/>
<path d="m28 31.13l2.686-1.551"/>
<path d="m29.15 28.694l1.534-.886"/>
<path d="m13 69.909l17.686-10.211"/>
<path d="m9.206 79.19l21.48-12.402"/>
<path d="m8.36 81.45l22.326-12.89"/>
<path d="m7.671 83.62l19.946-11.516"/>
<path d="m6.137 86.27l17.02-9.827"/>
<path d="m10 76.956l20.686-11.943"/>
<path d="m11.279 74.45l19.407-11.205"/>
<path d="m14 67.56l16.686-9.634"/>
<path d="m30.562 65.744v-43.566" transform="translate(0 3.829)"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1,317 +0,0 @@
from qgis.core import (
QgsLayoutSize,
QgsUnitTypes,
QgsLayoutPoint,
)
def fletch_canvas(self,values_page):
### Modèle carto standard ###
if values_page == '1. Modèle carto standard.qpt':
if self.radioButton_6.isChecked() and self.radioButton_7.isChecked():
self.template_parameters['position_map_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['position_map_position'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_size'] = QgsLayoutSize(199, 175, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_position'] = QgsLayoutPoint(5, 25, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_position'] = QgsLayoutPoint(5, 12, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_size'] = QgsLayoutSize(46, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_position'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_position'] = QgsLayoutPoint(5, 275, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_position'] = QgsLayoutPoint(5, 205, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_size'] = QgsLayoutSize(55, 5, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_position'] = QgsLayoutPoint(145, 228, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_position'] = QgsLayoutPoint(145, 215, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_position'] = QgsLayoutPoint(193, 214, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_position'] = QgsLayoutPoint(205, 125, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_position'] = QgsLayoutPoint(104, 201, QgsUnitTypes.LayoutMillimeters)
if self.radioButton_6.isChecked() and self.radioButton_8.isChecked():
self.template_parameters['position_map_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['position_map_position'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_size'] = QgsLayoutSize(285, 145, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_position'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_position'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_size'] = QgsLayoutSize(46, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_position'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_position'] = QgsLayoutPoint(5, 185, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_position'] = QgsLayoutPoint(5, 168, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_position'] = QgsLayoutPoint(207, 193, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_position'] = QgsLayoutPoint(207, 180, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_size'] = QgsLayoutSize(8.4, 12.5, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_position'] = QgsLayoutPoint(273, 182, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_position'] = QgsLayoutPoint(291.5, 123, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_position'] = QgsLayoutPoint(189, 168.5, QgsUnitTypes.LayoutMillimeters)
if self.radioButton_5.isChecked() and self.radioButton_7.isChecked():
self.template_parameters['map_size'] = QgsLayoutSize(285, 260, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_position'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_position'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_size'] = QgsLayoutSize(46, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_position'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_position'] = QgsLayoutPoint(5, 395, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_position'] = QgsLayoutPoint(5, 284, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_size'] = QgsLayoutSize(50, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_position'] = QgsLayoutPoint(207, 310, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_size'] = QgsLayoutSize(50, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_position'] = QgsLayoutPoint(207, 298, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_size'] = QgsLayoutSize(8.4, 12.5, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_position'] = QgsLayoutPoint(273, 297, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_position'] = QgsLayoutPoint(291.5, 123, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_position'] = QgsLayoutPoint(189, 284, QgsUnitTypes.LayoutMillimeters)
if self.radioButton_5.isChecked() and self.radioButton_8.isChecked():
self.template_parameters['map_size'] = QgsLayoutSize(408.5, 222, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_position'] = QgsLayoutPoint(5, 23.5, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_size'] = QgsLayoutSize(409, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_size'] = QgsLayoutSize(409, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_position'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_size'] = QgsLayoutSize(46, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_position'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_position'] = QgsLayoutPoint(5, 275, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_position'] = QgsLayoutPoint(5, 249, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_position'] = QgsLayoutPoint(323, 282, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_position'] = QgsLayoutPoint(323, 270, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_size'] = QgsLayoutSize(8.4, 12.5, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_position'] = QgsLayoutPoint(402, 270, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_position'] = QgsLayoutPoint(415, 123, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_position'] = QgsLayoutPoint(313, 247, QgsUnitTypes.LayoutMillimeters)
### Modèle carto plein page ###
if values_page == '2. Modèle carto plein page.qpt':
if self.radioButton_6.isChecked() and self.radioButton_7.isChecked():
self.template_parameters['position_map_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['position_map_position'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_size'] = QgsLayoutSize(210, 297, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_position'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_position'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_position'] = QgsLayoutPoint(5, 275, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_position'] = QgsLayoutPoint(133, 215, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_position'] = QgsLayoutPoint(3, 288, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_position'] = QgsLayoutPoint(3, 273, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_position'] = QgsLayoutPoint(196, 283, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_position'] = QgsLayoutPoint(205, 125, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_position'] = QgsLayoutPoint(55, 292, QgsUnitTypes.LayoutMillimeters)
if self.radioButton_6.isChecked() and self.radioButton_8.isChecked():
self.template_parameters['position_map_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['position_map_position'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_size'] = QgsLayoutSize(297, 210, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_position'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_position'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_position'] = QgsLayoutPoint(5, 185, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_position'] = QgsLayoutPoint(231, 135, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_position'] = QgsLayoutPoint(3, 201, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_position'] = QgsLayoutPoint(3, 186, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_position'] = QgsLayoutPoint(283, 196, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_position'] = QgsLayoutPoint(291.5, 123, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_position'] = QgsLayoutPoint(98, 205, QgsUnitTypes.LayoutMillimeters)
if self.radioButton_5.isChecked() and self.radioButton_7.isChecked():
self.template_parameters['position_map_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['position_map_position'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_size'] = QgsLayoutSize(297, 420, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_position'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_position'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_position'] = QgsLayoutPoint(5, 370, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_position'] = QgsLayoutPoint(219, 324, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_position'] = QgsLayoutPoint(3, 410, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_position'] = QgsLayoutPoint(3, 395, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_size'] = QgsLayoutSize(24, 24, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_position'] = QgsLayoutPoint(271, 394, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_position'] = QgsLayoutPoint(291, 125, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_position'] = QgsLayoutPoint(98, 414, QgsUnitTypes.LayoutMillimeters)
if self.radioButton_5.isChecked() and self.radioButton_8.isChecked():
self.template_parameters['position_map_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['position_map_position'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_size'] = QgsLayoutSize(420, 297, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['map_position'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_size'] = QgsLayoutSize(411, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['title_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_size'] = QgsLayoutSize(411, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['subtitle_position'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['logo_credit_position'] = QgsLayoutPoint(5, 247, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['legend_position'] = QgsLayoutPoint(341, 196, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebarnumeric_position'] = QgsLayoutPoint(3, 287, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['scalebar_position'] = QgsLayoutPoint(3, 272, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_size'] = QgsLayoutSize(24, 24, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['north_position'] = QgsLayoutPoint(394, 271, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text_position'] = QgsLayoutPoint(414, 123, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['credit_text2_position'] = QgsLayoutPoint(185, 292, QgsUnitTypes.LayoutMillimeters)
# Retour des info #
return self.template_parameters

View File

@ -1 +0,0 @@
# CenRa_COPIE

View File

@ -1,925 +0,0 @@
# -*- coding: utf-8 -*-
"""
/***************************************************************************
CenRa
A QGIS plugin
Conservatoire d'Espaces Naturels de Rhône-Alpes
-------------------
begin : 2014-03-27
copyright : (C) 2014 by Conservatoire d'Espaces Naturels de Rhône-Alpes
email : guillaume.costes@espaces-naturels.fr
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
"""
from __future__ import absolute_import
# Import the PyQt and QGIS libraries
from builtins import next
from builtins import str
from builtins import object
from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog
from qgis.PyQt.QtGui import QIcon
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from qgis.core import *
from qgis.core import QgsDataSourceUri
# Initialize Qt resources from file resources.py
from . import resources_rc
# Import the code for the dialog
from .cenradialog import CenRaDialog
from .table_postgisdialog import table_postgisDialog
from .tools.PythonSQL import *
from .tools.resources import maj_verif
import os.path
import webbrowser, os
import psycopg2
import psycopg2.extras
import base64
class CenRa(object):
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value("locale/userLocale")[0:2]
localePath = os.path.join(self.plugin_dir, 'i18n', 'cenra_{}.qm'.format(locale))
if os.path.exists(localePath):
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
self.dlg = CenRaDialog()
self.dlgAjout = table_postgisDialog()
maj_verif('CenRa_POSTGIS')
def initGui(self):
self.toolBar = self.iface.addToolBar("CEN-RA")
self.toolBar.setObjectName("CEN-RA")
# ***Create action that will start plugin configuration
self.action = QAction(
QIcon(":/plugins/CenRa/page_new.png"),
u"Création d'un dossier", self.iface.mainWindow())
# connect the action to the run method
self.action.triggered.connect(self.creation)
# Add toolbar button and menu item
self.toolBar.addAction(self.action)
self.iface.addPluginToMenu(u"CenRa", self.action)
# ***Create action that will start plugin configuration
self.action = QAction(
QIcon(":/plugins/CenRa/page_ajout.png"),
u"Ajout d'une table", self.iface.mainWindow())
# connect the action to the run method
self.action.triggered.connect(self.ajout)
# Add toolbar button and menu item
self.toolBar.addAction(self.action)
self.iface.addPluginToMenu(u"&CenRa", self.action)
# ***Create action that will start plugin configuration
self.action = QAction(
QIcon(":/plugins/CenRa/help.png"),
u"Aide", self.iface.mainWindow())
# connect the action to the run method
self.action.triggered.connect(self.doHelp)
# Add toolbar button and menu item
self.toolBar.addAction(self.action)
self.iface.addPluginToMenu(u"CenRa", self.action)
self.menu = QMenu()
self.menu.setTitle( QCoreApplication.translate( "CENRA","&CenRa" ) )
self.cenra_new = QAction( QIcon(":/plugins/CenRa/page_new.png"), QCoreApplication.translate("CENRA", u"Création d'un dossier" ), self.iface.mainWindow() )
self.cenra_ajout = QAction( QIcon(":/plugins/CenRa/page_ajout.png"), QCoreApplication.translate("CENRA", "Ajout d'une table" ), self.iface.mainWindow() )
self.cenra_help = QAction( QIcon(":/plugins/CenRa/help.png"), QCoreApplication.translate("CENRA", "Aide" ), self.iface.mainWindow() )
self.menu.addActions( [self.cenra_new, self.cenra_ajout, self.cenra_help] )
menu_bar = self.iface.mainWindow().menuBar()
actions = menu_bar.actions()
lastAction = actions[ len( actions ) - 1 ]
menu_bar.insertMenu( lastAction, self.menu )
self.cenra_new.triggered.connect(self.creation)
self.cenra_ajout.triggered.connect(self.ajout)
self.cenra_help.triggered.connect(self.doHelp)
def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu(u"&CENRA", self.action)
self.iface.removePluginMenu(u"&CenRa", self.action)
self.iface.removeToolBarIcon(self.action)
# run method that performs all the real work
def creation(self):
# show the dialog
self.dlg.show()
# Run the dialog event loop
result = self.dlg.exec_()
# See if OK was pressed
if result == 1:
#**********************************Debut_script****************************************
### Creation du schema pour le nouveau site
if self.dlg.at.isChecked():
schema = "_" + self.dlg.dept.currentText() + "_at_" + self.dlg.nom.text().lower() # Ajout de "_" pour eviter pb de numero en premier caractere
else :
schema = "_" + self.dlg.dept.currentText() + "_" + self.dlg.nom.text().lower() # Ajout de "_" pour eviter pb de numero en premier caractere
if self.dlg.nom.text() == "" or self.dlg.nom.text() == "NULL":
QMessageBox.warning(None, "Oups :", "Veuillez renseigner un nom de dossier.")
return
ch = [u"à", u"À", u"â", u"Â", u"ä", u"Ä", u"å", u"Å", u"ç", u"Ç", u"é", u"É", u"è", u"È", u"ê", u"Ê", u"ë", u"Ë", u"î", u"Î", u"ï", u"Ï", u"ô", u"Ô", u"ö", u"Ö", u"ù", u"Ù", u"û", u"Û", u"ü", u"Ü", u"ÿ", u"Ÿ", u"'", u"-", u" "]
for car in ch :
if self.dlg.nom.text().find(car) != -1 :
QMessageBox.warning(None, "Oups :", u"Le nom de dossier ne doit pas comporter de caractères spéciaux, ni d'espaces !\n\n\t" + self.dlg.nom.text().lower() )
return
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
SQL_schema = "CREATE SCHEMA " + schema + ";"
SQL_GRANT_SCHEMA="GRANT CREATE, USAGE ON SCHEMA "+schema+" TO grp_qgis; GRANT CREATE, USAGE ON SCHEMA "+schema+" TO grp_sig;"
cur.execute(SQL_schema)
cur.execute(SQL_GRANT_SCHEMA)
### Creation de la table contour
if self.dlg.couche_contour.isChecked(): # Verifie si la checkbox est cochee
if self.dlg.annee_1.text() == 'aaaa' or self.dlg.annee_1.text() == '':
tablename = schema + "_contour"
else :
tablename = schema + "_contour_" + self.dlg.annee_1.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_contour = "CREATE TABLE " + schema + "."+ tablename + champ_contour
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'contour_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_contour)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
### Creation de la table habitat
if self.dlg.couche_habitat.isChecked():
if self.dlg.annee_2.text() == 'aaaa' or self.dlg.annee_2.text() == '':
tablename = schema + "_habitat"
else :
tablename = schema + "_habitat_" + self.dlg.annee_2.text()
tablename_1=tablename+"_points"
tablename_qgis = tablename_1[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_1 + champ_vegethab_point
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_1 + " ADD CONSTRAINT " + tablename_1 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename_1 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_1 + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_1 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_points_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_1+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_1+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_1+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_coordonnees)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_1, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_2=tablename+"_lignes"
tablename_qgis = tablename_2[1:]
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_2 + champ_vegethab_multilinestring
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_2 + " ADD CONSTRAINT " + tablename_2 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_2 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_lignes_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_2+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_2+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_2+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_2, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_3=tablename+"_polygones"
tablename_qgis = tablename_3[1:]
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_3 + champ_vegethab_multipolygon
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_3 + " ADD CONSTRAINT " + tablename_3 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_3 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_polygones_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_3+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_3+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_3+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_3, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
'''
SQL_habitat = "CREATE TABLE " + schema + "."+ tablename + champ_habitat
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_concat_cd_cb = "CREATE TRIGGER concat_cd_cb" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.concat_cd_cb();"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'habitat_modele_v3'"""
cur.execute(SQL_habitat)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_trigger_concat_cd_cb)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
'''
### Creation de la table travaux prevus
if self.dlg.couche_travaux_prevus.isChecked():
#**********Poly
if self.dlg.annee_5.text() == 'aaaa' or self.dlg.annee_5.text() == '':
tablename = schema + "_travaux_prevus_poly"
else :
tablename = schema + "_travaux_prevus_poly_" + self.dlg.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_multipolygon
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_poly_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
#**********ligne
if self.dlg.annee_5.text() == 'aaaa' or self.dlg.annee_5.text() == '':
tablename = schema + "_travaux_prevus_ligne"
else :
tablename = schema + "_travaux_prevus_ligne_" + self.dlg.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_multilinestring
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_ligne_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
#**********point
if self.dlg.annee_5.text() == 'aaaa' or self.dlg.annee_5.text() == '':
tablename = schema + "_travaux_prevus_point"
else :
tablename = schema + "_travaux_prevus_point_" + self.dlg.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_point
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_point_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_coordonnees)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
### Creation de la table vierge
if self.dlg.couche_vierge.isChecked():
if self.dlg.annee_4.text() == 'aaaa' or self.dlg.annee_4.text() == '':
tablename = schema + "_" + self.dlg.nom_couche_vierge.text().lower()
else :
tablename = schema + "_" + self.dlg.nom_couche_vierge.text().lower() + "_" + self.dlg.annee_4.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
if self.dlg.couche_vierge_point.isChecked() == 1 :
champ_vierge = champ_viergePoint
if self.dlg.couche_vierge_ligne.isChecked() == 1 :
champ_vierge = champ_viergeLigne
if self.dlg.couche_vierge_polygone.isChecked() == 1 :
champ_vierge = champ_viergePolygone
SQL_vierge = "CREATE TABLE " + schema + "."+ tablename + champ_vierge
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
cur.execute(SQL_vierge)
cur.execute(SQL_pkey)
if self.dlg.couche_vierge_point.isChecked() == 1 :
cur.execute(SQL_trigger_coordonnees)
if self.dlg.couche_vierge_ligne.isChecked() == 1 :
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
if self.dlg.couche_vierge_polygone.isChecked() == 1 :
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
else :
con.commit()
con.close()
pass
### Outil Aide
def doHelp(self):
webbrowser.open("http://plateformesig.cenra-outils.org/")
### Outil Ajout de nouvelles couche a un dossier
def ajout(self):
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
# Creation de la liste des schemas de la base de donnees
SQL = """WITH list_schema AS (
select schemaname,'sig' as group from pg_catalog.pg_tables
where schemaname ~ E'^_(0|1|2|3|4|6|7|f)'
group by schemaname
order by schemaname)
select string_agg(schemaname,',')
from list_schema
group by "group";"""
cur.execute(SQL)
list_brut = str(next(cur))
list = list_brut [2:-2]
listItems = list.split(",")
con.close()
self.dlgAjout.ui.schema.clear()
self.dlgAjout.ui.schema.addItems(listItems)
self.dlgAjout.ui.schema.setCurrentIndex(-1) # Pour ne pas commencer la liste au premier schema
# show the dialog
self.dlgAjout.show()
# Run the dialog event loop
result = self.dlgAjout.exec_()
# See if OK was pressed
if result == 1:
#******************************debut script*********************************
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if self.dlgAjout.ui.schema.currentIndex() == -1 :
QMessageBox.warning(None, "Oups :", "Veuillez choisir un nom de dossier.")
return
schema = self.dlgAjout.ui.schema.currentText()
### Creation de la table contour
if self.dlgAjout.ui.couche_contour.isChecked(): # Verifie si la checkbox est cochee
if self.dlgAjout.ui.annee_1.text() == 'aaaa' or self.dlgAjout.ui.annee_1.text() == '':
tablename = schema + "_contour"
else :
tablename = schema + "_contour_" + self.dlgAjout.ui.annee_1.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_contour = "CREATE TABLE " + schema + "."+ tablename + champ_contour
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'contour_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_contour)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
### Creation de la table habitat
if self.dlgAjout.ui.couche_habitat.isChecked():
if self.dlgAjout.ui.annee_2.text() == 'aaaa' or self.dlgAjout.ui.annee_2.text() == '':
tablename = schema + "_habitat"
else :
tablename = schema + "_habitat_" + self.dlgAjout.ui.annee_2.text()
tablename_1=tablename+"_points"
tablename_qgis = tablename_1[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_1 + champ_vegethab_point
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_1 + " ADD CONSTRAINT " + tablename_1 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename_1 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_1 + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_1 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_points_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_1+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_1+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_1+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_coordonnees)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_1, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_2=tablename+"_lignes"
tablename_qgis = tablename_2[1:]
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_2 + champ_vegethab_multilinestring
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_2 + " ADD CONSTRAINT " + tablename_2 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_2 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_lignes_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_2+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_2+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_2+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_2, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_3=tablename+"_polygones"
tablename_qgis = tablename_3[1:]
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_3 + champ_vegethab_multipolygon
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_3 + " ADD CONSTRAINT " + tablename_3 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_3 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_polygones_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_3+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_3+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_3+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_3, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
'''
SQL_habitat = "CREATE TABLE " + schema + "."+ tablename + champ_habitat
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_concat_cd_cb = "CREATE TRIGGER concat_cd_cb" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.concat_cd_cb();"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'habitat_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_habitat)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_trigger_concat_cd_cb)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
'''
### Creation de la table travaux prevus
if self.dlgAjout.ui.couche_travaux_prevus.isChecked():
#**********Poly
if self.dlgAjout.ui.annee_5.text() == 'aaaa' or self.dlgAjout.ui.annee_5.text() == '':
tablename = schema + "_travaux_prevus_poly"
else :
tablename = schema + "_travaux_prevus_poly_" + self.dlgAjout.ui.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_multipolygon
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_poly_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
#**********ligne
if self.dlgAjout.ui.annee_5.text() == 'aaaa' or self.dlgAjout.ui.annee_5.text() == '':
tablename = schema + "_travaux_prevus_ligne"
else :
tablename = schema + "_travaux_prevus_ligne_" + self.dlgAjout.ui.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_multilinestring
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_ligne_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
#**********point
if self.dlgAjout.ui.annee_5.text() == 'aaaa' or self.dlgAjout.ui.annee_5.text() == '':
tablename = schema + "_travaux_prevus_point"
else :
tablename = schema + "_travaux_prevus_point_" + self.dlgAjout.ui.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_point
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_point_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_coordonnees)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
### Creation de la table vierge
if self.dlgAjout.ui.couche_vierge.isChecked():
if self.dlgAjout.ui.annee_4.text() == 'aaaa' or self.dlgAjout.ui.annee_4.text() == '':
tablename = schema + "_" + self.dlgAjout.ui.nom_couche_vierge.text().lower()
else :
tablename = schema + "_" + self.dlgAjout.ui.nom_couche_vierge.text().lower() + "_" + self.dlgAjout.ui.annee_4.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
if self.dlgAjout.ui.couche_vierge_point.isChecked() == 1 :
champ_vierge = champ_viergePoint
if self.dlgAjout.ui.couche_vierge_ligne.isChecked() == 1 :
champ_vierge = champ_viergeLigne
if self.dlgAjout.ui.couche_vierge_polygone.isChecked() == 1 :
champ_vierge = champ_viergePolygone
SQL_vierge = "CREATE TABLE " + schema + "."+ tablename + champ_vierge
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
cur.execute(SQL_vierge)
cur.execute(SQL_pkey)
if self.dlgAjout.ui.couche_vierge_point.isChecked() == 1 :
cur.execute(SQL_trigger_coordonnees)
if self.dlgAjout.ui.couche_vierge_ligne.isChecked() == 1 :
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
if self.dlgAjout.ui.couche_vierge_polygone.isChecked() == 1 :
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
else :
con.commit()
con.close()
pass

View File

@ -36,9 +36,12 @@ from qgis.gui import *
# Initialize Qt resources from file resources.py
from . import resources_rc
# Import the code for the dialog
import qgis
from .forms.about_form import CopieAboutDialog
from .copie_dialog import CopieDialog
import os.path
from .PythonSQL import *
from .tools.PythonSQL import *
from .tools.resources import maj_verif
import psycopg2
import psycopg2.extras
import base64
@ -77,6 +80,15 @@ class Copie(object):
# Create the dialog (after translation) and keep reference
self.dlg = CopieDialog()
maj_verif('CenRa_COPIE')
version = qgis.utils.pluginMetadata('CenRa_COPIE','version')
# Display About window on first use
s = QSettings()
versionUse = s.value("copie/version", 1, type=str)
if str(versionUse) != str(version) :
s.setValue("copie/version", str(version))
self.open_about_dialog()
# Declare instance attributes
self.actions = []
@ -85,6 +97,10 @@ class Copie(object):
self.toolbar = self.iface.addToolBar(u'Copie')
self.toolbar.setObjectName(u'Copie')
def open_about_dialog(self):
dialog = CopieAboutDialog(self.iface)
dialog.exec_()
# noinspection PyMethodMayBeStatic
def tr(self, message):
"""Get the translation for a string using Qt translation API.

View File

@ -10,7 +10,7 @@
name=CenRA_COPIE
qgisMinimumVersion=3.0
description=Permet la copie d'une table dans une base PostGis
version=1.3
version=1.5
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr
@ -19,7 +19,7 @@ email=si_besoin@cen-rhonealpes.fr
# Recommended items:
# Uncomment the following line and add your changelog:
changelog=Traduction pour QGIS v3
changelog=<h2>CenRa_COPIE:</h2></br><p><h3>13/09/2024 - Version 1.5:</h3>- Ajoute d'un changelog et vérification de mise à jour.</p>
# Tags are comma separated with spaces allowed
tags=cenra, database, table

View File

@ -57,8 +57,8 @@ champ_vegethab_point = """(
occupati_3 bigint,
milieu_cod character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default",
x_wgs84 double precision,
y_wgs84 double precision,
surface_m2 numeric,
surface_ha numeric,
commentair character varying(254) COLLATE pg_catalog."default",
date_creat date,
date_maj date,
@ -99,8 +99,8 @@ champ_vegethab_multilinestring = """(
occupati_3 bigint,
milieu_cod character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default",
longueur_m double precision,
longueur_km double precision,
surface_m2 numeric,
surface_ha numeric,
commentair character varying(254) COLLATE pg_catalog."default",
date_creat date,
date_maj date,

View File

@ -117,6 +117,7 @@ def login_base(take=None):
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
@ -138,24 +139,45 @@ def send_issues(url,titre,body,labels):
payload = {'title': titre, 'body': body, 'labels': labels}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.text)
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
r = ''
if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers)
return r
def maj_verif(NAME):
import qgis
import urllib
import urllib.request
iface = qgis.utils.iface
from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository')
URL = url+'/raw/branch/main/plugins.xml'
#URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml'
# print(URL)
version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version)
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
if binar:
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
if version_plugin == version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
def devlog(NAME):
import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog')
return devmaj

View File

@ -31,7 +31,7 @@ else:
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user = 'admin'
os_user = 'stage'
schemaname_distinct="""SELECT DISTINCT schemaname from pg_catalog.pg_tables
WHERE schemaname NOT LIKE '_archives' AND schemaname NOT LIKE 'topology' AND schemaname NOT LIKE 'information_schema' AND schemaname NOT LIKE 'pg_catalog' and schemaname NOT LIKE 'public' AND schemaname NOT LIKE '_trier'

View File

@ -89,7 +89,7 @@ def resources_path(*args):
:return: Absolute path to the resources folder.
:rtype: str
"""
path = abspath(abspath(join(plugin_path(), "CenRa_Metabase\\resources")))
path = abspath(abspath(join(plugin_path(), "CenRa_Metabase\\tools")))
for item in args:
path = abspath(join(path, item))
return path
@ -108,7 +108,7 @@ def load_ui(*args):
return ui_class
def login_base(take=None):
from CenRa_Metabase.resources.PythonSQL import host,port,dbname,password,os_user
from .tools.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
@ -117,6 +117,7 @@ def login_base(take=None):
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
@ -138,24 +139,45 @@ def send_issues(url,titre,body,labels):
payload = {'title': titre, 'body': body, 'labels': labels}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.text)
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
r = ''
if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers)
return r
def maj_verif(NAME):
import qgis
import urllib
import urllib.request
iface = qgis.utils.iface
from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository')
URL = url+'/raw/branch/main/plugins.xml'
#URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml'
# print(URL)
version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version)
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
if binar:
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
if version_plugin == version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
def devlog(NAME):
import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog')
return devmaj

View File

@ -6,5 +6,5 @@ __email__ = "info@3liz.org"
# noinspection PyPep8Naming
def classFactory(iface): # pylint: disable=invalid-name
_ = iface
from CenRa_Metabase.CenRa_Metabase import PgMetadata
from CenRa_METABASE.CenRa_Metabase import PgMetadata
return PgMetadata()

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0" language="af" sourcelanguage="en">
<context>
<name>@default</name>
<message>
<location filename="test_translations.py" line="48"/>
<source>Good morning</source>
<translation>Goeie more</translation>
</message>
</context>
</TS>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -32,9 +32,8 @@ from qgis.PyQt.QtWidgets import (
)
from qgis.utils import iface
from CenRa_Metabase.resources.i18n import tr
from CenRa_Metabase.resources.resources import (
from .tools.resources import (
load_ui,
resources_path,
send_issues,

View File

@ -1,32 +0,0 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
#print(IPAddr)
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.11"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'

View File

@ -1,61 +0,0 @@
body {
font-family: Ubuntu, Lucida Grande, Segoe UI, Arial, sans-serif;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
font-size: 14px;
}
img {
max-width: 100%;
}
img.logo{
display: inline-block;
margin-left:0px;
margin-right: 0px;
margin-top: 10px;
margin-bottom: 10px;
vertical-align: top;
width:25%
}
h2, h3 {
color: #fff;
background-color: #8cb63c;
line-height: 2;
padding-left:5px;
}
table {
border-collapse: collapse;
width: 100%;
font-size: 13px;
}
th{
color: #2c4491
}
table tr th, table tr td {
text-align: left;
padding: 5px;
}
table.table-striped {
border: 1px solid #BBB;
}
table.table-striped tr td {
border: 1px solid #BBB;
}
table.table-striped tr th {
border: 1px solid #BBB;
}
table.table-striped tr:nth-child(even) {
background: #EEE;
}
table.table-striped tr:nth-child(odd) {
background: #FFF;
}
#map {
padding: 5px;
width: 400px;
height: 400px;
box-shadow: 0 0 10px #999;
}

View File

@ -1,49 +0,0 @@
"""I18n tools."""
from os.path import join
from qgis.PyQt.QtCore import QLocale, QFileInfo
from qgis.PyQt.QtWidgets import QApplication
from qgis.core import QgsSettings
from .resources import resources_path
__copyright__ = "Copyright 2019, 3Liz"
__license__ = "GPL version 3"
__email__ = "info@3liz.org"
__revision__ = "$Format:%H$"
def setup_translation(file_pattern="{}.qm", folder=None):
"""Find the translation file according to locale.
:param file_pattern: Custom file pattern to use to find QM files.
:type file_pattern: basestring
:param folder: Optional folder to look in if it's not the default.
:type folder: basestring
:return: The locale and the file path to the QM file, or None.
:rtype: (basestring, basestring)
"""
locale = QgsSettings().value("locale/userLocale", QLocale().name())
if folder:
ts_file = QFileInfo(join(folder, file_pattern.format(locale)))
else:
ts_file = QFileInfo(resources_path("i18n", file_pattern.format(locale)))
if ts_file.exists():
return locale, ts_file.absoluteFilePath()
if folder:
ts_file = QFileInfo(join(folder, file_pattern.format(locale[0:2])))
else:
ts_file = QFileInfo(resources_path("i18n", file_pattern.format(locale[0:2])))
if ts_file.exists():
return locale, ts_file.absoluteFilePath()
return locale, None
def tr(text, context="@default"):
return QApplication.translate(context, text)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

View File

@ -1,161 +0,0 @@
"""Tools to work with resource files."""
import configparser
import shutil
import tempfile
import base64
import psycopg2
import psycopg2.extras
from os.path import abspath, join, pardir, dirname
from qgis.PyQt import uic
__copyright__ = "Copyright 2019, 3Liz"
__license__ = "GPL version 3"
__email__ = "info@3liz.org"
__revision__ = "$Format:%H$"
def plugin_path(*args):
"""Get the path to plugin root folder.
:param args List of path elements e.g. ['img', 'logos', 'image.png']
:type args: str
:return: Absolute path to the plugin path.
:rtype: str
"""
path = dirname(dirname(__file__))
path = abspath(abspath(join(path, pardir)))
for item in args:
path = abspath(join(path, item))
return path
def plugin_name():
"""Return the plugin name according to metadata.txt.
:return: The plugin name.
:rtype: basestring
"""
metadata = metadata_config()
name = metadata["general"]["name"]
return name
def metadata_config() -> configparser:
"""Get the INI config parser for the metadata file.
:return: The config parser object.
:rtype: ConfigParser
"""
path = plugin_path("metadata.txt")
config = configparser.ConfigParser()
config.read(path, encoding='utf8')
return config
def plugin_test_data_path(*args, copy=False):
"""Get the path to the plugin test data path.
:param args List of path elements e.g. ['img', 'logos', 'image.png']
:type args: str
:param copy: If the file must be copied into a temporary directory first.
:type copy: bool
:return: Absolute path to the resources folder.
:rtype: str
"""
path = abspath(abspath(join(plugin_path(), "test", "data")))
for item in args:
path = abspath(join(path, item))
if copy:
temp = tempfile.mkdtemp()
shutil.copy(path, temp)
return join(temp, args[-1])
else:
return path
def resources_path(*args):
"""Get the path to our resources folder.
:param args List of path elements e.g. ['img', 'logos', 'image.png']
:type args: str
:return: Absolute path to the resources folder.
:rtype: str
"""
path = abspath(abspath(join(plugin_path(), "CenRa_Metabase\\resources")))
for item in args:
path = abspath(join(path, item))
return path
def load_ui(*args):
"""Get compile UI file.
:param args List of path elements e.g. ['img', 'logos', 'image.png']
:type args: str
:return: Compiled UI file.
"""
ui_class, _ = uic.loadUiType(resources_path("ui", *args))
return ui_class
def login_base(take=None):
from CenRa_Metabase.resources.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels):
import requests
import json
import os
import qgis
usr = os.environ['USERNAME']
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
url=url+'?token='+token
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
payload = {'title': titre, 'body': body, 'labels': labels}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.text)
return r
def maj_verif(NAME):
import qgis
import urllib
url = qgis.utils.pluginMetadata(NAME,'repository')
URL = url+'/raw/branch/main/plugins.xml'
# print(URL)
version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version)
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
if version_plugin == version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)

View File

@ -1,332 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CenRa_IssuesSend</class>
<widget class="QDialog" name="CenRa_IssuesSend">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>810</width>
<height>587</height>
</rect>
</property>
<property name="windowTitle">
<string>CEN-RA Metabase</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>icon.svg</normaloff>icon.svg</iconset>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>550</y>
<width>811</width>
<height>31</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="2">
<widget class="QPushButton" name="annuler_button">
<property name="text">
<string>Annuler</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="ok_button">
<property name="text">
<string>Envoyer</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>791</width>
<height>531</height>
</rect>
</property>
<property name="title">
<string>Issues</string>
</property>
<widget class="QLineEdit" name="titre_line">
<property name="geometry">
<rect>
<x>240</x>
<y>40</y>
<width>321</width>
<height>41</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPlainTextEdit" name="messages_plain">
<property name="geometry">
<rect>
<x>10</x>
<y>101</y>
<width>571</width>
<height>421</height>
</rect>
</property>
</widget>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>589</x>
<y>100</y>
<width>191</width>
<height>431</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>341</width>
<height>411</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="formAlignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
<item row="0" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="check_bug">
<property name="text">
<string>Bug</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="check_aide">
<property name="text">
<string>Aide</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="check_question">
<property name="text">
<string>Question</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="check_amelioration">
<property name="text">
<string>Amélioration</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="check_autre">
<property name="text">
<string>Autre</string>
</property>
</widget>
</item>
<item row="6" column="0">
<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>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>250</x>
<y>20</y>
<width>51</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Titre:</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Messages:</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>600</x>
<y>70</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Sujet:</string>
</property>
</widget>
</widget>
</widget>
<tabstops>
<tabstop>ok_button</tabstop>
<tabstop>annuler_button</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,87 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CenRa_MetabaseDockWidgetBase</class>
<widget class="QDockWidget" name="CenRa_MetabaseDockWidgetBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>329</width>
<height>515</height>
</rect>
</property>
<property name="windowTitle">
<string>CenRa MetaBase</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="save_button">
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="config">
<property name="text">
<string notr="true">...</string>
</property>
<property name="arrowType">
<enum>Qt::NoArrow</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="flatten_dataset_table">
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="external_help">
<property name="text">
<string notr="true">help</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWebView" name="viewer" native="true">
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
<?xml version="1.0" ?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:dcat="http://www.w3.org/ns/dcat#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:adms="http://www.w3.org/ns/adms#"
xmlns:vcard="http://www.w3.org/2006/vcard/ns#"
xmlns:schema="http://schema.org/"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<dcat:Catalog>
<dct:description>CEN-RA DCAT RDF catalog</dct:description>
<dct:language>{language}</dct:language>
<dct:title>CEN-RA Metadata</dct:title>
<dcat:dataset>
<dcat:Dataset>
{content}
</dcat:Dataset>
</dcat:dataset>
</dcat:Catalog>
</rdf:RDF>

View File

@ -1,9 +0,0 @@
<dcat:distribution>
<dcat:Distribution>
<dct:title></dct:title>
<dcat:downloadURL></dcat:downloadURL>
<dcat:mediaType></dcat:mediaType>
<dct:format></dct:format>
<dct:bytesize></dct:bytesize>
</dcat:Distribution>
</dcat:distribution>

View File

@ -1,6 +0,0 @@
<dct:publisher>
<foaf:Organization>
<foaf:name></foaf:name>
<foaf:mbox></foaf:mbox>
</foaf:Organization>
</dct:publisher>

View File

@ -1 +1,34 @@
# CenRa_POSTGIS
Plugin Builder Results
Your plugin CenRa was created in:
C:\Users\gcostes\.qgis2\python\plugins\CenRa
Your QGIS plugin directory is located at:
C:/Users/gcostes/.qgis2/python/plugins
What's Next:
* Copy the entire directory containing your new plugin to the QGIS plugin
directory
* Compile the ui file using pyuic4
* Compile the resources file using pyrcc4
* Test the plugin by enabling it in the QGIS plugin manager
* Customize it by editing the implementation file:
cenra.py
* Create your own custom icon, replacing the default icon.png
* Modify your user interface by opening cenra.ui
in Qt Designer (don't forget to compile it with pyuic4 after changing it)
* You can use the Makefile to compile your Ui and resource files when
you make changes. This requires GNU make (gmake)
For more information, see the PyQGIS Developer Cookbook at:
http://www.qgis.org/pyqgis-cookbook/index.html
(C) 2011-2014 GeoApt LLC - geoapt.com

View File

@ -24,6 +24,7 @@ from __future__ import absolute_import
from builtins import next
from builtins import str
from builtins import object
import qgis
from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog
from qgis.PyQt.QtGui import QIcon
@ -31,6 +32,7 @@ from PyQt5.QtCore import *
from PyQt5.QtGui import *
from qgis.core import *
from qgis.core import QgsDataSourceUri
from .forms.about_form import PostgisAboutDialog
# Initialize Qt resources from file resources.py
from . import resources_rc
# Import the code for the dialog
@ -67,6 +69,15 @@ class CenRa(object):
self.dlg = CenRaDialog()
self.dlgAjout = table_postgisDialog()
maj_verif('CenRa_POSTGIS')
version = qgis.utils.pluginMetadata('CenRa_POSTGIS','version')
# Display About window on first use
s = QSettings()
versionUse = s.value("postgis/version", 1, type=str)
if str(versionUse) != str(version) :
s.setValue("postgis/version", str(version))
self.open_about_dialog()
def initGui(self):
self.toolBar = self.iface.addToolBar("CEN-RA")
self.toolBar.setObjectName("CEN-RA")
@ -122,6 +133,10 @@ class CenRa(object):
self.cenra_ajout.triggered.connect(self.ajout)
self.cenra_help.triggered.connect(self.doHelp)
def open_about_dialog(self):
dialog = PostgisAboutDialog(self.iface)
dialog.exec_()
def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu(u"&CENRA", self.action)

View File

@ -12,7 +12,7 @@
name=CenRa_POSTGIS
qgisMinimumVersion=3.0
description=Permet de crée un dossier dans la base PostGis
version=1.6
version=1.8
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr
@ -21,7 +21,7 @@ email=si_besoin@cen-rhonealpes.fr
# Optional items:
# Uncomment the following line and add your changelog entries:
changelog=Traduction en Qgis v3.x
changelog=<h2>CenRa_POSTGIS:</h2></br><p><h3>13/09/2024 - Version 1.8:</h3>- Ajoute d'un changelog et vérification de mise à jour.</p>
# tags are comma separated with spaces allowed
tags=cenra, postgis, database

View File

@ -1,161 +0,0 @@
"""Tools to work with resource files."""
import configparser
import shutil
import tempfile
import base64
import psycopg2
import psycopg2.extras
from os.path import abspath, join, pardir, dirname
from qgis.PyQt import uic
__copyright__ = "Copyright 2019, 3Liz"
__license__ = "GPL version 3"
__email__ = "info@3liz.org"
__revision__ = "$Format:%H$"
def plugin_path(*args):
"""Get the path to plugin root folder.
:param args List of path elements e.g. ['img', 'logos', 'image.png']
:type args: str
:return: Absolute path to the plugin path.
:rtype: str
"""
path = dirname(dirname(__file__))
path = abspath(abspath(join(path, pardir)))
for item in args:
path = abspath(join(path, item))
return path
def plugin_name():
"""Return the plugin name according to metadata.txt.
:return: The plugin name.
:rtype: basestring
"""
metadata = metadata_config()
name = metadata["general"]["name"]
return name
def metadata_config() -> configparser:
"""Get the INI config parser for the metadata file.
:return: The config parser object.
:rtype: ConfigParser
"""
path = plugin_path("metadata.txt")
config = configparser.ConfigParser()
config.read(path, encoding='utf8')
return config
def plugin_test_data_path(*args, copy=False):
"""Get the path to the plugin test data path.
:param args List of path elements e.g. ['img', 'logos', 'image.png']
:type args: str
:param copy: If the file must be copied into a temporary directory first.
:type copy: bool
:return: Absolute path to the resources folder.
:rtype: str
"""
path = abspath(abspath(join(plugin_path(), "test", "data")))
for item in args:
path = abspath(join(path, item))
if copy:
temp = tempfile.mkdtemp()
shutil.copy(path, temp)
return join(temp, args[-1])
else:
return path
def resources_path(*args):
"""Get the path to our resources folder.
:param args List of path elements e.g. ['img', 'logos', 'image.png']
:type args: str
:return: Absolute path to the resources folder.
:rtype: str
"""
path = abspath(abspath(join(plugin_path(), "CenRa_Metabase\\resources")))
for item in args:
path = abspath(join(path, item))
return path
def load_ui(*args):
"""Get compile UI file.
:param args List of path elements e.g. ['img', 'logos', 'image.png']
:type args: str
:return: Compiled UI file.
"""
ui_class, _ = uic.loadUiType(resources_path("ui", *args))
return ui_class
def login_base(take=None):
from CenRa_Metabase.resources.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels):
import requests
import json
import os
import qgis
usr = os.environ['USERNAME']
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
url=url+'?token='+token
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
payload = {'title': titre, 'body': body, 'labels': labels}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.text)
return r
def maj_verif(NAME):
import qgis
import urllib
url = qgis.utils.pluginMetadata(NAME,'repository')
URL = url+'/raw/branch/main/plugins.xml'
# print(URL)
version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version)
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
if version_plugin == version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)

View File

@ -116,8 +116,8 @@ def login_base(take=None):
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
#con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
con = psycopg2.connect("host=" + '100.100.100.81' + " port=" + port + " dbname="+'postgres'+" user=" + 'tlaveille' + " password=" + 'tlaveille')
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
@ -139,26 +139,45 @@ def send_issues(url,titre,body,labels):
payload = {'title': titre, 'body': body, 'labels': labels}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.text)
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
r = ''
if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers)
return r
def maj_verif(NAME):
import qgis
import urllib
from qgis.utils import iface
import urllib.request
iface = qgis.utils.iface
from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository')
URL = url+'/raw/branch/main/plugins.xml'
#URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml'
# print(URL)
version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version)
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
if binar:
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
if version_plugin == version:
qgis.utils.iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
def devlog(NAME):
import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog')
return devmaj

View File

@ -1 +1,34 @@
# CenRa_SICEN
Plugin Builder Results
Your plugin SICEN was created in:
C:\Users\gcostes\.qgis2\python\plugins\SICEN
Your QGIS plugin directory is located at:
C:/Users/gcostes/.qgis2/python/plugins
What's Next:
* Copy the entire directory containing your new plugin to the QGIS plugin
directory
* Compile the ui file using pyuic4
* Compile the resources file using pyrcc4
* Test the plugin by enabling it in the QGIS plugin manager
* Customize it by editing the implementation file:
sicen.py
* Create your own custom icon, replacing the default icon.png
* Modify your user interface by opening sicen.ui
in Qt Designer (don't forget to compile it with pyuic4 after changing it)
* You can use the Makefile to compile your Ui and resource files when
you make changes. This requires GNU make (gmake)
For more information, see the PyQGIS Developer Cookbook at:
http://www.qgis.org/pyqgis-cookbook/index.html
(C) 2011-2014 GeoApt LLC - geoapt.com

View File

@ -12,7 +12,7 @@
name=CenRa SICEN
qgisMinimumVersion=3.0
description=Filtre des données saisies dans SICEN et export d'une liste d'espèces.
version=1.4
version=1.7
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr
@ -21,7 +21,7 @@ email=si_besoin@cen-rhonealpes.fr
# Optional items:
# Uncomment the following line and add your changelog entries:
changelog=Traduction en Qgis v3.x
changelog=<h2>CenRa_SICEN:</h2></br><p><h3>13/09/2024 - Version 1.7:</h3> - Il est maintenant possible de sélectionné plusieurs entité pour le filtre par Emprise.</br>- Ajoute d'un changelog.</br>- Ajoute une vérification de mise à jour.</p>
# tags are comma separated with spaces allowed
tags=cenra, postgis, sicen

View File

@ -52,6 +52,8 @@ import qgis
import datetime
import csv
from .forms.about_form import SicenAboutDialog
import psycopg2
import psycopg2.extras
import base64
@ -59,6 +61,7 @@ import base64
import os
#import sys
class SICEN(object):
def __init__(self, iface):
@ -81,6 +84,14 @@ class SICEN(object):
self.dlg = SICENDialog()
maj_verif('CenRa_SICEN')
version = qgis.utils.pluginMetadata('CenRa_SICEN','version')
# Display About window on first use
s = QSettings()
versionUse = s.value("sicen/version", 1, type=str)
if str(versionUse) != str(version) :
s.setValue("sicen/version", str(version))
self.open_about_dialog()
def initGui(self):
self.toolBar = self.iface.addToolBar("SICEN")
self.toolBar.setObjectName("SICEN")
@ -123,6 +134,10 @@ class SICEN(object):
self.sicen_ouverture.triggered.connect(self.ouverture)
self.sicen_export.triggered.connect(self.export)
def open_about_dialog(self):
dialog = SicenAboutDialog(self.iface)
dialog.exec_()
def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu(u"&SICEN", self.action)
@ -561,13 +576,16 @@ class SICEN(object):
else :
selection = layer.selectedFeatures()
if layer.selectedFeatureCount() == 1 :
if layer.selectedFeatureCount() >= 1 :
GEOM = ''
for feature in selection:
geom = feature.geometry()
poly = geom.asWkt()
poly = "ST_GeomFromText('"+geom.asWkt()+"',2154),"
GEOM = GEOM + poly
poly = GEOM[0:-1]
#print(poly)
buffer = self.dlg.buffer.text()
reqwhere_geom = " ST_intersects(geometrie,ST_Buffer(ST_geomFromText('" + poly + "',2154), " + buffer + " ))"
reqwhere_geom = " ST_intersects(geometrie,ST_Buffer(ST_Collect(array[" + poly + "]), " + buffer + " ))"
# Requete finale
reqwhere_final = '(' + reqwhere_obs + ')' + 'AND' + reqwhere_insee + 'AND' + reqwhere_ordre + 'AND' + reqwhere_sp + 'AND' + '(' + reqwhere_pat + ')' + 'AND' + reqwhere_regne + 'AND' + reqwhere_date + 'AND' + reqwhere_geom
@ -596,6 +614,7 @@ class SICEN(object):
### Centroide
if reqwhere_final.find('()') != -1 :
reqwhere_final = ''
print(reqwhere_final)
uri.setDataSource("_agregation_ra", "observations_centroide", "geometrie", reqwhere_final, "gid")
layer = self.iface.addVectorLayer(uri.uri(), table_name + '_centroides', "postgres")

View File

@ -89,7 +89,7 @@ def resources_path(*args):
:return: Absolute path to the resources folder.
:rtype: str
"""
path = abspath(abspath(join(plugin_path(), "CenRa_Metabase\\resources")))
path = abspath(abspath(join(plugin_path(), "CenRa_Metabase\\tools")))
for item in args:
path = abspath(join(path, item))
return path
@ -108,7 +108,7 @@ def load_ui(*args):
return ui_class
def login_base(take=None):
from CenRa_Metabase.resources.PythonSQL import host,port,dbname,password,os_user
from .tools.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
@ -139,26 +139,46 @@ def send_issues(url,titre,body,labels):
payload = {'title': titre, 'body': body, 'labels': labels}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.text)
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
r = ''
if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers)
return r
def maj_verif(NAME):
import qgis
import urllib
import urllib.request
iface = qgis.utils.iface
from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository')
URL = url+'/raw/branch/main/plugins.xml'
#URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml'
# print(URL)
version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version)
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
if binar:
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
return version_plugin
if version_plugin == version:
qgis.utils.iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
def devlog(NAME):
import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog')
return devmaj