震度推定

by 3f5
http://12at1995.net/kita/test/estimateSeismicIntensity.cgi?mode=source
のソースを参考にさせて頂きました。
♥0 | Line 380 | Modified 2011-12-03 22:29:09 | MIT License
play

ActionScript3 source code

/**
 * Copyright 3f5 ( http://wonderfl.net/user/3f5 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/nkyN
 */

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:maps="com.google.maps.*">
    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        @namespace mx "library://ns.adobe.com/flex/mx";
        global
        {
            font-family: "メイリオ";
        }
    </fx:Style>
    <s:layout>    
        <s:VerticalLayout horizontalAlign="center" />
    </s:layout>
    <s:Panel width="100%" minHeight="70">
        <s:layout>
            <s:VerticalLayout paddingTop="10" paddingBottom="10" paddingRight="10" paddingLeft="10" />
        </s:layout>
        <s:HGroup>
            <s:Label>Mw:</s:Label><s:TextInput id="inputMag" width="40">9.0</s:TextInput>
            <s:Label>震源の深さ:</s:Label><s:TextInput id="inputDepth" width="30">24</s:TextInput>
            <s:Label>緯度:</s:Label><s:TextInput id="inputLat" width="50">38.103333</s:TextInput>
            <s:Label>経度:</s:Label><s:TextInput id="inputLng" width="50">142.86</s:TextInput>
        </s:HGroup>
        <s:Button click="calc()">計算</s:Button>
    </s:Panel>
    <maps:Map id="map" mapevent_mapready="init(event)" width="100%" height="100%" sensor="false" />
    <fx:Script>
        <![CDATA[
        import com.google.maps.interfaces.IOverlay;
        import com.google.maps.LatLng;
        import com.google.maps.Map;
        import com.google.maps.MapEvent;
        import com.google.maps.MapMouseEvent;
        import com.google.maps.MapType;
        import com.google.maps.LatLng;
        import com.google.maps.Map;
        import com.google.maps.MapEvent;
        import com.google.maps.MapType;
        import com.google.maps.controls.*;
        import com.google.maps.overlays.Marker;
        import com.google.maps.overlays.MarkerOptions;
        import com.google.maps.MapType;
        import com.google.maps.LatLng;
        import com.google.maps.styles.FillStyle;
        import com.google.maps.styles.StrokeStyle;
        import com.google.maps.InfoWindowOptions;
        
        private const pref:Object = {
            '北海道' : {
                'lat' : 43.06214998650346,
                'lon' : 141.35048810732084,
                'amp' : 2.035000
            },
            '青森県' : {
                'lat' : 40.82161396239954,
                'lon' : 140.74352555302377,
                'amp' : 2.245000
            },
            '岩手県' : {
                'lat' : 39.70079858520135,
                'lon' : 141.1561937218077,
                'amp' : 2.166000
            },
            '宮城県' : {
                'lat' : 38.265867921866906,
                'lon' : 140.87552045218405,
                'amp' : 2.166000
            },
            'K-NET 築館' : {
                'lat' : 38.7233768778796,
                'lon' : 141.02865423177093,
                'amp' : 4.5783527
            },
            '秋田県' : {
                'lat' : 39.71581263490273,
                'lon' : 140.1057875842486,
                'amp' : 2.929000
            },
            '山形県' : {
                'lat' : 38.23747196539823,
                'lon' : 140.36701021671539,
                'amp' : 2.046000
            },
            '福島県' : {
                'lat' : 37.747280825217956,
                'lon' : 140.47091437767585,
                'amp' : 3.119000
            },
            '茨城県' : {
                'lat' : 36.338643135983894,
                'lon' : 140.45008989713372,
                'amp' : 1.923000
            },
            '栃木県' : {
                'lat' : 36.5625907237144,
                'lon' : 139.88682503213707,
                'amp' : 1.775000
            },
            '群馬県' : {
                'lat' : 36.38752887768245,
                'lon' : 139.06358960873254,
                'amp' : 1.817000
            },
            '埼玉県' : {
                'lat' : 35.8537931181835,
                'lon' : 139.65205650447325,
                'amp' : 2.460000
            },
            '千葉県' : {
                'lat' : 35.601816183148365,
                'lon' : 140.126541906543,
                'amp' : 3.119000
            },
            '東京都' : {
                'lat' : 35.686262852547316,
                'lon' : 139.6949100503557,
                'amp' : 2.343000
            },
            '神奈川県' : {
                'lat' : 35.4475073,
                'lon' : 139.6423446,
                'amp' : 3.455000
            },
            '新潟県' : {
                'lat' : 37.89957554054715,
                'lon' : 139.0263446277862,
                'amp' : 2.999000
            },
            '富山県' : {
                'lat' : 36.69221695784719,
                'lon' : 137.21438227248532,
                'amp' : 2.433000
            },
            '石川県' : {
                'lat' : 36.59160732826734,
                'lon' : 136.62856329248248,
                'amp' : 2.451000
            },
            '福井県' : {
                'lat' : 36.06205405001782,
                'lon' : 136.22445965483425,
                'amp' : 2.608000
            },
            '山梨県' : {
                'lat' : 35.66094976319451,
                'lon' : 138.57155779854818,
                'amp' : 3.119000
            },
            '長野県' : {
                'lat' : 36.64820321614504,
                'lon' : 138.18407817253657,
                'amp' : 2.166000
            },
            '岐阜県' : {
                'lat' : 35.38802251741141,
                'lon' : 136.72523390935092,
                'amp' : 3.119000
            },
            '静岡県' : {
                'lat' : 34.97384211542894,
                'lon' : 138.38614666823386,
                'amp' : 1.874000
            },
            '愛知県' : {
                'lat' : 35.17695782597495,
                'lon' : 136.9095135954224,
                'amp' : 2.200000
            },
            '三重県' : {
                'lat' : 34.72701125554715,
                'lon' : 136.51148342708643,
                'amp' : 2.007000
            },
            '滋賀県' : {
                'lat' : 35.001299467933194,
                'lon' : 135.87144450414314,
                'amp' : 2.174000
            },
            '京都府' : {
                'lat' : 35.0212466,
                'lon' : 135.7555968,
                'amp' : 2.007000
            },
            '大阪府' : {
                'lat' : 34.683038024420874,
                'lon' : 135.52247187224066,
                'amp' : 1.890000
            },
            '兵庫県' : {
                'lat' : 34.68801613541668,
                'lon' : 135.1858538476847,
                'amp' : 1.832000
            },
            '奈良県' : {
                'lat' : 34.68206985287186,
                'lon' : 135.83557902899636,
                'amp' : 2.166000
            },
            '和歌山県' : {
                'lat' : 34.222684540664716,
                'lon' : 135.17026913043128,
                'amp' : 2.822000
            },
            '鳥取県' : {
                'lat' : 35.50074136561085,
                'lon' : 134.2404777573543,
                'amp' : 1.161000
            },
            '島根県' : {
                'lat' : 35.469163323616336,
                'lon' : 133.05314180372665,
                'amp' : 3.119000
            },
            '岡山県' : {
                'lat' : 34.65851708863329,
                'lon' : 133.93708388811189,
                'amp' : 2.292000
            },
            '広島県' : {
                'lat' : 34.39332368386348,
                'lon' : 132.46216599760115,
                'amp' : 1.917000
            },
            '山口県' : {
                'lat' : 34.182714432054524,
                'lon' : 131.47310096668346,
                'amp' : 1.161000
            },
            '徳島県' : {
                'lat' : 34.062409220843726,
                'lon' : 134.56206274440908,
                'amp' : 2.166000
            },
            '香川県' : {
                'lat' : 34.33687878551837,
                'lon' : 134.04611603479313,
                'amp' : 2.053000
            },
            '愛媛県' : {
                'lat' : 33.838322481935116,
                'lon' : 132.76822416227589,
                'amp' : 2.007000
            },
            '高知県' : {
                'lat' : 33.55636135882524,
                'lon' : 133.53367254633804,
                'amp' : 2.319000
            },
            '福岡県' : {
                'lat' : 33.60329014293248,
                'lon' : 130.4206345911342,
                'amp' : 2.720000
            },
            '佐賀県' : {
                'lat' : 33.24612001376824,
                'lon' : 130.30210550464588,
                'amp' : 3.134000
            },
            '長崎県' : {
                'lat' : 32.7414706830585,
                'lon' : 129.87600888717088,
                'amp' : 1.805000
            },
            '熊本県' : {
                'lat' : 32.78644853519494,
                'lon' : 130.74399403788317,
                'amp' : 2.401000
            },
            '大分県' : {
                'lat' : 33.2348260772414,
                'lon' : 131.6150387144839,
                'amp' : 2.309000
            },
            '宮崎県' : {
                'lat' : 31.907611229639357,
                'lon' : 131.42623643314207,
                'amp' : 3.134000
            },
            '鹿児島県' : {
                'lat' : 31.556639617058966,
                'lon' : 130.5602328595679,
                'amp' : 3.417000
            },
            '沖縄県' : {
                'lat' : 26.208372775609046,
                'lon' : 127.68270147613941,
                'amp' : 1.768000
            }
        };
    
        private var overlays:Array = [];
    
        private function init(event:Event):void {
            map.setCenter(new LatLng(37.38454050269700, 136.77921640625000), 5, MapType.NORMAL_MAP_TYPE);
            map.addControl(new MapTypeControl());
            map.addControl(new ZoomControl());
            map.addControl(new PositionControl());
        }
        
        private function calc():void {
            var marker:Marker;
            var position:LatLng;
            var epicenter:LatLng = new LatLng(Number(inputLat.text), Number(inputLng.text));

            for each (var overlay:IOverlay in overlays) {
                map.removeOverlay(overlay);
            }

            overlays = [new Marker(epicenter)];

            map.addOverlay(overlays[0]);
 
            for each (var place:Object in pref) {
                position = new LatLng(place.lat - (place.lat * 0.00010695) + (place.lon * 0.000017464) + 0.0046017, place.lon - (place.lat * 0.000046038) - (place.lon * 0.000083043) + 0.010040);
                marker = new Marker(
                    position,
                    new MarkerOptions( {
                        fillStyle : new FillStyle({color: 0xFFFFFF}),
                        hasShadow : true
                    })
                );
                map.addOverlay(marker);

                (function (marker:Marker, place:Object):void {
                    var distance:Number = position.distanceFrom(epicenter) / 1000;
                    var i:Number = calcIntensity(Number(inputMag.text), Number(inputDepth.text), distance, place.amp);
                    var intensity:String = intensityByISI(i);

                    marker.addEventListener(MapMouseEvent.CLICK, function (e:Event):void {
                        marker.openInfoWindow(new InfoWindowOptions( {
                            content :
                                "震度" + intensity + "\n"
                                + "計測震度: " + i.toString() + "\n"
                                + "震央からの距離: " + distance.toString() + "km\n"
                                + "地盤増幅率: " + place.amp.toString() + "\n"
                                + "S波到達時刻: " + (distance / 4).toString() + "秒後"
                        } ));
                    });
                })(marker, place)

                overlays.push(marker);
            }

            map.setCenter(epicenter, 8, MapType.NORMAL_MAP_TYPE);
        }
        
        private function intensityByISI(intensity:Number):String {
            if (intensity < 0.5) {
                return '0';
            }
            else if (intensity < 1.5) {
                return '1';
            }
            else if (intensity < 2.5) {
                return '2';
            }
            else if (intensity < 3.5) {
                return '3';
            }
            else if (intensity < 4.5) {
                return '4';
            }
            else if (intensity < 5.0) {
                return '5弱';
            }
            else if (intensity < 5.5) {
                return '5強';
            }
            else if (intensity < 6.0) {
                return '6弱';
            }
            else if (intensity < 6.5) {
                return '6強';
            }
            else {
                return '7';
            }
        }

        private function calcIntensity(mag:Number, dep:Number, dist:Number, amp:Number):Number {
            dist = Math.sqrt(dep * dep + dist * dist);

            var d:Number = 0;

            var PGVb600:Number = Math.pow(10, 0.58 * mag + 0.0038 * dep + d - 1.29 - Math.log(dist + 0.0028 * Math.pow(10, 0.50 * mag)) / Math.log(10) - 0.002 * dist);
            var PGVb400:Number = PGVb600 * 1.31;
            var PGV:Number = PGVb400 * amp;
            var estimatedIntensity:Number = 2.68 + (1.72 * (Math.log(PGV) / Math.log(10)));

            return estimatedIntensity + 0.5;
        }
        ]]>
    </fx:Script>
</s:Application>