This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static double[] ToSphericalMercatorFromWgs84(double Longitude, double Latitude) | |
| { | |
| var x = Longitude * 20037508.34 / 180; | |
| var y = Math.Log(Math.Tan((90 + Latitude) * Math.PI / 360)) / (Math.PI / 180); | |
| y = y * 20037508.34 / 180; | |
| return new double[] { x, y }; | |
| } | |
| public static double[] ToWgs84FromSphericalMercator(double x, double y) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Two methods to get from 4326 (longitude, latitude) to 4978 (cartesian - ecef). TLDR; use DotSpatial.Positioning when possible (because much faster). | |
| 1] using DotSpatial.Positioning (fast): | |
| ``` | |
| private static System.Numerics.Vector3 ToCartesian(double lat, double lon, double alt) | |
| { | |
| var pos3d = new Position3D(new Distance(alt, DistanceUnit.Meters), new Latitude(lat), new Longitude(lon)); | |
| var res1 = pos3d.ToCartesianPoint(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ogr.RegisterAll(); | |
| var driver = Ogr.GetDriverByName("ESRI Shapefile"); | |
| var shp = @"D:\dev\github.com\Mattgerg\ShapefileSharp\ShapefileSharp Tests\Data\multipatch.shp"; | |
| var dataSource = driver.Open(shp, 0); | |
| var layer = dataSource.GetLayerByIndex(0); | |
| Console.WriteLine(layer.GetFeatureCount(0)); | |
| Console.WriteLine(layer.GetGeomType().ToString()); | |
| for(var i = 0; i < layer.GetFeatureCount(0); i++) | |
| { | |
| var feature = layer.GetFeature(i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ogr.RegisterAll(); | |
| Gdal.AllRegister(); | |
| var driver = Ogr.GetDriverByName("ESRI Shapefile"); | |
| var data_source = driver.CreateDataSource("volcanoes.shp", null); | |
| var sr = new OSGeo.OSR.SpatialReference(string.Empty); | |
| sr.ImportFromEPSG(4326); | |
| var layer = data_source.CreateLayer("volcanoes", sr, wkbGeometryType.wkbPoint, null); | |
| var fdefn = new FieldDefn("Name", FieldType.OFTString); | |
| fdefn.SetWidth(24); | |
| layer.CreateField(fdefn,1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var connectionString = $"Host=localhost;Username=postgres;Password=postgres;Database=postgres;Port=5432"; | |
| var sql = "select st_asbinary(geom_triangle) as geom1 from delaware_buildings limit 10"; | |
| var conn = new NpgsqlConnection(connectionString); | |
| conn.Open(); | |
| var cmd = new NpgsqlCommand(sql, conn); | |
| var reader = cmd.ExecuteReader(); | |
| while (reader.Read()) | |
| { | |
| var b = (byte[])reader.GetValue(0); | |
| IntPtr unmanagedPointer = Marshal.AllocHGlobal(b.Length); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import psycopg2 | |
| from osgeo import ogr | |
| connection = psycopg2.connect(user = "postgres", | |
| password = "postgres", | |
| host = "localhost", | |
| port = "5432", | |
| database = "postgres") | |
| cursor = connection.cursor() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Transforms a coordinate from WGS84 (epsg:4326) to Dutch RD New (epsg:28992) using ProjNET | |
| Dependency : https://www.nuget.org/packages/ProjNET/2.0.0 | |
| ``` | |
| var csFact = new CoordinateSystemFactory(); | |
| var ctFact = new CoordinateTransformationFactory(); | |
| var wgs84 = GeographicCoordinateSystem.WGS84; | |
| var rdm = csFact.CreateFromWkt("PROJCS[\"Amersfoort / RD New\",GEOGCS[\"Amersfoort\",DATUM[\"Amersfoort\",SPHEROID[\"Bessel 1841\",6377397.155,299.1528128,AUTHORITY[\"EPSG\",\"7004\"]],TOWGS84[565.4171,50.3319,465.5524,-0.398957,0.343988,-1.87740,4.0725],AUTHORITY[\"EPSG\",\"6289\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4289\"]],PROJECTION[\"Oblique_Stereographic\"],PARAMETER[\"latitude_of_origin\",52.15616055555555],PARAMETER[\"central_meridian\",5.38763888888889],PARAMETER[\"scale_factor\",0.9999079],PARAMETER[\"false_easting\",155000],PARAMETER[\"false_northing\",463000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| How to: Creating a new app release in the various store | |
| 1] Android App | |
| - Chenge version in project - properties (id, name) | |
| - Project on release | |
| - Archive |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using DotSpatial.Projections; | |
| using System; | |
| namespace ConsoleApp1 | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var longitude = 5.11995; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI1OGUyODEwNC03YTIzLTRjMmItOTk4Ni1iZWNkNGE1MWZhMTkiLCJpZCI6NTQzLCJpYXQiOjE1MjUyNzM4OTd9.F2r6H2XRAcnkHjkFgXAzDieW6TeIxDhTZ5hdikd-_Q8'; | |
| var viewer = new Cesium.Viewer('cesiumContainer', { | |
| terrainExaggeration : 10.0 | |
| }); | |
| var terrainProvider = new Cesium.CesiumTerrainProvider({ | |
| url : '/tilesets/tiles' | |
| }); | |
| viewer.scene.terrainProvider = terrainProvider; |