-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
98 lines (84 loc) · 2.61 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# -*- coding: utf-8 -*-
'''
Created on 2016. jún. 29.
@author: padanyigulyasgergely
'''
from osgeo import ogr
from tools.atool import Atool
from tools.dbtool import DbTool
from tools.wmstool import WmsTool
atool = Atool()
dbParams = None
wmsParams = None
###########################
# USER DEFINED PARAMETERS #
###########################
# scales for wms requests
scales = [4000000, 2000000, 1000000]
# save directory in the file system
saveDir = r"E:\DATA\wms-thief_tiles"
# wms GetMap call parameters
url = "http://172.24.0.170:8080/geoserver/wms"
layer = "osmWsp:osm_hungary"
crs = 23700
width = 256
height = width
image_format = "png"
wms_version = "1.3.0"
styles = ""
# set the bounding box of the area to process
startX = 426402.66751693
startY = 43771.2799996209
endX = 937395.20651658
endY = 362942.143500254
# decide whether you wish to use a mask layer for the tiles or not
use_wkt = True
# decide whether you wish to store tile vectors and metadata in a PostGIS db
use_db = True
# decide whether you wish to clean the vector tiles in the db before processing
# it is recommended to set to True for the first run
# it is recommended to set to False if you have already processed a few scales and wish to continue
# with another scales but want to keep the previous run's metadata
clean_db = True
# path to a wkt file for intersection checking
# it should be in the same crs as stored in the 'crs' variable (e.g. 23700)
# MANDATORY IF 'use_wkt' is set to True
wktFile = "data/wkt/intersect_layer_wkt.txt"
# database connection parameters
# MANDATORY IF 'use_db' is set to True
dbHost = 'localhost'
dbName = 'wmsthief'
dbUser = 'postgres'
dbPassword = 'passpostgres'
dbPort = '5435'
######################
# PREPARE FOR LAUNCH #
######################
if use_db:
dbParams = {'host': dbHost,
'name': dbName,
'user': dbUser,
'password': dbPassword,
'port': dbPort}
wmsParams = {'dir': saveDir,
'scales': scales,
'url': url,
'crs': crs,
'width': width,
'height': height,
'layer': layer,
'image_format': image_format,
'wms_version': wms_version,
'styles': styles,
'startx': startX,
'starty' : startY,
'endx': endX,
'endy': endY,
'wkt': ogr.CreateGeometryFromWkt(atool.read_file_content(wktFile)) if use_wkt else None,
'db': DbTool(dbParams) if use_db else None,
'clean_db': clean_db}
wms = WmsTool(wmsParams)
###############
# THE PROGRAM #
###############
wms.process_scales()