Created
April 3, 2017 07:01
-
-
Save KMR-zoar/b17ee135a70a67fd5280d5dfca552f4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$filename = $ARGS | |
$elements = @("id", "lat", "lon", "created_at", "closed_at") | |
if ((Test-Path $filename) -eq $false) | |
{ | |
Write-Host "File is not exist or access denied." | |
exit | |
} | |
Write-Output ("{") | |
Write-Output (" `"type`": `"FeatureCollection`",") | |
Write-Output (" `"features`": [") | |
Get-Content $filename | ForEach-Object { | |
$items = $_ | |
if ($items.indexof("<note") -ne -1 ) | |
{ | |
$item = $items -split " " | |
$feature = @{} | |
foreach ($element in $item) | |
{ | |
foreach ($ele in $elements) | |
{ | |
if ($element.contains("$ele=")) | |
{ | |
$feature.add($ele, $element.Replace("$ele=","").Replace(">","").Replace("`"","")) | |
} | |
} | |
} | |
Write-Output ("{") | |
Write-Output (" `"type`": `"Feature`",") | |
Write-Output (" `"id`": " + $feature.id + ",") | |
Write-Output (" `"properties`": {") | |
Write-Output (" `"id`":" + $feature.id + ",") | |
Write-Output (" `"create`": `"" + $feature.created_at + "`",") | |
if ($feature.closed_at) | |
{ | |
Write-Output (" `"close`": `"" + $feature.closed_at + "`",") | |
} | |
Else | |
{ | |
Write-Output (" `"close`": Null,") | |
} | |
# Write-Output (" `"longitude`": `"" + $feature.lon + "`",") | |
# Write-Output (" `"latitude`": `"" + $feature.lat + "`",") | |
Write-Output (" },") | |
Write-Output (" `"geometry`": {") | |
Write-Output (" `"type`": `"Point`",") | |
Write-Output (" `"coordinates`": [") | |
Write-Output (" " + $feature.lon + ",") | |
Write-Output (" " + $feature.lat) | |
Write-Output (" ]") | |
Write-Output (" }") | |
Write-Output ("},") | |
} | |
} | |
Write-Output (" ]") | |
Write-Output ("}") | |
#ムシャクシャしてやった。後悔はしていない |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment