-
Notifications
You must be signed in to change notification settings - Fork 1
/
kml.bat
168 lines (168 loc) · 8.1 KB
/
kml.bat
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
@echo off
setlocal enabledelayedexpansion
if "%~1"=="" (set kmlrepscan=%~dp0) else (for /F "delims=" %%i in ("%~1\") do set kmlrepscan=%%~dpi)
if "%~2"=="" (set kmlrepdest=%kmlrepscan%) else (for /F "delims=" %%i in ("%~2\") do set kmlrepdest=%%~dpi)
if not exist "%kmlrepdest%thumbs" mkdir "%kmlrepdest%thumbs"
chcp 1252 >nul
echo.
set kmlviewer=%kmlrepdest%viewer.htm
if not exist "%kmlviewer%" copy "%~dp0viewer.htm" "%kmlviewer%">nul
if exist "%~dp0kmlz.ps1" (
for %%p in (pwsh.exe) do set kmlps="%%~$PATH:p"
if !kmlps!=="" (set kmlps=powershell) else (set DOTNET_SYSTEM_GLOBALIZATION_USENLS=1)
!kmlps! -executionpolicy bypass -file "%~dp0kmlz.ps1" "%kmlrepscan%\" "%kmlrepdest%\" l
if !ERRORLEVEL! NEQ 0 (
echo.
pause
)
goto end
)
if exist "%~dp0kmlz.py" (
call "%~dp0kmlz" "%kmlrepscan%\" "%kmlrepdest%\" l
if !ERRORLEVEL! NEQ 0 (
echo.
pause
)
goto end
)
echo Scan de "%kmlrepscan%" pour création des miniatures dans "%kmlrepdest%thumbs\"
for /F "delims=/" %%i in ("%kmlrepscan:~0,-1%") do set kmlname=%%~ni
if exist "%kmlrepdest%%kmlname%.lst" del "%kmlrepdest%%kmlname%.lst"
set kmlerr=0
for %%i in ("%kmlrepscan%*.jp*g") do if not exist "%kmlrepdest%thumbs\%kmlname% - %%~ni.jpg" echo %%i >>"%kmlrepdest%%kmlname%.lst"
if exist "%kmlrepdest%%kmlname%.lst" (
if exist "%~dp0resize.ps1" (
powershell -executionpolicy bypass -file "%~dp0resize.ps1" "%kmlrepdest%%kmlname%.lst" "%kmlrepdest%thumbs\%kmlname%"
) else if exist "%~dp0resize.py" (
call "%~dp0resize" "%kmlrepdest%%kmlname%.lst" "%kmlrepdest%thumbs\%kmlname%"
) else (
"C:\Program Files (x86)\Irfanview\i_view32.exe" /filelist="%kmlrepdest%\%kmlname%.lst" /resize_long=150 /aspectratio /resample /ini="%~dp0" /convert="%kmlrepdest%thumbs\%kmlname% - $N.jpg"
)
if !ERRORLEVEL! NEQ 0 (
set kmlerr=1
echo Erreur lors de la création des miniatures
)
del "%kmlrepdest%%kmlname%.lst"
)
set kmlfic="%kmlrepdest%%kmlname%.kml"
set kmlviewer=%kmlviewer:\=/%
set kmliconpref=file:///%kmlrepdest:\=/%thumbs/%kmlname% -
echo. 2>"%kmlrepdest%%kmlname%.lst"
echo Scan de "%kmlrepscan%" pour création de %kmlfic%
for /F "delims=*" %%i in ('dir /b /o:n "%kmlrepscan%*.jp*g"') do echo %kmlrepscan%%%~nxi>>"%kmlrepdest%%kmlname%.lst"
chcp 65001 >nul
"C:\Program Files (x86)\ExifTool\exiftool.exe" -createdate -gpslatitude -gpslongitude -ifd0:orientation# -filename -d "%%d/%%m/%%Y %%H:%%M:%%S" -c "%%+.6f" -f -args -charset filename=Latin -charset EXIF=UTF8 -@ "%kmlrepdest%%kmlname%.lst" >"%kmlrepdest%%kmlname%.exif"
if !ERRORLEVEL! NEQ 0 (
set kmlerr=1
echo Erreur lors de la récupération des métadonnées
)
echo ^<?xml version="1.0" encoding="UTF-8"?^>>%kmlfic%
echo ^<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"^>>>%kmlfic%
echo ^<Folder^>>>%kmlfic%
echo ^<name^>%kmlname%^</name^>>>%kmlfic%
echo ^<description^>^<^^![CDATA[Images du répertoire %kmlrepscan:~0,-1%]]^>^</description^>>>%kmlfic%
echo ^<Style id="placemark"^>>>%kmlfic%
echo ^<IconStyle^>>>%kmlfic%
echo ^<scale^>2.2^</scale^>>>%kmlfic%
echo ^</IconStyle^>>>%kmlfic%
echo ^<LabelStyle^>>>%kmlfic%
echo ^<scale^>0.7^</scale^>>>%kmlfic%
echo ^</LabelStyle^>>>%kmlfic%
echo ^<BalloonStyle^>>>%kmlfic%
echo ^<bgColor^>ff000000^</bgColor^>>>%kmlfic%
echo ^<textColor^>ffaaaaaa^</textColor^>>>%kmlfic%
echo ^<text^>>>%kmlfic%
echo ^<^^![CDATA[>>%kmlfic%
echo ^<style type="text/css"^>>>%kmlfic%
echo .ori0 {max-width:300px;max-height:200px;}>>%kmlfic%
echo .ori1 {max-width:200px;max-height:300px;-webkit-transform:rotate^(90deg^) translate^(0px,-100%%^);-webkit-transform-origin:top left;}>>%kmlfic%
echo .ori2 {max-width:200px;max-height:300px;-webkit-transform:rotate^(270deg^) translate^(-100%%,0px^);-webkit-transform-origin:top left;}>>%kmlfic%
echo .ori3 {max-width:300px;max-height:200px;-webkit-transform:rotate^(180deg^) translate^(-100%%,-100%%^);-webkit-transform-origin:top left;}>>%kmlfic%
echo ^</style^>>>%kmlfic%
echo ^<div style="float:left;width:200px;height:1.2em;overflow:hidden;"^>^<b^>%kmlname%^</b^>^</div^>>>%kmlfic%
echo ^<div style="float:right;padding-top:0.2em;font-size:0.8em;"^>$[date]^</div^>^<br/^>^<hr/^>>>%kmlfic%
echo ^<b^>Lat: ^</b^>^<code^>$[lat]^</code^>^ ^ ^ ^<b^>Lon: ^</b^>^<code^>$[lon]^</code^>^<br/^>^<br/^>>>%kmlfic%
echo ^<div style="width:308px;height:200px;"^>^<img src="$[url]" class="ori$[ori]"/^>^</div^>^<br/^>>>%kmlfic%
echo ^<div style="width:300px;"^>^<b^>Nom: ^</b^>^<a href="" id="lien"^>$[name]^</a^>^</div^>^<hr/^>>>%kmlfic%
echo ^<script^>>>%kmlfic%
echo var p="$[ori]"+encodeURIComponent^("$[url]"^).replace^(/%%/g,"*"^);>>%kmlfic%
echo document.getElementById^("lien"^).href="file:///%kmlviewer%#"+p;>>%kmlfic%
echo ^</script^>>>%kmlfic%
echo ^<br/^>$[geDirections]]]^>>>%kmlfic%
echo ^</text^>>>%kmlfic%
echo ^</BalloonStyle^>>>%kmlfic%
echo ^</Style^>>>%kmlfic%
echo ^<Style^>>>%kmlfic%
echo ^<BalloonStyle^>>>%kmlfic%
echo ^<bgColor^>ff000000^</bgColor^>>>%kmlfic%
echo ^<textColor^>ffaaaaaa^</textColor^>>>%kmlfic%
echo ^</BalloonStyle^>>>%kmlfic%
echo ^</Style^>>>%kmlfic%
set kmlnbim=0
set kmlnbimsgps=0
set kmlnbimsdate=0
for /F "usebackq tokens=1,2 delims==" %%i in ("%kmlrepdest%%kmlname%.exif") do (
if /I "%%i"=="-CreateDate" set kmldate=%%j
if /I "%%i"=="-GPSLatitude" set kmllatitude=%%j
if /I "%%i"=="-GPSLongitude" set kmllongitude=%%j
if /I "%%i"=="-Orientation#" set kmlorientation=%%j
if /I "%%i"=="-Filename" (
set /A kmlnbim=!kmlnbim!+1
set kmldate=!kmlDate:~0,19!
if !kmlorientation!==6 (set kmlorientation=1) else if !kmlorientation!==8 (set kmlorientation=2) else if not !kmlorientation!==3 (set kmlorientation=0)
for /F "delims=*" %%k in ("%%j") do set kmlimgnom=%%~nj
if "!kmllatitude!"=="" (set kmllatitude=-)
if "!kmllongitude!"=="" (set kmllongitude=-)
if not "!kmllatitude!"=="-" (
if not "!kmllongitude!"=="-" (
if "!kmldate!"=="-" (
set /A kmlnbimsdate=!kmlnbimsdate!+1
echo Traitement de %%j -^> intégrée sans données de date de création
) else echo Traitement de %%j
set kmlurl=file:///%kmlrepscan%%%j
set kmlurl=!kmlurl:\=/!
echo ^<Placemark^>>>%kmlfic%
echo ^<name^>!kmlimgnom!^</name^>>>%kmlfic%
echo ^<ExtendedData^>>>%kmlfic%
echo ^<Data name="date"^>^<value^>!kmldate!^</value^>^</Data^>>>%kmlfic%
echo ^<Data name="lat"^>^<value^>!kmllatitude!^</value^>^</Data^>>>%kmlfic%
echo ^<Data name="lon"^>^<value^>!kmllongitude!^</value^>^</Data^>>>%kmlfic%
echo ^<Data name="url"^>^<value^>!kmlurl!^</value^>^</Data^>>>%kmlfic%
echo ^<Data name="ori"^>^<value^>!kmlorientation!^</value^>^</Data^>>>%kmlfic%
echo ^</ExtendedData^>>>%kmlfic%
echo ^<styleUrl^>#placemark^</styleUrl^>>>%kmlfic%
echo ^<Style^>>>%kmlfic%
echo ^<IconStyle^>>>%kmlfic%
echo ^<Icon^>^<href^>%kmliconpref%!kmlimgnom!.jpg^</href^>^</Icon^>>>%kmlfic%
echo ^</IconStyle^>>>%kmlfic%
echo ^</Style^>>>%kmlfic%
echo ^<Point^>>>%kmlfic%
echo ^<coordinates^>!kmllongitude!,!kmllatitude!,0^</coordinates^>>>%kmlfic%
echo ^</Point^>>>%kmlfic%
echo ^</Placemark^>>>%kmlfic%
) else (
set /A kmlnbimsgps=!kmlnbimsgps!+1
echo Traitement de %%j -^> ignorée ^(pas de données de géolocalisation^)
)
) else (
set /A kmlnbimsgps=!kmlnbimsgps!+1
echo Traitement de %%j -^> ignorée ^(pas de données de géolocalisation^)
)
)
)
echo ^</Folder^>>>%kmlfic%
echo ^</kml^>>>%kmlfic%
del "%kmlrepdest%%kmlname%.lst"
del "%kmlrepdest%%kmlname%.exif"
echo %kmlnbim% image^(s^) traitée^(s^)
if not %kmlnbimsgps%%kmlnbimsdate%%kmlerr%==000 (
if not %kmlnbimsdate%==0 echo dont %kmlnbimsdate% image^(s^) intégrée^(s^) sans données de date de création
if not %kmlnbimsgps%==0 echo dont %kmlnbimsgps% image^(s^) ignorée^(s^) ^(pas de données de géolocalisation^)
echo.
pause
)
:end
chcp 850 >nul
endlocal
echo on
@if "%~3"=="exit" @exit