├── GRASS-scripts ├── v.osm.acc │ ├── v.osm.acc.html │ ├── Makefile │ └── v.osm.acc.py ├── v.osm.preproc │ ├── v.osm.preproc.html │ ├── Makefile │ └── v.osm.preproc.py ├── v.osm.precomp │ ├── Makefile │ ├── v.osm.precomp.html │ └── v.osm.precomp.py └── README.md ├── .gitmodules ├── README.md~ ├── README.md └── LICENSE /GRASS-scripts/v.osm.acc/v.osm.acc.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /GRASS-scripts/v.osm.preproc/v.osm.preproc.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "WPS_OSM-REF-Comparison"] 2 | path = WPS_OSM-REF-Comparison 3 | url = https://github.com/GabrielePrestifilippo/WPS_OSM-REF-Comparison 4 | -------------------------------------------------------------------------------- /GRASS-scripts/v.osm.acc/Makefile: -------------------------------------------------------------------------------- 1 | MODULE_TOPDIR = ../.. 2 | 3 | PGM = v.osm.acc 4 | 5 | include $(MODULE_TOPDIR)/include/Make/Script.make 6 | 7 | default: script 8 | -------------------------------------------------------------------------------- /GRASS-scripts/v.osm.precomp/Makefile: -------------------------------------------------------------------------------- 1 | MODULE_TOPDIR = ../.. 2 | 3 | PGM = v.osm.precomp 4 | 5 | include $(MODULE_TOPDIR)/include/Make/Script.make 6 | 7 | default: script 8 | -------------------------------------------------------------------------------- /GRASS-scripts/v.osm.preproc/Makefile: -------------------------------------------------------------------------------- 1 | MODULE_TOPDIR = ../.. 2 | 3 | PGM = v.osm.preproc 4 | 5 | include $(MODULE_TOPDIR)/include/Make/Script.make 6 | 7 | default: script 8 | -------------------------------------------------------------------------------- /README.md~: -------------------------------------------------------------------------------- 1 | # Comparison between OSM and authoritative road network datasets 2 | This repository contains scripts for comparing road network datasets from [OpenStreetMap (OSM)](http://openstreetmap.org) and an authoritative source. The repository contains two folders: 3 | * [GRASS-scripts](https://github.com/MoniaMolinari/OSM-roads-comparison/tree/master/GRASS-scripts) provides three Python modules to perform the complete dataset comparison in [GRASS GIS](https://grass.osgeo.org/) 4 | * [WPS_OSM-REF-Comparison](https://github.com/GabrielePrestifilippo/WPS_OSM-REF-Comparison) provides the code to setup the Web Processing Service (WPS) for a preliminary comparison of the datasets 5 | 6 | Detailed instructions on how to use the tools are provided in each of the two folders. 7 | 8 | ## Related academic publications 9 | * Brovelli M. A., Minghini M., Molinari M. & Mooney P. (2015) A FOSS4G-based procedure to compare OpenStreetMap and authoritative road network datasets. *Geomatics Workbooks* 12, pp. 235-238, ISSN 1591-092X [[pdf](http://geomatica.como.polimi.it/workbooks/n12/FOSS4G-eu15_submission_70.pdf)] 10 | -------------------------------------------------------------------------------- /GRASS-scripts/README.md: -------------------------------------------------------------------------------- 1 | # GRASS scripts 2 | This folder contains, in the corresponding subfolders, three Python modules for [GRASS GIS](https://grass.osgeo.org/) aimed at performing a geometrical comparison between two road network datasets: one from the [OpenStreetMap (OSM)](http://openstreetmap.org) project and one from an authoritative source: 3 | * [v.osm.precomp](https://github.com/MoniaMolinari/OSM-roads-comparison/tree/master/GRASS-scripts/v.osm.precomp) (Step 1) performs a preliminary comparison of the two datasets, computes global statistics and performs a sensitivity analysis to help users choosing a suitable value of the buffer parameter, which is key in Step 2 4 | * [v.osm.preproc](https://github.com/MoniaMolinari/OSM-roads-comparison/tree/master/GRASS-scripts/v.osm.preproc) (Step 2) performs a geometric preprocessing of the OSM road network dataset to extract its subset representing the same road features of the authoritative dataset 5 | * [v.osm.acc](https://github.com/MoniaMolinari/OSM-roads-comparison/tree/master/GRASS-scripts/v.osm.acc) (Step 3) evaluates the spatial accuracy of the OSM subset extracted in Step 2 using a grid-based approach 6 | 7 | The modules are independent, however users are suggested to apply them subsequently to maximize the effectiveness of the procedure. 8 | 9 | **NOTE**: current versions are tested in GRASS GIS 7.1 (development version) and NOT in previous releases. Authors will update the modules as soon as the next stable release will come out. 10 | 11 | ## Installation (Linux) 12 | * Copy the three folders in the `scripts` folder, which is inside the GRASS source code folder 13 | * Open a terminal window, enter each of the three folders and compile the code. For example, for the `v.osm.precomp` module, type: 14 | ``` 15 | cd path-to-GRASS-folder/scripts/v.osm.precomp 16 | sudo make 17 | sudo make install 18 | ``` 19 | ## Running the Script (Linux) 20 | To simply run the scripts without installing them: 21 | * From GRASS GIS top menu select `File` 22 | * Select `Launch Script` 23 | * Select a ".py" module such as "v.osm.precomp.py" 24 | * Select `Open` 25 | 26 | ## Related academic publications 27 | * Brovelli M. A., Minghini M., Molinari M. & Mooney P. (2015) A FOSS4G-based procedure to compare OpenStreetMap and authoritative road network datasets. *Geomatics Workbooks* 12, pp. 235-238, ISSN 1591-092X [[pdf](http://geomatica.como.polimi.it/workbooks/n12/FOSS4G-eu15_submission_70.pdf)] 28 | -------------------------------------------------------------------------------- /GRASS-scripts/v.osm.precomp/v.osm.precomp.html: -------------------------------------------------------------------------------- 1 |

DESCRIPTION

2 | 3 | buffers parameter is a comma separated list of buffers to consider. 4 | All the values between 1 and 20 could be useful, but you can also extend more. 5 | 6 | roi parameter is a vector layer used to cut the input network layers. 7 | 8 |

EXAMPLE

9 | 10 |
11 | wget -c -O osm_roadsmajor.geojson
12 | http://overpass-api.de/api/interpreter?data=%5Bout%3Ajson%5D%5Btimeout%3A25%5D%3B%28node%5B%22highway%22%3D%22motorway%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Bway%5B%22highway%22%3D%22motorway%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Brelation%5B%22highway%22%3D%22motorway%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Bnode%5B%22highway%22%3D%22motorway%5Flink%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Bway%5B%22highway%22%3D%22motorway%5Flink%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Brelation%5B%22highway%22%3D%22motorway%5Flink%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Bnode%5B%22highway%22%3D%22trunk%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Bway%5B%22highway%22%3D%22trunk%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Brelation%5B%22highway%22%3D%22trunk%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Bnode%5B%22highway%22%3D%22trunk%5Flink%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Bway%5B%22highway%22%3D%22trunk%5Flink%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3Brelation%5B%22highway%22%3D%22trunk%5Flink%22%5D%2835%2E59255224089235%2C%2D78%2E88114929199219%2C35%2E905736972317364%2C%2D78%2E36616516113281%29%3B%29%3Bout%20body%3B%3E%3Bout%20skel%20qt%3B%0A
13 | 
14 | v.import input=osm_roadsmajor.geojson output=osm_roadsmajor
15 | 
16 | v.osm.precomp osm=osm_roadsmajor ref=roadsmajor buffers=1,5,10,15 out_graphs=precomp/ output=precomp/osm_precomp.txt
17 | 
18 | 19 |

SEE ALSO

20 | 21 | 22 | v.osm.acc, 23 | v.osm.preproc 24 | 25 | 26 | 27 |

AUTHOR

28 | 29 | Monia Molinari, Marco Minghini (Politecnico di Milano), parallelization 30 | Luca Delucchi (Fondazione Edmund Mach) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Comparison between OSM and authoritative road network datasets 2 | This repository contains scripts for comparing road network datasets from [OpenStreetMap (OSM)](http://openstreetmap.org) and an authoritative source. The repository contains two folders: 3 | * [GRASS-scripts](https://github.com/MoniaMolinari/OSM-roads-comparison/tree/master/GRASS-scripts) provides three Python modules to perform the complete dataset comparison in [GRASS GIS](https://grass.osgeo.org/) 4 | * [WPS_OSM-REF-Comparison](https://github.com/GabrielePrestifilippo/WPS_OSM-REF-Comparison) provides the code to setup the Web Processing Service (WPS) for a preliminary comparison of the datasets 5 | 6 | Detailed instructions on how to use the tools are provided in each of the two folders. 7 | 8 | ## Related academic publications 9 | 10 | * Brovelli M.A., Minghini M. & Molinari M.E. (2016) An automated GRASS-based procedure to assess the geometrical accuracy of the OpenStreetMap Paris road network. *International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences* Volume XLI-B2, 609-614. doi:10.5194/isprsarchives-XLI-B2-609-2016 [[pdf](http://www.int-arch-photogramm-remote-sens-spatial-inf-sci.net/XLI-B7/919/2016/isprs-archives-XLI-B7-919-2016.pdf)] 11 | 12 | * Brovelli M.A., Minghini M., Molinari M.E. & Mooney P. (2016) Towards an Automated Comparison of OpenStreetMap with Authoritative Road Datasets. *Transactions in GIS*. doi:10.1111/tgis.12182 [[pdf](https://www.researchgate.net/profile/Marco_Minghini/publication/298296464_Towards_an_Automated_Comparison_of_OpenStreetMap_with_Authoritative_Road_Datasets/links/56e7c9e108ae4c354b1d001a.pdf)] 13 | 14 | * Antunes F., Fonte C.C., Brovelli M.A., Minghini M., Molinari M.E. & Mooney P. (2015) Assessing OSM Road Positional Quality with Authoritative Data. *Proceedings of the VIII Conferência Nacional de Cartografia e Geodesia*, Lisbon (Portugal), October 29-30, 2015, ISBN 978-989-8152-10-7 [[pdf](http://geomobile.como.polimi.it/website/papers/Antunes_Fonte_Brovelli_Minghini_Molinari_Mooney_2015.pdf)] 15 | 16 | * Brovelli M.A., Minghini M., Molinari M.E. & Mooney P. (2015) A FOSS4G-based procedure to compare OpenStreetMap and authoritative road network datasets. *Geomatics Workbooks* 12, 235-238, ISSN 1591-092X [[pdf](http://geomatica.como.polimi.it/workbooks/n12/FOSS4G-eu15_submission_70.pdf)] 17 | 18 | ## Related academic presentations 19 | * Brovelli M. A., Minghini M. & Molinari M. (2016) A GRASS-based automated procedure to compare OpenStreetMap and authoritative road network datasets. Presented at the XVII Meeting of GRASS and FOSS4G Italian users, Parma (Italy), February 11-12 2016 [[pdf](http://www.slideshare.net/mingo23/a-grassbased-automated-procedure-to-compare-openstreetmap-and-authoritative-road-network-datasets)] 20 | -------------------------------------------------------------------------------- /GRASS-scripts/v.osm.preproc/v.osm.preproc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | ############################################################################## 4 | # MODULE: v.osm.preproc 5 | # AUTHOR(S): Monia Molinari, Marco Minghini 6 | # PURPOSE: Tool for extracting road features in the OSM dataset which have a correspondence in the reference dataset 7 | # COPYRIGHT: (C) 2015 by the GRASS Development Team 8 | # 9 | # This program is free software under the GNU General Public 10 | # License (>=v2). Read the file COPYING that comes with GRASS 11 | # for details. 12 | # ############################################################################ 13 | #%Module 14 | #% description: Tool for extracting road features in the OSM dataset which have a correspondence in the reference dataset 15 | #% keywords: vector, OSM, preprocessing 16 | #%End 17 | 18 | #%option 19 | #% key: osm 20 | #% type: string 21 | #% gisprompt: old,vector,vector 22 | #% description: OpenStreetMap dataset 23 | #% required: yes 24 | #%end 25 | 26 | #%option 27 | #% key: ref 28 | #% type: string 29 | #% gisprompt: old,vector,input 30 | #% description: Reference dataset 31 | #% required: yes 32 | #%end 33 | 34 | #%option 35 | #% key: buffer 36 | #% type: double 37 | #% description: Buffer around reference dataset (map units) 38 | #% required: yes 39 | #%end 40 | 41 | #%option 42 | #% key: angle_thres 43 | #% type: double 44 | #% description: Threshold value for angular coefficient comparison (degrees) 45 | #% required: yes 46 | #%end 47 | 48 | #%option G_OPT_V_OUTPUT 49 | #% key: output 50 | #% description: Name for output map 51 | #% required: yes 52 | #%end 53 | 54 | #%option 55 | #% key: douglas_thres 56 | #% type: double 57 | #% description: Threshold value for Douglas-Peucker algorithm (map unit) 58 | #% required: no 59 | #%end 60 | 61 | #%option G_OPT_F_OUTPUT 62 | #% key: out_file 63 | #% description: Name for output file with statistics (if omitted or "-" output to stdout) 64 | #% required: no 65 | #%end 66 | 67 | import math 68 | import sys 69 | import shutil 70 | import time 71 | import grass.script as grass 72 | 73 | def length(data): 74 | feat_osm = int(((grass.read_command("v.info", map=data,flags="t",quiet=True)).split("\n")[2]).split("=")[1]) 75 | if feat_osm>0: 76 | length_data = grass.read_command("v.to.db",map=data,option="length",flags="p") 77 | s_data=0 78 | l_data = length_data.split("\n") 79 | for item in l_data[1:-1]: 80 | s_data+=float(item.split("|")[1]) 81 | else: 82 | s_data=0 83 | return s_data 84 | 85 | 86 | def GetCoeff(vect): 87 | coord_start = grass.read_command("v.to.db", map=vect, option="start", type="line",flags="p").split("\n")[1] 88 | x_start = float(coord_start.split("|")[1]) 89 | y_start = float(coord_start.split("|")[2]) 90 | coord_end = grass.read_command("v.to.db", map=vect, option="end", type="line",flags="p").split("\n")[1] 91 | x_end = float(coord_end.split("|")[1]) 92 | y_end = float(coord_end.split("|")[2]) 93 | if (x_end-x_start) <> 0: 94 | m = (y_end-y_start)/(x_end-x_start) 95 | else: 96 | m = 10**9 97 | return m 98 | 99 | def main(): 100 | osm = options["osm"] 101 | ref = options["ref"] 102 | bf = options["buffer"] 103 | angle_thres = options["angle_thres"] 104 | doug = options["douglas_thres"] 105 | out = options["output"] 106 | out_file = options["out_file"] 107 | 108 | ## Check if input files exist 109 | if not grass.find_file(name=osm,element='vector')['file']: 110 | grass.fatal(_("Vector map <%s> not found") % osm) 111 | 112 | if not grass.find_file(name=ref,element='vector')['file']: 113 | grass.fatal(_("Vector map <%s> not found") % ref) 114 | 115 | ## Prepare temporary map names 116 | processid = str(time.time()).replace(".","_") 117 | ref_gen = "ref_gen_" + processid 118 | ref_split = "ref_split_" + processid 119 | osm_split = "osm_split_" + processid 120 | deg_points = "deg_points_" + processid 121 | degmin_points = "degmin_points_" + processid 122 | ref_degmin = "ref_degmin_" + processid 123 | patch = "patch_" + processid 124 | fdata = "fdata_" + processid 125 | fbuffer = "fbuffer_" + processid 126 | odata = "odata_" + processid 127 | osdata = "osdata_" + processid 128 | outbuff = "outbuff_" + processid 129 | 130 | ## Calculate length original data 131 | l_osm = length(osm) 132 | l_ref = length(ref) 133 | 134 | if l_ref == 0: 135 | grass.run_command("g.remove", type="vect", pattern="%s"%processid,flags="fr",quiet=True) 136 | grass.fatal(_("No reference data for comparison")) 137 | 138 | if l_osm == 0: 139 | grass.run_command("g.remove", type="vect", pattern="%s"%processid,flags="fr",quiet=True) 140 | grass.fatal(_("No OSM data for comparison")) 141 | 142 | 143 | ## Generalize 144 | if doug: 145 | grass.run_command("v.generalize",input=ref,output=ref_gen,method="douglas", threshold=doug,quiet=True) 146 | ref = ref_gen 147 | 148 | ## Split REF datasets 149 | grass.run_command("v.split",input=ref,output=ref_split,vertices=2,quiet=True) 150 | grass.run_command("v.out.ogr",input=ref_split,output="/tmp/%s"%ref_split,flags="s",quiet=True) 151 | grass.run_command("g.remove",type="vect",name=ref_split,flags="f",quiet=True) 152 | grass.run_command("v.in.ogr",input="/tmp/%s/%s.shp"%(ref_split,ref_split),output=ref_split,quiet=True) 153 | ref = ref_split 154 | shutil.rmtree('/tmp/%s/'%ref_split) 155 | 156 | ## Split OSM datasets 157 | grass.run_command("v.split",input=osm,output=osm_split,vertices=2,quiet=True) 158 | grass.run_command("v.out.ogr",input=osm_split,output="/tmp/%s"%osm_split,flags="s",quiet=True) 159 | grass.run_command("g.remove",type="vect",name=osm_split,flags="f",quiet=True) 160 | grass.run_command("v.in.ogr",input="/tmp/%s/%s.shp"%(osm_split,osm_split),output=osm_split,quiet=True) 161 | osm_orig = osm 162 | osm = osm_split 163 | shutil.rmtree('/tmp/%s/'%osm_split) 164 | 165 | # Calculate degree and extract REF category lines intersecting points with minimum value 166 | grass.run_command("v.net.centrality",input=ref, output=deg_points, degree="degree",flags="a",quiet=True) 167 | list_values = (grass.read_command("v.db.select",map=deg_points,columns="degree",flags="c",quiet=True)).split("\n")[0:-1] 168 | degmin = min(map(float,list_values)) 169 | 170 | grass.run_command("v.extract", input=deg_points, output=degmin_points, where="degree=%s"%degmin,quiet=True) 171 | grass.run_command("v.select",ainput=ref,binput=degmin_points,output=ref_degmin,operator="overlap",quiet=True) 172 | list_lines = (grass.read_command("v.db.select",map=ref_degmin,columns="cat",flags="c",quiet=True)).split("\n")[0:-1] 173 | #print list_lines 174 | 175 | ## Create new vector map 176 | grass.run_command("v.edit",map=patch+"_0_0",tool="create",quiet=True) 177 | 178 | list_feature = grass.read_command("v.db.select",map=ref,columns="cat",flags="c",quiet=True).split("\n")[0:-1] 179 | i=0 180 | z=0 181 | #print list_feature 182 | 183 | ## Angular coefficient Comparison 184 | for f in list_feature: 185 | grass.run_command("v.extract",input=ref,output=fdata+"_%s"%f,where="cat=%s"%f,overwrite=True,quiet=True) 186 | if f in list_lines: 187 | grass.run_command("v.buffer",input=fdata+"_%s"%f,output=fbuffer+"_%s"%f,flags="c",distance=bf,overwrite=True,quiet=True) 188 | else: 189 | grass.run_command("v.buffer",input=fdata+"_%s"%f,output=fbuffer+"_%s"%f,distance=bf,overwrite=True,quiet=True) 190 | 191 | grass.run_command("v.overlay",ainput=osm, atype="line",binput=fbuffer+"_%s"%f,output=odata+"_%s"%f,operator="and",overwrite=True,quiet=True) 192 | lines = ((grass.read_command("v.info", map=odata+"_%s"%f,flags="t",quiet=True)).split("\n")[2]).split("=")[1] 193 | if int(lines)==0: 194 | grass.run_command("g.remove", type="vect", name="%s_%s,%s_%s,%s_%s"%(fdata,f,fbuffer,f,odata,f),flags="f",quiet=True) 195 | else: 196 | ## Get REF angular coefficient 197 | list_subfeature = grass.read_command("v.db.select",map=odata+"_%s"%f,columns="cat",flags="c",quiet=True).split("\n")[0:-1] 198 | m_ref = GetCoeff(fdata+"_%s"%f) 199 | #print m_ref 200 | 201 | ## Get OSM subfeatures angular coefficient 202 | for sf in list_subfeature: 203 | grass.run_command("v.extract",input=odata+"_%s"%f,output=osdata+"_%s_%s"%(f,sf),where="cat=%s"%sf,overwrite=True,quiet=True) 204 | m_osm = GetCoeff(osdata+"_%s_%s"%(f,sf)) 205 | 206 | 207 | if math.degrees(abs(math.atan((m_ref-m_osm)/(1+m_ref*m_osm))))<=angle_thres: 208 | grass.run_command("v.patch",input="%s_%s_%s,%s_%s_%s"%(patch,i,z,osdata,f,sf),output=patch+"_%s_%s"%(f,sf),overwrite=True,quiet=True) 209 | grass.run_command("g.remove", type="vect", name="%s_%s_%s,%s_%s_%s"%(patch,i,z,osdata,f,sf), flags="f",quiet=True) 210 | i=f 211 | z=sf 212 | else: 213 | grass.run_command("g.remove", type="vect", name=osdata+"_%s_%s"%(f,sf), flags="f",quiet=True) 214 | grass.run_command("g.remove", type="vect", name="%s_%s,%s_%s,%s_%s"%(fdata,f,fbuffer,f,odata,f), flags="f",quiet=True) 215 | 216 | ## Clean output map 217 | l_map = grass.read_command("g.list",type="vect",quiet=True).split("\n")[0:-1] 218 | last_map = [s for s in l_map if "patch" in s] 219 | grass.run_command("v.buffer", input=last_map[0],output=outbuff, distance=0.0001,quiet=True) 220 | grass.run_command("v.overlay",ainput=osm_orig,atype="line",binput=outbuff,output=out,operator="and",flags="t",quiet=True) 221 | 222 | ## Delete all maps 223 | grass.run_command("g.remove",type="vect",name="%s,%s,%s,%s,%s,%s,%s"%(deg_points,ref_degmin,degmin_points,ref_gen,ref_split,osm_split,outbuff),flags="f",quiet=True) 224 | 225 | grass.run_command("g.remove",type="vect",name="%s"%last_map[0],flags="f",quiet=True) 226 | 227 | ## Calculate final map statistics 228 | l_osm_proc = length(out) 229 | diff_osm = l_osm - l_osm_proc 230 | diff_p_osm = diff_osm/l_osm*100 231 | diff_new = l_ref - l_osm_proc 232 | diff_p_new = diff_new/l_ref*100 233 | 234 | ## Write output file with statistics (if required) 235 | if len(out_file)>0: 236 | fil=open(out_file,"w") 237 | fil.write("REF dataset length: %s m\n"%(round(l_ref,1))) 238 | fil.write("Original OSM dataset length: %s m\n"%(round(l_osm,1))) 239 | fil.write("Processed OSM dataset length: %s m\n"%(round(l_osm_proc,1))) 240 | fil.write("Difference between OSM original and processed datasets length: %s m (%s%%)\n"%(round(diff_osm,1),round(diff_p_osm,1))) 241 | fil.write("Difference between REF dataset and processed OSM dataset length: %s m (%s%%)\n"%(round(diff_new,1),round(diff_p_new,1))) 242 | fil.close() 243 | 244 | ## Print statistics 245 | print("#####################################################################\n") 246 | print("Original OSM dataset length: %s m\n"%(round(l_osm,1))) 247 | print("Processed OSM dataset length: %s m\n"%(round(l_osm_proc,1))) 248 | print("Difference between OSM original and processed datasets length: %s m (%s%%)\n"%(round(diff_osm,1),round(diff_p_osm,1))) 249 | print("Difference between REF dataset and processed OSM dataset length: %s m (%s%%)\n"%(round(diff_new,1),round(diff_p_new,1))) 250 | print("#####################################################################\n") 251 | 252 | 253 | 254 | if __name__ == "__main__": 255 | options,flags = grass.parser() 256 | sys.exit(main()) 257 | 258 | -------------------------------------------------------------------------------- /GRASS-scripts/v.osm.acc/v.osm.acc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | ############################################################################## 4 | # MODULE: v.osm.acc 5 | # AUTHOR(S): Monia Elisa Molinari, Marco Minghini 6 | # PURPOSE: Tool for accuracy assessment of OSM data 7 | # COPYRIGHT: (C) 2015 by the GRASS Development Team 8 | # 9 | # This program is free software under the GNU General Public 10 | # License (>=v2). Read the file COPYING that comes with GRASS 11 | # for details. 12 | # ############################################################################ 13 | #%Module 14 | #% description: Tool for accuracy assessment of OSM data 15 | #% keywords: vector 16 | #% keyword: OSM 17 | #% keyword: accuracy 18 | #%End 19 | #%option G_OPT_V_INPUT 20 | #% key: osm 21 | #% label: OpenStreetMap dataset 22 | #% required : yes 23 | #%end 24 | #%option G_OPT_V_INPUT 25 | #% key: ref 26 | #% label: Reference dataset 27 | #% required : yes 28 | #%end 29 | #%option G_OPT_V_INPUT 30 | #% key: grid 31 | #% label: Vector grid for comparison 32 | #% guisection: Grid 33 | #% required: no 34 | #%end 35 | #%option 36 | #% key: ul_grid 37 | #% type: string 38 | #% guisection: Grid 39 | #% description: Coordinates of the upper left grid corner (x,y) 40 | #% required: no 41 | #%end 42 | #%option 43 | #% key: lr_grid 44 | #% type: string 45 | #% guisection: Grid 46 | #% description: Coordinates of the lower right grid corner (x,y) 47 | #% required: no 48 | #%end 49 | #%option 50 | #% key: box_grid 51 | #% type: string 52 | #% guisection: Grid 53 | #% description: Width and height for boxes in grid (map units) 54 | #% required: no 55 | #%end 56 | #%option G_OPT_V_INPUT 57 | #% key: output 58 | #% type: string 59 | #% guisection: Grid 60 | #% label: Name for the grid vector output map 61 | #% required: no 62 | #%end 63 | #%option 64 | #% key: tol_max 65 | #% type: double 66 | #% guisection: Deviation analysis 67 | #% description: Upper bound value for automated accuracy evaluation (map units) 68 | #% required: no 69 | #%end 70 | #%option 71 | #% key: perc 72 | #% type: double 73 | #% guisection: Deviation analysis 74 | #% description: Length percentage of OSM dataset to be considered for automated accuracy evaluation (%) 75 | #% required: no 76 | #% answer: 100 77 | #%end 78 | #%option 79 | #% key: tol_eval 80 | #% type: string 81 | #% guisection: Deviation analysis 82 | #% description: Threshold values for accuracy evaluation, separated by comma (map units) 83 | #% required: no 84 | #%end 85 | 86 | import sys 87 | import math 88 | import time 89 | import grass.script as grass 90 | 91 | def GetList(vect): 92 | list_vect = grass.read_command("v.db.select",map=vect,columns="cat",flags="c",quiet=True) 93 | list_v = list_vect.split("\n")[0:-1] 94 | return list_v 95 | 96 | def MakeGrid(n,w,s,e,nsres,ewres,out): 97 | rows = math.ceil(float((n-s)/nsres)) 98 | cols = math.ceil(float((e-w)/ewres)) 99 | grass.run_command("g.region",n=n,s=n-nsres*rows,e=w+ewres*cols,w=w,quiet=True) 100 | grass.run_command("v.mkgrid",map=out,grid="%s,%s"%(rows,cols),quiet=True) 101 | 102 | def GetRefBox(ref,ref_box,k_box,processid): 103 | N = grass.region()['n'] 104 | S = grass.region()['s'] 105 | E = grass.region()['e'] 106 | W = grass.region()['w'] 107 | grass.run_command("g.region",vect=k_box,quiet=True) 108 | ns_ext = (math.ceil(grass.region()['n']-grass.region()['s']))*10/100 109 | ew_ext = (math.ceil(grass.region()['e']-grass.region()['w']))*10/100 110 | grass.run_command("g.region",n=grass.region()['n']+ns_ext/2,s=grass.region()['s']-ns_ext/2,w=grass.region()['w']-ew_ext/2,e=grass.region()['e']+ew_ext/2,quiet=True) 111 | grass.run_command("v.in.region",output="new_box_%s"%processid,quiet=True) 112 | grass.run_command("v.overlay",ainput=ref,atype="line",binput="new_box_%s"%processid,btype="area",operator="and",output=ref_box,quiet=True) 113 | grass.run_command("g.remove",type="vect", name="new_box_%s"%processid,flags="f",quiet=True) 114 | grass.run_command("g.region",n=N,s=S,e=E,w=W,quiet=True) 115 | 116 | def AddCol(vect,t): 117 | list_c = [] 118 | list_col = ((grass.read_command("db.describe",table=vect,flags="c",quiet=True)).split("\n"))[2:-1] 119 | for c in list_col: 120 | list_c.append((c.split(":")[1]).lstrip()) 121 | if not "%s"%t in list_c: 122 | grass.run_command("v.db.addcolumn",map=vect,columns="%s double"%t,quiet=True) 123 | 124 | def length(data): 125 | feat_data = int(((grass.read_command("v.info", map=data,flags="t")).split("\n")[2]).split("=")[1]) 126 | if feat_data>0: 127 | length_data = grass.read_command("v.to.db",map=data,option="length",flags="p") 128 | s_data=0 129 | l_data = length_data.split("\n") 130 | for item in l_data[1:-1]: 131 | s_data+=float(item.split("|")[1]) 132 | else: 133 | s_data=0 134 | return s_data 135 | 136 | def CalcTol(data1,data2,value): 137 | processid = str(time.time()).replace(".","_") 138 | grass.run_command("v.buffer",input=data1,output="data1_buf_"+processid,distance=value,quiet=True) 139 | grass.run_command("v.overlay",ainput=data2,binput="data1_buf_"+processid,atype="line",btype="area",operator="and",output="data2_in_"+processid,quiet=True) 140 | val = length("data2_in_"+processid) 141 | grass.run_command("g.remove",type="vect", pattern=processid,flags="fr",quiet=True) 142 | return val 143 | 144 | def main(): 145 | osm = options["osm"] 146 | ref = options["ref"] 147 | grid = options["grid"] 148 | ul_grid = options["ul_grid"] 149 | lr_grid = options["lr_grid"] 150 | box_grid = options["box_grid"] 151 | output = options["output"] 152 | tol_eval = options["tol_eval"] 153 | tol_max = options["tol_max"] 154 | perc = float(options["perc"]) 155 | 156 | 157 | 158 | ## Check if input files exist 159 | if not grass.find_file(name=osm,element='vector')['file']: 160 | grass.fatal(_("Vector map <%s> not found") % osm) 161 | 162 | if not grass.find_file(name=ref,element='vector')['file']: 163 | grass.fatal(_("Vector map <%s> not found") % ref) 164 | 165 | if grass.find_file(name=output,element='vector')['file']: 166 | grass.fatal(_("Vector map <%s> already exists") % output) 167 | 168 | if len(grid)>0: 169 | if not grass.find_file(name=grid,element='vector')['file']: 170 | grass.fatal(_("Vector map <%s> not found") % grid) 171 | 172 | # Check length OSM and REF 173 | check_ref = length(ref) 174 | check_osm = length(osm) 175 | 176 | if check_ref == 0: 177 | grass.run_command("g.remove", type="vect", pattern="%s"%processid,flags="fr",quiet=True) 178 | grass.fatal(_("No reference data for comparison")) 179 | 180 | if check_osm == 0: 181 | grass.run_command("g.remove", type="vect", pattern="%s"%processid,flags="fr",quiet=True) 182 | grass.fatal(_("No OSM data for comparison")) 183 | 184 | 185 | ## Check tolerance parameters 186 | if (len(tol_eval)>0 and len(str(tol_max))>0): 187 | grass.fatal("Please specify only one between or parameters") 188 | 189 | if (len(tol_eval)==0 and len(str(tol_max))==0): 190 | grass.fatal("Please specify almost one between or parameters") 191 | 192 | 193 | ## Check grid parameters 194 | if (len(grid)>0 and (len(ul_grid)>0 or len(lr_grid)>0 or len(box_grid)>0 or len(output)>0)): 195 | grass.warning("A vector has been specified. All the others parameters will be ignored") 196 | 197 | if len(grid)==0: 198 | if (len(ul_grid)>0 or len(lr_grid)>0 or len(box_grid)>0) and (len(ul_grid)==0 or len(lr_grid)==0 or len(box_grid)==0 or len(output)==0): 199 | grass.fatal("Please specify all the required parameters for grid generation: ,, and .") 200 | 201 | if (len(grid)==0 and len(ul_grid)==0 and len(lr_grid)==0 and len(box_grid)==0 and len(output)==0): 202 | grass.fatal("No grid specified. The accuracy will be calculated on the whole current region. Please specify the name for the grid output vector map") 203 | 204 | 205 | # Prepare temporary map raster names 206 | processid = str(time.time()).replace(".","_") 207 | k_box = "k_box_"+processid 208 | osm_box = "osm_box_"+processid 209 | ref_box = "ref_box_"+processid 210 | tmp_output = "tmp_out_"+processid 211 | 212 | # Get or create grid # 213 | if (len(grid)>0): 214 | tmp_output = grid 215 | grass.run_command("g.region",vect=grid,quiet=True) 216 | if (len(grid)==0 and len(ul_grid)>0 and len(lr_grid)>0 and len(box_grid)>0 and len(output)>0): 217 | n = float(ul_grid.split(",")[0]) 218 | w = float(ul_grid.split(",")[1]) 219 | s = float(lr_grid.split(",")[0]) 220 | e = float(lr_grid.split(",")[1]) 221 | nsres = float(box_grid.split(",")[1]) 222 | ewres = float(box_grid.split(",")[0]) 223 | MakeGrid(n,w,s,e,nsres,ewres,tmp_output) 224 | if (len(grid)==0 and len(ul_grid)==0 and len(lr_grid)==0 and len(box_grid)==0 and len(output)>0): 225 | grass.run_command("g.region",vect=ref,quiet=True) 226 | grass.run_command("v.in.region",output=output,quiet=True) 227 | grass.run_command("v.db.addtable", map=output,quiet=True) 228 | 229 | # Extract box id with where OSM data exists 230 | if not (len(grid)==0 and len(ul_grid)==0 and len(lr_grid)==0 and len(box_grid)==0 and len(output)>0): 231 | grass.run_command("v.select",ainput=tmp_output,binput=osm,operator="overlap",output=output,quiet=True) 232 | list_box = GetList(output) 233 | 234 | # Get tolerance values and evaluate # 235 | if len(tol_eval)>0: 236 | list_tol = tol_eval.split(",") 237 | AddCol(output,"OSM") 238 | for item in list_tol: 239 | AddCol(output,"t_%s"%item) 240 | AddCol(output,"p_%s"%item) 241 | 242 | for k in list_box: 243 | grass.run_command("v.extract",input=output,output=k_box,where="cat=%s"%k,quiet=True) 244 | grass.run_command("v.overlay",ainput=osm,atype="line",binput=k_box,btype="area",operator="and",output=osm_box,quiet=True) 245 | l_osm = length(osm_box) 246 | grass.run_command("v.db.update",map=output,column="OSM",value=l_osm,where="cat=%s"%k,quiet=True) 247 | grass.run_command("v.overlay",ainput=ref,atype="line",binput=k_box,btype="area",operator="and",output=ref_box,quiet=True) 248 | feat_ref_box = int(((grass.read_command("v.info", map=ref_box,flags="t")).split("\n")[2]).split("=")[1]) 249 | if feat_ref_box>0: 250 | for item in list_tol: 251 | val = CalcTol(ref_box,osm_box,float(item)) 252 | grass.run_command("v.db.update",map=output,column="t_%s"%item,value=val,where="cat=%s"%k,quiet=True) 253 | grass.run_command("v.db.update",map=output,column="p_%s"%item,value=val*100.0/l_osm,where="cat=%s"%k,quiet=True) 254 | grass.run_command("g.remove",type="vect", pattern=processid,flags="fr",quiet=True) 255 | 256 | 257 | # Automated evaluation # 258 | if len(str(tol_max))>0: 259 | acc = 0.005 260 | AddCol(output,"OSM") 261 | AddCol(output,"TOL") 262 | 263 | for k in list_box: 264 | grass.run_command("v.extract",input=output,output=k_box,where="cat=%s"%k,quiet=True) 265 | grass.run_command("v.overlay",ainput=osm,atype="line",binput=k_box,btype="area",operator="and",output=osm_box,quiet=True) 266 | real_l_osm = length(osm_box) 267 | if perc == 100.0: 268 | l_osm = real_l_osm 269 | else: 270 | l_osm = real_l_osm*float(perc)/100.0 271 | 272 | grass.run_command("v.db.update",map=output,column="OSM",value=real_l_osm,where="cat=%s"%k,quiet=True) 273 | # Get REF_BOX data in slightly bigger box 274 | GetRefBox(ref,ref_box,k_box,processid) 275 | if length(ref_box)>0: 276 | x = 0 277 | val = 0 278 | UP = float(tol_max) 279 | DOWN = 0.0 280 | up = float(tol_max) 281 | down = 0.0 282 | mid = down + (up-down)/2 283 | exit = 0 284 | while exit==0: 285 | val = CalcTol(ref_box,osm_box,mid) 286 | 287 | if val >= l_osm: # all in 288 | new_mid = down + (mid-down)/2 289 | up = mid 290 | mid = new_mid 291 | 292 | elif val < l_osm: # not all in 293 | 294 | if not down < mid + acc < up: 295 | if up!=UP: 296 | x = up 297 | exit = 1 298 | else: 299 | exit = 2 300 | else: 301 | val = CalcTol(ref_box,osm_box,mid + acc) 302 | 303 | if val >= l_osm: # all in (considering epsilon) 304 | x = mid + acc 305 | exit = 1 306 | elif val < l_osm: # not all in (considering epsilon) 307 | new_mid =(mid+acc) + (up-(mid+acc))/2 308 | down = mid + acc 309 | mid = new_mid 310 | if exit == 1: 311 | grass.run_command("v.db.update",map=output,column="TOL",value=(math.ceil(x*100))/100,where="cat=%s"%k) 312 | grass.run_command("g.remove",type="vect",pattern=processid,flags="fr") 313 | grass.run_command("g.remove",type="vect",pattern=processid,flags="fr") 314 | 315 | 316 | if __name__ == "__main__": 317 | options,flags = grass.parser() 318 | sys.exit(main()) 319 | 320 | -------------------------------------------------------------------------------- /GRASS-scripts/v.osm.precomp/v.osm.precomp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:utf-8 -*- 3 | ############################################################################## 4 | # MODULE: v.osm.precomp 5 | # AUTHOR(S): Monia Molinari, Marco Minghini 6 | # Luca Delucchi added multiprocessing 7 | # PURPOSE: Tool for the comparison of two road datasets 8 | # COPYRIGHT: (C) 2015 by the GRASS Development Team 9 | # 10 | # This program is free software under the GNU General Public 11 | # License (>=v2). Read the file COPYING that comes with GRASS 12 | # for details. 13 | # ############################################################################ 14 | #%Module 15 | #% description: Tool for the preliminary comparison between OSM and reference datasets 16 | #% keywords: vector, OSM, comparison 17 | #%End 18 | 19 | #%option 20 | #% key: osm 21 | #% type: string 22 | #% gisprompt: old,vector,vector 23 | #% description: OpenStreetMap dataset 24 | #% required: yes 25 | #%end 26 | 27 | #%option 28 | #% key: ref 29 | #% type: string 30 | #% gisprompt: old,vector,input 31 | #% description: Reference dataset 32 | #% required: yes 33 | #%end 34 | 35 | #%option 36 | #% key: buffers 37 | #% type: string 38 | #% description: List of buffer values around reference and OpenStreetMap dataset (map units) 39 | #% required: yes 40 | #%end 41 | 42 | #%option 43 | #% key: roi 44 | #% type: string 45 | #% gisprompt: old,vector,vector 46 | #% description: Clipping mask 47 | #% required: no 48 | #%end 49 | 50 | #%option 51 | #% key: out_graphs 52 | #% type: string 53 | #% description: Folder for output graphs 54 | #% required: no 55 | #%end 56 | 57 | #%option G_OPT_F_OUTPUT 58 | #% description: Name for output file 59 | #% required: yes 60 | #%end 61 | 62 | #%option 63 | #% key: nprocs 64 | #% type: integer 65 | #% description: Number of processes to run in parallel 66 | #% required: no 67 | #% multiple: no 68 | #% answer: 1 69 | #%end 70 | 71 | import sys 72 | import time 73 | import grass.script as grass 74 | import os 75 | from multiprocessing import Queue, Process 76 | from types import TupleType 77 | 78 | 79 | def checkPath(path): 80 | if os.path.exists(path): 81 | return 0 82 | else: 83 | try: 84 | os.mkdir(path) 85 | return 0 86 | except: 87 | grass.error(_("The path '{st}' doesn't exists".format(st=path))) 88 | return 1 89 | 90 | 91 | def GetStat(osm, ref, buff, processid): 92 | buffs = str(buff).replace('.', '_') 93 | ref_buffer = "ref_buffer_{idd}_{buf}".format(idd=processid, buf=buffs) 94 | osm_buffer = "osm_buffer_{idd}_{buf}".format(idd=processid, buf=buffs) 95 | ref_in = "ref_in_{idd}_{buf}".format(idd=processid, buf=buffs) 96 | ref_out = "ref_out_{idd}_{buf}".format(idd=processid, buf=buffs) 97 | osm_in = "osm_in_{idd}_{buf}".format(idd=processid, buf=buffs) 98 | osm_out = "osm_out_{idd}_{buf}".format(idd=processid, buf=buffs) 99 | 100 | # Calculate REF data in and out OSM buffer 101 | grass.run_command("v.buffer", input=osm, output=osm_buffer, distance=buff, 102 | type="line", overwrite=True, quiet=True) 103 | grass.run_command("v.overlay", ainput=ref, binput=osm_buffer, 104 | operator="and", output=ref_in, atype="line", flags="t", 105 | overwrite=True, quiet=True) 106 | grass.run_command("v.overlay", ainput=ref, binput=osm_buffer, 107 | operator="not", output=ref_out, atype="line", flags="t", 108 | overwrite=True, quiet=True) 109 | s_ref_in = length(ref_in) 110 | s_ref_out = length(ref_out) 111 | 112 | # Calculate OSM data in and out REF buffer 113 | grass.run_command("v.buffer", input=ref, output=ref_buffer, distance=buff, 114 | type="line", overwrite=True, quiet=True) 115 | grass.run_command("v.overlay", ainput=osm, binput=ref_buffer, 116 | operator="and", output=osm_in, atype="line", flags="t", 117 | overwrite=True, quiet=True) 118 | grass.run_command("v.overlay", ainput=osm, binput=ref_buffer, 119 | operator="not", output=osm_out, atype="line", flags="t", 120 | overwrite=True, quiet=True) 121 | s_osm_in = length(osm_in) 122 | s_osm_out = length(osm_out) 123 | 124 | # Remove temporary data 125 | grass.run_command("g.remove", type="vect", flags="fr", quiet=True, 126 | pattern="*{st}_{buf}".format(st=processid, buf=buffs)) 127 | 128 | return (s_ref_in, s_ref_out, s_osm_in, s_osm_out) 129 | 130 | 131 | def Plot(buff, osm_in, ref_in, REF_tot, OSM_tot, out): 132 | import pylab 133 | 134 | ref_in = pylab.array(ref_in) 135 | ref_out = REF_tot - ref_in 136 | ref_in_perc = (ref_in / float(REF_tot)) * 100 137 | ref_out_perc = 100 - ref_in_perc 138 | osm_in = pylab.array(osm_in) 139 | osm_out = OSM_tot - osm_in 140 | osm_in_perc = (osm_in / float(OSM_tot)) * 100 141 | osm_out_perc = 100 - osm_in_perc 142 | 143 | REF_tot_km = REF_tot / float(1000) 144 | ref_in_km = ref_in / float(1000) 145 | ref_out_km = ref_out / float(1000) 146 | OSM_tot_km = OSM_tot / float(1000) 147 | osm_in_km = osm_in / float(1000) 148 | osm_out_km = osm_out / float(1000) 149 | 150 | # Plot of the length of OSM in the buffer around REF 151 | pylab.figure() 152 | pylab.plot(buff, osm_in_km, 'ro-', 153 | label='OSM total length = {st} km'.format(st=OSM_tot_km)) 154 | pylab.title('Similarity of OSM compared to REF') 155 | pylab.xlabel('Buffer width around REF dataset [m]') 156 | pylab.ylabel('OSM length included in the buffer [km]') 157 | pylab.axis([0, buff[-1] * 1.05, 0, OSM_tot_km * 1.05]) 158 | pylab.legend(loc="lower right") 159 | pylab.grid() 160 | pylab.savefig("{st}/osm_in_km.png".format(st=out)) 161 | 162 | # Plot of the percentage of OSM in the buffer around REF 163 | pylab.figure() 164 | pylab.plot(buff, osm_in_perc, 'ro-', 165 | label='OSM total length = {st} km'.format(st=OSM_tot_km)) 166 | pylab.title('Similarity of OSM compared to REF') 167 | pylab.xlabel('Buffer width around REF dataset [m]') 168 | pylab.ylabel('OSM length included in the buffer [%]') 169 | pylab.axis([0, buff[-1] * 1.05, 0, 100]) 170 | pylab.legend(loc="lower right") 171 | pylab.grid() 172 | pylab.savefig("{st}/osm_in_perc.png".format(st=out)) 173 | 174 | # Plot of the length of OSM outside the buffer around REF 175 | pylab.figure() 176 | pylab.plot(buff, osm_out_km, 'ro-', 177 | label='OSM total length = {st} km'.format(st=OSM_tot_km)) 178 | pylab.title('Similarity of OSM compared to REF') 179 | pylab.xlabel('Buffer width around REF dataset [m]') 180 | pylab.ylabel('OSM length not included in the buffer [km]') 181 | pylab.axis([0, buff[-1] * 1.05, 0, OSM_tot_km * 1.05]) 182 | pylab.legend(loc="upper right") 183 | pylab.grid() 184 | pylab.savefig("{st}/osm_out_km.png".format(st=out)) 185 | 186 | # Plot of the percentage of OSM outside the buffer around REF 187 | pylab.figure() 188 | pylab.plot(buff, osm_out_perc, 'ro-', 189 | label='OSM total length = {st} km'.format(st=OSM_tot_km)) 190 | pylab.title('Similarity of OSM compared to REF') 191 | pylab.xlabel('Buffer width around REF dataset [m]') 192 | pylab.ylabel('OSM length not included in the buffer [%]') 193 | pylab.axis([0, buff[-1] * 1.05, 0, 100]) 194 | pylab.legend(loc="upper right") 195 | pylab.grid() 196 | pylab.savefig("{st}/osm_out_perc.png".format(st=out)) 197 | 198 | # Plot of the length of REF in the buffer around OSM 199 | pylab.figure() 200 | pylab.plot(buff, ref_in_km, 'bo-', 201 | label='REF total length = {st} km'.format(st=REF_tot_km)) 202 | pylab.title('Similarity of REF compared to OSM') 203 | pylab.xlabel('Buffer width around OSM dataset [m]') 204 | pylab.ylabel('REF length included in the buffer [km]') 205 | pylab.axis([0, buff[-1] * 1.05, 0, REF_tot_km * 1.05]) 206 | pylab.legend(loc="lower right") 207 | pylab.grid() 208 | pylab.savefig("{st}/ref_in_km.png".format(st=out)) 209 | 210 | # Plot of the percentage of REF in the buffer around OSM 211 | pylab.figure() 212 | pylab.plot(buff, ref_in_perc, 'bo-', 213 | label='REF total length = {st} km'.format(st=REF_tot_km)) 214 | pylab.title('Similarity of REF compared to OSM') 215 | pylab.xlabel('Buffer width around OSM dataset [m]') 216 | pylab.ylabel('REF length included in the buffer [%]') 217 | pylab.axis([0, buff[-1] * 1.05, 0, 100]) 218 | pylab.legend(loc="lower right") 219 | pylab.grid() 220 | pylab.savefig("{st}/ref_in_perc.png".format(st=out)) 221 | 222 | # Plot of the length of REF outside the buffer around OSM 223 | pylab.figure() 224 | pylab.plot(buff, ref_out_km, 'bo-', 225 | label='REF total length = {st} km'.format(st=REF_tot_km)) 226 | pylab.title('Similarity of REF compared to OSM') 227 | pylab.xlabel('Buffer width around OSM dataset [m]') 228 | pylab.ylabel('REF length not included in the buffer [km]') 229 | pylab.axis([0, buff[-1] * 1.05, 0, REF_tot_km * 1.05]) 230 | pylab.legend(loc="upper right") 231 | pylab.grid() 232 | pylab.savefig("{st}/ref_out_km.png".format(st=out)) 233 | 234 | # Plot of the percentage of REF outside the buffer around OSM 235 | pylab.figure() 236 | pylab.plot(buff, ref_out_perc, 'bo-', 237 | label='REF total length = {st} km'.format(st=REF_tot_km)) 238 | pylab.title('Similarity of REF compared to OSM') 239 | pylab.xlabel('Buffer width around OSM dataset [m]') 240 | pylab.ylabel('REF length not included in the buffer [%]') 241 | pylab.axis([0, buff[-1] * 1.05, 0, 100]) 242 | pylab.legend(loc="upper right") 243 | pylab.grid() 244 | pylab.savefig("{st}/ref_out_perc.png".format(st=out)) 245 | return 0 246 | 247 | 248 | def length(data): 249 | feat_osm = int(((grass.read_command("v.info", map=data, flags="t", 250 | quiet=True)).split("\n")[2]).split("=")[1]) 251 | if feat_osm > 0: 252 | length_data = grass.read_command("v.to.db", map=data, option="length", 253 | flags="p") 254 | s_data = 0 255 | l_data = length_data.split("\n") 256 | for item in l_data[1:-1]: 257 | s_data += float(item.split("|")[1]) 258 | else: 259 | s_data = 0 260 | return s_data 261 | 262 | 263 | def GetInfo(fileName): 264 | lines = [line.strip() for line in open(fileName)] 265 | ref_in = lines[3].split(': ')[1].split(' ')[0] 266 | osm_in = lines[5].split(': ')[1].split(' ')[0] 267 | return (float(ref_in), float(osm_in)) 268 | 269 | 270 | def calculate(osm, s_osm, ref, s_ref, b, processid): 271 | (s_ref_in, s_ref_out, s_osm_in, s_osm_out) = GetStat(osm, ref, b, 272 | processid) 273 | osm_in = round(s_osm_in, 1) 274 | var_osm_in = round(s_osm_in / s_osm * 100, 1) 275 | ref_in = round(s_ref_in, 1) 276 | var_ref_in = round(s_ref_in / s_ref * 100, 1) 277 | osm_out = round(s_osm_out, 1) 278 | var_osm_out = round(s_osm_out / s_osm * 100, 1) 279 | ref_out = round(s_ref_out, 1) 280 | var_ref_out = round(s_ref_out / s_ref * 100, 1) 281 | 282 | out = "{bi}|{oi}|{voi}|{oo}|{voo}|{ri}|{vri}|{ro}|{vro}" \ 283 | "\n".format(bi=b, oi=osm_in, voi=var_osm_in, oo=osm_out, 284 | voo=var_osm_out, ri=ref_in, vri=var_ref_in, 285 | ro=ref_out, vro=var_ref_out) 286 | return osm_in, ref_in, out 287 | 288 | 289 | def spawn(func): 290 | def fun(q_in, q_out): 291 | while True: 292 | osm, so, ref, sr, b, pr = q_in.get() 293 | if b is None: 294 | break 295 | q_out.put(func(osm, so, ref, sr, b, pr)) 296 | return fun 297 | 298 | 299 | def main(): 300 | processid = str(time.time()).replace(".", "_") 301 | osm = options["osm"] 302 | ref = options["ref"] 303 | buff = options["buffers"] 304 | roi = options["roi"] 305 | out_graphs = options["out_graphs"] 306 | out = options["output"] 307 | nproc = int(options["nprocs"]) 308 | 309 | # Check if input files exist 310 | if not grass.find_file(name=osm, element='vector')['file']: 311 | grass.fatal(_("Vector map <%s> not found") % osm) 312 | 313 | if not grass.find_file(name=ref, element='vector')['file']: 314 | grass.fatal(_("Vector map <%s> not found") % ref) 315 | 316 | if len(roi) > 0: 317 | if not grass.find_file(name=roi, element='vector')['file']: 318 | grass.fatal(_("Vector map <%s> not found") % roi) 319 | 320 | # OSM and REF length 321 | s_ref = length(ref) 322 | s_osm = length(osm) 323 | 324 | if s_ref == 0: 325 | grass.run_command("g.remove", type="vect", flags="fr", 326 | pattern="{st}*".format(st=processid), quiet=True) 327 | grass.fatal(_("No reference data for comparison")) 328 | 329 | if s_osm == 0: 330 | grass.run_command("g.remove", type="vect", flags="fr", 331 | pattern="{st}*".format(st=processid), quiet=True) 332 | grass.fatal(_("No OSM data for comparison")) 333 | 334 | diff = s_ref - s_osm 335 | diff_p = diff / s_ref * 100 336 | 337 | # Temporary names 338 | processid = str(time.time()).replace(".", "_") 339 | ref_roi = "ref_roi_" + processid 340 | osm_roi = "osm_roi_" + processid 341 | 342 | # Apply mask 343 | if len(roi) > 0: 344 | grass.run_command("v.overlay", ainput=ref, atype="line", binput=roi, 345 | operator="and", output=ref_roi, flags="t", quiet=True) 346 | grass.run_command("v.overlay", ainput=osm, atype="line", binput=roi, 347 | operator="and", output=osm_roi, flags="t", quiet=True) 348 | ref = ref_roi 349 | osm = osm_roi 350 | 351 | # Extract list of buffer values 352 | list_buff = map(float, buff.split(",")) 353 | 354 | # Calculate list of statistics 355 | l_osm_in = [] 356 | l_ref_in = [] 357 | 358 | q_in = Queue(1) 359 | q_out = Queue() 360 | procs = [Process(target=spawn(calculate), args=(q_in, q_out)) 361 | for _ in range(nproc)] 362 | for proc in procs: 363 | proc.daemon = True 364 | proc.start() 365 | # for each file create the polygon of bounding box 366 | ans = [q_in.put((osm, s_osm, ref, s_ref, i, processid)) for i in list_buff] 367 | 368 | # set the end of the cycle 369 | [q_in.put((None, None, None, None, None, None)) for proc in procs] 370 | [proc.join() for proc in procs] 371 | processed = [q_out.get() for _ in ans] 372 | if len(processed) != len(list_buff): 373 | grass.fatal(_("Some errors occurred during analysis")) 374 | return 0 375 | # Print statistics 376 | checkPath(os.path.split(out)[0]) 377 | fil = open(out, "w") 378 | fil.write("REF length: {rl} m\n".format(rl=round(s_ref, 1))) 379 | fil.write("OSM length: {ol} m\n".format(ol=round(s_osm, 1))) 380 | fil.write("REF-OSM difference: {di} m ({dp}%)\n".format(di=round(diff, 1), 381 | dp=round(diff_p, 1))) 382 | fil.write("\n") 383 | fil.write("BUFFER(m)|OSM_IN(m)|OSM_IN(%%)|OSM_OUT(m)|OSM_OUT(%%)|REF_IN(m)" 384 | "|REF_IN(%%)|REF_OUT(m)|REF_OUT(%%)\n") 385 | for p in processed: 386 | if type(p) != TupleType or len(p) != 3: 387 | grass.fatal(_("Some errors occurred during analysis")) 388 | return 0 389 | l_osm_in.append(p[0]) 390 | l_ref_in.append(p[1]) 391 | fil.write(p[2]) 392 | 393 | fil.close() 394 | # Remove temporary data 395 | grass.run_command("g.remove", type="vect", flags="fr", 396 | pattern="{st}*".format(st=processid), quiet=True) 397 | # Graphs 398 | checkPath(out_graphs) 399 | if out_graphs: 400 | Plot(list_buff, l_osm_in, l_ref_in, s_ref, s_osm, out_graphs) 401 | 402 | if __name__ == "__main__": 403 | options, flags = grass.parser() 404 | sys.exit(main()) 405 | 406 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | --------------------------------------------------------------------------------