├── 1_Software_Design_LifeCycle.pdf ├── Assignment_1.md ├── Assignment_2.md ├── Git 101.md ├── LICENSE ├── LanguageSupport.md ├── README.md ├── README_1.md ├── Unit Test.md ├── code └── save_attributes │ ├── Makefile │ ├── README.html │ ├── README.txt │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-37.pyc │ ├── resources.cpython-37.pyc │ ├── save_attributes.cpython-37.pyc │ └── save_attributes_dialog.cpython-37.pyc │ ├── compile.bat │ ├── help │ ├── Makefile │ ├── make.bat │ └── source │ │ ├── conf.py │ │ └── index.rst │ ├── i18n │ └── af.ts │ ├── icon.png │ ├── metadata.txt │ ├── pb_tool.cfg │ ├── plugin_upload.py │ ├── pylintrc │ ├── resources.py │ ├── resources.qrc │ ├── save_attributes.py │ ├── save_attributes_dialog.py │ ├── save_attributes_dialog_base.ui │ ├── scripts │ ├── compile-strings.sh │ ├── run-env-linux.sh │ └── update-strings.sh │ └── test │ ├── __init__.py │ ├── qgis_interface.py │ ├── tenbytenraster.asc │ ├── tenbytenraster.asc.aux.xml │ ├── tenbytenraster.keywords │ ├── tenbytenraster.lic │ ├── tenbytenraster.prj │ ├── tenbytenraster.qml │ ├── test_init.py │ ├── test_qgis_environment.py │ ├── test_resources.py │ ├── test_save_attributes_dialog.py │ ├── test_translations.py │ └── utilities.py ├── data ├── Readme.md ├── beytepe │ ├── c_beytepe.cpg │ ├── c_beytepe.dbf │ ├── c_beytepe.prj │ ├── c_beytepe.qpj │ ├── c_beytepe.shp │ ├── c_beytepe.shx │ ├── n_beytepe.cpg │ ├── n_beytepe.dbf │ ├── n_beytepe.prj │ ├── n_beytepe.qpj │ ├── n_beytepe.shp │ ├── n_beytepe.shx │ ├── n_beytepe_WGS84.dbf │ ├── n_beytepe_WGS84.prj │ ├── n_beytepe_WGS84.qpj │ ├── n_beytepe_WGS84.shp │ ├── n_beytepe_WGS84.shx │ ├── p_beytepe.cpg │ ├── p_beytepe.dbf │ ├── p_beytepe.prj │ ├── p_beytepe.qpj │ ├── p_beytepe.shp │ └── p_beytepe.shx ├── cities │ ├── p_iller.cpg │ ├── p_iller.dbf │ ├── p_iller.prj │ ├── p_iller.qpj │ ├── p_iller.shp │ └── p_iller.shx ├── districts │ ├── p_ilceler.cpg │ ├── p_ilceler.dbf │ ├── p_ilceler.prj │ ├── p_ilceler.qpj │ ├── p_ilceler.shp │ └── p_ilceler.shx ├── landcover │ ├── N-34-97-C-b-1-2-m.tif │ ├── N-34-97-C-b-1-2.tif │ ├── buildings.cpg │ ├── buildings.dbf │ ├── buildings.prj │ ├── buildings.shp │ ├── buildings.shx │ ├── data_2180 │ │ ├── OSM_buildings.geojson │ │ ├── mask_buildings.geojson │ │ └── selected_poi.geojson │ ├── selected_poi.cpg │ ├── selected_poi.dbf │ ├── selected_poi.prj │ ├── selected_poi.shp │ └── selected_poi.shx ├── selected_poi.geojson └── simulated │ └── poi_100000.geojson ├── img ├── active_project_QGIS.jpg ├── contol_add_new_attributes.png ├── editors_of_git.png ├── git_add.png ├── git_bash.png ├── git_checkout.png ├── git_cnfig_new_attributes.png ├── git_commit.png ├── git_commit_VSCode.png ├── git_gui.png ├── git_init.png ├── git_log.png ├── git_pull_before_push.png ├── git_push.png ├── git_status.png ├── issue_push_button_horizontal_layout.png ├── new_branch.png ├── open_git_bash.png ├── view_branches.png ├── visualization (0).png ├── visualization (1).png ├── visualization (2).png ├── visualization (3).png └── welcome_screen.jpg ├── midterm_projects ├── 2020-21 │ ├── Group3.md │ ├── Group6.md │ ├── Midterm_Project.md │ ├── group1.md │ ├── group2.md │ ├── group4.md │ └── img │ │ ├── Group6-Img │ │ └── Group6-Img │ │ │ ├── 1.PNG │ │ │ └── 2.PNG │ │ ├── group1-images │ │ ├── group1_1.jpg │ │ ├── group1_10.jpg │ │ ├── group1_11jpg.jpg │ │ ├── group1_2.jpg │ │ ├── group1_6.jpg │ │ ├── group1_7.jpg │ │ ├── group1_8.jpg │ │ ├── group_1_3.jpg │ │ ├── group_1_4.jpg │ │ └── group_1_5.jpg │ │ ├── group2-images │ │ ├── GUI.png │ │ ├── area-peri.png │ │ ├── azimuth.png │ │ ├── line_1feat.JPG │ │ ├── line_mult.JPG │ │ ├── lines_attr.JPG │ │ ├── minmax.JPG │ │ └── point_attr.JPG │ │ ├── group6-images │ │ └── gui_save_attributes.png └── 2021-22 │ └── ps1.zip └── software_documentation.md /1_Software_Design_LifeCycle.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/1_Software_Design_LifeCycle.pdf -------------------------------------------------------------------------------- /Assignment_1.md: -------------------------------------------------------------------------------- 1 | # Assignment #1 (Due: 6 October 2021 14:00) 2 | 3 | Please have a look at the lecture notes on [Software Design LifeCycle (SDLC)](https://github.com/banbar/GMT-456-GIS-Programming/blob/master/1_Software_Design_LifeCycle.pdf). 4 | 5 | Your task is as follows: 6 | 1. Create a GitHub account. 7 | 2. Associate your GitHub account with your [assignment](https://classroom.github.com/a/cS-w5Ehs). 8 | 3. Choose **one** of the SDLC methodologies and describe it in **your own words** as a markdown file. Use sections to improve legibility of your Readme file. 9 | 4. Complete the markdown file until the start of the course. 10 | 11 | Some SDLC methodologies are: 12 | * Waterfall 13 | * Agile 14 | * V model 15 | * Spiral 16 | * Lean 17 | 18 | You **must** use the following commands: 19 | * git init 20 | * git config 21 | * git status 22 | * git add 23 | * git commit 24 | * git push 25 | 26 | In other words you are **not** allowed to use the GitHub interface to edit your markdown file. 27 | 28 | I would like to see your progress, so I encourage you start editing your markdown file today. 29 | 30 | You may use [Atom](https://atom.io/) that is handy for editing markdown files. 31 | -------------------------------------------------------------------------------- /Assignment_2.md: -------------------------------------------------------------------------------- 1 | # Assignment #2 (Due: 20 October 2021 14:00) 2 | 3 | Form a group of **two-three** students. Find your teammate(s) on GitHub Classroom and do the following together: 4 | 5 | * Open a SHP file 6 | * Print the attribute names - in TWO different ways 7 | * Print attribute types 8 | * Print the first n features 9 | * Print the total number of features - N - how many records do we have? 10 | * Print the layer type - point, polygon, line - in TWO different ways 11 | * Plot the shp file & projection details 12 | 13 | While doing so, investigate how the following git commands operate: 14 | * git branch 15 | * git checkout 16 | * git revert 17 | -------------------------------------------------------------------------------- /Git 101.md: -------------------------------------------------------------------------------- 1 | # Git - Version Control System 2 | Git is a distributed Version Control System (VCS). 3 | 4 | ## Why Git: 5 | * Many open source geospatial projects are developed using Git. 6 | * Common tool to develop software. 7 | * Better project management. 8 | * No more project1.py, project2.py, project_final, project_final2 etc. 9 | * Versioning and tracking changes are systematic, hence, easier. 10 | * GitHub 11 | * Web based hosting service 12 | * Free and Open Source for Geospatial (FOSS4G) are hosted on GitHub. Some renowned examples include [QGIS](https://github.com/qgis), [PostGIS](https://github.com/postgis/postgis) and [GeoSever](https://github.com/geoserver/geoserver). Please note how active these projects are. 13 | ![](img/active_project_QGIS.jpg) 14 | * Many online tutorials ease learning. 15 | 16 | ## Installation 17 | * Download Git from [https://git-scm.com/](https://git-scm.com/) 18 | * Leave the default options until ***Choosing the default editor*** 19 | * Vim is the default, but it could be complicated for beginners. 20 | * Choose the editor that you feel comfortable with. 21 | ![](img/editors_of_git.png) 22 | * Leave the rest options in their default values: 23 | * Adjusting your Path environment, 24 | * Choosing HTTPS transport etc. 25 | 26 | ## Hello Git 27 | * Git Bash 28 | * A Command Line Interface (CLI) to use Git. 29 | ![](img/git_bash.png) 30 | * Better for learning, but it might be difficult to get used to. 31 | * Open Git Bash by right-clicking the project's folder. 32 | ![](img/open_git_bash.png) 33 | * Investigate Git GUI - installed with Git. 34 | ![](img/git_gui.png) 35 | * Investigate [GitHub Desktop](https://desktop.github.com/) - separate software. 36 | 37 | ## Git Commands 38 | * This section will define and describe some of the common Git commands. 39 | 40 | ### init 41 | * **git init** initialises a folder. 42 | ![](img/git_init.png) 43 | * Creates the hidden **.git** folder. In order to see it, go to ***Folder Options*** and select ***Show hidden files, folders and drivers***. 44 | 45 | ### config 46 | * Provides the configuration of the project. 47 | * Name of the contributor, email etc. 48 | * New attributes could be added. 49 | ![](img/git_cnfig_new_attributes.png) 50 | * To view the configuration details: `git config --list` 51 | * To edit our own parameters: `git config --global --edit` 52 | * To remove e.g. user.name: `git config --global --unset-all user.name` 53 | 54 | ### add 55 | * Adds the file(s) to index. 56 | ![](img/git_add.png) 57 | * With `git add hello.py` we index our first file - hello.py. 58 | * `git add .` will add all the files and folders to the index. 59 | 60 | 61 | ### status 62 | * Checks the current state of the working directory. Which files are tracked, which of them were updated etc. 63 | ![](img/git_status.png) 64 | * We can observe the: 65 | * **branch** we are working on -i.e. master. 66 | * **Updated** files. 67 | * Here we observe that we need a **commit** to make changes recorded for future use. 68 | 69 | ### commit 70 | * Captures the snapshot of the project's staged changes. 71 | * Safe version of the project, which can be used to refer to later on. 72 | ![](img/git_commit.png) 73 | * This would open *VSCode* as it was chosen as the default Git Editor. Here, we will prompt a commit message. 74 | ![](img/git_commit_VSCode.png) 75 | * A shorter way of doing this is to provide the commit message within the Git CLI: `git commit -m "An explanatory message of this commit`. 76 | 77 | ### log 78 | * Displays the past commits and their messages. 79 | ![](img/git_log.png) 80 | * Commit identifiers (long arbitrary text) would be useful to visit a previous commit. 81 | * Once the project has many commits, it might be useful to track the milestones. Therefore, [**commit messages are important**](https://www.freecodecamp.org/news/writing-good-commit-messages-a-practical-guide/). 82 | * `git log --oneline` provides a simplified view of the previous commits - each in one line. 83 | 84 | ### rm 85 | * We might need to remove a file that was previously added from the index. 86 | * `git rm -cached ` 87 | 88 | ### clone 89 | * Copied a remote repo to your local machine. 90 | * Clone the content of our course to your computer: `git clone https://github.com/banbar/GMT-456-GIS-Programming` 91 | 92 | ## Useful Workflows 93 | 94 | ## Branches 95 | * If we working on a new feature, it might be better to open a new branch in order to make sure that the master branch is intact. 96 | * Provides an isolated environment to test a new feature. 97 | * Two or more developers can work on different branches at the same time. 98 | * To view the branches of a repo: `git branch -a`. This would result something like: 99 | ![](img/view_branches.png) 100 | * The * indicates the current branch we are on. 101 | * The red lines indicate the remote branches (i.e. the branches on GitHub). 102 | * Create a new branch entitled **feature-1**: `git branch feature-1`. 103 | * This command does not immediately change our working branch. 104 | * Note that once we view all the branches with `git branch -a`, we realise the presence of our new branch **(feature-1)**, and that the branch we are on did not change - we are still on the master branch. 105 | ![](img/new_branch.png) 106 | * To change our branch to **feature-1**: `git checkout feature-1`. 107 | ![](img/git_checkout.png) 108 | * Now, let's **add a new file** to our branch: **Git_102.md**. You may see the added file with `git status` 109 | * Next steps: 110 | * `git add Git 102.md` - add the new file to the stating area. 111 | * `git commit -m 'New markdown file - Git 102.md'` 112 | 113 | 114 | 115 | ## Ignoring files 116 | * Some files are sensitive (e.g. database passwords, private keys etc.) or they are simply not directly related to our project. 117 | * Do **not** track those files. 118 | * We need the .gitignore folder. 119 | * xxx: touch gitignore 120 | 121 | ### Undo the Last Commit 122 | xxx 123 | 124 | ### Handling Merge Conflicts 125 | xxx 126 | 127 | ### Sync with a GitHub Repo 128 | xxx 129 | 130 | 131 | ## Discussion 132 | * This section is open to discuss some specific examples, which would hopefully be useful to our overall understanding of how Git works. 133 | 134 | ### What is the benefit of git's two-stage commit process (staging)? 135 | * In Git there is a two-stage commit process. We first add the files to the staging area (index), and then we commit these changes. 136 | * The benefits of this process are described in several resources [1](https://gitolite.com/uses-of-index.html), [2](https://softwareengineering.stackexchange.com/questions/69178/what-is-the-benefit-of-gits-two-stage-commit-process-staging) and summarised here: 137 | * One large change of multiple files -> multiple commits instead of a single one. Use the `git gui` for a better management of this. 138 | 139 | ### Fork vs. Clone 140 | * Fork is done on GitHub Account while clone is done on Git. 141 | * Changes made to the forked repo can be merged with the original repo via a pull request. 142 | 143 | ## Useful Practices 144 | 145 | This section briefly describes the useful patterns while using git. 146 | 147 | * `git diff` before committing. 148 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /LanguageSupport.md: -------------------------------------------------------------------------------- 1 |

Language Support (Internationalization) For Plugins

2 | This markdown file shows how to internationalize your plugin with other languages. 3 | First of all we need to download qt and qtlinguist for using lupdate and lrelease functions. 4 | 5 | After that create new .pro file in our plugin`s i18n folder. 6 | 7 | 8 | Our .pro file need to be like that. Sources shows our main .py file , forms shows our user interface file , translations shows which language our plugin language support. 9 | Languages part needs to be with .ts format because qt linguist is working with .ts file format. 10 | After that we open qt shell and define our i18n file path. 11 | 12 | **Be sure to name the ts file like your_plugin_ + language + .ts otherwise the language loading will fail! Use 2 letters shortcut for the language (it for Italian, de for German, etc...)** 13 | 14 | 15 | Write command like "lupdate saveattributes.pro". You need to write your .pro file name that you choose. 16 | 17 | After we run this command our .ts file has created in our i18n folder. 18 | We need to open this .ts file in qt linguist and make translations. 19 | 20 | After we translate our text we save .ts file in qt linguist and we run command like "lrelease saveattributes.pro" in qt shell and this fuction create .qm file of our translation. 21 | 22 | This .qm file is the only file that QGIS need for language support. 23 | 24 | So you have the language support for language that you choose. 25 | 26 | 27 | 28 | # LANGUAGE SUPPORT 29 | 30 | In order to add Language Support feature in the plugin (The name of the plugin we created is **FinalProject** ), the following steps are done: 31 | 32 | - A .pro file to be managed by [QT Linguist](https://github.com/thurask/Qt-Linguist/releases/tag/20211214) is in the i18n folder in the plugin directory where Translation related files will be found. 33 | should be created. The contents of the FinalProject.pro file should be as follows: 34 | 35 | ``` 36 | FORMS = C:\Users\kfyka\OneDrive\Belgeler\finalproject\FinalProject_dialog_base.ui 37 | SOURCES = C:\Users\kfyka\OneDrive\Belgeler\finalproject\FinalProject.py 38 | TRANSLATIONS = FinalProject_tr.ts 39 | ``` 40 |

41 | 42 |

43 | 44 | 45 | - After creating the **FinalProject.pro** file, the .ts file should be created. The file to be created must be located in the i18n folder. The point to be considered while creating the **.ts file** is that it should be created as **your_plugin_language.ts**. The language to be translated should be written as an abbreviation to the place specified as language here. The .ts file to be created for the Turkish language in the FinalProject plugin is **FinalProject_tr.ts**. To create the **FinalProject_tr.ts** file, the following command should be run by going to the i18n folder in the plugin directory in the terminal: 46 | 47 | ``` 48 | pylupdate5 your_plugin.pro 49 | ``` 50 |

51 | 52 |

53 | 54 | After running this command, the .ts file will appear in the i18n folder. 55 | 56 | - The application called **QT Linguist** is used to create the content of the .ts file. With this application, the translation of the parameters in the plugin interface with the specified language is performed. 57 | 58 | - Run the **QT Linguist** and **"File"** ----> **"Open..."** 59 | 60 |

61 | 62 |

63 | 64 | - Choose the **FinalProject_tr.ts** file and **"Open"** 65 | 66 |

67 | 68 |

69 | 70 | - Choose the target language. 71 | 72 |

73 | 74 |

75 | 76 | - Choose the Sting from the **"Strings"** label and write the **"Translation to Türkçe (Türkiye)"** 77 | 78 |

79 | 80 |

81 | 82 | - After all the words are translated, the **"Strings"** menu should look like this. 83 | 84 |

85 | 86 |

87 | 88 | - After the conversion process is completed, we save the file. **"File"** -----> **"Save"** 89 | 90 |

91 | 92 |

93 | 94 | - Another file to be created is the .qm file. To create this file, select the **"Release"** option from the **"File"** menu in the **QT Linguist** application. 95 | 96 |

97 | 98 |

99 | 100 | - Process completed. If your language is Turkish you will see this screen. 101 | 102 |

103 | 104 |

105 | 106 | - If your language is English you will see this screen. 107 | 108 |

109 | 110 |

111 | 112 | ## REFERENCES 113 | 114 | [QGIS Documentation for Language Support in Plugins](https://docs.qgis.org/3.16/tr/docs/pyqgis_developer_cookbook/plugins/plugins.html#translation) 115 | You can download qt from https://www.qt.io/download . 116 | You can download qt linguist from https://github.com/thurask/Qt-Linguist/releases/tag/20211214. 117 | - [QGIS Documentation](https://docs.qgis.org/3.16/tr/docs/pyqgis_developer_cookbook/plugins/plugins.html#translation) 118 | - You can download qt from https://www.qt.io/download . 119 | - You can download qt linguist from https://github.com/lelegard/qtlinguist-installers/releases 120 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GMT 456 GIS Programming 2 | This repository contains sample data, information and code about the "GMT 456 GIS Programming" course offered at the Geomatics Engineering Dept. of Hacettepe University, Turkey. 3 | 4 | The **aim** of this course is to teach students how to collaborate on a software project involving spatial analysis by using git. 5 | 6 | The **successful students** would: 7 | * ***Describe*** the Software Design Life Cycle (SDLC) phases, 8 | * ***Document*** the design and requirements of the software project that s/he worked on, 9 | * ***Demonstrate*** the ability to work as a team for the purpose of developing a new or updating an existing QGIS plugin. 10 | 11 | ## Contents: 12 | * Object oriented programming - recap 13 | * Function Calls – pass by reference vs pass by value 14 | * Data structures (arrays, linked lists, graphs) - recap 15 | * Qt Designer 16 | * Signal- Slot 17 | * Google Earth Engine 18 | * Building a QGIS Plugin 19 | 20 | ## Assignment 1 (deadline: 16 Oct): 21 | You will be submitting your README.md files on the comparison of different SDLC methodologies to this address: 22 | https://classroom.github.com/a/Wnp3Y_Qw 23 | 24 | ## Software: 25 | * QGIS 3.x 26 | * [Anaconda Individual Edition](https://www.anaconda.com/products/individual) 27 | * Spyder Integrated Development Environment (IDE) for Python scripting 28 | 29 | 30 | ## Resources: 31 | * Software Engineering 32 | * [PEP 8 Style Guide](https://www.python.org/dev/peps/pep-0008/) 33 | * [A Comparison between Agile and Traditional Software Development Methodologies](https://www.unf.edu/~broggio/cen6940/ComparisonAgileTraditional.pdf) 34 | * Python 35 | * [Panel](https://panel.holoviz.org/index.html) 36 | * [HoloViews & GeoViews, Anita Graser's Fosdem 21 Presentation](https://archive.fosdem.org/2021/schedule/event/geopandasholoviews/) 37 | * Git 38 | * [Git Cheat Sheet - from GitHub](https://education.github.com/git-cheat-sheet-education.pdf) 39 | * [Saving Changes - add vs commit](https://www.atlassian.com/git/tutorials/saving-changes) 40 | * [Learning Git 101 by Yasoob Khalid](https://yasoob.github.io/learn-git/) 41 | * Git GUI 42 | * [GitKraken](https://www.gitkraken.com/) 43 | * [Pretty git branch graphs](https://stackoverflow.com/questions/1057564/pretty-git-branch-graphs) 44 | * [JSFiddle](http://jsfiddle.net/fracz/q76vj8ow/) 45 | * [Git Grapher](http://bsara.github.io/git-grapher/) 46 | * [Commits Graph](https://github.com/tclh123/commits-graph) 47 | * [Gitinspector - statistical analysis on a repo](https://github.com/ejwa/gitinspector) 48 | 49 | * GitHub 50 | * [GitHub Campus Advisor Training](https://www.youtube.com/playlist?list=PLIRjfNq867be7VngMuXsjTvzBM26nBINg) 51 | * [Understanding the GitHub flow](https://guides.github.com/introduction/flow/) 52 | * [Using Markdown](https://commonmark.org/help/) 53 | * [GitHub Flavored Markdown](https://enterprise.github.com/downloads/en/markdown-cheatsheet.pdf) 54 | * [Workflow](https://enterprise.github.com/downloads/en/github-flow-cheatsheet.pdf) 55 | 56 | * Sphinx 57 | * [Brandon’s Sphinx Tutorial](https://buildmedia.readthedocs.org/media/pdf/brandons-sphinx-tutorial/latest/brandons-sphinx-tutorial.pdf) 58 | 59 | * QGIS 60 | * [Plugin Builder](https://g-sherman.github.io/Qgis-Plugin-Builder/) 61 | 62 | * Google Earth Engine 63 | * [Google Earth Engine - Beginner's Cookbook](https://developers.google.com/earth-engine/tutorials/community/beginners-cookbook) 64 | 65 | * [spatialthoughts](https://github.com/spatialthoughts/courses) 66 | * [PyQGIS in a Day](https://courses.spatialthoughts.com/pyqgis-in-a-day.html) 67 | * [Part 1: Building a Python Plugin (QGIS3)](https://www.qgistutorials.com/en/docs/3/building_a_python_plugin.html) 68 | * [Part 2: Building a Processing Plugin (QGIS3)](https://www.qgistutorials.com/en/docs/3/processing_python_plugin.html) 69 | 70 | * **Book**: [Geoprocessing with Python](https://www.manning.com/books/geoprocessing-with-python) 71 | * **Book**: [Applied Spatial Data Analysis with R](https://www.springer.com/gp/book/9781461476177) 72 | * **Book**: [Introduction to GIS Programming and Fundamentals with Python and ArcGIS](https://www.routledge.com/Introduction-to-GIS-Programming-and-Fundamentals-with-Python-and-ArcGIS/Yang/p/book/9780367573775) 73 | * **Book**: [The PyQGIS Programmer's Guide: Extending QGIS 3 with Python](https://locatepress.com/ppg3) 74 | -------------------------------------------------------------------------------- /README_1.md: -------------------------------------------------------------------------------- 1 | # GMT 456 GIS Programming 2 | This repository contains sample data, information and code about the "GMT 456 GIS Programming" course offered at the Geomatics Engineering Dept. of Hacettepe University, Turkey. 3 | 4 | The **aim** of this course is to teach students how to collaborate on a software project involving spatial analysis by using git. 5 | 6 | The **successful students** would: 7 | * ***Describe*** the Software Design Life Cycle (SDLC) phases, 8 | * ***Document*** the design and requirements of the software project that s/he worked on, 9 | * ***Demonstrate*** the ability to work as a team for the purpose of developing a new or updating an existing QGIS plugin. 10 | 11 | ## Contents: 12 | * Object oriented programming - recap 13 | * Function Calls – pass by reference vs pass by value 14 | * Data structures (arrays, linked lists, graphs) - recap 15 | * Qt Designer 16 | * Signal- Slot 17 | * Google Earth Engine 18 | * Building a QGIS Plugin 19 | 20 | ## Assignment 1 (deadline: 16 Oct): 21 | You will be submitting your README.md files on the comparison of different SDLC methodologies to this address: 22 | https://classroom.github.com/a/Wnp3Y_Qw 23 | 24 | ## Software: 25 | * QGIS 3.x 26 | * [Anaconda Individual Edition](https://www.anaconda.com/products/individual) 27 | * Spyder Integrated Development Environment (IDE) for Python scripting 28 | 29 | 30 | ## Resources: 31 | * Software Engineering 32 | * [PEP 8 Style Guide](https://www.python.org/dev/peps/pep-0008/) 33 | * [A Comparison between Agile and Traditional Software Development Methodologies](https://www.unf.edu/~broggio/cen6940/ComparisonAgileTraditional.pdf) 34 | * Google Earth Engine 35 | * [Google Earth Engine - Beginner's Cookbook](https://developers.google.com/earth-engine/tutorials/community/beginners-cookbook) 36 | * Git 37 | * [Git Cheat Sheet - from GitHub](https://education.github.com/git-cheat-sheet-education.pdf) 38 | * [Saving Changes - add vs commit](https://www.atlassian.com/git/tutorials/saving-changes) 39 | * [Learning Git 101 by Yasoob Khalid](https://yasoob.github.io/learn-git/) 40 | * Git GUI 41 | * [GitKraken](https://www.gitkraken.com/) 42 | * [Pretty git branch graphs](https://stackoverflow.com/questions/1057564/pretty-git-branch-graphs) 43 | * [JSFiddle](http://jsfiddle.net/fracz/q76vj8ow/) 44 | * [Git Grapher](http://bsara.github.io/git-grapher/) 45 | * [Commits Graph](https://github.com/tclh123/commits-graph) 46 | * [Gitinspector - statistical analysis on a repo](https://github.com/ejwa/gitinspector) 47 | 48 | 49 | * GitHub 50 | * [GitHub Campus Advisor Training](https://www.youtube.com/playlist?list=PLIRjfNq867be7VngMuXsjTvzBM26nBINg) 51 | * [Understanding the GitHub flow](https://guides.github.com/introduction/flow/) 52 | * [Using Markdown](https://commonmark.org/help/) 53 | * [GitHub Flavored Markdown](https://enterprise.github.com/downloads/en/markdown-cheatsheet.pdf) 54 | * [Workflow](https://enterprise.github.com/downloads/en/github-flow-cheatsheet.pdf) 55 | * GitHub is cool. ![](img/welcome_screen.jpg) 56 | * QGIS 57 | * [Plugin Builder](https://g-sherman.github.io/Qgis-Plugin-Builder/) 58 | 59 | 60 | * [spatialthoughts](https://github.com/spatialthoughts/courses) 61 | * [PyQGIS in a Day](https://courses.spatialthoughts.com/pyqgis-in-a-day.html) 62 | * [Part 1: Building a Python Plugin (QGIS3)](https://www.qgistutorials.com/en/docs/3/building_a_python_plugin.html) 63 | * [Part 2: Building a Processing Plugin (QGIS3)](https://www.qgistutorials.com/en/docs/3/processing_python_plugin.html) 64 | 65 | * **Book**: [Geoprocessing with Python](https://www.manning.com/books/geoprocessing-with-python) 66 | * **Book**: [Applied Spatial Data Analysis with R](https://www.springer.com/gp/book/9781461476177) 67 | * **Book**: [Introduction to GIS Programming and Fundamentals with Python and ArcGIS](https://www.routledge.com/Introduction-to-GIS-Programming-and-Fundamentals-with-Python-and-ArcGIS/Yang/p/book/9780367573775) 68 | * **Book**: [The PyQGIS Programmer's Guide: Extending QGIS 3 with Python](https://locatepress.com/ppg3) 69 | -------------------------------------------------------------------------------- /Unit Test.md: -------------------------------------------------------------------------------- 1 | # Unit Test 2 | * Steps: 3 | 1. Adjust the `compile.bat` file under the plugin. 4 | 2. Run `compile.bat` from your command window. 5 | 3. Set the Python path: `set "PYTHONPATH=C:\OSGeo4W64\apps\qgis\python;%PYTHONPATH%"` 6 | 4. Set the Qt Path: `set "QT_QPA_PLATFORM_PLUGIN_PATH=C:\OSGeo4W64\apps\Qt5\plugins"` 7 | 4. QGIS has the nose module. Run `python -m nose2 -v`. 8 | * Important: Understand the difference between **error** and **failure**. 9 | 10 | 11 | ## References 12 | * [Unit Tests in Python](https://youtu.be/6tNS--WetLI) 13 | * [Writing unit tests for QGIS Python plugins](https://snorfalorpagus.net/blog/2014/01/04/writing-unit-tests-for-qgis-python-plugins/) 14 | -------------------------------------------------------------------------------- /code/save_attributes/Makefile: -------------------------------------------------------------------------------- 1 | #/*************************************************************************** 2 | # SaveAttributes 3 | # 4 | # This plugin saves the attribute of the selected vector layer as a csv file. 5 | # ------------------- 6 | # begin : 2020-10-30 7 | # git sha : $Format:%H$ 8 | # copyright : (C) 2020 by Berk Anbaroğlu 9 | # email : banbar@hacettepe.edu.tr 10 | # ***************************************************************************/ 11 | # 12 | #/*************************************************************************** 13 | # * * 14 | # * This program is free software; you can redistribute it and/or modify * 15 | # * it under the terms of the GNU General Public License as published by * 16 | # * the Free Software Foundation; either version 2 of the License, or * 17 | # * (at your option) any later version. * 18 | # * * 19 | # ***************************************************************************/ 20 | 21 | ################################################# 22 | # Edit the following to match your sources lists 23 | ################################################# 24 | 25 | 26 | #Add iso code for any locales you want to support here (space separated) 27 | # default is no locales 28 | # LOCALES = af 29 | LOCALES = 30 | 31 | # If locales are enabled, set the name of the lrelease binary on your system. If 32 | # you have trouble compiling the translations, you may have to specify the full path to 33 | # lrelease 34 | #LRELEASE = lrelease 35 | #LRELEASE = lrelease-qt4 36 | 37 | 38 | # translation 39 | SOURCES = \ 40 | __init__.py \ 41 | save_attributes.py save_attributes_dialog.py 42 | 43 | PLUGINNAME = save_attributes 44 | 45 | PY_FILES = \ 46 | __init__.py \ 47 | save_attributes.py save_attributes_dialog.py 48 | 49 | UI_FILES = save_attributes_dialog_base.ui 50 | 51 | EXTRAS = metadata.txt icon.png 52 | 53 | EXTRA_DIRS = 54 | 55 | COMPILED_RESOURCE_FILES = resources.py 56 | 57 | PEP8EXCLUDE=pydev,resources.py,conf.py,third_party,ui 58 | 59 | # QGISDIR points to the location where your plugin should be installed. 60 | # This varies by platform, relative to your HOME directory: 61 | # * Linux: 62 | # .local/share/QGIS/QGIS3/profiles/default/python/plugins/ 63 | # * Mac OS X: 64 | # Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins 65 | # * Windows: 66 | # AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins' 67 | 68 | QGISDIR=C:\Users\banbar\AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins 69 | 70 | ################################################# 71 | # Normally you would not need to edit below here 72 | ################################################# 73 | 74 | HELP = help/build/html 75 | 76 | PLUGIN_UPLOAD = $(c)/plugin_upload.py 77 | 78 | RESOURCE_SRC=$(shell grep '^ *@@g;s/.*>//g' | tr '\n' ' ') 79 | 80 | .PHONY: default 81 | default: 82 | @echo While you can use make to build and deploy your plugin, pb_tool 83 | @echo is a much better solution. 84 | @echo A Python script, pb_tool provides platform independent management of 85 | @echo your plugins and runs anywhere. 86 | @echo You can install pb_tool using: pip install pb_tool 87 | @echo See https://g-sherman.github.io/plugin_build_tool/ for info. 88 | 89 | compile: $(COMPILED_RESOURCE_FILES) 90 | 91 | %.py : %.qrc $(RESOURCES_SRC) 92 | pyrcc5 -o $*.py $< 93 | 94 | %.qm : %.ts 95 | $(LRELEASE) $< 96 | 97 | test: compile transcompile 98 | @echo 99 | @echo "----------------------" 100 | @echo "Regression Test Suite" 101 | @echo "----------------------" 102 | 103 | @# Preceding dash means that make will continue in case of errors 104 | @-export PYTHONPATH=`pwd`:$(PYTHONPATH); \ 105 | export QGIS_DEBUG=0; \ 106 | export QGIS_LOG_FILE=/dev/null; \ 107 | nosetests -v --with-id --with-coverage --cover-package=. \ 108 | 3>&1 1>&2 2>&3 3>&- || true 109 | @echo "----------------------" 110 | @echo "If you get a 'no module named qgis.core error, try sourcing" 111 | @echo "the helper script we have provided first then run make test." 112 | @echo "e.g. source run-env-linux.sh ; make test" 113 | @echo "----------------------" 114 | 115 | deploy: compile doc transcompile 116 | @echo 117 | @echo "------------------------------------------" 118 | @echo "Deploying plugin to your .qgis2 directory." 119 | @echo "------------------------------------------" 120 | # The deploy target only works on unix like operating system where 121 | # the Python plugin directory is located at: 122 | # $HOME/$(QGISDIR)/python/plugins 123 | mkdir -p $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 124 | cp -vf $(PY_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 125 | cp -vf $(UI_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 126 | cp -vf $(COMPILED_RESOURCE_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 127 | cp -vf $(EXTRAS) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 128 | cp -vfr i18n $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 129 | cp -vfr $(HELP) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/help 130 | # Copy extra directories if any 131 | (foreach EXTRA_DIR,(EXTRA_DIRS), cp -R (EXTRA_DIR) (HOME)/(QGISDIR)/python/plugins/(PLUGINNAME)/;) 132 | 133 | 134 | # The dclean target removes compiled python files from plugin directory 135 | # also deletes any .git entry 136 | dclean: 137 | @echo 138 | @echo "-----------------------------------" 139 | @echo "Removing any compiled python files." 140 | @echo "-----------------------------------" 141 | find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname "*.pyc" -delete 142 | find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname ".git" -prune -exec rm -Rf {} \; 143 | 144 | 145 | derase: 146 | @echo 147 | @echo "-------------------------" 148 | @echo "Removing deployed plugin." 149 | @echo "-------------------------" 150 | rm -Rf $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) 151 | 152 | zip: deploy dclean 153 | @echo 154 | @echo "---------------------------" 155 | @echo "Creating plugin zip bundle." 156 | @echo "---------------------------" 157 | # The zip target deploys the plugin and creates a zip file with the deployed 158 | # content. You can then upload the zip file on http://plugins.qgis.org 159 | rm -f $(PLUGINNAME).zip 160 | cd $(HOME)/$(QGISDIR)/python/plugins; zip -9r $(CURDIR)/$(PLUGINNAME).zip $(PLUGINNAME) 161 | 162 | package: compile 163 | # Create a zip package of the plugin named $(PLUGINNAME).zip. 164 | # This requires use of git (your plugin development directory must be a 165 | # git repository). 166 | # To use, pass a valid commit or tag as follows: 167 | # make package VERSION=Version_0.3.2 168 | @echo 169 | @echo "------------------------------------" 170 | @echo "Exporting plugin to zip package. " 171 | @echo "------------------------------------" 172 | rm -f $(PLUGINNAME).zip 173 | git archive --prefix=$(PLUGINNAME)/ -o $(PLUGINNAME).zip $(VERSION) 174 | echo "Created package: $(PLUGINNAME).zip" 175 | 176 | upload: zip 177 | @echo 178 | @echo "-------------------------------------" 179 | @echo "Uploading plugin to QGIS Plugin repo." 180 | @echo "-------------------------------------" 181 | $(PLUGIN_UPLOAD) $(PLUGINNAME).zip 182 | 183 | transup: 184 | @echo 185 | @echo "------------------------------------------------" 186 | @echo "Updating translation files with any new strings." 187 | @echo "------------------------------------------------" 188 | @chmod +x scripts/update-strings.sh 189 | @scripts/update-strings.sh $(LOCALES) 190 | 191 | transcompile: 192 | @echo 193 | @echo "----------------------------------------" 194 | @echo "Compiled translation files to .qm files." 195 | @echo "----------------------------------------" 196 | @chmod +x scripts/compile-strings.sh 197 | @scripts/compile-strings.sh $(LRELEASE) $(LOCALES) 198 | 199 | transclean: 200 | @echo 201 | @echo "------------------------------------" 202 | @echo "Removing compiled translation files." 203 | @echo "------------------------------------" 204 | rm -f i18n/*.qm 205 | 206 | clean: 207 | @echo 208 | @echo "------------------------------------" 209 | @echo "Removing uic and rcc generated files" 210 | @echo "------------------------------------" 211 | rm $(COMPILED_UI_FILES) $(COMPILED_RESOURCE_FILES) 212 | 213 | doc: 214 | @echo 215 | @echo "------------------------------------" 216 | @echo "Building documentation using sphinx." 217 | @echo "------------------------------------" 218 | cd help; make html 219 | 220 | pylint: 221 | @echo 222 | @echo "-----------------" 223 | @echo "Pylint violations" 224 | @echo "-----------------" 225 | @pylint --reports=n --rcfile=pylintrc . || true 226 | @echo 227 | @echo "----------------------" 228 | @echo "If you get a 'no module named qgis.core' error, try sourcing" 229 | @echo "the helper script we have provided first then run make pylint." 230 | @echo "e.g. source run-env-linux.sh ; make pylint" 231 | @echo "----------------------" 232 | 233 | 234 | # Run pep8 style checking 235 | #http://pypi.python.org/pypi/pep8 236 | pep8: 237 | @echo 238 | @echo "-----------" 239 | @echo "PEP8 issues" 240 | @echo "-----------" 241 | @pep8 --repeat --ignore=E203,E121,E122,E123,E124,E125,E126,E127,E128 --exclude $(PEP8EXCLUDE) . || true 242 | @echo "-----------" 243 | @echo "Ignored in PEP8 check:" 244 | @echo $(PEP8EXCLUDE) 245 | -------------------------------------------------------------------------------- /code/save_attributes/README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Plugin Builder Results

4 | 5 | Congratulations! You just built a plugin for QGIS!

6 | 7 |
8 | Your plugin SaveAttributes was created in:
9 |   C:/Users/banbar/Desktop\save_attributes 10 |

11 | Your QGIS plugin directory is located at:
12 |   C:/Users/banbar/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins 13 |

14 |

What's Next

15 |
    16 |
  1. If resources.py is not present in your plugin directory, compile the resources file using pyrcc5 (simply use pb_tool or make if you have automake) 17 |
  2. Optionally, test the generated sources using make test (or run tests from your IDE) 18 |
  3. Copy the entire directory containing your new plugin to the QGIS plugin directory (see Notes below) 19 |
  4. Test the plugin by enabling it in the QGIS plugin manager 20 |
  5. Customize it by editing the implementation file save_attributes.py 21 |
  6. Create your own custom icon, replacing the default icon.png 22 |
  7. Modify your user interface by opening save_attributes_dialog_base.ui in Qt Designer 23 |
24 | Notes: 25 |
    26 |
  • You can use pb_tool to compile, deploy, and manage your plugin. Tweak the pb_tool.cfg file included with your plugin as you add files. Install pb_tool using 27 | pip or easy_install. See http://loc8.cc/pb_tool for more information. 28 |
  • You can also use the Makefile to compile and deploy when you 29 | make changes. This requires GNU make (gmake). The Makefile is ready to use, however you 30 | will have to edit it to add addional Python source files, dialogs, and translations. 31 |
32 |
33 |
34 |

35 | For information on writing PyQGIS code, see http://loc8.cc/pyqgis_resources for a list of resources. 36 |

37 |
38 |

39 | ©2011-2019 GeoApt LLC - geoapt.com 40 |

41 | 42 | 43 | -------------------------------------------------------------------------------- /code/save_attributes/README.txt: -------------------------------------------------------------------------------- 1 | Plugin Builder Results 2 | 3 | Your plugin SaveAttributes was created in: 4 | C:/Users/banbar/Desktop\save_attributes 5 | 6 | Your QGIS plugin directory is located at: 7 | C:/Users/banbar/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins 8 | 9 | What's Next: 10 | 11 | * Copy the entire directory containing your new plugin to the QGIS plugin 12 | directory 13 | 14 | * Compile the resources file using pyrcc5 15 | 16 | * Run the tests (``make test``) 17 | 18 | * Test the plugin by enabling it in the QGIS plugin manager 19 | 20 | * Customize it by editing the implementation file: ``save_attributes.py`` 21 | 22 | * Create your own custom icon, replacing the default icon.png 23 | 24 | * Modify your user interface by opening SaveAttributes_dialog_base.ui in Qt Designer 25 | 26 | * You can use the Makefile to compile your Ui and resource files when 27 | you make changes. This requires GNU make (gmake) 28 | 29 | For more information, see the PyQGIS Developer Cookbook at: 30 | http://www.qgis.org/pyqgis-cookbook/index.html 31 | 32 | (C) 2011-2018 GeoApt LLC - geoapt.com 33 | -------------------------------------------------------------------------------- /code/save_attributes/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | SaveAttributes 5 | A QGIS plugin 6 | This plugin saves the attribute of the selected vector layer as a csv file. 7 | Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 8 | ------------------- 9 | begin : 2020-10-30 10 | copyright : (C) 2020 by Berk Anbaroğlu 11 | email : banbar@hacettepe.edu.tr 12 | git sha : $Format:%H$ 13 | ***************************************************************************/ 14 | 15 | /*************************************************************************** 16 | * * 17 | * This program is free software; you can redistribute it and/or modify * 18 | * it under the terms of the GNU General Public License as published by * 19 | * the Free Software Foundation; either version 2 of the License, or * 20 | * (at your option) any later version. * 21 | * * 22 | ***************************************************************************/ 23 | This script initializes the plugin, making it known to QGIS. 24 | """ 25 | 26 | 27 | # noinspection PyPep8Naming 28 | def classFactory(iface): # pylint: disable=invalid-name 29 | """Load SaveAttributes class from file SaveAttributes. 30 | 31 | :param iface: A QGIS interface instance. 32 | :type iface: QgsInterface 33 | """ 34 | # 35 | from .save_attributes import SaveAttributes 36 | return SaveAttributes(iface) 37 | -------------------------------------------------------------------------------- /code/save_attributes/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/code/save_attributes/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /code/save_attributes/__pycache__/resources.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/code/save_attributes/__pycache__/resources.cpython-37.pyc -------------------------------------------------------------------------------- /code/save_attributes/__pycache__/save_attributes.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/code/save_attributes/__pycache__/save_attributes.cpython-37.pyc -------------------------------------------------------------------------------- /code/save_attributes/__pycache__/save_attributes_dialog.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/code/save_attributes/__pycache__/save_attributes_dialog.cpython-37.pyc -------------------------------------------------------------------------------- /code/save_attributes/compile.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | call "C:\OSGeo4W64\bin\o4w_env.bat" 3 | call "C:\OSGeo4W64\bin\qt5_env.bat" 4 | call "C:\OSGeo4W64\bin\py3_env.bat" 5 | 6 | @echo on 7 | pyrcc5 -o resources.py resources.qrc -------------------------------------------------------------------------------- /code/save_attributes/help/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 14 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " singlehtml to make a single large HTML file" 22 | @echo " pickle to make pickle files" 23 | @echo " json to make JSON files" 24 | @echo " htmlhelp to make HTML files and a HTML help project" 25 | @echo " qthelp to make HTML files and a qthelp project" 26 | @echo " devhelp to make HTML files and a Devhelp project" 27 | @echo " epub to make an epub" 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 30 | @echo " text to make text files" 31 | @echo " man to make manual pages" 32 | @echo " changes to make an overview of all changed/added/deprecated items" 33 | @echo " linkcheck to check all external links for integrity" 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 35 | 36 | clean: 37 | -rm -rf $(BUILDDIR)/* 38 | 39 | html: 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 41 | @echo 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 43 | 44 | dirhtml: 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 48 | 49 | singlehtml: 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 51 | @echo 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 53 | 54 | pickle: 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 56 | @echo 57 | @echo "Build finished; now you can process the pickle files." 58 | 59 | json: 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 61 | @echo 62 | @echo "Build finished; now you can process the JSON files." 63 | 64 | htmlhelp: 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 66 | @echo 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." 69 | 70 | qthelp: 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 72 | @echo 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/template_class.qhcp" 76 | @echo "To view the help file:" 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/template_class.qhc" 78 | 79 | devhelp: 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 81 | @echo 82 | @echo "Build finished." 83 | @echo "To view the help file:" 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/template_class" 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/template_class" 86 | @echo "# devhelp" 87 | 88 | epub: 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 90 | @echo 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 92 | 93 | latex: 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 95 | @echo 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 98 | "(use \`make latexpdf' here to do that automatically)." 99 | 100 | latexpdf: 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 102 | @echo "Running LaTeX files through pdflatex..." 103 | make -C $(BUILDDIR)/latex all-pdf 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 105 | 106 | text: 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 108 | @echo 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 110 | 111 | man: 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 113 | @echo 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 115 | 116 | changes: 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 118 | @echo 119 | @echo "The overview file is in $(BUILDDIR)/changes." 120 | 121 | linkcheck: 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 123 | @echo 124 | @echo "Link check complete; look for any errors in the above output " \ 125 | "or in $(BUILDDIR)/linkcheck/output.txt." 126 | 127 | doctest: 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 129 | @echo "Testing of doctests in the sources finished, look at the " \ 130 | "results in $(BUILDDIR)/doctest/output.txt." 131 | -------------------------------------------------------------------------------- /code/save_attributes/help/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 10 | if NOT "%PAPER%" == "" ( 11 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 12 | ) 13 | 14 | if "%1" == "" goto help 15 | 16 | if "%1" == "help" ( 17 | :help 18 | echo.Please use `make ^` where ^ is one of 19 | echo. html to make standalone HTML files 20 | echo. dirhtml to make HTML files named index.html in directories 21 | echo. singlehtml to make a single large HTML file 22 | echo. pickle to make pickle files 23 | echo. json to make JSON files 24 | echo. htmlhelp to make HTML files and a HTML help project 25 | echo. qthelp to make HTML files and a qthelp project 26 | echo. devhelp to make HTML files and a Devhelp project 27 | echo. epub to make an epub 28 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 29 | echo. text to make text files 30 | echo. man to make manual pages 31 | echo. changes to make an overview over all changed/added/deprecated items 32 | echo. linkcheck to check all external links for integrity 33 | echo. doctest to run all doctests embedded in the documentation if enabled 34 | goto end 35 | ) 36 | 37 | if "%1" == "clean" ( 38 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 39 | del /q /s %BUILDDIR%\* 40 | goto end 41 | ) 42 | 43 | if "%1" == "html" ( 44 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 45 | echo. 46 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 47 | goto end 48 | ) 49 | 50 | if "%1" == "dirhtml" ( 51 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 52 | echo. 53 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 54 | goto end 55 | ) 56 | 57 | if "%1" == "singlehtml" ( 58 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 59 | echo. 60 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 61 | goto end 62 | ) 63 | 64 | if "%1" == "pickle" ( 65 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 66 | echo. 67 | echo.Build finished; now you can process the pickle files. 68 | goto end 69 | ) 70 | 71 | if "%1" == "json" ( 72 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 73 | echo. 74 | echo.Build finished; now you can process the JSON files. 75 | goto end 76 | ) 77 | 78 | if "%1" == "htmlhelp" ( 79 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 80 | echo. 81 | echo.Build finished; now you can run HTML Help Workshop with the ^ 82 | .hhp project file in %BUILDDIR%/htmlhelp. 83 | goto end 84 | ) 85 | 86 | if "%1" == "qthelp" ( 87 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 88 | echo. 89 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 90 | .qhcp project file in %BUILDDIR%/qthelp, like this: 91 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\template_class.qhcp 92 | echo.To view the help file: 93 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\template_class.ghc 94 | goto end 95 | ) 96 | 97 | if "%1" == "devhelp" ( 98 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 99 | echo. 100 | echo.Build finished. 101 | goto end 102 | ) 103 | 104 | if "%1" == "epub" ( 105 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 106 | echo. 107 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 108 | goto end 109 | ) 110 | 111 | if "%1" == "latex" ( 112 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 113 | echo. 114 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 115 | goto end 116 | ) 117 | 118 | if "%1" == "text" ( 119 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 120 | echo. 121 | echo.Build finished. The text files are in %BUILDDIR%/text. 122 | goto end 123 | ) 124 | 125 | if "%1" == "man" ( 126 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 127 | echo. 128 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 129 | goto end 130 | ) 131 | 132 | if "%1" == "changes" ( 133 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 134 | echo. 135 | echo.The overview file is in %BUILDDIR%/changes. 136 | goto end 137 | ) 138 | 139 | if "%1" == "linkcheck" ( 140 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 141 | echo. 142 | echo.Link check complete; look for any errors in the above output ^ 143 | or in %BUILDDIR%/linkcheck/output.txt. 144 | goto end 145 | ) 146 | 147 | if "%1" == "doctest" ( 148 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 149 | echo. 150 | echo.Testing of doctests in the sources finished, look at the ^ 151 | results in %BUILDDIR%/doctest/output.txt. 152 | goto end 153 | ) 154 | 155 | :end 156 | -------------------------------------------------------------------------------- /code/save_attributes/help/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # SaveAttributes documentation build configuration file, created by 4 | # sphinx-quickstart on Sun Feb 12 17:11:03 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ['sphinx.ext.todo', 'sphinx.ext.imgmath', 'sphinx.ext.viewcode'] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.rst' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'SaveAttributes' 44 | copyright = u'2013, Berk Anbaroğlu' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = '0.1' 52 | # The full version, including alpha/beta/rc tags. 53 | release = '0.1' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | #today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | #today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = [] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_TemplateModuleNames = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | #html_theme_path = [] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | #html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | #html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | #html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | #html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | #html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | #html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | #html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | #html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | #html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | #html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | #html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | #html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | #html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | #html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | #html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | #html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = 'TemplateClassdoc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | # The paper size ('letter' or 'a4'). 173 | #latex_paper_size = 'letter' 174 | 175 | # The font size ('10pt', '11pt' or '12pt'). 176 | #latex_font_size = '10pt' 177 | 178 | # Grouping the document tree into LaTeX files. List of tuples 179 | # (source start file, target name, title, author, documentclass [howto/manual]). 180 | latex_documents = [ 181 | ('index', 'SaveAttributes.tex', u'SaveAttributes Documentation', 182 | u'Berk Anbaroğlu', 'manual'), 183 | ] 184 | 185 | # The name of an image file (relative to this directory) to place at the top of 186 | # the title page. 187 | #latex_logo = None 188 | 189 | # For "manual" documents, if this is true, then toplevel headings are parts, 190 | # not chapters. 191 | #latex_use_parts = False 192 | 193 | # If true, show page references after internal links. 194 | #latex_show_pagerefs = False 195 | 196 | # If true, show URL addresses after external links. 197 | #latex_show_urls = False 198 | 199 | # Additional stuff for the LaTeX preamble. 200 | #latex_preamble = '' 201 | 202 | # Documents to append as an appendix to all manuals. 203 | #latex_appendices = [] 204 | 205 | # If false, no module index is generated. 206 | #latex_domain_indices = True 207 | 208 | 209 | # -- Options for manual page output -------------------------------------------- 210 | 211 | # One entry per manual page. List of tuples 212 | # (source start file, name, description, authors, manual section). 213 | man_pages = [ 214 | ('index', 'TemplateClass', u'SaveAttributes Documentation', 215 | [u'Berk Anbaroğlu'], 1) 216 | ] 217 | -------------------------------------------------------------------------------- /code/save_attributes/help/source/index.rst: -------------------------------------------------------------------------------- 1 | .. SaveAttributes documentation master file, created by 2 | sphinx-quickstart on Sun Feb 12 17:11:03 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to SaveAttributes's documentation! 7 | ============================================ 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | Indices and tables 15 | ================== 16 | 17 | * :ref:`genindex` 18 | * :ref:`modindex` 19 | * :ref:`search` 20 | 21 | -------------------------------------------------------------------------------- /code/save_attributes/i18n/af.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @default 5 | 6 | 7 | Good morning 8 | Goeie more 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /code/save_attributes/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/code/save_attributes/icon.png -------------------------------------------------------------------------------- /code/save_attributes/metadata.txt: -------------------------------------------------------------------------------- 1 | # This file contains metadata for your plugin. 2 | 3 | # This file should be included when you package your plugin.# Mandatory items: 4 | 5 | [general] 6 | name=Save Attributes 7 | qgisMinimumVersion=3.0 8 | description=This plugin saves the attribute of the selected vector layer as a csv file. 9 | version=0.1 10 | author=Berk Anbaroğlu 11 | email=banbar@hacettepe.edu.tr 12 | 13 | about=Tutorial plugin. 14 | 15 | tracker=http://bugs 16 | repository=http://repo 17 | # End of mandatory metadata 18 | 19 | # Recommended items: 20 | 21 | hasProcessingProvider=no 22 | # Uncomment the following line and add your changelog: 23 | # changelog= 24 | 25 | # Tags are comma separated with spaces allowed 26 | tags=python 27 | 28 | homepage=http://homepage 29 | category=Vector 30 | icon=icon.png 31 | # experimental flag 32 | experimental=True 33 | 34 | # deprecated flag (applies to the whole plugin, not just a single version) 35 | deprecated=False 36 | 37 | # Since QGIS 3.8, a comma separated list of plugins to be installed 38 | # (or upgraded) can be specified. 39 | # Check the documentation for more information. 40 | # plugin_dependencies= 41 | 42 | Category of the plugin: Raster, Vector, Database or Web 43 | # category= 44 | 45 | # If the plugin can run on QGIS Server. 46 | server=False 47 | 48 | -------------------------------------------------------------------------------- /code/save_attributes/pb_tool.cfg: -------------------------------------------------------------------------------- 1 | #/*************************************************************************** 2 | # SaveAttributes 3 | # 4 | # Configuration file for plugin builder tool (pb_tool) 5 | # Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 6 | # ------------------- 7 | # begin : 2020-10-30 8 | # copyright : (C) 2020 by Berk Anbaroğlu 9 | # email : banbar@hacettepe.edu.tr 10 | # ***************************************************************************/ 11 | # 12 | #/*************************************************************************** 13 | # * * 14 | # * This program is free software; you can redistribute it and/or modify * 15 | # * it under the terms of the GNU General Public License as published by * 16 | # * the Free Software Foundation; either version 2 of the License, or * 17 | # * (at your option) any later version. * 18 | # * * 19 | # ***************************************************************************/ 20 | # 21 | # 22 | # You can install pb_tool using: 23 | # pip install http://geoapt.net/files/pb_tool.zip 24 | # 25 | # Consider doing your development (and install of pb_tool) in a virtualenv. 26 | # 27 | # For details on setting up and using pb_tool, see: 28 | # http://g-sherman.github.io/plugin_build_tool/ 29 | # 30 | # Issues and pull requests here: 31 | # https://github.com/g-sherman/plugin_build_tool: 32 | # 33 | # Sane defaults for your plugin generated by the Plugin Builder are 34 | # already set below. 35 | # 36 | # As you add Python source files and UI files to your plugin, add 37 | # them to the appropriate [files] section below. 38 | 39 | [plugin] 40 | # Name of the plugin. This is the name of the directory that will 41 | # be created in .qgis2/python/plugins 42 | name: save_attributes 43 | 44 | # Full path to where you want your plugin directory copied. If empty, 45 | # the QGIS default path will be used. Don't include the plugin name in 46 | # the path. 47 | plugin_path: 48 | 49 | [files] 50 | # Python files that should be deployed with the plugin 51 | python_files: __init__.py save_attributes.py save_attributes_dialog.py 52 | 53 | # The main dialog file that is loaded (not compiled) 54 | main_dialog: save_attributes_dialog_base.ui 55 | 56 | # Other ui files for dialogs you create (these will be compiled) 57 | compiled_ui_files: 58 | 59 | # Resource file(s) that will be compiled 60 | resource_files: resources.qrc 61 | 62 | # Other files required for the plugin 63 | extras: metadata.txt icon.png 64 | 65 | # Other directories to be deployed with the plugin. 66 | # These must be subdirectories under the plugin directory 67 | extra_dirs: 68 | 69 | # ISO code(s) for any locales (translations), separated by spaces. 70 | # Corresponding .ts files must exist in the i18n directory 71 | locales: 72 | 73 | [help] 74 | # the built help directory that should be deployed with the plugin 75 | dir: help/build/html 76 | # the name of the directory to target in the deployed plugin 77 | target: help 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /code/save_attributes/plugin_upload.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | """This script uploads a plugin package to the plugin repository. 4 | Authors: A. Pasotti, V. Picavet 5 | git sha : $TemplateVCSFormat 6 | """ 7 | 8 | import sys 9 | import getpass 10 | import xmlrpc.client 11 | from optparse import OptionParser 12 | 13 | standard_library.install_aliases() 14 | 15 | # Configuration 16 | PROTOCOL = 'https' 17 | SERVER = 'plugins.qgis.org' 18 | PORT = '443' 19 | ENDPOINT = '/plugins/RPC2/' 20 | VERBOSE = False 21 | 22 | 23 | def main(parameters, arguments): 24 | """Main entry point. 25 | 26 | :param parameters: Command line parameters. 27 | :param arguments: Command line arguments. 28 | """ 29 | address = "{protocol}://{username}:{password}@{server}:{port}{endpoint}".format( 30 | protocol=PROTOCOL, 31 | username=parameters.username, 32 | password=parameters.password, 33 | server=parameters.server, 34 | port=parameters.port, 35 | endpoint=ENDPOINT) 36 | print("Connecting to: %s" % hide_password(address)) 37 | 38 | server = xmlrpc.client.ServerProxy(address, verbose=VERBOSE) 39 | 40 | try: 41 | with open(arguments[0], 'rb') as handle: 42 | plugin_id, version_id = server.plugin.upload( 43 | xmlrpc.client.Binary(handle.read())) 44 | print("Plugin ID: %s" % plugin_id) 45 | print("Version ID: %s" % version_id) 46 | except xmlrpc.client.ProtocolError as err: 47 | print("A protocol error occurred") 48 | print("URL: %s" % hide_password(err.url, 0)) 49 | print("HTTP/HTTPS headers: %s" % err.headers) 50 | print("Error code: %d" % err.errcode) 51 | print("Error message: %s" % err.errmsg) 52 | except xmlrpc.client.Fault as err: 53 | print("A fault occurred") 54 | print("Fault code: %d" % err.faultCode) 55 | print("Fault string: %s" % err.faultString) 56 | 57 | 58 | def hide_password(url, start=6): 59 | """Returns the http url with password part replaced with '*'. 60 | 61 | :param url: URL to upload the plugin to. 62 | :type url: str 63 | 64 | :param start: Position of start of password. 65 | :type start: int 66 | """ 67 | start_position = url.find(':', start) + 1 68 | end_position = url.find('@') 69 | return "%s%s%s" % ( 70 | url[:start_position], 71 | '*' * (end_position - start_position), 72 | url[end_position:]) 73 | 74 | 75 | if __name__ == "__main__": 76 | parser = OptionParser(usage="%prog [options] plugin.zip") 77 | parser.add_option( 78 | "-w", "--password", dest="password", 79 | help="Password for plugin site", metavar="******") 80 | parser.add_option( 81 | "-u", "--username", dest="username", 82 | help="Username of plugin site", metavar="user") 83 | parser.add_option( 84 | "-p", "--port", dest="port", 85 | help="Server port to connect to", metavar="80") 86 | parser.add_option( 87 | "-s", "--server", dest="server", 88 | help="Specify server name", metavar="plugins.qgis.org") 89 | options, args = parser.parse_args() 90 | if len(args) != 1: 91 | print("Please specify zip file.\n") 92 | parser.print_help() 93 | sys.exit(1) 94 | if not options.server: 95 | options.server = SERVER 96 | if not options.port: 97 | options.port = PORT 98 | if not options.username: 99 | # interactive mode 100 | username = getpass.getuser() 101 | print("Please enter user name [%s] :" % username, end=' ') 102 | 103 | res = input() 104 | if res != "": 105 | options.username = res 106 | else: 107 | options.username = username 108 | if not options.password: 109 | # interactive mode 110 | options.password = getpass.getpass() 111 | main(options, args) 112 | -------------------------------------------------------------------------------- /code/save_attributes/pylintrc: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | 3 | # Specify a configuration file. 4 | #rcfile= 5 | 6 | # Python code to execute, usually for sys.path manipulation such as 7 | # pygtk.require(). 8 | #init-hook= 9 | 10 | # Profiled execution. 11 | profile=no 12 | 13 | # Add files or directories to the blacklist. They should be base names, not 14 | # paths. 15 | ignore=CVS 16 | 17 | # Pickle collected data for later comparisons. 18 | persistent=yes 19 | 20 | # List of plugins (as comma separated values of python modules names) to load, 21 | # usually to register additional checkers. 22 | load-plugins= 23 | 24 | 25 | [MESSAGES CONTROL] 26 | 27 | # Enable the message, report, category or checker with the given id(s). You can 28 | # either give multiple identifier separated by comma (,) or put this option 29 | # multiple time. See also the "--disable" option for examples. 30 | #enable= 31 | 32 | # Disable the message, report, category or checker with the given id(s). You 33 | # can either give multiple identifiers separated by comma (,) or put this 34 | # option multiple times (only on the command line, not in the configuration 35 | # file where it should appear only once).You can also use "--disable=all" to 36 | # disable everything first and then reenable specific checks. For example, if 37 | # you want to run only the similarities checker, you can use "--disable=all 38 | # --enable=similarities". If you want to run only the classes checker, but have 39 | # no Warning level messages displayed, use"--disable=all --enable=classes 40 | # --disable=W" 41 | # see http://stackoverflow.com/questions/21487025/pylint-locally-defined-disables-still-give-warnings-how-to-suppress-them 42 | disable=locally-disabled,C0103 43 | 44 | 45 | [REPORTS] 46 | 47 | # Set the output format. Available formats are text, parseable, colorized, msvs 48 | # (visual studio) and html. You can also give a reporter class, eg 49 | # mypackage.mymodule.MyReporterClass. 50 | output-format=text 51 | 52 | # Put messages in a separate file for each module / package specified on the 53 | # command line instead of printing them on stdout. Reports (if any) will be 54 | # written in a file name "pylint_global.[txt|html]". 55 | files-output=no 56 | 57 | # Tells whether to display a full report or only the messages 58 | reports=yes 59 | 60 | # Python expression which should return a note less than 10 (10 is the highest 61 | # note). You have access to the variables errors warning, statement which 62 | # respectively contain the number of errors / warnings messages and the total 63 | # number of statements analyzed. This is used by the global evaluation report 64 | # (RP0004). 65 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) 66 | 67 | # Add a comment according to your evaluation note. This is used by the global 68 | # evaluation report (RP0004). 69 | comment=no 70 | 71 | # Template used to display messages. This is a python new-style format string 72 | # used to format the message information. See doc for all details 73 | #msg-template= 74 | 75 | 76 | [BASIC] 77 | 78 | # Required attributes for module, separated by a comma 79 | required-attributes= 80 | 81 | # List of builtins function names that should not be used, separated by a comma 82 | bad-functions=map,filter,apply,input 83 | 84 | # Regular expression which should only match correct module names 85 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ 86 | 87 | # Regular expression which should only match correct module level names 88 | const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ 89 | 90 | # Regular expression which should only match correct class names 91 | class-rgx=[A-Z_][a-zA-Z0-9]+$ 92 | 93 | # Regular expression which should only match correct function names 94 | function-rgx=[a-z_][a-z0-9_]{2,30}$ 95 | 96 | # Regular expression which should only match correct method names 97 | method-rgx=[a-z_][a-z0-9_]{2,30}$ 98 | 99 | # Regular expression which should only match correct instance attribute names 100 | attr-rgx=[a-z_][a-z0-9_]{2,30}$ 101 | 102 | # Regular expression which should only match correct argument names 103 | argument-rgx=[a-z_][a-z0-9_]{2,30}$ 104 | 105 | # Regular expression which should only match correct variable names 106 | variable-rgx=[a-z_][a-z0-9_]{2,30}$ 107 | 108 | # Regular expression which should only match correct attribute names in class 109 | # bodies 110 | class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ 111 | 112 | # Regular expression which should only match correct list comprehension / 113 | # generator expression variable names 114 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ 115 | 116 | # Good variable names which should always be accepted, separated by a comma 117 | good-names=i,j,k,ex,Run,_ 118 | 119 | # Bad variable names which should always be refused, separated by a comma 120 | bad-names=foo,bar,baz,toto,tutu,tata 121 | 122 | # Regular expression which should only match function or class names that do 123 | # not require a docstring. 124 | no-docstring-rgx=__.*__ 125 | 126 | # Minimum line length for functions/classes that require docstrings, shorter 127 | # ones are exempt. 128 | docstring-min-length=-1 129 | 130 | 131 | [MISCELLANEOUS] 132 | 133 | # List of note tags to take in consideration, separated by a comma. 134 | notes=FIXME,XXX,TODO 135 | 136 | 137 | [TYPECHECK] 138 | 139 | # Tells whether missing members accessed in mixin class should be ignored. A 140 | # mixin class is detected if its name ends with "mixin" (case insensitive). 141 | ignore-mixin-members=yes 142 | 143 | # List of classes names for which member attributes should not be checked 144 | # (useful for classes with attributes dynamically set). 145 | ignored-classes=SQLObject 146 | 147 | # When zope mode is activated, add a predefined set of Zope acquired attributes 148 | # to generated-members. 149 | zope=no 150 | 151 | # List of members which are set dynamically and missed by pylint inference 152 | # system, and so shouldn't trigger E0201 when accessed. Python regular 153 | # expressions are accepted. 154 | generated-members=REQUEST,acl_users,aq_parent 155 | 156 | 157 | [VARIABLES] 158 | 159 | # Tells whether we should check for unused import in __init__ files. 160 | init-import=no 161 | 162 | # A regular expression matching the beginning of the name of dummy variables 163 | # (i.e. not used). 164 | dummy-variables-rgx=_$|dummy 165 | 166 | # List of additional names supposed to be defined in builtins. Remember that 167 | # you should avoid to define new builtins when possible. 168 | additional-builtins= 169 | 170 | 171 | [FORMAT] 172 | 173 | # Maximum number of characters on a single line. 174 | max-line-length=80 175 | 176 | # Regexp for a line that is allowed to be longer than the limit. 177 | ignore-long-lines=^\s*(# )??$ 178 | 179 | # Allow the body of an if to be on the same line as the test if there is no 180 | # else. 181 | single-line-if-stmt=no 182 | 183 | # List of optional constructs for which whitespace checking is disabled 184 | no-space-check=trailing-comma,dict-separator 185 | 186 | # Maximum number of lines in a module 187 | max-module-lines=1000 188 | 189 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 190 | # tab). 191 | indent-string=' ' 192 | 193 | 194 | [SIMILARITIES] 195 | 196 | # Minimum lines number of a similarity. 197 | min-similarity-lines=4 198 | 199 | # Ignore comments when computing similarities. 200 | ignore-comments=yes 201 | 202 | # Ignore docstrings when computing similarities. 203 | ignore-docstrings=yes 204 | 205 | # Ignore imports when computing similarities. 206 | ignore-imports=no 207 | 208 | 209 | [IMPORTS] 210 | 211 | # Deprecated modules which should not be used, separated by a comma 212 | deprecated-modules=regsub,TERMIOS,Bastion,rexec 213 | 214 | # Create a graph of every (i.e. internal and external) dependencies in the 215 | # given file (report RP0402 must not be disabled) 216 | import-graph= 217 | 218 | # Create a graph of external dependencies in the given file (report RP0402 must 219 | # not be disabled) 220 | ext-import-graph= 221 | 222 | # Create a graph of internal dependencies in the given file (report RP0402 must 223 | # not be disabled) 224 | int-import-graph= 225 | 226 | 227 | [DESIGN] 228 | 229 | # Maximum number of arguments for function / method 230 | max-args=5 231 | 232 | # Argument names that match this expression will be ignored. Default to name 233 | # with leading underscore 234 | ignored-argument-names=_.* 235 | 236 | # Maximum number of locals for function / method body 237 | max-locals=15 238 | 239 | # Maximum number of return / yield for function / method body 240 | max-returns=6 241 | 242 | # Maximum number of branch for function / method body 243 | max-branches=12 244 | 245 | # Maximum number of statements in function / method body 246 | max-statements=50 247 | 248 | # Maximum number of parents for a class (see R0901). 249 | max-parents=7 250 | 251 | # Maximum number of attributes for a class (see R0902). 252 | max-attributes=7 253 | 254 | # Minimum number of public methods for a class (see R0903). 255 | min-public-methods=2 256 | 257 | # Maximum number of public methods for a class (see R0904). 258 | max-public-methods=20 259 | 260 | 261 | [CLASSES] 262 | 263 | # List of interface methods to ignore, separated by a comma. This is used for 264 | # instance to not check methods defines in Zope's Interface base class. 265 | ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by 266 | 267 | # List of method names used to declare (i.e. assign) instance attributes. 268 | defining-attr-methods=__init__,__new__,setUp 269 | 270 | # List of valid names for the first argument in a class method. 271 | valid-classmethod-first-arg=cls 272 | 273 | # List of valid names for the first argument in a metaclass class method. 274 | valid-metaclass-classmethod-first-arg=mcs 275 | 276 | 277 | [EXCEPTIONS] 278 | 279 | # Exceptions that will emit a warning when being caught. Defaults to 280 | # "Exception" 281 | overgeneral-exceptions=Exception 282 | -------------------------------------------------------------------------------- /code/save_attributes/resources.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Resource object code 4 | # 5 | # Created by: The Resource Compiler for PyQt5 (Qt v5.11.2) 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt5 import QtCore 10 | 11 | qt_resource_data = b"\ 12 | \x00\x00\x04\x0a\ 13 | \x89\ 14 | \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ 15 | \x00\x00\x17\x00\x00\x00\x18\x08\x06\x00\x00\x00\x11\x7c\x66\x75\ 16 | \x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\ 17 | \x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\xa7\x93\x00\ 18 | \x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\ 19 | \x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45\x07\xd9\x02\x15\ 20 | \x16\x11\x2c\x9d\x48\x83\xbb\x00\x00\x03\x8a\x49\x44\x41\x54\x48\ 21 | \xc7\xad\x95\x4b\x68\x5c\x55\x18\xc7\x7f\xe7\xdc\x7b\x67\xe6\xce\ 22 | \x4c\x66\x26\x49\xd3\x24\x26\xa6\xc6\xf8\x40\x21\xa5\x04\xb3\x28\ 23 | \xda\x98\x20\xa5\x0b\xad\x55\xa8\x2b\xc5\x50\x1f\xa0\x6e\x34\x2b\ 24 | \x45\x30\x14\x02\xba\x52\x69\x15\x17\x66\x63\x45\x97\x95\xa0\xad\ 25 | \x0b\xfb\xc0\x06\x25\xb6\x71\x61\x12\x41\x50\xdb\x2a\x21\xd1\xe2\ 26 | \x24\xf3\x9e\xc9\xcc\xbd\xe7\x1c\x17\x35\x43\x1e\x33\x21\xb6\xfd\ 27 | \x56\x87\xf3\x9d\xfb\xfb\x1e\xf7\xff\x9d\x23\x8c\x31\x43\x95\xf4\ 28 | \x85\x1e\x3f\x3b\x35\xac\xfd\xcc\x43\xdc\xa4\x49\x3b\xfe\x9d\x1d\ 29 | \xdb\x7b\x22\x90\x78\xf8\xb2\x28\xa7\xbe\x7d\xc1\x4b\x9d\x79\xdf\ 30 | \x18\x15\xe5\x16\x99\x10\x56\xde\x69\xdc\x3f\x22\xfd\xec\xd4\xf0\ 31 | \xad\x04\x03\x18\xa3\xa2\x7e\x76\x6a\x58\xde\x68\x2b\xb4\x36\xf8\ 32 | \xbe\xc6\x18\x53\xdb\xef\xe7\xfa\xec\xed\x67\x63\x10\x42\x00\xf0\ 33 | \xfb\xd5\x65\x2a\x15\x45\xc7\x6d\x0d\x00\xc4\xa2\xc1\xaa\x6f\x0d\ 34 | \x3e\x6c\xab\xc2\x1c\x56\xa4\x77\x4b\xb0\xf2\x35\x15\x5f\x21\x85\ 35 | \xe0\xc8\x6b\x5f\x92\x2d\x37\x33\x39\xf9\x03\x27\x8e\x1f\xa2\xf7\ 36 | \xbe\x9d\x04\x1c\x0b\x37\xe4\xac\xff\xa6\x30\x87\xbd\xba\x00\x6a\ 37 | \x06\x79\xe5\xf5\xaf\x89\xd9\x92\xc5\xcc\x0a\xd9\x7c\x19\xcf\xe9\ 38 | \xe2\xe4\xa9\x2f\x78\x7c\xff\x01\x72\x85\x0a\x2b\x65\x1f\xa5\x4c\ 39 | \xb5\xb2\x55\x16\x80\xbd\x31\xda\xda\x20\x1f\x7d\x3e\xcd\xc2\xfd\ 40 | \x59\xa6\x93\x39\x92\xd1\x22\xea\x9b\x16\xce\x9d\x3f\xce\xe0\x83\ 41 | \x03\x24\x82\x59\x3a\xdb\x7b\x88\xc7\x82\x68\x63\x58\xc9\xcc\x62\ 42 | \x8c\x21\x18\xb0\x6a\xc3\x37\x06\x49\x16\xff\x24\x6b\xa5\x49\xbb\ 43 | \x25\xbc\xa2\xa6\x21\xbb\x40\x7f\xdf\x00\x83\xbd\x01\x8e\x3c\xd5\ 44 | \x45\xd7\x8e\x6b\x9c\x9c\x98\x25\x1a\xb6\xe8\xbe\x3d\xc2\xdd\x77\ 45 | \x44\x48\xc4\x1c\x22\xe1\xeb\x58\x59\xaf\xcf\xd3\x33\x29\x2e\x34\ 46 | \x2d\x91\x93\x3e\xbe\x34\x78\x01\xc5\xe2\x61\xc5\xae\x72\x8e\x70\ 47 | \xc8\xc2\x0d\x5a\xbc\xf5\xee\x2f\x9c\xfa\x3e\x86\x69\x7a\x8e\xcf\ 48 | \x26\xe6\xf9\x63\xa1\x44\xa1\xa4\xd0\xda\x6c\x0d\x2f\x15\x7c\xb4\ 49 | \x67\x28\x59\x0a\xcf\xd6\x54\xe2\x06\x13\x87\x2b\x6f\x68\xa6\x27\ 50 | \xaf\x31\x32\x36\xc7\xb2\x7f\x17\xef\x7d\x7c\x8c\x33\x67\xcf\x12\ 51 | \x70\x24\x4a\x69\xd6\x6a\x46\xd6\xd3\x70\x72\xa9\x82\x67\x34\x45\ 52 | \xad\x28\xdb\x1a\x15\x34\x98\xff\x46\xed\xef\x37\x0d\x99\xbf\x4a\ 53 | \x3c\x30\x38\xc0\xc8\x4b\xaf\x92\x5a\x9c\xe2\xe0\x23\x6d\x74\xb4\ 54 | \xba\x84\x5d\x0b\x29\x45\x7d\xb8\x94\x82\x96\xb6\x10\xf3\xc5\x12\ 55 | \x2a\xef\x53\x11\x1a\x63\xad\x3f\x93\x19\x85\xf1\xb1\x77\x58\x5a\ 56 | \xf8\x99\x97\x9f\xe9\xa6\x75\x47\x90\xc6\xb8\x43\xd8\xb5\xb6\xce\ 57 | \xfc\xfa\xfd\x00\xfb\x3e\xf4\xc8\x05\x35\xba\x5e\xeb\x46\x21\xf9\ 58 | \xcf\x0a\xa9\x8c\x87\xe3\x48\xdc\x90\xb5\x6e\x98\x6a\xaa\x65\xf2\ 59 | \x52\x92\x43\x2f\x5e\xc2\x8c\x02\x1a\x10\xf5\x07\xac\xc3\x75\x70\ 60 | \x83\x92\x80\xb3\xf9\xd0\x26\xf8\x8f\xb3\x29\xc6\x3e\xb8\x8c\x19\ 61 | \x35\x75\x6b\x7b\x7e\x3c\xca\x45\x0c\x7e\x49\x31\xf4\x58\x3b\xf7\ 62 | \xf6\x34\x90\x88\x39\x04\x1c\x59\x1f\xfe\xdb\xd5\x3c\x5f\x9d\x4b\ 63 | \x32\xfd\x44\xb2\xba\xd7\xfa\xb6\x60\xcf\xde\x16\xdc\x90\x45\x4c\ 64 | \x4a\x2a\x9e\x62\xfe\x4e\xc5\xc8\xc1\x4e\xda\x76\x86\xe8\xe9\x0a\ 65 | \xe3\xd8\x92\x58\xd4\xc6\xb2\x44\x6d\x78\x2a\x53\xe1\xca\x7c\x99\ 66 | \x63\x5d\xbf\x56\x9d\xbd\x9f\x44\x18\x7a\xba\x95\x27\x0f\xb4\xd3\ 67 | \xdc\x18\xc0\xf3\x0d\x52\x40\xd8\xb5\xb0\xa4\x20\x14\xb2\x70\x6c\ 68 | \x81\x63\xcb\xaa\x42\xd6\xfd\xb7\xf4\xec\xa3\x06\xa0\x50\x52\xd8\ 69 | \x4e\x1b\x7e\x4a\xd3\x31\xf9\x29\xcf\xfe\xd4\x49\x7f\x5f\x13\xfb\ 70 | \xfa\x9b\x71\x43\x92\x58\xd4\x21\x18\x90\xac\xde\xb0\x42\x50\x13\ 71 | \x58\x33\xf3\x88\x6b\xa1\xfd\x65\x96\xf2\x79\xc6\x43\x7b\xd8\x75\ 72 | \x38\xcc\x3d\xdd\xd1\xaa\xcf\x71\xe4\xff\x7f\x91\x56\x33\xaf\xea\ 73 | \x37\xe7\xa1\x94\x21\x16\xb5\xd1\x06\x2c\x29\x36\xf5\x72\x9b\x96\ 74 | \x95\xc0\xc4\xda\x9d\x78\x83\x43\x53\x22\x80\x65\x09\x1c\xfb\x86\ 75 | \xc1\x00\xe7\x25\x70\x14\x48\x6f\x1e\x22\x51\xe3\x75\xd9\xb6\xa5\ 76 | \x81\xa3\x32\xb1\xfb\xf4\x0c\x30\xb8\xb1\x82\x9b\xb0\x09\x60\x30\ 77 | \xb1\xfb\xf4\xcc\xbf\xa0\xe9\x6e\xae\x5a\xdf\x4b\x81\x00\x00\x00\ 78 | \x00\x49\x45\x4e\x44\xae\x42\x60\x82\ 79 | " 80 | 81 | qt_resource_name = b"\ 82 | \x00\x07\ 83 | \x07\x3b\xe0\xb3\ 84 | \x00\x70\ 85 | \x00\x6c\x00\x75\x00\x67\x00\x69\x00\x6e\x00\x73\ 86 | \x00\x0f\ 87 | \x01\x93\x3b\x83\ 88 | \x00\x73\ 89 | \x00\x61\x00\x76\x00\x65\x00\x5f\x00\x61\x00\x74\x00\x74\x00\x72\x00\x69\x00\x62\x00\x75\x00\x74\x00\x65\x00\x73\ 90 | \x00\x08\ 91 | \x0a\x61\x5a\xa7\ 92 | \x00\x69\ 93 | \x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\ 94 | " 95 | 96 | qt_resource_struct_v1 = b"\ 97 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 98 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ 99 | \x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ 100 | \x00\x00\x00\x38\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 101 | " 102 | 103 | qt_resource_struct_v2 = b"\ 104 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ 105 | \x00\x00\x00\x00\x00\x00\x00\x00\ 106 | \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ 107 | \x00\x00\x00\x00\x00\x00\x00\x00\ 108 | \x00\x00\x00\x14\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\ 109 | \x00\x00\x00\x00\x00\x00\x00\x00\ 110 | \x00\x00\x00\x38\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ 111 | \x00\x00\x01\x75\x7a\xd4\xec\xc0\ 112 | " 113 | 114 | qt_version = [int(v) for v in QtCore.qVersion().split('.')] 115 | if qt_version < [5, 8, 0]: 116 | rcc_version = 1 117 | qt_resource_struct = qt_resource_struct_v1 118 | else: 119 | rcc_version = 2 120 | qt_resource_struct = qt_resource_struct_v2 121 | 122 | def qInitResources(): 123 | QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) 124 | 125 | def qCleanupResources(): 126 | QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) 127 | 128 | qInitResources() 129 | -------------------------------------------------------------------------------- /code/save_attributes/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icon.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /code/save_attributes/save_attributes.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | SaveAttributes 5 | A QGIS plugin 6 | This plugin saves the attribute of the selected vector layer as a csv file. 7 | Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 8 | ------------------- 9 | begin : 2020-10-30 10 | git sha : $Format:%H$ 11 | copyright : (C) 2020 by Berk Anbaroğlu 12 | email : banbar@hacettepe.edu.tr 13 | ***************************************************************************/ 14 | 15 | /*************************************************************************** 16 | * * 17 | * This program is free software; you can redistribute it and/or modify * 18 | * it under the terms of the GNU General Public License as published by * 19 | * the Free Software Foundation; either version 2 of the License, or * 20 | * (at your option) any later version. * 21 | * * 22 | ***************************************************************************/ 23 | """ 24 | from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication 25 | from qgis.PyQt.QtGui import QIcon 26 | from qgis.PyQt.QtWidgets import QAction, QFileDialog 27 | from qgis.core import QgsProject, Qgis, QgsVectorLayer, QgsField 28 | from osgeo import ogr, osr, gdal 29 | import os 30 | from PyQt5.QtCore import QVariant 31 | from qgis.utils import iface 32 | 33 | 34 | 35 | 36 | # Initialize Qt resources from file resources.py 37 | #from .resources import * 38 | # Import the code for the dialog 39 | from .save_attributes_dialog import SaveAttributesDialog 40 | import os.path 41 | 42 | 43 | class SaveAttributes: 44 | """QGIS Plugin Implementation.""" 45 | 46 | def __init__(self, iface): 47 | """Constructor. 48 | 49 | :param iface: An interface instance that will be passed to this class 50 | which provides the hook by which you can manipulate the QGIS 51 | application at run time. 52 | :type iface: QgsInterface 53 | """ 54 | # Save reference to the QGIS interface 55 | self.iface = iface 56 | # initialize plugin directory 57 | self.plugin_dir = os.path.dirname(__file__) 58 | # initialize locale 59 | locale = QSettings().value('locale/userLocale')[0:2] 60 | locale_path = os.path.join( 61 | self.plugin_dir, 62 | 'i18n', 63 | 'SaveAttributes_{}.qm'.format(locale)) 64 | 65 | if os.path.exists(locale_path): 66 | self.translator = QTranslator() 67 | self.translator.load(locale_path) 68 | QCoreApplication.installTranslator(self.translator) 69 | 70 | # Declare instance attributes 71 | self.actions = [] 72 | self.menu = self.tr(u'&Save Attributes') 73 | 74 | # Check if plugin was started the first time in current QGIS session 75 | # Must be set in initGui() to survive plugin reloads 76 | self.first_start = None 77 | 78 | # noinspection PyMethodMayBeStatic 79 | def tr(self, message): 80 | """Get the translation for a string using Qt translation API. 81 | 82 | We implement this ourselves since we do not inherit QObject. 83 | 84 | :param message: String for translation. 85 | :type message: str, QString 86 | 87 | :returns: Translated version of message. 88 | :rtype: QString 89 | """ 90 | # noinspection PyTypeChecker,PyArgumentList,PyCallByClass 91 | return QCoreApplication.translate('SaveAttributes', message) 92 | 93 | 94 | def add_action( 95 | self, 96 | icon_path, 97 | text, 98 | callback, 99 | enabled_flag=True, 100 | add_to_menu=True, 101 | add_to_toolbar=True, 102 | status_tip=None, 103 | whats_this=None, 104 | parent=None): 105 | """Add a toolbar icon to the toolbar. 106 | 107 | :param icon_path: Path to the icon for this action. Can be a resource 108 | path (e.g. ':/plugins/foo/bar.png') or a normal file system path. 109 | :type icon_path: str 110 | 111 | :param text: Text that should be shown in menu items for this action. 112 | :type text: str 113 | 114 | :param callback: Function to be called when the action is triggered. 115 | :type callback: function 116 | 117 | :param enabled_flag: A flag indicating if the action should be enabled 118 | by default. Defaults to True. 119 | :type enabled_flag: bool 120 | 121 | :param add_to_menu: Flag indicating whether the action should also 122 | be added to the menu. Defaults to True. 123 | :type add_to_menu: bool 124 | 125 | :param add_to_toolbar: Flag indicating whether the action should also 126 | be added to the toolbar. Defaults to True. 127 | :type add_to_toolbar: bool 128 | 129 | :param status_tip: Optional text to show in a popup when mouse pointer 130 | hovers over the action. 131 | :type status_tip: str 132 | 133 | :param parent: Parent widget for the new action. Defaults None. 134 | :type parent: QWidget 135 | 136 | :param whats_this: Optional text to show in the status bar when the 137 | mouse pointer hovers over the action. 138 | 139 | :returns: The action that was created. Note that the action is also 140 | added to self.actions list. 141 | :rtype: QAction 142 | """ 143 | 144 | icon = QIcon(icon_path) 145 | action = QAction(icon, text, parent) 146 | action.triggered.connect(callback) 147 | action.setEnabled(enabled_flag) 148 | 149 | if status_tip is not None: 150 | action.setStatusTip(status_tip) 151 | 152 | if whats_this is not None: 153 | action.setWhatsThis(whats_this) 154 | 155 | if add_to_toolbar: 156 | # Adds plugin icon to Plugins toolbar 157 | self.iface.addToolBarIcon(action) 158 | 159 | if add_to_menu: 160 | self.iface.addPluginToVectorMenu( 161 | self.menu, 162 | action) 163 | 164 | self.actions.append(action) 165 | 166 | return action 167 | 168 | def initGui(self): 169 | """Create the menu entries and toolbar icons inside the QGIS GUI.""" 170 | 171 | icon_path = ':/plugins/save_attributes/icon.png' 172 | self.add_action( 173 | icon_path, 174 | text=self.tr(u''), 175 | callback=self.run, 176 | parent=self.iface.mainWindow()) 177 | 178 | # will be set False in run() 179 | self.first_start = True 180 | 181 | 182 | def unload(self): 183 | """Removes the plugin menu item and icon from QGIS GUI.""" 184 | for action in self.actions: 185 | self.iface.removePluginVectorMenu( 186 | self.tr(u'&Save Attributes'), 187 | action) 188 | self.iface.removeToolBarIcon(action) 189 | 190 | def select_output_file(self): 191 | filename, _filter = QFileDialog.getSaveFileName( 192 | self.dlg, 193 | "Select output file ", 194 | "", 195 | '*.csv') 196 | self.dlg.lineEdit.setText(filename) 197 | 198 | def input_shp_file(self): 199 | self.dlg.lineEdit_input_shp.setText("") 200 | self.dlg.comboBox_id.clear() 201 | self.shpPath, self._filter = QFileDialog.getOpenFileName(self.dlg, "Select input shp file","", 'ESRI Shapefiles(*.shp *.SHP);; GeoJSON (*.GEOJSON *.geojson);; Geography Markup Language(*.GML)') 202 | try: 203 | self.shp = ogr.Open(self.shpPath) 204 | self.layer = self.shp.GetLayer(0) 205 | self.name = self.layer.GetName() 206 | # self.sr = self.layer.GetSpatialRef().ExportToProj4() 207 | # If POINT, display . otherwise a LINE 208 | #self.dlg.m2_lbl_status.setText('

') 209 | self.dlg.lineEdit_input_shp.setText(self.shpPath) 210 | 211 | self.dlg.comboBox_id.clear() 212 | self.layerDef = self.layer.GetLayerDefn() 213 | self.fieldNames = [self.layerDef.GetFieldDefn(i).name for i in range(self.layerDef.GetFieldCount())] 214 | self.dlg.comboBox_id.addItems(self.fieldNames) 215 | except: 216 | self.dlg.label_wrong_input.setText('Wrong Input') 217 | 218 | # createShp is supposed to create a new shapefile. 219 | def createShp(self, input_line, costs, out_shp, sr): 220 | driver = ogr.GetDriverByName('Esri Shapefile') 221 | ds = driver.CreateDataSource(out_shp) 222 | srs = osr.SpatialReference() 223 | srs.ImportFromProj4(sr) 224 | layer = ds.CreateLayer('mst', srs, ogr.wkbLineString) 225 | layer.CreateField(ogr.FieldDefn('id', ogr.OFTInteger)) 226 | layer.CreateField(ogr.FieldDefn('cost', ogr.OFTReal)) 227 | defn = layer.GetLayerDefn() 228 | 229 | for e,i in enumerate(zip(input_line, costs)): 230 | feat = ogr.Feature(defn) 231 | feat.SetField('id', e) 232 | feat.SetField('cost', i[1]) 233 | 234 | # Geometry 235 | feat.SetGeometry(i[0]) 236 | layer.CreateFeature(feat) 237 | 238 | ds = layer = defn = feat = None 239 | 240 | def run(self): 241 | """Run method that performs all the real work""" 242 | 243 | # Create the dialog with elements (after translation) and keep reference 244 | # Only create GUI ONCE in callback, so that it will only load when the plugin is started 245 | if self.first_start == True: 246 | self.first_start = False 247 | self.dlg = SaveAttributesDialog() 248 | #self.dlg.pushButton.clicked.connect(self.select_output_file) 249 | self.dlg.pb_select_layer.clicked.connect(self.input_shp_file) 250 | 251 | 252 | 253 | # show the dialog 254 | self.dlg.show() 255 | # Run the dialog event loop 256 | result = self.dlg.exec_() 257 | # See if OK was pressed 258 | if result: 259 | # Do something useful here - delete the line containing pass and 260 | # substitute with your code. 261 | 262 | file_path = self.dlg.lineEdit_input_shp.text() 263 | # Open the shp file 264 | # Second argument tell whether to read (0, default), or to update (1) 265 | ds = ogr.Open(file_path,0) 266 | 267 | if ds is None: 268 | sys.exit('Could not open {0}.'.format(file_path)) 269 | 270 | # Obtain the layer 271 | lyr = ds.GetLayer() 272 | 273 | # Runs, but does not create a new field------------- 274 | # lyr.CreateField(ogr.FieldDefn('x', ogr.OFTReal)) 275 | # lyr.CreateField(ogr.FieldDefn('y', ogr.OFTReal)) 276 | # # Runs, but does not create a new field------------- 277 | 278 | if (lyr.GetGeomType() == ogr.wkbPoint): #wkb: wll known binary 279 | type_of_layer = "point" 280 | elif(lyr.GetGeomType() == ogr.wkbLineString): 281 | type_of_layer = "line" 282 | elif(lyr.GetGeomType() == ogr.wkbPolygon): 283 | type_of_layer = "polygon" 284 | 285 | 286 | vlayer = QgsVectorLayer(self.dlg.lineEdit_input_shp.text(), 287 | type_of_layer, 288 | "ogr") 289 | 290 | 291 | 292 | 293 | # Obtain the chosen ID field - it is supposed to be ID. 294 | # Note: If the "No ID" checkbox is checked, we should not include ID's in the newly created shp file. 295 | idFieldName = self.dlg.comboBox_id.currentText() 296 | 297 | 298 | # Number of features/records 299 | num_features = lyr.GetFeatureCount() 300 | print("Number of features: ", num_features) 301 | 302 | if not vlayer.isValid(): 303 | print("Layer failed to load!") 304 | else: 305 | QgsProject.instance().addMapLayer(vlayer) 306 | # QgsMapLayerRegistry.instance().addMapLayer(vlayer) #test this statement 307 | 308 | # Add two new attributes to the vlayer: the POIs X and Y 309 | # Field definition 310 | vlayer = iface.activeLayer() 311 | # Start editing this virtual layer 312 | 313 | vlayer.startEditing() 314 | layer_provider = vlayer.dataProvider() 315 | layer_provider.addAttributes([QgsField('x', QVariant.Double), 316 | QgsField('y', QVariant.Double)]) 317 | vlayer.updateFields() 318 | vlayer.commitChanges() 319 | 320 | # Iterate over all POIs and add their coordinates to the newly defined fields 321 | layer = iface.activeLayer() 322 | 323 | if(type_of_layer == "point"): 324 | 325 | layer.startEditing() 326 | all_features = layer.getFeatures() 327 | 328 | for feat in all_features: 329 | geom = feat.geometry() 330 | x = geom.asPoint().x() 331 | y = geom.asPoint().y() 332 | #print(x,y) #OK 333 | #x = pt.GetX() does not exist in PyQGIS 334 | #y = pt.GetY() 335 | 336 | # X 337 | new_x = {feat.fieldNameIndex('x'): x} 338 | layer.dataProvider().changeAttributeValues({feat.id(): new_x }) 339 | # Question: What is the difference between changeAttributeValue() changeAttributeValues()? 340 | # REF: https://qgis.org/api/classQgsVectorLayer.html#aaf39ac56bb98c118b881e512e07c5d76 341 | # changeAttributeValue() does not work in QGIS 3.12. 342 | 343 | 344 | # Y 345 | new_y = {feat.fieldNameIndex('y'): y} 346 | layer.dataProvider().changeAttributeValues({feat.id(): new_y }) 347 | 348 | # Does not work: 349 | #feat["x"] = x 350 | #feat["y"] = y 351 | 352 | #layer.updateFeature(feat.id()) 353 | # Commit changes 354 | layer.commitChanges() 355 | -------------------------------------------------------------------------------- /code/save_attributes/save_attributes_dialog.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | /*************************************************************************** 4 | SaveAttributesDialog 5 | A QGIS plugin 6 | This plugin saves the attribute of the selected vector layer as a csv file. 7 | Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ 8 | ------------------- 9 | begin : 2020-10-30 10 | git sha : $Format:%H$ 11 | copyright : (C) 2020 by Berk Anbaroğlu 12 | email : banbar@hacettepe.edu.tr 13 | ***************************************************************************/ 14 | 15 | /*************************************************************************** 16 | * * 17 | * This program is free software; you can redistribute it and/or modify * 18 | * it under the terms of the GNU General Public License as published by * 19 | * the Free Software Foundation; either version 2 of the License, or * 20 | * (at your option) any later version. * 21 | * * 22 | ***************************************************************************/ 23 | """ 24 | 25 | import os 26 | 27 | from qgis.PyQt import uic 28 | from qgis.PyQt import QtWidgets 29 | 30 | # This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer 31 | FORM_CLASS, _ = uic.loadUiType(os.path.join( 32 | os.path.dirname(__file__), 'save_attributes_dialog_base.ui')) 33 | 34 | 35 | class SaveAttributesDialog(QtWidgets.QDialog, FORM_CLASS): 36 | def __init__(self, parent=None): 37 | """Constructor.""" 38 | super(SaveAttributesDialog, self).__init__(parent) 39 | # Set up the user interface from Designer through FORM_CLASS. 40 | # After self.setupUi() you can access any designer object by doing 41 | # self., and you can use autoconnect slots - see 42 | # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html 43 | # #widgets-and-dialogs-with-auto-connect 44 | self.setupUi(self) 45 | -------------------------------------------------------------------------------- /code/save_attributes/save_attributes_dialog_base.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | SaveAttributesDialogBase 4 | 5 | 6 | 7 | 0 8 | 0 9 | 720 10 | 305 11 | 12 | 13 | 14 | 15 | 50 16 | false 17 | 18 | 19 | 20 | Save Attributes 21 | 22 | 23 | 24 | 25 | 30 26 | 240 27 | 341 28 | 32 29 | 30 | 31 | 32 | 33 | MS Shell Dlg 2 34 | 35 | 36 | 37 | Qt::Horizontal 38 | 39 | 40 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 41 | 42 | 43 | 44 | 45 | 46 | 20 47 | 40 48 | 161 49 | 20 50 | 51 | 52 | 53 | 54 | 10 55 | 56 | 57 | 58 | Input file 59 | 60 | 61 | 62 | 63 | 64 | 90 65 | 40 66 | 281 67 | 31 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 370 80 | 40 81 | 95 82 | 31 83 | 84 | 85 | 86 | 87 | 88 | 89 | ... 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 470 99 | 20 100 | 201 101 | 61 102 | 103 | 104 | 105 | ID field 106 | 107 | 108 | 109 | 110 | 10 111 | 20 112 | 101 113 | 22 114 | 115 | 116 | 117 | 118 | 119 | 120 | 120 121 | 20 122 | 81 123 | 20 124 | 125 | 126 | 127 | No ID 128 | 129 | 130 | 131 | 132 | 133 | 134 | 90 135 | 80 136 | 81 137 | 16 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | button_box 149 | accepted() 150 | SaveAttributesDialogBase 151 | accept() 152 | 153 | 154 | 20 155 | 20 156 | 157 | 158 | 20 159 | 20 160 | 161 | 162 | 163 | 164 | button_box 165 | rejected() 166 | SaveAttributesDialogBase 167 | reject() 168 | 169 | 170 | 20 171 | 20 172 | 173 | 174 | 20 175 | 20 176 | 177 | 178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /code/save_attributes/scripts/compile-strings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LRELEASE=$1 3 | LOCALES=$2 4 | 5 | 6 | for LOCALE in ${LOCALES} 7 | do 8 | echo "Processing: ${LOCALE}.ts" 9 | # Note we don't use pylupdate with qt .pro file approach as it is flakey 10 | # about what is made available. 11 | $LRELEASE i18n/${LOCALE}.ts 12 | done 13 | -------------------------------------------------------------------------------- /code/save_attributes/scripts/run-env-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | QGIS_PREFIX_PATH=/usr/local/qgis-2.0 4 | if [ -n "$1" ]; then 5 | QGIS_PREFIX_PATH=$1 6 | fi 7 | 8 | echo ${QGIS_PREFIX_PATH} 9 | 10 | 11 | export QGIS_PREFIX_PATH=${QGIS_PREFIX_PATH} 12 | export QGIS_PATH=${QGIS_PREFIX_PATH} 13 | export LD_LIBRARY_PATH=${QGIS_PREFIX_PATH}/lib 14 | export PYTHONPATH=${QGIS_PREFIX_PATH}/share/qgis/python:${QGIS_PREFIX_PATH}/share/qgis/python/plugins:${PYTHONPATH} 15 | 16 | echo "QGIS PATH: $QGIS_PREFIX_PATH" 17 | export QGIS_DEBUG=0 18 | export QGIS_LOG_FILE=/tmp/inasafe/realtime/logs/qgis.log 19 | 20 | export PATH=${QGIS_PREFIX_PATH}/bin:$PATH 21 | 22 | echo "This script is intended to be sourced to set up your shell to" 23 | echo "use a QGIS 2.0 built in $QGIS_PREFIX_PATH" 24 | echo 25 | echo "To use it do:" 26 | echo "source $BASH_SOURCE /your/optional/install/path" 27 | echo 28 | echo "Then use the make file supplied here e.g. make guitest" 29 | -------------------------------------------------------------------------------- /code/save_attributes/scripts/update-strings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | LOCALES=$* 3 | 4 | # Get newest .py files so we don't update strings unnecessarily 5 | 6 | CHANGED_FILES=0 7 | PYTHON_FILES=`find . -regex ".*\(ui\|py\)$" -type f` 8 | for PYTHON_FILE in $PYTHON_FILES 9 | do 10 | CHANGED=$(stat -c %Y $PYTHON_FILE) 11 | if [ ${CHANGED} -gt ${CHANGED_FILES} ] 12 | then 13 | CHANGED_FILES=${CHANGED} 14 | fi 15 | done 16 | 17 | # Qt translation stuff 18 | # for .ts file 19 | UPDATE=false 20 | for LOCALE in ${LOCALES} 21 | do 22 | TRANSLATION_FILE="i18n/$LOCALE.ts" 23 | if [ ! -f ${TRANSLATION_FILE} ] 24 | then 25 | # Force translation string collection as we have a new language file 26 | touch ${TRANSLATION_FILE} 27 | UPDATE=true 28 | break 29 | fi 30 | 31 | MODIFICATION_TIME=$(stat -c %Y ${TRANSLATION_FILE}) 32 | if [ ${CHANGED_FILES} -gt ${MODIFICATION_TIME} ] 33 | then 34 | # Force translation string collection as a .py file has been updated 35 | UPDATE=true 36 | break 37 | fi 38 | done 39 | 40 | if [ ${UPDATE} == true ] 41 | # retrieve all python files 42 | then 43 | echo ${PYTHON_FILES} 44 | # update .ts 45 | echo "Please provide translations by editing the translation files below:" 46 | for LOCALE in ${LOCALES} 47 | do 48 | echo "i18n/"${LOCALE}".ts" 49 | # Note we don't use pylupdate with qt .pro file approach as it is flakey 50 | # about what is made available. 51 | pylupdate4 -noobsolete ${PYTHON_FILES} -ts i18n/${LOCALE}.ts 52 | done 53 | else 54 | echo "No need to edit any translation files (.ts) because no python files" 55 | echo "has been updated since the last update translation. " 56 | fi 57 | -------------------------------------------------------------------------------- /code/save_attributes/test/__init__.py: -------------------------------------------------------------------------------- 1 | # import qgis libs so that ve set the correct sip api version 2 | import qgis # pylint: disable=W0611 # NOQA -------------------------------------------------------------------------------- /code/save_attributes/test/qgis_interface.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """QGIS plugin implementation. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | .. note:: This source code was copied from the 'postgis viewer' application 10 | with original authors: 11 | Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk 12 | Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org 13 | Copyright (c) 2014 Tim Sutton, tim@linfiniti.com 14 | 15 | """ 16 | 17 | __author__ = 'tim@linfiniti.com' 18 | __revision__ = '$Format:%H$' 19 | __date__ = '10/01/2011' 20 | __copyright__ = ( 21 | 'Copyright (c) 2010 by Ivan Mincik, ivan.mincik@gista.sk and ' 22 | 'Copyright (c) 2011 German Carrillo, geotux_tuxman@linuxmail.org' 23 | 'Copyright (c) 2014 Tim Sutton, tim@linfiniti.com' 24 | ) 25 | 26 | import logging 27 | from qgis.PyQt.QtCore import QObject, pyqtSlot, pyqtSignal 28 | from qgis.core import QgsMapLayerRegistry 29 | from qgis.gui import QgsMapCanvasLayer 30 | LOGGER = logging.getLogger('QGIS') 31 | 32 | 33 | #noinspection PyMethodMayBeStatic,PyPep8Naming 34 | class QgisInterface(QObject): 35 | """Class to expose QGIS objects and functions to plugins. 36 | 37 | This class is here for enabling us to run unit tests only, 38 | so most methods are simply stubs. 39 | """ 40 | currentLayerChanged = pyqtSignal(QgsMapCanvasLayer) 41 | 42 | def __init__(self, canvas): 43 | """Constructor 44 | :param canvas: 45 | """ 46 | QObject.__init__(self) 47 | self.canvas = canvas 48 | # Set up slots so we can mimic the behaviour of QGIS when layers 49 | # are added. 50 | LOGGER.debug('Initialising canvas...') 51 | # noinspection PyArgumentList 52 | QgsMapLayerRegistry.instance().layersAdded.connect(self.addLayers) 53 | # noinspection PyArgumentList 54 | QgsMapLayerRegistry.instance().layerWasAdded.connect(self.addLayer) 55 | # noinspection PyArgumentList 56 | QgsMapLayerRegistry.instance().removeAll.connect(self.removeAllLayers) 57 | 58 | # For processing module 59 | self.destCrs = None 60 | 61 | @pyqtSlot('QStringList') 62 | def addLayers(self, layers): 63 | """Handle layers being added to the registry so they show up in canvas. 64 | 65 | :param layers: list list of map layers that were added 66 | 67 | .. note:: The QgsInterface api does not include this method, 68 | it is added here as a helper to facilitate testing. 69 | """ 70 | #LOGGER.debug('addLayers called on qgis_interface') 71 | #LOGGER.debug('Number of layers being added: %s' % len(layers)) 72 | #LOGGER.debug('Layer Count Before: %s' % len(self.canvas.layers())) 73 | current_layers = self.canvas.layers() 74 | final_layers = [] 75 | for layer in current_layers: 76 | final_layers.append(QgsMapCanvasLayer(layer)) 77 | for layer in layers: 78 | final_layers.append(QgsMapCanvasLayer(layer)) 79 | 80 | self.canvas.setLayerSet(final_layers) 81 | #LOGGER.debug('Layer Count After: %s' % len(self.canvas.layers())) 82 | 83 | @pyqtSlot('QgsMapLayer') 84 | def addLayer(self, layer): 85 | """Handle a layer being added to the registry so it shows up in canvas. 86 | 87 | :param layer: list list of map layers that were added 88 | 89 | .. note: The QgsInterface api does not include this method, it is added 90 | here as a helper to facilitate testing. 91 | 92 | .. note: The addLayer method was deprecated in QGIS 1.8 so you should 93 | not need this method much. 94 | """ 95 | pass 96 | 97 | @pyqtSlot() 98 | def removeAllLayers(self): 99 | """Remove layers from the canvas before they get deleted.""" 100 | self.canvas.setLayerSet([]) 101 | 102 | def newProject(self): 103 | """Create new project.""" 104 | # noinspection PyArgumentList 105 | QgsMapLayerRegistry.instance().removeAllMapLayers() 106 | 107 | # ---------------- API Mock for QgsInterface follows ------------------- 108 | 109 | def zoomFull(self): 110 | """Zoom to the map full extent.""" 111 | pass 112 | 113 | def zoomToPrevious(self): 114 | """Zoom to previous view extent.""" 115 | pass 116 | 117 | def zoomToNext(self): 118 | """Zoom to next view extent.""" 119 | pass 120 | 121 | def zoomToActiveLayer(self): 122 | """Zoom to extent of active layer.""" 123 | pass 124 | 125 | def addVectorLayer(self, path, base_name, provider_key): 126 | """Add a vector layer. 127 | 128 | :param path: Path to layer. 129 | :type path: str 130 | 131 | :param base_name: Base name for layer. 132 | :type base_name: str 133 | 134 | :param provider_key: Provider key e.g. 'ogr' 135 | :type provider_key: str 136 | """ 137 | pass 138 | 139 | def addRasterLayer(self, path, base_name): 140 | """Add a raster layer given a raster layer file name 141 | 142 | :param path: Path to layer. 143 | :type path: str 144 | 145 | :param base_name: Base name for layer. 146 | :type base_name: str 147 | """ 148 | pass 149 | 150 | def activeLayer(self): 151 | """Get pointer to the active layer (layer selected in the legend).""" 152 | # noinspection PyArgumentList 153 | layers = QgsMapLayerRegistry.instance().mapLayers() 154 | for item in layers: 155 | return layers[item] 156 | 157 | def addToolBarIcon(self, action): 158 | """Add an icon to the plugins toolbar. 159 | 160 | :param action: Action to add to the toolbar. 161 | :type action: QAction 162 | """ 163 | pass 164 | 165 | def removeToolBarIcon(self, action): 166 | """Remove an action (icon) from the plugin toolbar. 167 | 168 | :param action: Action to add to the toolbar. 169 | :type action: QAction 170 | """ 171 | pass 172 | 173 | def addToolBar(self, name): 174 | """Add toolbar with specified name. 175 | 176 | :param name: Name for the toolbar. 177 | :type name: str 178 | """ 179 | pass 180 | 181 | def mapCanvas(self): 182 | """Return a pointer to the map canvas.""" 183 | return self.canvas 184 | 185 | def mainWindow(self): 186 | """Return a pointer to the main window. 187 | 188 | In case of QGIS it returns an instance of QgisApp. 189 | """ 190 | pass 191 | 192 | def addDockWidget(self, area, dock_widget): 193 | """Add a dock widget to the main window. 194 | 195 | :param area: Where in the ui the dock should be placed. 196 | :type area: 197 | 198 | :param dock_widget: A dock widget to add to the UI. 199 | :type dock_widget: QDockWidget 200 | """ 201 | pass 202 | 203 | def legendInterface(self): 204 | """Get the legend.""" 205 | return self.canvas 206 | -------------------------------------------------------------------------------- /code/save_attributes/test/tenbytenraster.asc: -------------------------------------------------------------------------------- 1 | NCOLS 10 2 | NROWS 10 3 | XLLCENTER 1535380.000000 4 | YLLCENTER 5083260.000000 5 | DX 10 6 | DY 10 7 | NODATA_VALUE -9999 8 | 0 1 2 3 4 5 6 7 8 9 9 | 0 1 2 3 4 5 6 7 8 9 10 | 0 1 2 3 4 5 6 7 8 9 11 | 0 1 2 3 4 5 6 7 8 9 12 | 0 1 2 3 4 5 6 7 8 9 13 | 0 1 2 3 4 5 6 7 8 9 14 | 0 1 2 3 4 5 6 7 8 9 15 | 0 1 2 3 4 5 6 7 8 9 16 | 0 1 2 3 4 5 6 7 8 9 17 | 0 1 2 3 4 5 6 7 8 9 18 | CRS 19 | NOTES 20 | -------------------------------------------------------------------------------- /code/save_attributes/test/tenbytenraster.asc.aux.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Point 4 | 5 | 6 | 7 | 9 8 | 4.5 9 | 0 10 | 2.872281323269 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /code/save_attributes/test/tenbytenraster.keywords: -------------------------------------------------------------------------------- 1 | title: Tenbytenraster 2 | -------------------------------------------------------------------------------- /code/save_attributes/test/tenbytenraster.lic: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tim Sutton, Linfiniti Consulting CC 5 | 6 | 7 | 8 | tenbytenraster.asc 9 | 2700044251 10 | Yes 11 | Tim Sutton 12 | Tim Sutton (QGIS Source Tree) 13 | Tim Sutton 14 | This data is publicly available from QGIS Source Tree. The original 15 | file was created and contributed to QGIS by Tim Sutton. 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /code/save_attributes/test/tenbytenraster.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /code/save_attributes/test/tenbytenraster.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 0 26 | 27 | -------------------------------------------------------------------------------- /code/save_attributes/test/test_init.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Tests QGIS plugin init.""" 3 | 4 | __author__ = 'Tim Sutton ' 5 | __revision__ = '$Format:%H$' 6 | __date__ = '17/10/2010' 7 | __license__ = "GPL" 8 | __copyright__ = 'Copyright 2012, Australia Indonesia Facility for ' 9 | __copyright__ += 'Disaster Reduction' 10 | 11 | import os 12 | import unittest 13 | import logging 14 | import configparser 15 | 16 | LOGGER = logging.getLogger('QGIS') 17 | 18 | 19 | class TestInit(unittest.TestCase): 20 | """Test that the plugin init is usable for QGIS. 21 | 22 | Based heavily on the validator class by Alessandro 23 | Passoti available here: 24 | 25 | http://github.com/qgis/qgis-django/blob/master/qgis-app/ 26 | plugins/validator.py 27 | 28 | """ 29 | 30 | def test_read_init(self): 31 | """Test that the plugin __init__ will validate on plugins.qgis.org.""" 32 | 33 | # You should update this list according to the latest in 34 | # https://github.com/qgis/qgis-django/blob/master/qgis-app/ 35 | # plugins/validator.py 36 | 37 | required_metadata = [ 38 | 'name', 39 | 'description', 40 | 'version', 41 | 'qgisMinimumVersion', 42 | 'email', 43 | 'author'] 44 | 45 | file_path = os.path.abspath(os.path.join( 46 | os.path.dirname(__file__), os.pardir, 47 | 'metadata.txt')) 48 | LOGGER.info(file_path) 49 | metadata = [] 50 | parser = configparser.ConfigParser() 51 | parser.optionxform = str 52 | parser.read(file_path) 53 | message = 'Cannot find a section named "general" in %s' % file_path 54 | assert parser.has_section('general'), message 55 | metadata.extend(parser.items('general')) 56 | 57 | for expectation in required_metadata: 58 | message = ('Cannot find metadata "%s" in metadata source (%s).' % ( 59 | expectation, file_path)) 60 | 61 | self.assertIn(expectation, dict(metadata), message) 62 | 63 | if __name__ == '__main__': 64 | unittest.main() 65 | -------------------------------------------------------------------------------- /code/save_attributes/test/test_qgis_environment.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Tests for QGIS functionality. 3 | 4 | 5 | .. note:: This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | """ 11 | __author__ = 'tim@linfiniti.com' 12 | __date__ = '20/01/2011' 13 | __copyright__ = ('Copyright 2012, Australia Indonesia Facility for ' 14 | 'Disaster Reduction') 15 | 16 | import os 17 | import unittest 18 | from qgis.core import ( 19 | QgsProviderRegistry, 20 | QgsCoordinateReferenceSystem, 21 | QgsRasterLayer) 22 | 23 | from .utilities import get_qgis_app 24 | QGIS_APP = get_qgis_app() 25 | 26 | 27 | class QGISTest(unittest.TestCase): 28 | """Test the QGIS Environment""" 29 | 30 | def test_qgis_environment(self): 31 | """QGIS environment has the expected providers""" 32 | 33 | r = QgsProviderRegistry.instance() 34 | self.assertIn('gdal', r.providerList()) 35 | self.assertIn('ogr', r.providerList()) 36 | self.assertIn('postgres', r.providerList()) 37 | 38 | def test_projection(self): 39 | """Test that QGIS properly parses a wkt string. 40 | """ 41 | crs = QgsCoordinateReferenceSystem() 42 | wkt = ( 43 | 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",' 44 | 'SPHEROID["WGS_1984",6378137.0,298.257223563]],' 45 | 'PRIMEM["Greenwich",0.0],UNIT["Degree",' 46 | '0.0174532925199433]]') 47 | crs.createFromWkt(wkt) 48 | auth_id = crs.authid() 49 | expected_auth_id = 'EPSG:4326' 50 | self.assertEqual(auth_id, expected_auth_id) 51 | 52 | # now test for a loaded layer 53 | path = os.path.join(os.path.dirname(__file__), 'tenbytenraster.asc') 54 | title = 'TestRaster' 55 | layer = QgsRasterLayer(path, title) 56 | auth_id = layer.crs().authid() 57 | self.assertEqual(auth_id, expected_auth_id) 58 | 59 | if __name__ == '__main__': 60 | unittest.main() 61 | -------------------------------------------------------------------------------- /code/save_attributes/test/test_resources.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Resources test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | 11 | __author__ = 'banbar@hacettepe.edu.tr' 12 | __date__ = '2020-10-30' 13 | __copyright__ = 'Copyright 2020, Berk Anbaroğlu' 14 | 15 | import unittest 16 | 17 | from qgis.PyQt.QtGui import QIcon 18 | 19 | 20 | 21 | class SaveAttributesDialogTest(unittest.TestCase): 22 | """Test rerources work.""" 23 | 24 | def setUp(self): 25 | """Runs before each test.""" 26 | pass 27 | 28 | def tearDown(self): 29 | """Runs after each test.""" 30 | pass 31 | 32 | def test_icon_png(self): 33 | """Test we can click OK.""" 34 | path = ':/plugins/SaveAttributes/icon.png' 35 | icon = QIcon(path) 36 | self.assertFalse(icon.isNull()) 37 | 38 | if __name__ == "__main__": 39 | suite = unittest.makeSuite(SaveAttributesResourcesTest) 40 | runner = unittest.TextTestRunner(verbosity=2) 41 | runner.run(suite) 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /code/save_attributes/test/test_save_attributes_dialog.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Dialog test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | 11 | __author__ = 'banbar@hacettepe.edu.tr' 12 | __date__ = '2020-10-30' 13 | __copyright__ = 'Copyright 2020, Berk Anbaroğlu' 14 | 15 | import unittest 16 | 17 | from qgis.PyQt.QtGui import QDialogButtonBox, QDialog 18 | 19 | from save_attributes_dialog import SaveAttributesDialog 20 | 21 | from utilities import get_qgis_app 22 | QGIS_APP = get_qgis_app() 23 | 24 | 25 | class SaveAttributesDialogTest(unittest.TestCase): 26 | """Test dialog works.""" 27 | 28 | def setUp(self): 29 | """Runs before each test.""" 30 | self.dialog = SaveAttributesDialog(None) 31 | 32 | def tearDown(self): 33 | """Runs after each test.""" 34 | self.dialog = None 35 | 36 | def test_dialog_ok(self): 37 | """Test we can click OK.""" 38 | 39 | button = self.dialog.button_box.button(QDialogButtonBox.Ok) 40 | button.click() 41 | result = self.dialog.result() 42 | self.assertEqual(result, QDialog.Accepted) 43 | 44 | def test_dialog_cancel(self): 45 | """Test we can click cancel.""" 46 | button = self.dialog.button_box.button(QDialogButtonBox.Cancel) 47 | button.click() 48 | result = self.dialog.result() 49 | self.assertEqual(result, QDialog.Rejected) 50 | 51 | if __name__ == "__main__": 52 | suite = unittest.makeSuite(SaveAttributesDialogTest) 53 | runner = unittest.TextTestRunner(verbosity=2) 54 | runner.run(suite) 55 | 56 | -------------------------------------------------------------------------------- /code/save_attributes/test/test_translations.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Safe Translations Test. 3 | 4 | .. note:: This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | """ 10 | from .utilities import get_qgis_app 11 | 12 | __author__ = 'ismailsunni@yahoo.co.id' 13 | __date__ = '12/10/2011' 14 | __copyright__ = ('Copyright 2012, Australia Indonesia Facility for ' 15 | 'Disaster Reduction') 16 | import unittest 17 | import os 18 | 19 | from qgis.PyQt.QtCore import QCoreApplication, QTranslator 20 | 21 | QGIS_APP = get_qgis_app() 22 | 23 | 24 | class SafeTranslationsTest(unittest.TestCase): 25 | """Test translations work.""" 26 | 27 | def setUp(self): 28 | """Runs before each test.""" 29 | if 'LANG' in iter(os.environ.keys()): 30 | os.environ.__delitem__('LANG') 31 | 32 | def tearDown(self): 33 | """Runs after each test.""" 34 | if 'LANG' in iter(os.environ.keys()): 35 | os.environ.__delitem__('LANG') 36 | 37 | def test_qgis_translations(self): 38 | """Test that translations work.""" 39 | parent_path = os.path.join(__file__, os.path.pardir, os.path.pardir) 40 | dir_path = os.path.abspath(parent_path) 41 | file_path = os.path.join( 42 | dir_path, 'i18n', 'af.qm') 43 | translator = QTranslator() 44 | translator.load(file_path) 45 | QCoreApplication.installTranslator(translator) 46 | 47 | expected_message = 'Goeie more' 48 | real_message = QCoreApplication.translate("@default", 'Good morning') 49 | self.assertEqual(real_message, expected_message) 50 | 51 | 52 | if __name__ == "__main__": 53 | suite = unittest.makeSuite(SafeTranslationsTest) 54 | runner = unittest.TextTestRunner(verbosity=2) 55 | runner.run(suite) 56 | -------------------------------------------------------------------------------- /code/save_attributes/test/utilities.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | """Common functionality used by regression tests.""" 3 | 4 | import sys 5 | import logging 6 | 7 | 8 | LOGGER = logging.getLogger('QGIS') 9 | QGIS_APP = None # Static variable used to hold hand to running QGIS app 10 | CANVAS = None 11 | PARENT = None 12 | IFACE = None 13 | 14 | 15 | def get_qgis_app(): 16 | """ Start one QGIS application to test against. 17 | 18 | :returns: Handle to QGIS app, canvas, iface and parent. If there are any 19 | errors the tuple members will be returned as None. 20 | :rtype: (QgsApplication, CANVAS, IFACE, PARENT) 21 | 22 | If QGIS is already running the handle to that app will be returned. 23 | """ 24 | 25 | try: 26 | from qgis.PyQt import QtGui, QtCore 27 | from qgis.core import QgsApplication 28 | from qgis.gui import QgsMapCanvas 29 | from .qgis_interface import QgisInterface 30 | except ImportError: 31 | return None, None, None, None 32 | 33 | global QGIS_APP # pylint: disable=W0603 34 | 35 | if QGIS_APP is None: 36 | gui_flag = True # All test will run qgis in gui mode 37 | #noinspection PyPep8Naming 38 | QGIS_APP = QgsApplication(sys.argv, gui_flag) 39 | # Make sure QGIS_PREFIX_PATH is set in your env if needed! 40 | QGIS_APP.initQgis() 41 | s = QGIS_APP.showSettings() 42 | LOGGER.debug(s) 43 | 44 | global PARENT # pylint: disable=W0603 45 | if PARENT is None: 46 | #noinspection PyPep8Naming 47 | PARENT = QtGui.QWidget() 48 | 49 | global CANVAS # pylint: disable=W0603 50 | if CANVAS is None: 51 | #noinspection PyPep8Naming 52 | CANVAS = QgsMapCanvas(PARENT) 53 | CANVAS.resize(QtCore.QSize(400, 400)) 54 | 55 | global IFACE # pylint: disable=W0603 56 | if IFACE is None: 57 | # QgisInterface is a stub implementation of the QGIS plugin interface 58 | #noinspection PyPep8Naming 59 | IFACE = QgisInterface(CANVAS) 60 | 61 | return QGIS_APP, CANVAS, IFACE, PARENT 62 | -------------------------------------------------------------------------------- /data/Readme.md: -------------------------------------------------------------------------------- 1 | # Credit 2 | 3 | * Landcover data was kindly obtained from: [https://landcover.ai/](https://landcover.ai/). 4 | -------------------------------------------------------------------------------- /data/beytepe/c_beytepe.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /data/beytepe/c_beytepe.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/c_beytepe.dbf -------------------------------------------------------------------------------- /data/beytepe/c_beytepe.prj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/beytepe/c_beytepe.qpj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]] 2 | -------------------------------------------------------------------------------- /data/beytepe/c_beytepe.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/c_beytepe.shp -------------------------------------------------------------------------------- /data/beytepe/c_beytepe.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/c_beytepe.shx -------------------------------------------------------------------------------- /data/beytepe/n_beytepe.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /data/beytepe/n_beytepe.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/n_beytepe.dbf -------------------------------------------------------------------------------- /data/beytepe/n_beytepe.prj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/beytepe/n_beytepe.qpj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]] 2 | -------------------------------------------------------------------------------- /data/beytepe/n_beytepe.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/n_beytepe.shp -------------------------------------------------------------------------------- /data/beytepe/n_beytepe.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/n_beytepe.shx -------------------------------------------------------------------------------- /data/beytepe/n_beytepe_WGS84.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/n_beytepe_WGS84.dbf -------------------------------------------------------------------------------- /data/beytepe/n_beytepe_WGS84.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /data/beytepe/n_beytepe_WGS84.qpj: -------------------------------------------------------------------------------- 1 | GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]] 2 | -------------------------------------------------------------------------------- /data/beytepe/n_beytepe_WGS84.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/n_beytepe_WGS84.shp -------------------------------------------------------------------------------- /data/beytepe/n_beytepe_WGS84.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/n_beytepe_WGS84.shx -------------------------------------------------------------------------------- /data/beytepe/p_beytepe.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /data/beytepe/p_beytepe.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/p_beytepe.dbf -------------------------------------------------------------------------------- /data/beytepe/p_beytepe.prj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/beytepe/p_beytepe.qpj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]] 2 | -------------------------------------------------------------------------------- /data/beytepe/p_beytepe.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/p_beytepe.shp -------------------------------------------------------------------------------- /data/beytepe/p_beytepe.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/beytepe/p_beytepe.shx -------------------------------------------------------------------------------- /data/cities/p_iller.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /data/cities/p_iller.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/cities/p_iller.dbf -------------------------------------------------------------------------------- /data/cities/p_iller.prj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/cities/p_iller.qpj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]] 2 | -------------------------------------------------------------------------------- /data/cities/p_iller.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/cities/p_iller.shp -------------------------------------------------------------------------------- /data/cities/p_iller.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/cities/p_iller.shx -------------------------------------------------------------------------------- /data/districts/p_ilceler.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /data/districts/p_ilceler.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/districts/p_ilceler.dbf -------------------------------------------------------------------------------- /data/districts/p_ilceler.prj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/districts/p_ilceler.qpj: -------------------------------------------------------------------------------- 1 | PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]] 2 | -------------------------------------------------------------------------------- /data/districts/p_ilceler.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/districts/p_ilceler.shp -------------------------------------------------------------------------------- /data/districts/p_ilceler.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/districts/p_ilceler.shx -------------------------------------------------------------------------------- /data/landcover/N-34-97-C-b-1-2-m.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/landcover/N-34-97-C-b-1-2-m.tif -------------------------------------------------------------------------------- /data/landcover/N-34-97-C-b-1-2.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/landcover/N-34-97-C-b-1-2.tif -------------------------------------------------------------------------------- /data/landcover/buildings.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /data/landcover/buildings.prj: -------------------------------------------------------------------------------- 1 | PROJCS["Projection_Transverse_Mercator_Datum_WGS84_Ellipsoid_WGS84",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",-5300000.0],PARAMETER["Central_Meridian",19.0],PARAMETER["Scale_Factor",0.9993],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/landcover/buildings.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/landcover/buildings.shp -------------------------------------------------------------------------------- /data/landcover/buildings.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/landcover/buildings.shx -------------------------------------------------------------------------------- /data/landcover/data_2180/selected_poi.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "name": "selected_poi", 4 | "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::2180" } }, 5 | "features": [ 6 | { "type": "Feature", "properties": { "id": 3 }, "geometry": { "type": "Point", "coordinates": [ 444317.888724730641115, 588535.438238060101867 ] } }, 7 | { "type": "Feature", "properties": { "id": 2 }, "geometry": { "type": "Point", "coordinates": [ 444008.84031816071365, 588667.068272814154625 ] } }, 8 | { "type": "Feature", "properties": { "id": 1 }, "geometry": { "type": "Point", "coordinates": [ 444749.813415395561606, 588675.020104575902224 ] } }, 9 | { "type": "Feature", "properties": { "id": 4 }, "geometry": { "type": "Point", "coordinates": [ 444195.64539226226043, 589242.279568919911981 ] } } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /data/landcover/selected_poi.cpg: -------------------------------------------------------------------------------- 1 | UTF-8 -------------------------------------------------------------------------------- /data/landcover/selected_poi.dbf: -------------------------------------------------------------------------------- 1 | y A idN 2 | 3 2 1 4 -------------------------------------------------------------------------------- /data/landcover/selected_poi.prj: -------------------------------------------------------------------------------- 1 | PROJCS["Projection_Transverse_Mercator_Datum_WGS84_Ellipsoid_WGS84",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",-5300000.0],PARAMETER["Central_Meridian",19.0],PARAMETER["Scale_Factor",0.9993],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /data/landcover/selected_poi.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/landcover/selected_poi.shp -------------------------------------------------------------------------------- /data/landcover/selected_poi.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/data/landcover/selected_poi.shx -------------------------------------------------------------------------------- /data/selected_poi.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "name": "selected_poi", 4 | "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3857" } }, 5 | "features": [ 6 | { "type": "Feature", "properties": { "id": 3 }, "geometry": { "type": "Point", "coordinates": [ 2022337.412444498389959, 7012497.94419336412102 ] } }, 7 | { "type": "Feature", "properties": { "id": 2 }, "geometry": { "type": "Point", "coordinates": [ 2021820.218788574915379, 7012711.649294756352901 ] } }, 8 | { "type": "Feature", "properties": { "id": 1 }, "geometry": { "type": "Point", "coordinates": [ 2023053.973159867804497, 7012739.301232798025012 ] } }, 9 | { "type": "Feature", "properties": { "id": 4 }, "geometry": { "type": "Point", "coordinates": [ 2022120.122832620283589, 7013675.541233709082007 ] } } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /img/active_project_QGIS.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/active_project_QGIS.jpg -------------------------------------------------------------------------------- /img/contol_add_new_attributes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/contol_add_new_attributes.png -------------------------------------------------------------------------------- /img/editors_of_git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/editors_of_git.png -------------------------------------------------------------------------------- /img/git_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_add.png -------------------------------------------------------------------------------- /img/git_bash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_bash.png -------------------------------------------------------------------------------- /img/git_checkout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_checkout.png -------------------------------------------------------------------------------- /img/git_cnfig_new_attributes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_cnfig_new_attributes.png -------------------------------------------------------------------------------- /img/git_commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_commit.png -------------------------------------------------------------------------------- /img/git_commit_VSCode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_commit_VSCode.png -------------------------------------------------------------------------------- /img/git_gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_gui.png -------------------------------------------------------------------------------- /img/git_init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_init.png -------------------------------------------------------------------------------- /img/git_log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_log.png -------------------------------------------------------------------------------- /img/git_pull_before_push.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_pull_before_push.png -------------------------------------------------------------------------------- /img/git_push.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_push.png -------------------------------------------------------------------------------- /img/git_status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/git_status.png -------------------------------------------------------------------------------- /img/issue_push_button_horizontal_layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/issue_push_button_horizontal_layout.png -------------------------------------------------------------------------------- /img/new_branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/new_branch.png -------------------------------------------------------------------------------- /img/open_git_bash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/open_git_bash.png -------------------------------------------------------------------------------- /img/view_branches.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/view_branches.png -------------------------------------------------------------------------------- /img/visualization (0).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/visualization (0).png -------------------------------------------------------------------------------- /img/visualization (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/visualization (1).png -------------------------------------------------------------------------------- /img/visualization (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/visualization (2).png -------------------------------------------------------------------------------- /img/visualization (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/visualization (3).png -------------------------------------------------------------------------------- /img/welcome_screen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/img/welcome_screen.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/Group3.md: -------------------------------------------------------------------------------- 1 | # QGIS Plugin Group 3 2 |

Authors

3 | Fatih Afacan
4 | Abdülkadir Çakır 5 | 6 |

Our plugin`s User Interface

7 | 1 8 | 9 | ## How did we manage to do No ID panel: 10 | ``` 11 | if useID: 12 | lineLayer.dataProvider().addAttributes([QgsField('id_start', QVariant.Double),QgsField('id_end', QVariant.Double),QgsField('length', QVariant.Double)]) 13 | else: 14 | lineLayer.dataProvider().addAttributes([QgsField('length', QVariant.Double)]) 15 | ``` 16 | There is an output for No ID attribute table:
17 | 2 18 | 19 | 20 |

Algorithm

21 | Our algorithm able to classify the points with K means algorithm. So you can use this tool for classify the points for any case. For example If are the cargo manager and you want to make a save for fuel prices. This algorithm can save you. You can upload the data of customers location and you can select the how many cluster you wanted for. So you can make classification with them to your profit. You can open the department in the middle of the cluster or you can seperate the clusters and send the cargo cars to every cluster. 22 |
23 | As you can see the clusters and points. You can manage anything you want with this data according to your imagination.
24 | 3 25 | 26 |

Min Max distance calculator

27 | Our plugin also able to calculate the minimum and maximum distance from the points that in uploaded data.
28 | Ekran-Al-nt-s
29 | You can see the visualized lines that the maximum distance of the points.
30 | 5
31 | And you can check the points and distances in the attribute table. 32 | -------------------------------------------------------------------------------- /midterm_projects/2020-21/Group6.md: -------------------------------------------------------------------------------- 1 | # Group 6 Development of Qgis Plugin 2 | In this project, additional improvements were made to an existing plug-in within the scope of the Hacettepe University GMT-456-GIS-Programming lecture. 3 | 4 | Developers: 5 | Okan Demirbilek & Baran Canpolat 6 | 7 | ## I. Calculation Min and Max Distance 8 | ![Settings Window](https://github.com/bcanplt/GMT-456-GIS-Programming/tree/master/midterm_projects/2020-21/img/Group6-Img/Group6-Img/2.PNG) 9 | 10 | ## II. Detect Center Point (Centroids) From Polygons 11 | ![Settings Window](https://github.com/bcanplt/GMT-456-GIS-Programming/tree/master/midterm_projects/2020-21/img/Group6-Img/Group6-Img/1.PNG) 12 | -------------------------------------------------------------------------------- /midterm_projects/2020-21/Midterm_Project.md: -------------------------------------------------------------------------------- 1 | # Midterm Project Guidelines 2 | # Due: 3 December 2020 3 | 4 | 5 | Fork the course’s [**GitHub page**](https://github.com/banbar/GMT-456-GIS-Programming). You may start investigating the QGIS plugin under the `save_attributes/` folder. 6 | 7 | **Always work on your GitHub Classroom repo while doing your midterm project**. 8 | 9 | The GUI of the plugin is as follows: 10 | 11 | ![](/midterm_projects/2020-21/img/gui_save_attributes.png) 12 | 13 | At the moment, this plugin adds two attributes (X and Y) to a point shp file and populates them by inserting the relevant values corresponding to each feature. 14 | 15 | The objective of the midterm project is to update the plugin such that the following requirements are satisfied: 16 | 17 | * If a ***point*** shp file file is provided, it will identify the distances between all features (points). 18 | * The plugin will then ***create a new line shp file***, which provides the details of the **two special lines** (i.e. the min/max distance between the two closest/distant points, where the distance is calculated as the shortest distance between two points). 19 | * Template of the resulting line shp file looks like: 20 | 21 | | ***optional*** | ***optional*** | | 22 | |---------------------|-------------------|------------------------------------------------| 23 | | **poi\_id\_start** | **poi\_id\_end** | **length** | 24 | | shortest\_start | shortest\_end | distance between two closest pairs | 25 | | longest\_start | longest\_end | distance between two most distant pairs | 26 | 27 | 28 | * If the user provided an id field corresponding to each point feature, then the start and end points of these two special lines are recorded as shown in the first two columns. 29 | * If there is no such id field, the user will check the box ‘No ID’, and then only the length of the lines are recorded. That’s why the first two fields (id_start and id_end) are optional. 30 | 31 | * If a ***polyline*** shapefile is provided, it will add two attributes (fields) to the shp file. 32 | * The first attribute is ***length***, which records the ***actual length*** of the polyline. 33 | * The second attribute is ***shortest_length***, which first identifies the start and end points of a polyline, and records the shortest distance between these two points. 34 | * If a ***polygon*** shapefile is provided, provide a gentle warning to the user stating that the plugin cannot operate on polygons. 35 | 36 | ## Tasks 37 | 38 | The following tasks must be carried out. The first are relatively easy, and the last one is the main task you have to work on. 39 | 40 | ### 1 - Do not add the same fields more than once 41 | Add a control statement that checks whether a new field that you define is already present or not. If the new field(s) are present, there is no need to add once more. This will be useful when debugging the code multiple times, and prevent situations like this in which we add the same attributes (i.e. x and y) multiple times: 42 | 43 | ![](img/contol_add_new_attributes.png) 44 | 45 | ### 2 - X and Y fields are only added to Point shp files 46 | 47 | At the moment, the plugin adds the X and Y fields regardless of the input geometry. Make sure that the new fields are added only when **polyline** geometries are input. 48 | 49 | ### 3 - GUI Layout 50 | 51 | Investigate ways in which to increase the quality of the GUI layout. At the moment, the ***horizontal layout*** is not correctly structured, so that the “browse” button takes more space than it should. Can you also identify other aspects which increases the quality of the GUI? 52 | 53 | ![](img/issue_push_button_horizontal_layout.png) 54 | 55 | 56 | ### 4 - Branch & Merge - Adding New Features 57 | 58 | * This is the main part of the midterm project as it encourages teamwork. 59 | 60 | * Each student in a group **should add one new feature**. 61 | 62 | * Briefly describe this new feature in an **issue** so that your teammate knows what you will be working on. 63 | 64 | * **Create a new branch**, and add the new feature to this branch. 65 | 66 | * **Merge the feature branch into the master branch**. 67 | 68 | * Understand how different **merge** options will take place. Specifically, describe the difference between ***merge made by the 'recursive' strategy*** and ***fast-forward***. 69 | 70 | * Report any merge-conflicts and discuss how you dealt with the merge conflict. 71 | 72 | 73 | Follow these [1](https://youtu.be/QV0kVNvkMxc), [2](https://youtu.be/XX-Kct0PfFc) references for a better understanding of branch-merge process. Also, this [Atlassian - Git Merge](https://www.atlassian.com/git/tutorials/using-branches/git-merge) reference could be useful. 74 | 75 | *Updated:20 November 2020* 76 | -------------------------------------------------------------------------------- /midterm_projects/2020-21/group1.md: -------------------------------------------------------------------------------- 1 | # QGIS Plugin Development Group 1 Document 2 | --- 3 | ### Members involved in the development phase 4 | 5 | * Berkay İbiş 6 | Mail address: berkayyibis@hotmail.com 7 | 8 | * Berk Kıvılcım 9 | Mail address: brkkvlcm@gmail.com 10 | 11 | --- 12 | ### Graphical User Interface of the Plugin 13 | #### Parts of the GUI (Graphical User Interface) 14 | **1 - Line Label:** Line Labels just some string that give us information about other parts of the gui which is means line label does not run any function. 15 | 16 | **2 - Line Edit:** Line Edits show us the directory and name of the files which is selected by Push and Tool Buttons. 17 | 18 | **3 - Push Button:** Push buttons run the functions and algorithms when it clicked. 19 | 20 | **4 - Combo Box:** Combo boxes work for selecting correct options. This correct options like 'only point layer' listed in combo boxes and we can select the which layer we want to use. 21 | 22 | **5 - Layout:** Layout limits frame size of the gui so we can't make gui page smaller then selected layout frame. GUI example below here is the smallest interface according to layout. 23 | 24 |

25 | 26 | --- 27 | ### Functions and Details About Plugin 28 | #### Inputing Only Line and Point files: 29 | 30 | * Code's input_shp_file function upload a shape file into the QGIS but we don't want to upload any polygon type file so we limited it and when we try to upload a polygon file it will give us some error message. 31 | 32 | * The code part and the error example is below here. 33 | 34 | ```python 35 | if(self.layerDef.GetGeomType() == ogr.wkbPolygon):# 36 | self.error_msj("Sadece çizgi veya nokta katmanı girebilirsiniz !") 37 | self.dlg.lineEdit.setText("") 38 | return False 39 | ``` 40 | 41 | 42 | 43 | --- 44 | 45 | #### Run Button and Combo Box Relation: 46 | 47 | * When we click to Run button plugin will implement some algorithm on the layer which is selected on combo box. We want to implement it on only point layers so combo box must shuw only the point layers. 48 | 49 | * The code part and example result below here. Also in the 'geometryType()== 0' 0(zero) means point type layer. 50 | 51 | ```python 52 | try: 53 | if layer.geometryType() == 0: 54 | layersList.append(layer.name()) 55 | layersList_shp.append(layer) 56 | 57 | except: 58 | continue 59 | ``` 60 | 61 | * Combo box not allow to select c_beytepe layer below here because its a line type layer. 62 | 63 | 64 | --- 65 | 66 | #### Drawing New Layer in all type of CRS: 67 | * The Algorithms in the plugin create new layers and drawing some point or lines. In the beginning it only draw on QGIS's default crs. We identify crs as source crs instead of qgis default crs. That means we additionaly add 'crs=self.vlayer.sourceCrs()'. The code example is below here. 68 | 69 | ```python 70 | lineLayer = QgsVectorLayer("MultiLineString", "lines", "memory", crs=self.vlayer.sourceCrs()) 71 | ``` 72 | 73 | --- 74 | 75 | #### Algorithms: 76 | 77 | #### Drawing lines between closest and farthest two points. 78 | * When we select a point layer in combo box and click to run the plugin create a new line layer which is shows distance between closest and farthest two points. 79 | 80 | * Visual example and Attribute tables of the new line layer below here. This Attribute table include start and end point's id and distance between them. 81 | 82 | 83 | 84 | 85 | 86 | --- 87 | 88 | #### Finding and drawing center point between this farthest two points. 89 | * The code calculate it with getting x and y coordinates of the start and end points. Then getting avarage of the x and y. It give us new center point coordinates. Then we add it to created point layer. 90 | 91 | ```python 92 | baslangicx=lineStart.x() 93 | baslangicy=lineStart.y() 94 | bitisx=lineEnd.x() 95 | bitisy=lineEnd.y() 96 | 97 | ortX=(baslangicx+bitisx)/2 98 | ortY=(baslangicy+bitisy)/2 99 | 100 | segMid=QgsFeature() 101 | segMid.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(ortX,ortY))) 102 | ``` 103 | 104 | 105 | 106 | --- 107 | 108 | #### Finding and drawing break points of the Multi Line String: 109 | 110 | * After upload an multi line string data then we click to OK button. The algorithm starts and draw the break points (node points) on the Multi Line Strings type data layer. It work in a for loop until the multi line string complate. 111 | 112 | ```python 113 | vertex=[] 114 | for i in range(len(geom.constGet()[0])): 115 | pt = geom.constGet()[0][i] 116 | vertex.append(pt) 117 | i+=1 118 | 119 | print(vertex) 120 | 121 | 122 | v1= QgsVectorLayer("Point", "point", "memory",crs = self.vlayer.sourceCrs()) 123 | 124 | for i in range(len(vertex)): 125 | pr = v1.dataProvider() 126 | f = QgsFeature() 127 | f.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(vertex[i]))) 128 | pr.addFeatures( [f] ) 129 | v1.updateExtents() 130 | 131 | QgsProject.instance().addMapLayers([v1]) 132 | v1.commitChanges() 133 | ``` 134 | 135 | 136 | 137 | --- 138 | -------------------------------------------------------------------------------- /midterm_projects/2020-21/group2.md: -------------------------------------------------------------------------------- 1 | # Group 2 2 | ***Authors*** 3 | Ahmet Fırat Karaoğlu : karaoglu@email.com 4 | Metehan Ergen : metehan.ergenn@gmail.com 5 | 6 | Hello everyone ! we have contributed new features to a QGIS plugin called "save_attributes". You may find a brief information about the plugin below, 7 | 8 | ***Interface*** 9 | 10 | 11 | You could select the shapefile from the interface (Input layer part). And there will be 3 main cases, 12 | 13 | ***Case 1***
If the input layer geometry is line; the plugin will compute the shortest and real distance among features, azimuth and reverse azimuth between lines' start points and end points. And also draw the shortest line with its length. See below, 14 | 15 |
16 | 17 | If there is more than one feature on layer. It will also show the features which could possibly be a polygon. 18 |
19 | 20 | ***Case 2***
If the input layer is point. It will check whether feature number is greater than 2. If it is the case, it will calculate the minimum and maxiumum distannce among all points and draw the lines related to them. See below, 21 | 22 |
23 | 24 | ***Case 3***
If the input layer is polygon, the plugin computes the area and perimeter of the poligons and show in the table with inserting. 25 | ![Image](https://github.com/afkHub/GMT-456-GIS-Programming/blob/master/midterm_projects/2020-21/img/group2-images/area-peri.png) 26 | 27 | 28 |


Note: We used this to be able to add our university logo to the GUI: https://gis.stackexchange.com/questions/381661/image-adding-problem-to-qgis-plugin-gui-with-qt-designer (You may need to run the "compile.bat" file in the folder according to you for the logo.) 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /midterm_projects/2020-21/group4.md: -------------------------------------------------------------------------------- 1 |

QGIS Plugin Group-4  W3Schools

2 |

 

3 |

Authors:

4 |

Atahan Çelebi
Eda Karabaş

5 |

Plugin's User Interface

6 |

W3Schools
*Let's consider we give the value of 5000 unit.

7 |

 

8 |

How Does Plugin Works?

9 |

If the type of the geometry is polygon

10 |

Calculate the every QgsFeature's geom area

11 | 12 |

As a Result

13 |

W3Schools

14 |

We can see the lower and upper value according to user choice.

15 |

After the selection of the area unit this part split the higher areas and the lower areas

16 |

 

17 |

Apply The Graduated Function

18 | 19 |

You can also look at the Area_calc's attribues

20 |

W3Schools

21 |

Type of geometry is a point or line

22 |

Line

23 |

If we select a line shapefile it draws the minimum flight distance between the two points and the their real distance.

24 |

 

25 |

Point

26 |

If we select a point shapefile it calcultes minimum and maximum distances

27 |

28 | Find the points that have minimum distance and the maximum distance 29 |

30 | -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/Group6-Img/Group6-Img/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/Group6-Img/Group6-Img/1.PNG -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/Group6-Img/Group6-Img/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/Group6-Img/Group6-Img/2.PNG -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group1_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group1_1.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group1_10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group1_10.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group1_11jpg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group1_11jpg.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group1_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group1_2.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group1_6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group1_6.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group1_7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group1_7.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group1_8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group1_8.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group_1_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group_1_3.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group_1_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group_1_4.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group1-images/group_1_5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group1-images/group_1_5.jpg -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group2-images/GUI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group2-images/GUI.png -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group2-images/area-peri.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group2-images/area-peri.png -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group2-images/azimuth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group2-images/azimuth.png -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group2-images/line_1feat.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group2-images/line_1feat.JPG -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group2-images/line_mult.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group2-images/line_mult.JPG -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group2-images/lines_attr.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group2-images/lines_attr.JPG -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group2-images/minmax.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group2-images/minmax.JPG -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group2-images/point_attr.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/group2-images/point_attr.JPG -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/group6-images: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /midterm_projects/2020-21/img/gui_save_attributes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2020-21/img/gui_save_attributes.png -------------------------------------------------------------------------------- /midterm_projects/2021-22/ps1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/banbar/GMT-456-GIS-Programming/2712d256b9b4076476a9d2df2a910eccc4878592/midterm_projects/2021-22/ps1.zip -------------------------------------------------------------------------------- /software_documentation.md: -------------------------------------------------------------------------------- 1 | # Software Documentation 2 | Documentation of a developed software is of critical importance in terms of its outreach. The users will keep on using the sofware as long as they can follow a well-structured text. 3 | 4 | These markdown files are good way to start documenting our software. However, they are not suitable once we want to provide the documentation in multiple languages and also include the function descriptions in an automatic way. 5 | 6 | The Pythonic way of documenting software is to use [Sphinx](https://www.sphinx-doc.org/en/1.8/index.html). 7 | 8 | 9 | ## Why Sphinx? 10 | * One of the state-of-the-practice tools to document software. 11 | * [Variety of projects](https://www.sphinx-doc.org/en/1.8/examples.html) have already been relying on Sphinx for documentation. Some notable examples include [**QGIS**](https://qgis.org/en/docs/index.html), [**NetworkX**](https://networkx.org/) and [**Flask**](https://flask.palletsprojects.com/en/1.1.x/). Even books were written using Sphinx, such as [The Hitchhiker’s Guide to Python!](https://docs.python-guide.org/). Maybe we would better understand the importance of 42. :) 12 | 13 | ## How to document our code? 14 | 15 | 1. Install Sphinx 16 | * `pip install sphinx`. If you are using Anaconda: `conda install sphinx`. 17 | 2. Go to your project folder and create a `sources` subfolder and add your **.py** files under this folder. 18 | 3. In the Command Line Interface (CLI), write `sphinx-quickstart` while you are under your project folder. 19 | 4. Provide the details regarding your project. The default values are labelled as within square brackets. 20 | 5. Update the `conf.py`. 21 | * Uncomment: 22 | * `import os` 23 | * `import sys` 24 | * `sys.path.insert(0, os.path.abspath('.'))` 25 | * Add the folder that contains the **.py** files (i.e. ***sources***) to the sys.path: 26 | * Make sure that all `from` & `import` statements are removed. 27 | * `sys.path.append('sources')` 28 | * Update the **extensions** list to: 29 | * `extensions = ['sphinx.ext.autodoc']` 30 | * Under **index.rst**: 31 | * Add `docs/modules` In this way, all the source files' documentation would be auto-generated. 32 | * At CLI type: 33 | * `mkdir docs`: Create the **docs** directory 34 | * `sphinx-apidoc -o docs sources`: Creates the **rst** of the script under the **sources** directory, and saves it under the **docs** directory. 35 | * `make html` 36 | * Two warnings might appear: 37 | * **WARNING: Unknown directive type "automodule".** 38 | * **WARNING: document isn't included in any toctree** 39 | * Ignore these warnings, and run `make html` until no more warnings show up. 40 | * `make clean` would remove all the built html files. 41 | 6. [optional] - Autobuilding (simultaneous update of the documentation as you update the software): 42 | * Install the **sphinx-autobuild** package: `pip install sphinx-autobuild`. If you are using Anaconda: `conda install -c conda-forge sphinx-autobuild` 43 | * At CLI, type: 44 | * `sphinx-autobuild . _build/html`: Starts the server that reflects all changes made in the rst files on the fly. 45 | * Local address: http://127.0.0.1:8000 46 | * To shut down the server: **Ctrl + C**. Then, you have create another CLI. 47 | 48 | * Sphinx provides beautiful themes. These themes could be [browsed](https://sphinx-themes.org/). 49 | * You can also install, for example the [Read the Docs (rtd)](https://github.com/readthedocs/sphinx_rtd_theme), theme, by `pip install sphinx-rtd-theme`. 50 | * To enable a theme, under the **conf.py**, update the `html_theme` accordingly (e.g. `html_theme = 'sphinx_rtd_theme'`). 51 | 52 | ## Some Examples of Visualization 53 | ![Image](https://github.com/afkHub/GMT-456-GIS-Programming/blob/master/img/visualization%20(0).png) 54 | 55 | ![Image](https://github.com/afkHub/GMT-456-GIS-Programming/blob/master/img/visualization%20(1).png) 56 | 57 | ![Image](https://github.com/afkHub/GMT-456-GIS-Programming/blob/master/img/visualization%20(2).png) 58 | 59 | ![Image](https://github.com/afkHub/GMT-456-GIS-Programming/blob/master/img/visualization%20(3).png) 60 | 61 | If you also want to share your documentation on the web like this https://gmt456-documentation.readthedocs.io/, you can use this website https://readthedocs.org/
Sign up with your github account, make an "Import a Project" with the link of your documentation project you shared on github. 62 | 63 | ## References 64 | 65 | * https://www.youtube.com/watch?v=LQ6pFgQXQ0Q&ab_channel=EngineeringAnywhere 66 | * https://www.youtube.com/watch?v=d_XeV6oyNvI&ab_channel=%7BLP%7DWITHRAHMAT 67 | * https://pythonhosted.org/an_example_pypi_project/sphinx.html 68 | * https://www.youtube.com/watch?v=DSIuLnoKLd8 69 | * [Autobuild](https://pypi.org/project/sphinx-autobuild/) 70 | --------------------------------------------------------------------------------