public void Gcj02_To_Gps84() { var p1 = CoordinateUtil.Gcj02_To_Gps84(39.991754, 116.487585); Assert.AreEqual(0, Math.Round(p1.getWgLat() - 39.990475, 4)); Assert.AreEqual(0, Math.Round(p1.getWgLon() - 116.481499, 4)); }
public void Gcj02_To_Bd09() { var p1 = CoordinateUtil.Gcj02_To_Bd09(39.984717169345, 116.4748955248); Assert.AreEqual(0, Math.Round(p1.getWgLat() - 39.990475, 3)); Assert.AreEqual(0, Math.Round(p1.getWgLon() - 116.481499, 3)); }
public void Gps84_To_Gcj02() { var p1 = CoordinateUtil.Gps84_To_Gcj02(39.990475, 116.481499); Assert.AreEqual(0, Math.Round(p1.getWgLat() - 39.991754014757, 6)); Assert.AreEqual(0, Math.Round(p1.getWgLon() - 116.487585177952, 6)); }
private IEnumerator Detect() { Collider[] hitColliders = Physics.OverlapSphere(droneTransform.position, range); int found = 0; yield return(new WaitForSeconds(duration)); foreach (Collider c in hitColliders) { if (c.CompareTag(rayTag)) { Item item = c.gameObject.GetComponentInChildren <Item>(); if (item != null) { found++; Coordinate coordinate = CoordinateUtil.GetCoordinate(droneTransform.position, item.transform.position); Debug.Log("found: " + item.name + " at " + coordinate.ToString()); OnItemFound?.Invoke(this, item, coordinate); yield return(new WaitForSeconds(durationPerFind)); } } } }
public void Update() { var chunksWithinRadius = CoordinateUtil.CoordinatesWithinRadius( new Vector2(Source.position.x / ChunkSize, Source.position.z / ChunkSize), 128); var chunksToGenerate = new HashSet <Vector2>(chunksWithinRadius); chunksToGenerate.ExceptWith(_generatedChunkCoordinates); _generatedChunkCoordinates.UnionWith(chunksToGenerate); foreach (var chunkCoord in chunksToGenerate) { _generatedChunks[chunkCoord] = ChunkGenerator.GenerateChunk( Mathf.FloorToInt(chunkCoord.x), Mathf.FloorToInt(chunkCoord.y), ChunkSize); } foreach (var chunkCoordinate in _generatedChunkCoordinates.Except(chunksWithinRadius)) { Destroy(_generatedChunks[chunkCoordinate]); _generatedChunks.Remove(chunkCoordinate); } _generatedChunkCoordinates.IntersectWith(chunksWithinRadius); }
public ActionResult MapPost(string overlays, string countyId) { MyJsonResult result = new MyJsonResult(); if (string.IsNullOrEmpty(countyId)) { result.message = "请选择乡镇"; return(Json(result)); } if (string.IsNullOrEmpty(overlays)) { result.message = "请在地图中选取行政规划"; return(Json(result)); } List <Coordinate> list = JsonConvert.DeserializeObject <List <Coordinate> >(overlays); if (list == null || list.Count == 0) { throw new ApplicationException("解析失败"); } string coordinate = CoordinateUtil.getCoordinateString(list); TownCoordinateDao dao = new TownCoordinateDao(); dao.save(new TownCoordinate() { CountyId = countyId, Coordinate = coordinate }); dao.Dispose(); result.success = true; return(Json(result)); }
public HashSet <DateTime> DaysVisited(double centerLatitude, double centerLongitude, int meterRadius) { var daysVisited = new HashSet <DateTime>(); foreach (var visit in PlaceVisits) { if (CoordinateUtil.SurfaceDistance(centerLatitude, centerLongitude, visit.CenterLat, visit.CenterLng) < meterRadius) { daysVisited.UnionWith(DateUtil.DaysBetween(visit.StartDateTime, visit.EndDateTime)); } } return(daysVisited); }
public void RayCast_WhenOthogonal_DetectsEdgeCase() { // Arrange var mock = new Mock <IEdgeCaseDetector>(); var coordinateUtil = new CoordinateUtil(mock.Object); var source = new Coordinate(1, 1); // Act // Remember the ToArray because we need to evaluate the enumerable // before we can check if the edge case was detected. coordinateUtil.RayCast(source, new Coordinate(0, 0)).ToArray(); // Assert mock.Verify(x => x.EdgeDetected("Orthogonal_Edge_Case")); }
public string ConvertJourneyLogToCSVText() { string CSVfile = ""; //Ship playerShip = playerShipVars.ship; //Let's first add the headings to each column CSVfile += this.CSVheader; Debug.Log("Route Count: " + routeLog.Count); //first make sure the route isn't empty--if it is, then return a blank file if (routeLog.Count == 0) { CSVfile = "There is no player data to save currently"; } else { //Loop through each route in the list and respectively the cargo(they will always be the same size so a single for loop index can handle both at once // Each loop represents a single line in the CSV file for (int i = 0; i < routeLog.Count; i++) { //First add the player's unique machine ID--this will be different depending on the Operating System of the user, but will always be a consistent unique ID based on the users hardware(assuming there aren't major hardware changes) CSVfile += SystemInfo.deviceUniqueIdentifier + ","; //we're converting it to Web Mercator before saving it Vector3 mercator_origin = new Vector3((routeLog[i].theRoute[0].x * 1193.920898f) + (526320 - 0), (routeLog[i].theRoute[0].z * 1193.920898f) + (2179480 - 0), routeLog[i].theRoute[0].y); Vector3 mercator_end = new Vector3((routeLog[i].theRoute[1].x * 1193.920898f) + (526320 - 0), (routeLog[i].theRoute[1].z * 1193.920898f) + (2179480 - 0), routeLog[i].theRoute[1].y); Vector2 longXlatY_origin = CoordinateUtil.ConvertWebMercatorToWGS1984(new Vector2(mercator_origin.x, mercator_origin.y)); Vector2 longXlatY_end = CoordinateUtil.ConvertWebMercatorToWGS1984(new Vector2(mercator_end.x, mercator_end.y)); //TODO: This needs to be cleaned up below--the lat/long bit so it's not wasting resources on a pointless conversion above //TODO -- Seriously this XYZ / XZY business is a frankenstein monster of confusion--I can't even fathom in my current sleep deprived state why I'm having to put the y as a z here. My god. Someone Save me! //If this isn't a player travel route, but a port stop, then we don't need to worry about the conversion of of lat / long--it's already in lat long if (routeLog[i].settlementID != -1) { longXlatY_origin = new Vector2(routeLog[i].theRoute[0].x, routeLog[i].theRoute[0].z); longXlatY_end = Vector2.zero; } CSVfile += routeLog[i].timeStampInDays + "," + longXlatY_origin.x + "," + longXlatY_origin.y + "," + mercator_origin.z + "," + longXlatY_end.x + "," + longXlatY_end.y + "," + mercator_end.z; /*CSVfile += ((routeLog[i].theRoute[0].x * 1193.920898f) + (526320 - 0)) + "," + * ((routeLog[i].theRoute[0].z * 1193.920898f) + (2179480 - 0)) + "," + * routeLog[i].theRoute[0].y + "," + * * ((routeLog[i].theRoute[1].x * 1193.920898f) + (526320 - 0)) + "," + * ((routeLog[i].theRoute[1].z * 1193.920898f) + (2179480 - 0)) + "," + * routeLog[i].theRoute[1].y; */ //Add the Resources to the line record CSVfile += cargoLog[i]; CSVfile += otherAttributes[i]; //Add a newline if not on last route if (i != (routeLog.Count - 1)) { CSVfile += "\n"; //Debug.Log ("Adding a NEW Line?"); } //Debug.Log (CSVfile); } } return(CSVfile); }