Snippets

Takehiko NOZAKI 国土地理院 基盤地図情報 数値標高モデル ダウンローダー

Updated by Takehiko NOZAKI

File download.ps1 Modified

  • Ignore whitespace
  • Hide word diff
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-if (-not ([Net.ServicePointManager]::SecurityProtocol -band [Net.SecurityProtocolType]::Tls12)) {
-	[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
-}
 
 # パラメーター
 Param(
 # PowerShellプロセスのカレントディレクトリをシェル内と同期させる
 [System.IO.Directory]::SetCurrentDirectory((Get-Location -PSProvider FileSystem).Path)
 
+# TLS1.2を有効にする
+if (-not ([Net.ServicePointManager]::SecurityProtocol -band [Net.SecurityProtocolType]::Tls12)) {
+	[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
+}
+
 # ユーザー名/パスワード入力および保持
 try {
   $credencial = Get-Credential
Updated by Takehiko NOZAKI

File download.ps1 Modified

  • Ignore whitespace
  • Hide word diff
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
+if (-not ([Net.ServicePointManager]::SecurityProtocol -band [Net.SecurityProtocolType]::Tls12)) {
+	[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
+}
 
 # パラメーター
 Param(
 # PowerShellプロセスのカレントディレクトリをシェル内と同期させる
 [System.IO.Directory]::SetCurrentDirectory((Get-Location -PSProvider FileSystem).Path)
 
-# TLS1.2を有効にする
-if (-not ([Net.ServicePointManager]::SecurityProtocol -band [Net.SecurityProtocolType]::Tls12)) {
-	[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
-}
-
 # ユーザー名/パスワード入力および保持
 try {
   $credencial = Get-Credential
     $_.value -ne ''
   } | ForEach-Object {
     $pref = $_.value
-    $pref
+    Write-Host $pref
     # 市町村
     Get-Cities -pref $pref | ForEach-Object {
       $city = $_
-      "    {0}" -F $city
+      Write-Host ('    {0}' -F $city)
       # 2次メッシュ
       Get-Mesh2DEMs -pref $pref -city $city | ForEach-Object {
         $mesh2DEM = $_.code
-        "        {0}" -F $mesh2DEM
+        Write-Host ('        {0}' -F $mesh2DEM)
         # 重複2次メッシュ除外
         if (-Not $mesh2DEMList.ContainsKey($mesh2DEM)) {
           # ダウンロードファイルリスト
             $DLFile0 = $_.DLFile0
             $DLFile0Size = $_.DLFile0Size
             $selListId = $_.selListId
-            "            {0}({1}): {2}" -F ($DLFile0, $DLFile0Size, $selListId)
+            Write-Host ('            {0}({1}): {2}' -F ($DLFile0, $DLFile0Size, $selListId))
             # ダウンロード済ファイル除外
             $needDownload = $true
             if ($ziplist.ContainsKey($DLFile0)) {
               if ($ziplist[$DLFile0] -Eq $DLFile0Size) {
-                '              file exists, skipping...'
+                Write-Host '              file exists, skipping...'
                 $needDownload = $false
               }
             }
           Delete-Lists -delfile $delfile
           $mesh2DEMList[$mesh2DEM] = 1
         } else {
-          "            mesh2DEM duplicated, skipping..." -F $mesh2DEM
+          Write-Host ('            {0} duplicated, skipping...' -F $mesh2DEM)
         }
       }
     }
   }
 } finally {
   Session-Logout
-}
+}
Updated by Takehiko NOZAKI

File download.ps1 Modified

  • Ignore whitespace
  • Hide word diff
 # PowerShellプロセスのカレントディレクトリをシェル内と同期させる
 [System.IO.Directory]::SetCurrentDirectory((Get-Location -PSProvider FileSystem).Path)
 
+# TLS1.2を有効にする
+if (-not ([Net.ServicePointManager]::SecurityProtocol -band [Net.SecurityProtocolType]::Tls12)) {
+	[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
+}
+
 # ユーザー名/パスワード入力および保持
 try {
   $credencial = Get-Credential
Updated by Takehiko NOZAKI

File download.ps1 Modified

  • Ignore whitespace
  • Hide word diff
 Param(
 [Parameter(Position=0)]
 [ValidateSet('5m','10m')]
-[string]$Mesh='5m'
+[string]$Mesh='10m'
 )
 $Mesh2Param = @{
   '5m'=0;
Updated by Takehiko NOZAKI

File download.ps1 Modified

  • Ignore whitespace
  • Hide word diff
 )
 $Mesh2Param = @{
   '5m'=0;
-  '10m'=1
+  '10m'=1;
 }
 
-
 # 定数
 $userAgent         = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36'
 $baseUrl           = 'https://fgd.gsi.go.jp/download/'
  1. 1
  2. 2
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.