public void TagImage(Waypoint waypoint, string imagePath) { UTMCoordinate utmCoordinate = georeferencing.MapUnityToUTM(waypoint.dronePosition); LatLngUTMConverter.LatLng latlng = LatLngUTMConverter.ConvertUtmToLatLng(utmCoordinate.Easting, utmCoordinate.Northing, georeferencing.utmZone, georeferencing.hemisphere.Value); string latitudeRef = georeferencing.hemisphere.Value; string longitudeRef = georeferencing.utmZone <= 30 ? "W" : "E"; LongLatCoordidnates longLatCoord = new LongLatCoordidnates(latlng.Lng, latlng.Lat, utmCoordinate.Altitude, latitudeRef, longitudeRef); GeoTagImage(longLatCoord, imagePath); }
public JsonResult GetLatLongToUTM(float lat, float longt)//Creating Server and sending info { LatLngUTMConverter lt = new LatLngUTMConverter(null); var result = lt.ArrResult(lat, longt); HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*"); /*for(var x in result) { * * for(var y in result) * { * * } * }*/ var jsonResult = new { data = result }; // var jsonRes = new { arr = res }; return(Json(jsonResult, JsonRequestBehavior.AllowGet)); }
private void loadFile() { if (geoTiffFilename.Text.Length > 0) { GeoTIFFReader.GeoTIFF geoTiff = new GeoTIFFReader.GeoTIFF(geoTiffFilename.Text); double rangeW = geoTiff.NWidth * geoTiff.DW; double rangeH = geoTiff.NHeight * geoTiff.DH; rangeW /= 2; rangeH /= 2; double centerW = (geoTiff.StartW + rangeW); double centerH = (geoTiff.StartH + rangeH); LatLngUTMConverter converter = new LatLngUTMConverter("EUREF89"); LatLngUTMConverter.LatLng center = converter.convertUtmToLatLng((geoTiff.StartW + rangeW), (geoTiff.StartH + rangeH), Int32.Parse(textBox1.Text), "N"); geoTiffCenterLabel.Text = "E: " + centerW.ToString() + " m N: " + centerH.ToString() + " m" + " ( " + center.Lat.ToString() + ", " + center.Lng.ToString() + " )"; centerHeightLabel.Text = geoTiff.HeightMap[(int)(geoTiff.NWidth / 2.0), (int)(geoTiff.NHeight / 2.0)].ToString() + " m"; heightResolutionLabel.Text = "E: " + geoTiff.DH.ToString() + "m N: " + geoTiff.DW.ToString() + "m"; } else { MessageBox.Show("No valid filename selected, cannot load file !"); } }
public List <Borehole> getBoreholes(Location currentLocation, double radius) { List <Borehole> boreholes = null; /* * pointid = Id i database - Guid * pointno = punkt nummer - Guid * publicno = DGU nummer - String * PointType = punkttype - String - Table: PointTypes * Purpose = Formål - String - Table: PointPurposes * Projection1 = Primær Projektion: EPSG - Integer - Table: Projections * Projection2 * X1 = Primær X koordinat : float * Y1 = Primær Y koordinat : float * Z1 = primær z koordinat - Reference Niveau : float * ElevationMethod1 = Primær kote metode - String - Table: PointElevationMethods * CoordinateQuality1 = Primær koordinat kvalitet - String - Table: Pointcoordinatequalities * CoordinateMethod1 = Primær koordinat metode - String - Table: Pointcoordinatemethods * VerticalRefId1 - Højdesystem 1 - String - Table: VerticalRefs * ZDVR90 - DVR90 - Double * Top - Dybde til top af boring - float * Bottom - Dybde til bund af boring [m] - float * JupiterId - JupiterId - Int - Check om allerede har data? */ radius = radius * 100000; LatLngUTMConverter latLngUTMConverter = new LatLngUTMConverter("EUREF89"); LatLngUTMConverter.UTMResult utmResult = latLngUTMConverter.convertLatLngToUtm(currentLocation.X, currentLocation.Y); //Debug.Log(utmResult.ToString()); //Debug.Log("Radius:" + radius); String sql = "select PointNo, PublicNo, Purpose, X1, Y1, CoordinateMethod1, CoordinateQuality1, Z1, ZDVR90 from points" + " WHERE X1 >= " + (utmResult.Easting - radius).ToString(CultureInfo.InvariantCulture) + " AND X1 <= " + (utmResult.Easting + radius).ToString(CultureInfo.InvariantCulture) + " AND Y1 >= " + (utmResult.Northing - radius).ToString(CultureInfo.InvariantCulture) + " AND Y1 <= " + (utmResult.Northing + radius).ToString(CultureInfo.InvariantCulture); Debug.Log("GeoGis Boringer SQL: " + sql); String errMessage = null; DataSet dataset = client.GetDS(this.GEOGIS_DBNAME, this.GEOGIS_USERNAME, this.GEOGIS_PASSWORD, sql, ref errMessage); bool allGood = false; if (errMessage == null) { allGood = true; } else if (errMessage != null) { if (errMessage == "") { allGood = true; } else { Debug.Log("ErrMessage: " + errMessage); } } if (allGood) { boreholes = new List <Borehole>(); foreach (DataTable table in dataset.Tables) { String[] columnNames = new String[table.Columns.Count]; for (int i = 0; i < table.Columns.Count; i++) { columnNames[i] = table.Columns[i].ColumnName; //Debug.Log(table.Columns[i].ColumnName); } foreach (System.Data.DataRow row in table.Rows) { object[] itemArray = row.ItemArray; Borehole borehole = new Borehole(); String pointNo = null; String publicNo = null; float? latitude = null; float? longitude = null; String locationQuality_Code = null; String locationMethod_Code = null; for (int i = 0; i < itemArray.Length; i++) { if (!(itemArray[i] is DBNull)) { switch (columnNames[i]) { case "PointNo": pointNo = Convert.ToString(itemArray[i]); break; case "PublicNo": publicNo = Convert.ToString(itemArray[i]); break; case "X1": latitude = Convert.ToSingle(itemArray[i]); break; case "Y1": longitude = Convert.ToSingle(itemArray[i]); break; case "Z1": borehole.ReferencePoint = Convert.ToSingle(itemArray[i]); break; case "ZDVR90": borehole.ReferencePointKote = Convert.ToSingle(itemArray[i]); break; case "CoordinateQuality1": locationQuality_Code = Convert.ToString(itemArray[i]); break; case "CoordinateMethod1": locationMethod_Code = Convert.ToString(itemArray[i]); break; case "Purpose": borehole.BoreholeType = mediatorDatabase.getBoreholeType(Convert.ToString(itemArray[i])); break; default: Debug.Log("Unidentified Column!"); break; } } } borehole.BoreholeNo = publicNo != null ? publicNo : pointNo; if (latitude != null && longitude != null) { borehole.Location = new Location((float)latitude, (float)longitude); if (locationQuality_Code != null) { borehole.Location.LocationQuality = mediatorDatabase.getLocationQuality(locationQuality_Code); } if (locationMethod_Code != null) { borehole.Location.LocationMethod = mediatorDatabase.getLocationMethod(locationMethod_Code); } } boreholes.Add(borehole); } } } return(boreholes); }
public static bool ShowLandingSitesOnMap(MapLayersHandler layersHandler, string aoiGUID, GeoProjection gp, ref string layerName, bool uniqueLayerName = false) { layerName = "Landing sites"; var myDT = new DataTable(); var iShp = -1; using (var conection = new OleDbConnection(global.ConnectionString)) { try { conection.Open(); string query = $@"SELECT Municipality, ProvinceName, LSName, cx, cy FROM Provinces INNER JOIN (Municipalities INNER JOIN tblLandingSites ON Municipalities.MunNo = tblLandingSites.MunNo) ON Provinces.ProvNo = Municipalities.ProvNo WHERE tblLandingSites.AOIGuid={{{aoiGUID}}}"; var adapter = new OleDbDataAdapter(query, conection); adapter.Fill(myDT); if (myDT.Rows.Count > 0) { var sf = new Shapefile(); if (sf.CreateNewWithShapeID("", ShpfileType.SHP_POINT)) { var ifldName = sf.EditAddField("Name", FieldType.STRING_FIELD, 1, 50); var ifldLGU = sf.EditAddField("LGU", FieldType.STRING_FIELD, 1, 50); var ifldX = sf.EditAddField("x", FieldType.DOUBLE_FIELD, 8, 12); var ifldY = sf.EditAddField("y", FieldType.DOUBLE_FIELD, 8, 12); sf.GeoProjection = gp; for (int i = 0; i < myDT.Rows.Count; i++) { DataRow dr = myDT.Rows[i]; if (dr["cx"].ToString().Length > 0 && dr["cy"].ToString().Length > 0) { var x = (double)dr["cx"]; var y = (double)dr["cy"]; var name = dr["LSName"].ToString(); var LGU = $"{dr["Municipality"].ToString()}, {dr["ProvinceName"].ToString()}"; var shp = new Shape(); if (shp.Create(ShpfileType.SHP_POINT)) { if (global.MappingMode == fad3MappingMode.grid25Mode) { var converter = new LatLngUTMConverter("WGS 84"); var result = converter.convertLatLngToUtm(y, x); x = result.Easting; y = result.Northing; } shp.AddPoint(x, y); iShp = sf.EditAddShape(shp); if (iShp >= 0) { sf.EditCellValue(ifldName, iShp, name); sf.EditCellValue(ifldLGU, iShp, LGU); sf.EditCellValue(ifldX, iShp, x); sf.EditCellValue(ifldY, iShp, y); } } } } sf.DefaultDrawingOptions.PointShape = tkPointShapeType.ptShapeCircle; sf.DefaultDrawingOptions.FillColor = new Utils().ColorByName(tkMapColor.Red); sf.DefaultDrawingOptions.PointSize = 7; sf.DefaultDrawingOptions.LineVisible = false; if (sf.Labels.Generate("[Name]", tkLabelPositioning.lpCenter, false) > 0) { sf.Labels.FontSize = 7; sf.Labels.FontBold = true; sf.Labels.FrameVisible = false; } if (iShp >= 0) { layersHandler.AddLayer(sf, layerName, true, uniqueLayerName); } } } } catch (Exception ex) { Logger.Log(ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name); } } return(iShp >= 0); }