-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.bat
More file actions
395 lines (363 loc) · 11.3 KB
/
Copy pathsetup.bat
File metadata and controls
395 lines (363 loc) · 11.3 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
@echo off
REM City2TABULA Windows Setup Script
REM This script provides the same functionality as the makefile for Windows users
if "%1"=="" goto help
if "%1"=="help" goto help
if "%1"=="configure" goto configure
if "%1"=="configure-manual" goto configure-manual
if "%1"=="build" goto build
if "%1"=="up" goto up
if "%1"=="down" goto down
if "%1"=="dev" goto dev
if "%1"=="create-db" goto create-db
if "%1"=="extract-features" goto extract-features
if "%1"=="reset-db" goto reset-db
if "%1"=="version" goto version
if "%1"=="v" goto v
if "%1"=="setup" goto setup
if "%1"=="quick-start" goto quick-start
if "%1"=="status" goto status
if "%1"=="logs" goto logs
if "%1"=="clean" goto clean
if "%1"=="clean-all" goto clean-all
echo Unknown command: %1
goto help
:help
echo City2TABULA Windows Commands
echo ============================
echo.
echo Usage: setup.bat ^<command^>
echo.
echo Recommended Workflow:
echo 1. setup.bat configure - Set country, DB credentials in environment\docker.env
echo 2. setup.bat build - Build the Docker image
echo 3. setup.bat create-db - Create database schemas and import CityDB data
echo (If database already exists, run: setup.bat reset-db)
echo 4. setup.bat extract-features - Run the feature extraction pipeline
echo.
echo Docker Environment:
echo build Build the Docker environment
echo up Start the Docker environment
echo down Stop the Docker environment
echo logs View Docker logs
echo status Check container status
echo.
echo Application Commands:
echo dev Start development environment with shell
echo create-db Create database and setup schemas
echo extract-features Extract building features
echo reset-db Reset the entire database
echo version (v) Check City2TABULA version
echo.
echo Complete Workflows:
echo configure Interactive setup: select country and enter password
echo configure-manual Instructions for manual editing of docker.env
echo setup Build environment, configure, and start containers
echo quick-start Complete setup and processing
echo.
echo Cleanup:
echo clean Stop containers and remove volumes
echo clean-all Remove containers, volumes, and images
echo.
echo Examples:
echo setup.bat configure
echo setup.bat build
echo setup.bat create-db (or) setup.bat reset-db \if DB already exists
echo setup.bat extract-features
goto end
:configure
echo Interactive City2TABULA Configuration
echo ====================================
echo.
echo Base configuration copied!
echo.
echo Available Countries:
echo ===================
echo 1) austria - SRID: 31256 (MGI / Austria GK East)
echo 2) belgium - SRID: 31370 (Belgian Lambert 72)
echo 3) cyprus - SRID: 3879 (GRS 1980 / Cyprus TM)
echo 4) czechia - SRID: 5514 (S-JTSK / Krovak East North)
echo 5) denmark - SRID: 25832 (ETRS89 / UTM zone 32N)
echo 6) france - SRID: 2154 (RGF93 / Lambert-93)
echo 7) germany - SRID: 25832 (ETRS89 / UTM zone 32N)
echo 8) greece - SRID: 2100 (GGRS87 / Greek Grid)
echo 9) hungary - SRID: 23700 (EOV)
echo 10) ireland - SRID: 29902 (Irish National Grid)
echo 11) italy - SRID: 3003 (Monte Mario / Italy zone 1)
echo 12) netherlands - SRID: 28992 (Amersfoort / RD New)
echo 13) norway - SRID: 25833 (ETRS89 / UTM zone 33N)
echo 14) poland - SRID: 2180 (ETRS89 / Poland CS2000 zone 5)
echo 15) serbia - SRID: 3114 (Serbian 1970 / Serbian Grid)
echo 16) slovenia - SRID: 3794 (Slovenia 1996 / Slovene National Grid)
echo 17) spain - SRID: 25830 (ETRS89 / UTM zone 30N)
echo 18) sweden - SRID: 3006 (SWEREF99 TM)
echo 19) united_kingdom - SRID: 27700 (OSGB 1936 / British National Grid)
echo.
:country_loop
set /p country_choice="For which country would you like to configure City2TABULA? Enter a number (1-19): "
if "%country_choice%"=="1" (
set COUNTRY=austria
set SRID=31256
set SRS_NAME=MGI / Austria GK East
goto country_selected
)
if "%country_choice%"=="2" (
set COUNTRY=belgium
set SRID=31370
set SRS_NAME=Belgian Lambert 72
goto country_selected
)
if "%country_choice%"=="3" (
set COUNTRY=cyprus
set SRID=3879
set SRS_NAME=GRS 1980 / Cyprus TM
goto country_selected
)
if "%country_choice%"=="4" (
set COUNTRY=czechia
set SRID=5514
set SRS_NAME=S-JTSK / Krovak East North
goto country_selected
)
if "%country_choice%"=="5" (
set COUNTRY=denmark
set SRID=25832
set SRS_NAME=ETRS89 / UTM zone 32N
goto country_selected
)
if "%country_choice%"=="6" (
set COUNTRY=france
set SRID=2154
set SRS_NAME=RGF93 / Lambert-93
goto country_selected
)
if "%country_choice%"=="7" (
set COUNTRY=germany
set SRID=25832
set SRS_NAME=ETRS89 / UTM zone 32N
goto country_selected
)
if "%country_choice%"=="8" (
set COUNTRY=greece
set SRID=2100
set SRS_NAME=GGRS87 / Greek Grid
goto country_selected
)
if "%country_choice%"=="9" (
set COUNTRY=hungary
set SRID=23700
set SRS_NAME=EOV
goto country_selected
)
if "%country_choice%"=="10" (
set COUNTRY=ireland
set SRID=29902
set SRS_NAME=Irish National Grid
goto country_selected
)
if "%country_choice%"=="11" (
set COUNTRY=italy
set SRID=3003
set SRS_NAME=Monte Mario / Italy zone 1
goto country_selected
)
if "%country_choice%"=="12" (
set COUNTRY=netherlands
set SRID=28992
set SRS_NAME=Amersfoort / RD New
goto country_selected
)
if "%country_choice%"=="13" (
set COUNTRY=norway
set SRID=25833
set SRS_NAME=ETRS89 / UTM zone 33N
goto country_selected
)
if "%country_choice%"=="14" (
set COUNTRY=poland
set SRID=2180
set SRS_NAME=ETRS89 / Poland CS2000 zone 5
goto country_selected
)
if "%country_choice%"=="15" (
set COUNTRY=serbia
set SRID=3114
set SRS_NAME=Serbian 1970 / Serbian Grid
goto country_selected
)
if "%country_choice%"=="16" (
set COUNTRY=slovenia
set SRID=3794
set SRS_NAME=Slovenia 1996 / Slovene National Grid
goto country_selected
)
if "%country_choice%"=="17" (
set COUNTRY=spain
set SRID=25830
set SRS_NAME=ETRS89 / UTM zone 30N
goto country_selected
)
if "%country_choice%"=="18" (
set COUNTRY=sweden
set SRID=3006
set SRS_NAME=SWEREF99 TM
goto country_selected
)
if "%country_choice%"=="19" (
set COUNTRY=united_kingdom
set SRID=27700
set SRS_NAME=OSGB 1936 / British National Grid
goto country_selected
)
echo Invalid selection. Please enter a number (1-19).
goto country_loop
:country_selected
echo.
echo Selected: %COUNTRY% (SRID: %SRID%)
echo.
echo Database Configuration:
echo =======================
REM Get username with default
set /p pg_user="Enter PostgreSQL username [default: postgres]: "
if "%pg_user%"=="" set pg_user=postgres
REM Get password using PowerShell for hidden input
echo Enter PostgreSQL password:
powershell -Command "$password = Read-Host -AsSecureString; $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password); $PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR); [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($BSTR); $PlainPassword" > temp_password.txt
set /p pg_password=<temp_password.txt
del temp_password.txt
REM Get database name with default
set /p pg_name="Enter Database name [default: c2t_%COUNTRY%]: "
if "%pg_name%"=="" set pg_name=c2t_%COUNTRY%
echo.
echo Updating environment\docker.env...
REM Update docker.env file using PowerShell for reliable text replacement
powershell -Command "(Get-Content 'environment\docker.env') -replace '^COUNTRY=.*', 'COUNTRY=%COUNTRY%' | Set-Content 'environment\docker.env'"
powershell -Command "(Get-Content 'environment\docker.env') -replace '^CITYDB_SRID=.*', 'CITYDB_SRID=%SRID%' | Set-Content 'environment\docker.env'"
powershell -Command "(Get-Content 'environment\docker.env') -replace '^CITYDB_SRS_NAME=.*', 'CITYDB_SRS_NAME=%SRS_NAME%' | Set-Content 'environment\docker.env'"
powershell -Command "(Get-Content 'environment\docker.env') -replace '^DB_USER=.*', 'DB_USER=%pg_user%' | Set-Content 'environment\docker.env'"
powershell -Command "(Get-Content 'environment\docker.env') -replace '^DB_PASSWORD=.*', 'DB_PASSWORD=%pg_password%' | Set-Content 'environment\docker.env'"
powershell -Command "(Get-Content 'environment\docker.env') -replace '^DB_NAME=.*', 'DB_NAME=%pg_name%' | Set-Content 'environment\docker.env'"
echo Configuration completed!
echo.
echo Summary:
echo ========
echo Country: %COUNTRY%
echo SRID: %SRID%
echo SRS Name: %SRS_NAME%
echo Database: Configured
echo.
echo Next steps:
echo - Place your data in data\lod2\%COUNTRY%\ and data\lod3\%COUNTRY%\
echo - Run 'setup.bat build' to build the Docker image
echo - Run 'setup.bat create-db' to create database and import data
echo - Run 'setup.bat extract-features' to extract building features
goto end
:configure-manual
echo Manual configuration mode...
echo Please edit environment\docker.env manually:
copy environment\docker.env .env
echo .env file created!
echo Please edit .env manually:
echo - Set COUNTRY to your target country
echo - Set CITYDB_SRID to the appropriate SRID
echo - Set CITYDB_SRS_NAME to the appropriate SRS name
echo - Replace '^<your_pg_password^>' with your PostgreSQL password
echo.
echo You can edit the file with:
echo notepad docker.env
echo.
goto end
:build
echo Building Docker environment...
cd environment
docker compose --env-file docker.env build --no-cache
cd ..
goto end
:up
echo Starting Docker environment...
cd environment
docker compose --env-file docker.env up -d
cd ..
goto end
:down
echo Stopping Docker environment...
cd environment
docker compose --env-file docker.env down
cd ..
goto end
:dev
echo Starting development environment...
cd environment
docker compose --env-file docker.env up -d
docker exec -it city2tabula-environment bash
cd ..
goto end
:create-db
call :up
echo Creating database and setting up schemas...
cd environment
docker exec -it city2tabula-environment ./city2tabula -create-db
cd ..
goto end
:extract-features
call :up
echo Extracting building features...
cd environment
docker exec -it city2tabula-environment ./city2tabula -extract-features
cd ..
goto end
:reset-db
call :up
echo Resetting the entire database...
cd environment
docker exec -it city2tabula-environment ./city2tabula -reset-db
cd ..
goto end
:version
call :up
echo Checking City2TABULA version...
cd environment
docker exec -it city2tabula-environment ./city2tabula -version
cd ..
goto end
:v
goto version
:setup
echo Setting up City2TABULA environment...
call :build
call :configure
call :up
echo Environment is ready! Run 'setup.bat dev' to access the shell
goto end
:quick-start
echo Running complete City2TABULA pipeline...
call :setup
call :create-db
call :extract-features
echo Quick start complete!
goto end
:status
echo Checking container status...
cd environment
docker compose --env-file docker.env ps
cd ..
goto end
:logs
echo Viewing Docker logs...
cd environment
docker compose --env-file docker.env logs -f
cd ..
goto end
:clean
echo Stopping containers and removing volumes...
cd environment
docker compose --env-file docker.env down -v
cd ..
goto end
:clean-all
echo Removing containers, volumes, and images...
cd environment
docker compose --env-file docker.env down -v --rmi all
cd ..
goto end
:end