Skip to content

Commit 9cad3d7

Browse files
committed
Added split kml.ps1
1 parent 8f954ac commit 9cad3d7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
// "editor.fontFamily": "Cascadia Code, jetbrains mono, 'Courier New', monospace", // fallback fonts
23
"editor.fontSize": 18,
34
"workbench.colorTheme": "Default Dark Modern",
45
"workbench.colorCustomizations": {

file-processing/split kml.ps1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$kmlPath = 'C:\big.kml'
2+
$max = 240
3+
$partsFolder = "$PSScriptRoot\parts"
4+
5+
[xml]$doc = Get-Content -Path $kmlPath
6+
mkdir $partsFolder -ErrorAction SilentlyContinue | Out-Null
7+
$i = 1
8+
do {
9+
[xml]$clone = $doc.Clone()
10+
$clone.ChildNodes[0].Encoding = $null
11+
12+
# remove everything except max number count (i.e 240, 480, 720)
13+
$clone.kml.Document.Folder.Placemark | Select-Object -Skip ($max * $i) | % {
14+
$clone.kml.Document.Folder.RemoveChild($_) | Out-Null
15+
}
16+
17+
# buffering - selecting last max number count
18+
while ($clone.kml.Document.Folder.Placemark.Count -gt $max) {
19+
$clone.kml.Document.Folder.Placemark | Select-Object -First 1 | % {
20+
$clone.kml.Document.Folder.RemoveChild($_) | Out-Null
21+
}
22+
}
23+
24+
$clone.Save("$partsFolder\_part2_$($i).kml")
25+
$i++
26+
}
27+
while ($max * $i -le $doc.kml.Document.Folder.Placemark.Count)

0 commit comments

Comments
 (0)