//, decimal minLat, decimal maxLat, decimal minLng, decimal maxLng private Earthquake FindWeightedCenter(List <Earthquake> list) { Earthquake result = new Earthquake(); decimal meanLat = 0; decimal meanLng = 0; decimal totalLat = 0; decimal totalLng = 0; double totalWeight = 0; foreach (var eq in list) { totalLat += eq.Latitude * (decimal)eq.Magnitude; totalLng += eq.Longitude * (decimal)eq.Magnitude; totalWeight += eq.Magnitude; } meanLat = totalLat / (decimal)totalWeight; meanLng = totalLng / (decimal)totalWeight; result.Magnitude = list.Count; result.Latitude = meanLat; result.Longitude = meanLng; return(result); }
public IEnumerable <IDomainModel> ParseNodes(HtmlNodeCollection nodes) { List <Earthquake> lst = new List <Earthquake>(); if (nodes != null && nodes.Any()) { foreach (var node in nodes) { if (!string.IsNullOrWhiteSpace(node.InnerText)) { string[] content = node.InnerText.Split('\n').Select(o => o.Trim()).ToArray(); int startIndex = this.GetStartIndex(content); if (startIndex < 2) { continue; } Earthquake entity = new Earthquake(); entity.Scale = content[startIndex]; entity.CreateTime = DateTime.Parse(content[startIndex + 1]); entity.Latitude = content[startIndex + 2]; entity.Logitude = content[startIndex + 3]; entity.Depth = content[startIndex + 4]; entity.Position = content[startIndex + 5]; lst.Add(entity); } } } return(lst); }
public override void ProcessMouseClick(Point clickPoint, GeoCoord mouseGeoLocation, bool controlDown, bool shiftDown, bool altDown) { try { if (m_cameraManager.CanDrillDown) { Earthquake clickEq = EarthquakeByPoint(clickPoint); if (clickEq != null) { if (altDown) { Point screenPoint = m_pictureManager.PointToScreen(clickPoint); string tmp = string.Format("{0:F1} - ", clickEq.Magn) + clickEq.sDateTime + "\n" + clickEq.Comment + "\n" + clickEq.Source; Project.MapShowPopup(m_pictureManager.PictureBox, tmp, screenPoint); } else { string tmp = clickEq.Url; if (tmp != null && tmp.StartsWith("http://")) { tmp = "\"" + tmp + "\""; //LibSys.StatusBar.Trace(tmp); Project.RunBrowser(tmp); } } } } } catch {} }
private Earthquake CalculateCentralEarthquake(List <Earthquake> list, int occurTime) { int loopMax; if (occurTime == 1) { loopMax = (int)(list.Count * 0.6); } else { loopMax = (int)(list.Count * 0.7); } for (int i = 0; i < loopMax; i++) { Earthquake avgEarthquakeCurrent = GetAverageEarthquakePoint(list); Earthquake furthestEarthquake = GetFurthestEarthquake(list, avgEarthquakeCurrent); list.Remove(furthestEarthquake); } Earthquake finalAverageEarthquake = GetAverageEarthquakePoint(list); Earthquake finalFurthestEarthquake = GetFurthestEarthquake(list, finalAverageEarthquake); double circleRadius = GetDistance(finalAverageEarthquake, finalFurthestEarthquake); finalAverageEarthquake.Magnitude = circleRadius; return(finalAverageEarthquake); }
public override void ProcessMouseMove(Point movePoint, GeoCoord mouseGeoLocation, bool controlDown, bool shiftDown, bool altDown) { try { Earthquake hoverEq = EarthquakeByPoint(movePoint); if (hoverEq != null) { string tmp = string.Format("{0:F1} - ", hoverEq.Magn) + hoverEq.sDateTime + "\n" + hoverEq.Comment + "\n" + hoverEq.Source; if (!tmp.Equals(sEqPopup)) // && movePoint.Y > 30) // make sure the popup will not overlap menu { sEqPopup = tmp; LibSys.StatusBar.WriteLine("* " + sEqPopup); // will not be added to log //movePoint.Offset(0, -15); Point screenPoint = m_pictureManager.PointToScreen(movePoint); Project.MapShowPopup(m_pictureManager.PictureBox, sEqPopup, screenPoint); } Cursor.Current = Cursors.Hand; } else { sEqPopup = null; // mouse reentry into the same label is allowed } } catch (Exception e) { } }
public List <ScatterModel> GetScatterData(Earthquake centralPoint, List <Earthquake> eqList) { List <ScatterModel> result = new List <ScatterModel>(); foreach (Earthquake eq in eqList) { ScatterModel scatter = new ScatterModel(); scatter.x = (double)(eq.Latitude - centralPoint.Latitude); if (scatter.x > 90) { scatter.x -= 90; } else if (scatter.x < -90) { scatter.x += 90; } scatter.y = (double)(eq.Longitude - centralPoint.Longitude); if (scatter.y > 180) { scatter.y -= 180; } else if (scatter.y < -180) { scatter.y += 180; } result.Add(scatter); } return(result); }
public List <BubbleModel> GetBubbleData(Earthquake centralPoint, List <Earthquake> eqList) { List <BubbleModel> result = new List <BubbleModel>(); //FitPolynomial(eqList, 3); foreach (Earthquake eq in eqList) { BubbleModel bubble = new BubbleModel(); bubble.x = (double)(eq.Latitude - centralPoint.Latitude); if (bubble.x > 90) { bubble.x -= 90; } else if (bubble.x < -90) { bubble.x += 90; } bubble.y = (double)(eq.Longitude - centralPoint.Longitude); if (bubble.y > 180) { bubble.y -= 180; } else if (bubble.y < -180) { bubble.y += 180; } bubble.r = GetBubbleRadius(eq.Magnitude); result.Add(bubble); } return(result); }
public List <Earthquake> CentraliseRecursive(List <Earthquake> list, bool isMahalanobis) { List <Earthquake> result = new List <Earthquake>(); List <Earthquake> excludedEarthquakes = new List <Earthquake>(); bool isWeighted = true; int occurTime = 0; double distanceRange = GetMaximumDistance(list); double loopCoef = GetIterationCoefByMaxDistance(distanceRange); while (excludedEarthquakes.Count() < list.Count * loopCoef) { occurTime++; List <Earthquake> remainingEarthquakes = list.Where(t => !excludedEarthquakes.Contains(t)).ToList(); Earthquake centreEarthquake = CalculateCentralEarthquake(remainingEarthquakes, occurTime, isWeighted, isMahalanobis); centreEarthquake.Depth = remainingEarthquakes.Count; centreEarthquake.EventDate = DateTime.Today; if (centreEarthquake.Magnitude <= (GetDistanceCoefficientByMaxDistance(distanceRange, isToVerify: true) * distanceRange)) { result.Add(centreEarthquake); } excludedEarthquakes.AddRange(remainingEarthquakes); } return(result); }
private bool IsCentralized(List <Earthquake> list, Earthquake center) { int count = 0; foreach (var eq in list) { double difLat = Math.Abs((double)(eq.Latitude - center.Latitude)); double difLng = Math.Abs((double)(eq.Longitude - center.Longitude)); double distLat = 111; double distLng = GetDistancePerLongitude(eq.Latitude); double distance = Math.Sqrt(Math.Pow(difLat * distLat, 2) + Math.Pow(difLng * distLng, 2)); if (distance <= center.Magnitude) { count++; } } if (count > (0.6) * list.Count) { return(true); } else { return(false); } }
private void SendSensibleEarthquakeNotification(Earthquake earthquake) { try { PushNotification.PushNotification pn = new PushNotification.PushNotification(); var devices = Repository.DbContext.RegistrationDevices.OrderBy(e => e.Date).ToList(); //-------------------------------------------------------------------------------------- int elementsByList = 20000; int numberOfLists = (devices.Count / elementsByList) + 1; List <List <RegistrationDevice> > listOfLists = new List <List <RegistrationDevice> >(); for (int i = 0; i < numberOfLists; i++) { List <RegistrationDevice> newList = new List <RegistrationDevice>(); newList = devices.Skip(i * elementsByList).Take(elementsByList).ToList(); listOfLists.Add(newList); Task task4 = new Task(() => { NotificateMultipleDevices(newList, earthquake); }); task4.Start(); } //-------------------------------------------------------------------------------------- } catch (Exception ex) { ExceptionUtility.Error(ex, this.GetType()); } }
public List <Earthquake> CentraliseRecursive(List <Earthquake> list) { List <Earthquake> result = new List <Earthquake>(); List <Earthquake> excludedEarthquakes = new List <Earthquake>(); int occurTime = 0; while (excludedEarthquakes.Count() < list.Count * 0.6) { occurTime++; List <Earthquake> remainingEarthquakes = list.Where(t => !excludedEarthquakes.Contains(t)).ToList(); Earthquake centreEarthquake = CalculateCentralEarthquake(remainingEarthquakes, occurTime); centreEarthquake.Depth = remainingEarthquakes.Count; if (centreEarthquake.Magnitude <= (0.04 * GetMaximumDistance(list))) { result.Add(centreEarthquake); } excludedEarthquakes.AddRange(remainingEarthquakes); } return(result); }
private void FindStandardDeviation(List <Earthquake> list, Earthquake mean) { double result = 0; decimal totalX = 0; decimal totalY = 0; double devX, devY; foreach (var eq in list) { decimal difX = eq.Latitude - mean.Latitude; decimal difY = eq.Longitude - mean.Longitude; totalX += difX * difX; totalY += difY * difY; } devX = Math.Sqrt((double)totalX / (1.0 * list.Count)); devY = Math.Sqrt((double)totalY / (1.0 * list.Count)); double distLat = 111; double distLng = GetDistancePerLongitude(mean.Latitude); result = Math.Sqrt(Math.Pow(devX * distLat, 2) + Math.Pow(devY * distLng, 2)); mean.Magnitude = result; //result = Math.Sqrt(((double) (totalX + totalY))/(1.0*list.Count)); //mean.Magnitude = result; }
public void finishSkill() { GameObject earthquake = Instantiate(earthquakePrefab, targetPosition, Quaternion.identity) as GameObject; Earthquake quake = earthquake.GetComponent <Earthquake>(); quake.setParameters(myCharacter); Destroy(this.gameObject); }
private void OnMouseOver() { if (!GameObject.Find("Shield").GetComponent <Electric>().electric) { GameObject.Find("Hole").GetComponent <SpriteRenderer> ().sprite = l1; Earthquake.Shake(0.1F, 0.1F); } }
private Vector3 Vec3FromLatLon(Earthquake e, float r) { var threePosition = Quaternion.AngleAxis((float)e.lon, -Vector3.up) * Quaternion.AngleAxis((float)e.lat, -Vector3.right) * new Vector3(0f, 0f, 1f) * r; return(threePosition); }
public void Init(Earthquake _quake, GameObject _label) { quake = _quake; //Assign highlight material to earthquake points Label = _label; //InitLabel(quake, stromColCat); //Vector3 pos = transform.localPosition; //transform.localPosition = new Vector3(pos); }
void Awake() { _shake = GetComponent <ObjectShake> (); _blastLight.localScale = Vector3.zero; _earthquake = FindObjectOfType <Earthquake> (); _theHellFire = FindObjectOfType <TheHellFire> (); _settings = FindObjectOfType <Settings> (); _endGame = FindObjectOfType <EndGame> (); }
void Awake() { _skill = GetComponent <TheTrueDaystarSkill> (); _comeback = GetComponent <TheTrueDaystarComeback> (); _goesAway = GetComponent <TheTrueDaystarGoesAway> (); _earthquake = FindObjectOfType <Earthquake> (); _theHellFire = FindObjectOfType <TheHellFire> (); _endGame = FindObjectOfType <EndGame> (); _blastLight.localScale = Vector3.zero; }
internal void Setup(Dispatcher _dispatcher, int shareTent) { this._fc = _dispatcher.SiteFeatureClass; this._earthquake = _dispatcher.Earthquake; this._regionCoffe = _dispatcher.Region; _idxUrgentPop = _fc.Fields.FindField(UrgentPopField); _refugeeSites = GetRefugeeSites(); RefugeeSiteTentCol.PersonPerTent = shareTent; }
private double GetDistance(Earthquake eq1, Earthquake eq2) { double difLat = Math.Abs((double)(eq1.Latitude - eq2.Latitude)); double difLng = Math.Abs((double)(eq1.Longitude - eq2.Longitude)); double distLat = 111; double distLng = GetDistancePerLongitude(eq1.Latitude); double distance = Math.Sqrt(Math.Pow(difLat * distLat, 2) + Math.Pow(difLng * distLng, 2)); return(distance); }
internal void Setup(Dispatcher dispatcher, int daysInShort, int quota) { this._fc = dispatcher.SiteFeatureClass; this._earthquake = dispatcher.Earthquake; RefugeeSiteFoodCol.DaysInShort = daysInShort; RefugeeSiteFoodCol.FoodQuota = quota; this._regionCoffe = dispatcher.Region; _idxPop = _fc.Fields.FindField(PopulationField); _refugeeSites = GetRefugeeSites(); }
public List <Earthquake> CentralizeTest(List <Earthquake> list, string stepCount) { int step = String.IsNullOrEmpty(stepCount) ? 4 : Convert.ToInt32(stepCount); if (step == 0) { step = 4; } else if (step < 0) { step = Math.Abs(step); } int minLat = (int)list.Min(t => t.Latitude) - step - 2; int minLng = (int)list.Min(t => t.Longitude) - step - 2; int maxLat = (int)list.Max(t => t.Latitude) + step + 2; int maxLng = (int)list.Max(t => t.Longitude) + step + 2; int latParts = (maxLat - minLat) / step; int lngParts = (maxLng - minLng) / step; List <Earthquake> result = new List <Earthquake>(); for (int i = minLat; i < maxLat; i += step) { for (int j = minLng; j < maxLng; j += step) { List <Earthquake> curList = list.Where(t => t.Latitude < (i + step) && t.Latitude >= (i) && t.Longitude < (j + step) && t.Longitude >= (j)).ToList(); if (curList.Count == 0 || ((1.0 * curList.Count) / list.Count) < (1.0 / (1.0 * latParts * lngParts))) { continue; } Earthquake centerEq = FindWeightedCenter(curList); FindStandardDeviation(curList, centerEq); centerEq.Depth = curList.Count; //if(centerEq.Magnitude < 0.8) // result.Add(centerEq); //if (curList.Count > step * 5 && IsCentralized(curList, centerEq)) if (IsCentralized(curList, centerEq)) { result.Add(centerEq); } //double safeTest = (1.0 * curList.Count) / centerEq.Magnitude; //if (safeTest > 0.65) // result.Add(centerEq); } } return(result); }
private Vector3 CalculateVec3FromLatLon(Earthquake e) { float r = sphereCollider.radius * 100.5f; var threePosition = Quaternion.AngleAxis((float)e.lon, -Vector3.up) * Quaternion.AngleAxis((float)e.lat, -Vector3.right) * new Vector3(0.0f, 0.0f, 1.0f) * r; return(threePosition); }
public void TestParsingEarthquakesDataToStringTryDepth( string n, string t, string m, string lon, string lat, string d) { Earthquake e = new Earthquake(n, t, m, lon, lat, d); Assert.That(e.depth.ToString() != null && e.depth.ToString() != ""); }
private void OnGUI() { if (inTrigger) { GUI.color = Color.black; GUI.Label(new Rect(Screen.width / 24, Screen.height / 18, 300, 30), text); if (name.Equals("Poster")) { Earthquake.Shake(0.1F, 0.1F); } } }
public static string ToTelegramMessage(this Earthquake earthquake) { var stringBuilder = new StringBuilder(); var googleMapsUrl = $"{GOOGLE_MAPS_SEARCH_API_URL}?api=1&query={earthquake.Latitude},{earthquake.Longitude}"; stringBuilder.AppendLine($"Yer: [{earthquake.Location}]({googleMapsUrl})"); stringBuilder.AppendLine($"Buyukluk: {earthquake.Magnitude}"); stringBuilder.AppendLine($"Zaman: {earthquake.Date.ToString("dd/MM/yyyy HH:mm")}"); return(stringBuilder.ToString()); }
private static Core fromJMAQuake(JMAQuake jmaQuake) { Core core = new Core(); // .expire core.expire = null; // .issue Issue issue = new Issue(); issue.source = jmaQuake.issueOf; issue.time = jmaQuake.issueTime.ToString("yyyy/MM/dd HH:mm:ss"); // TODO: 要確認(toStringでいけるか?) issue.type = jmaQuake.issueType.ToString(); issue.correct = jmaQuake.correctType.ToString(); core.issue = issue; // .earthquake Earthquake earthquake = new Earthquake(); earthquake.time = jmaQuake.occuredTime.ToString("yyyy/MM/dd HH:mm:ss"); { Hypocenter hypocenter = new Hypocenter(); hypocenter.name = jmaQuake.occuredPlace; hypocenter.latitude = jmaQuake.occuredLatitude; hypocenter.longitude = jmaQuake.occuredLongitude; hypocenter.depth = jmaQuake.occuredDepth; hypocenter.magnitude = jmaQuake.occuredMagnitude; earthquake.hypocenter = hypocenter; } earthquake.maxScale = jmaQuake.occuredScale; earthquake.domesticTsunami = jmaQuake.domesticTsunamiType.ToString(); earthquake.foreignTsunami = jmaQuake.foreignTsunamiType.ToString(); core.earthquake = earthquake; // .points List <Point> points = new List <Point>(); if (jmaQuake.observationPoints != null) { foreach (ObservationPoint observationPoint in jmaQuake.observationPoints) { Point point = new Point(); point.pref = observationPoint.prefecture; point.addr = observationPoint.address; point.scale = observationPoint.seismicScale; point.isArea = observationPoint.isArea; // TODO: PointType(気象庁かそれ以外か)は捨てる? points.Add(point); } } core.points = points; return(core); }
public void TestFixingInputErrorsAtInitTryMag( string n, string t, string m, string lon, string lat, string d) { Earthquake e = new Earthquake(n, t, m, lon, lat, d); float testedMag = e.mag; Assert.GreaterOrEqual(testedMag, 0.1); }
public void TestFixingInputErrorsAtInitTryDepth( string n, string t, string m, string lon, string lat, string d) { Earthquake e = new Earthquake(n, t, m, lon, lat, d); float testedDepth = e.depth; Assert.GreaterOrEqual(testedDepth, 10); }
public ActionResult Backend3(Earthquake eq) { // Pobierz wybrany z listy rok z modelu i wybierze z dbf kolumy z rokiem i liczą trzęsień ziemi var year = eq.selectedYear; var query = string.Format("SELECT LEFT(YYYYMMDD, 4) AS Year, Count(*) FROM {1} WHERE (YYYYMMDD LIKE '{0}%') GROUP BY Year", year, _tableAdress); // Prześlij wybrane dane do widoku ViewBag.rows = myData(query); ViewBag.minYear = _minYear; ViewBag.maxYear = _maxYear; return(View()); }