[AppleScripts]GoogleMapのURLからAdobe Bridge用のGPS用の値を作る【v4新しいGoogleMapのURL対応】
GoogleMapのURLからBridge用のGPS用の値を作る
の
第4弾
新しいGoogleMapのURL
↑この@マークがあるタイプのURLに対応しました…と
elevationが加わったので、海抜も入れてあります
出来上がったXMPファイルは
ブリッジから使います
まぁ
自分ようだかんね笑
(*
GoogleMap2BridgeV4.0.scpt
2014年 新しくなったGoogleMapのURL用
まだ作りかけですが
なんとか動作はする
時間があれば後日ちゃんと書き直したい
*)
-----------設定項目
(*
True 著作を有している
False 著作フリー又は無し
*)
set theRights to "True" as «class utf8»
-----著作情報の掲載してあるWEBページ
set theWebStatement to "http://creativecommons.org/licenses/by-nc-nd/4.0/deed.ja" as «class utf8»
------著作権情報
set theDcRights to "Creative Commons Attribution-NonCommercial-NoDerivatives 4.0" as «class utf8»
-----使用にともなう制限について
set theUsageTerms to "商用利用はお問い合わせ下さい" as «class utf8»
-----作成者WEB
set theCiUrlWork to "https://force4u.cocolog-nifty.com/" as «class utf8»
-----------------------------ここから本処理
-----ファイル名初期化
set theXmpFileName to "" as text
-----検索語句初期化
set theSearchTXT to ""
--------------デフォルトアンサー用にシドニー・オペラハウスのURL
set theOrgGoogleMapUrl to "https://www.google.com/maps/place/%E3%82%AA%E3%83%9A%E3%83%A9%E3%83%8F%E3%82%A6%E3%82%B9/@-33.856731,151.215133,17z/data=!3m1!4b1!4m2!3m1!1s0x6b12ae665e892fdd:0x3133f8d75a1ac251" as «class utf8»
--------------URLをペーストするダイアログを出す
display dialog "GoogleMapのURLをペーストしてください" default answer the theOrgGoogleMapUrl with icon 1 with title "GoogleMapのURLをペーストしてください" default button 1
--------------リザルトをリスト形式で格納
copy the result as list to {the theOrgGoogleMapUrl, BottPressNo}
--------------テキスト形式に変更
set theOrgGoogleMapUrl to theOrgGoogleMapUrl as text
--------------区切りを/にしてリスト形式で取得
set AppleScript's text item delimiters to {"/"}
set listGoogleMapUrl to every text item of theOrgGoogleMapUrl as list
--------------区切りを戻す
set AppleScript's text item delimiters to {""}
----/////---------追加した処理
--------------検索語句のある場合
if theOrgGoogleMapUrl contains "/search/" then
set theSearchTXT to do shell script "echo " & quoted form of theOrgGoogleMapUrl & "| awk -F \"search/\" '{print($2)}' |awk -F \"/\" '{print($1)}' " as «class utf8»
set theSearchTXT to my doDecodeURL(theSearchTXT) as «class utf8»
end if
--------------プレイスの場合
if theOrgGoogleMapUrl contains "/place/" then
set theSearchTXT to do shell script "echo " & quoted form of theOrgGoogleMapUrl & "| awk -F \"place/\" '{print($2)}' |awk -F \"/\" '{print($1)}' " as «class utf8»
set theSearchTXT to my doDecodeURL(theSearchTXT) as «class utf8»
end if
if theOrgGoogleMapUrl does not contain "@" then
display alert "新しいGoogleMapのURLではありません"
error "URLに@が含まれていません" number -128
end if
--------------リピートで繰り返し回数分でリストから取得する部位を変更するための変数
set numLine to 1 as number
repeat
try
--------------リスト取得
set theLineData to (item numLine of listGoogleMapUrl) as text
--------------取得したリストに@があった場合
if theLineData contains "@" then
--------------取得結果をテキストに変更
set theGoogleLlNoList to theLineData as text
--------------区切り文字をカンマにしてリストにする
set AppleScript's text item delimiters to {","}
set listGoogleLlNoList to every text item of theGoogleLlNoList as list
--------------区切りを戻す
set AppleScript's text item delimiters to {""}
--------------theLatitude値を取り出す
set theLatitude to item 1 of listGoogleLlNoList as text
set theLatitude to doReplace(theLatitude, "@", "")
if theLatitude contains "-" then
set theLatitude to doReplace(theLatitude, "-", "")
end if
--------------theLongitude値を取り出す
set theLongitude to item 2 of listGoogleLlNoList as text
if theLongitude contains "-" then
set theLongitude to doReplace(theLongitude, "-", "")
end if
--------------標高を取り出す
set theSrtm to item 3 of listGoogleLlNoList as text
set theSrtm to doReplace(theSrtm, "z", "")
--------------theLatitudeの60進数の処理
-----整数部のみ取り出す
set theIntegerLatitude to theLatitude div 1 as string
-----小数点以下を処理する
set theLatitude to (text 2 thru 8 of (((theLatitude mod 1) as string) & "000000") as string)
-----整数部と小数点以下を結合
set theLatitude to theIntegerLatitude & theLatitude
-----60進数処理
set theDecimalLatitudeA to (((theLatitude as number) - (theIntegerLatitude as number)) as number) * 60
------整数部を確定
set theIntegerDecimalLatitudeA to theDecimalLatitudeA div 1 as integer
-----小数点以下を確定
set theDecimalLatitudeB to (((theDecimalLatitudeA as number) - (theIntegerDecimalLatitudeA as number)) as number) * 100 as integer
---修正されたゼロサプレス処理
set theIntegerLatitude to doZeroSuppress(theIntegerLatitude)
set theIntegerDecimalLatitudeA to doZeroSuppress(theIntegerDecimalLatitudeA)
set theDecimalLatitudeB to doZeroSuppress(theDecimalLatitudeB)
-----値がマイナスなら 南緯 マイナスが無ければ 北緯
if (item 1 of listGoogleLlNoList) contains "-" then
set theLatitude to theIntegerLatitude & "," & theIntegerDecimalLatitudeA & "." & theDecimalLatitudeB & "S" as «class utf8»
else
set theLatitude to theIntegerLatitude & "," & theIntegerDecimalLatitudeA & "." & theDecimalLatitudeB & "N" as «class utf8»
end if
--------------Longitudeの60進数の処理
set theIntegerLongitude to theLongitude div 1 as string
set theLongitude to (text 2 thru 8 of (((theLongitude mod 1) as string) & "000000") as string)
set theLongitude to theIntegerLongitude & theLongitude
set theDecimalLongitudeA to (((theLongitude as number) - (theIntegerLongitude as number)) as number) * 60
set theIntegerDecimalLongitudeA to theDecimalLongitudeA div 1 as integer
set theDecimalLongitudeB to (((theDecimalLongitudeA as number) - (theIntegerDecimalLongitudeA as number)) as number) * 100 as integer
---修正されたゼロサプレス処理
set theIntegerLongitude to doZeroSuppress(theIntegerLongitude)
set theIntegerDecimalLongitudeA to doZeroSuppress(theIntegerDecimalLongitudeA)
set theDecimalLongitudeB to doZeroSuppress(theDecimalLongitudeB)
-----値がマイナスなら 西経 マイナスが無ければ 東経
if (item 2 of listGoogleLlNoList) contains "-" then
set theLongitude to theIntegerLongitude & "," & theIntegerDecimalLongitudeA & "." & theDecimalLongitudeB & "W" as «class utf8»
else
set theLongitude to theIntegerLongitude & "," & theIntegerDecimalLongitudeA & "." & theDecimalLongitudeB & "E" as «class utf8»
end if
end if
on error
exit repeat
end try
set numLine to numLine + 1 as number
end repeat
--------------ダイアログ用に改行を入れて整形しておく
set tneAns to theLatitude & "\n" & theLongitude & "\n" & theSrtm & "m"
--------------出来上がりデータをダイアログで表示
display dialog "Bridge用のGPSの値です" default answer the tneAns with icon 1 with title "Adobe Bridge 用GPS値" default button 1 buttons {"XMPファイルも作る", " 終了 "}
--------------XMPファイルも作る場合の始まり
if button returned of the result is "XMPファイルも作る" then
--------------XMPファイルとBridgeの関連づけの確認
do shell script "date > /tmp/ApplicationChk.xmp"
set theTmpXmpFile to (the path to startup disk as string) & "tmp:ApplicationChk.xmp" as alias
set theFileInfo to default application of (info for theTmpXmpFile) as string
--------------Bridgeが未インストールの可能性のエラー制御
if (theFileInfo contains "Bridge") is false then
display alert "XMPファイルがAdobe Bridgeに関連づけられていません"
--------------XMPファイル作成の本処理のはじまり
else if (theFileInfo contains "Bridge") is true then
--------------XMPファイルの保存先ディレクトリを取得
set theSaveXmpPath to (the path to application support from user domain as text) & "Adobe:XMP:Metadata Templates:"
--------------検索語句の有無
if theSearchTXT is "" then
--------------検索語句が無い場合はファイル名を日付にするため日付の処理
set theDateTime to (do shell script "date +'%Y%m%d_%H%M%S'" as string)
set theXmpFileName to (theLatitude & "_" & theLongitude & "_" & theDateTime & ".xmp") as «class utf8»
set theXmpFileName to my doReplace(theXmpFileName, ",", ".") as «class utf8»
set theGooogleMapQ to theLatitude & " " & theLongitude
else
set theXmpFileName to (theSearchTXT & ".xmp") as «class utf8»
end if
-----------------------------------------------ここからXMPファイルの作成
-------------XMPファイルの最初の1行
set theXMPline to "<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n" as «class utf8»
-------------XMPファイル
set theXMPline to theXMPline & "<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27\">\n" as «class utf8»
-------------宣言
set theXMPline to theXMPline & "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" as «class utf8»
set theXMPline to theXMPline & "<rdf:Description rdf:about=\"\"\n" as «class utf8»
set theXMPline to theXMPline & " xmlns:xmpRights=\"http://ns.adobe.com/xap/1.0/rights/\"\n" as «class utf8»
set theXMPline to theXMPline & " xmpRights:WebStatement=\"" & theWebStatement & "\"\n" as «class utf8»
set theXMPline to theXMPline & " xmpRights:Marked=\"" & theRights & "\"\n" as «class utf8»
-------------Description
set theXMPline to theXMPline & " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" as «class utf8»
set theXMPline to theXMPline & " xmlns:photoshop=\"http://ns.adobe.com/photoshop/1.0/\"\n" as «class utf8»
set theXMPline to theXMPline & " xmlns:Iptc4xmpCore=\"http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/\"\n" as «class utf8»
set theXMPline to theXMPline & " xmlns:Iptc4xmpExt=\"http://iptc.org/std/Iptc4xmpExt/2008-02-29/\"\n" as «class utf8»
set theXMPline to theXMPline & " xmlns:exif=\"http://ns.adobe.com/exif/1.0/\"\n" as «class utf8»
-------------photoshop
set theXMPline to theXMPline & " photoshop:Instructions=\"" & theXmpFileName & "\"\n" as «class utf8»
-------------Iptc4xmpCore
set theXMPline to theXMPline & " Iptc4xmpCore:Location=\"" & theXmpFileName & "\"\n" as «class utf8»
-------------exif:
set theXMPline to theXMPline & " exif:GPSLatitude=\"" & theLatitude & "\"\n" as «class utf8»
set theXMPline to theXMPline & " exif:GPSProcessingMethod=\"MANUAL\"\n" as «class utf8»
set theXMPline to theXMPline & " exif:GPSAltitude=\"" & theSrtm & " m\"\n" as «class utf8»
set theXMPline to theXMPline & " exif:GPSLongitude=\"" & theLongitude & "\">\n" as «class utf8»
-------------dc
set theXMPline to theXMPline & " <dc:subject>\n" as «class utf8»
set theXMPline to theXMPline & " <rdf:Bag>\n" as «class utf8»
set theXMPline to theXMPline & " <rdf:li>" & theXmpFileName & "</rdf:li>\n" as «class utf8»
set theXMPline to theXMPline & " </rdf:Bag>\n" as «class utf8»
set theXMPline to theXMPline & " </dc:subject>\n" as «class utf8»
-------------Iptc4xmpExt
set theXMPline to theXMPline & " <Iptc4xmpExt:LocationShown>\n" as «class utf8»
set theXMPline to theXMPline & " <rdf:Bag>\n" as «class utf8»
set theXMPline to theXMPline & " <rdf:li\n" as «class utf8»
set theXMPline to theXMPline & " Iptc4xmpExt:Sublocation=\"" & theXmpFileName & "\"/>\n" as «class utf8»
set theXMPline to theXMPline & " </rdf:Bag>\n" as «class utf8»
set theXMPline to theXMPline & " </Iptc4xmpExt:LocationShown>\n" as «class utf8»
-------------著作情報...
set theXMPline to theXMPline & "<dc:rights>\n" as «class utf8»
set theXMPline to theXMPline & "<rdf:Alt>\n" as «class utf8»
set theXMPline to theXMPline & "<rdf:li xml:lang=\"x-default\">" & theDcRights & "</rdf:li>\n" as «class utf8»
set theXMPline to theXMPline & "</rdf:Alt>\n" as «class utf8»
set theXMPline to theXMPline & "</dc:rights>\n" as «class utf8»
set theXMPline to theXMPline & "<xmpRights:UsageTerms>\n" as «class utf8»
set theXMPline to theXMPline & "<rdf:Alt>\n" as «class utf8»
set theXMPline to theXMPline & "<rdf:li xml:lang=\"x-default\">" & theUsageTerms & "</rdf:li>\n" as «class utf8»
set theXMPline to theXMPline & "</rdf:Alt>\n" as «class utf8»
set theXMPline to theXMPline & "</xmpRights:UsageTerms>\n" as «class utf8»
----------ITPCCORE
set theXMPline to theXMPline & "<Iptc4xmpCore:CreatorContactInfo\n" as «class utf8»
set theXMPline to theXMPline & " Iptc4xmpCore:CiUrlWork=\"" & theCiUrlWork & "\"/>\n" as «class utf8»
-------------XMPの終了
set theXMPline to theXMPline & " </rdf:Description>\n" as «class utf8»
set theXMPline to theXMPline & " </rdf:RDF>\n" as «class utf8»
set theXMPline to theXMPline & "</x:xmpmeta>\n" as «class utf8»
set theXMPline to theXMPline & "<?xpacket end=\"w\"?>\n" as «class utf8»
--------------ファイルを作る
tell application "Finder"
try
make new file at (theSaveXmpPath) with properties {name:theXmpFileName}
set aliasXmlFileAlias to (theSaveXmpPath & theXmpFileName) as alias
set theXmlFileAlias to aliasXmlFileAlias as text
set numFileChk to 1
on error
-----すでにファイルがあった場合に別名にする
make new file at (theSaveXmpPath) with properties {name:(theDateTime & "_" & theXmpFileName)}
set aliasXmlFileAlias to (theSaveXmpPath & (theDateTime & "_" & theXmpFileName)) as alias
set theXmlFileAlias to aliasXmlFileAlias as text
set numFileChk to 2
try
delete (theSaveXmpPath & theXmpFileName) as alias
end try
end try
end tell
-----------検索語句がファイル名の場合の処理
if numFileChk is 1 then
try
set theData to open for access file theXmlFileAlias with write permission
write theXMPline to theData as «class utf8»
close theData
on error
------書き込みに失敗したらシェルでの書き込みを試す
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of (POSIX path of theXmlFileAlias)
end try
---------日付け付きのファイル名に鳴った場合
else if numFileChk is 2 then
set theData to open for access file theXmlFileAlias with write permission
write theXMPline to theData as «class utf8»
close theData
end if
-------------出来上がったXMPファイルにラベルを塗って保存したフォルダを開く
tell application "Finder"
set file type of aliasXmlFileAlias to "XML "
set creator type of aliasXmlFileAlias to "Brdg"
set label index of aliasXmlFileAlias to 4
open folder theSaveXmpPath
activate
end tell
end if
else if button returned of the result is "終了" then
end if
--------------------------------------------------#ここからサブルーチン
--------////////文字の置き換えのサブルーチン
to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace
--------////////URLデコードのサブルーチン(エラー避けに置き換えてからデコード)
on doDecodeURL(theUrlEncodeText)
set theUrlEncodeText to my doReplace(theUrlEncodeText, "¥n", "") as «class utf8»
set theUrlEncodeText to my doReplace(theUrlEncodeText, "\\n", "") as «class utf8»
set theUrlEncodeText to my doReplace(theUrlEncodeText, "¥r", "") as «class utf8»
set theUrlEncodeText to my doReplace(theUrlEncodeText, "\\r", "") as «class utf8»
set theUrlEncodeText to my doReplace(theUrlEncodeText, return, "") as «class utf8»
set theUrlEncodeText to my doReplace(theUrlEncodeText, "\\", "¥") as «class utf8»
set theUrlEncodeText to my doReplace(theUrlEncodeText, "'", "\\'") as «class utf8»
set theUrlEncodeText to my doReplace(theUrlEncodeText, "\"", "\\\"") as «class utf8»
set theUrlEncodeText to my doReplace(theUrlEncodeText, "`", "\\`") as «class utf8»
set theScpt to ("echo \"<?php print(urldecode('" & theUrlEncodeText & "'));?>\" | php")
return do shell script theScpt as «class utf8»
end doDecodeURL
--------////////ゼロサプレスのサブルーチン
to doZeroSuppress(n)
if n < 10 then
return "0" & n
else
return n as text
end if
end doZeroSuppress
「GoogleMap2BridgeV4.0.rtf」をダウンロード
「GoogleMap2BridgeV4.0.scpt.zip」をダウンロード
| 固定リンク
「AdobeBridge」カテゴリの記事
- AOM(Adobe Output Module)インストーラーちょっと直し(2017.04.10)
- AOM(Adobe Output Module)インストーラーCC2017対応版(2016.11.04)
- Install the Adobe Output Module for Bridge CC 2015 version 6.3(2016.08.31)
- Install the Adobe Output Module for Bridge CC 6.2(2016.08.31)
- Install_Adobe_Output_Module_CC2015.scpt(2016.07.23)