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
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
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
frame.Camera.EulerAngles.Y * 180 / Math.PI | |
0 degrees: blue towards device, red to the right, green up | |
positive [0 - 180] turning to left | |
negative [0 - -180] turning to right |
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
// test | |
var result = PointRotator.RotatePoint(new Vector2(5.0f, 0), new Vector2(0, 0), Math.PI / 2 ); | |
Assert.IsTrue(Math.Round(result.X, 0) == 0f); | |
Assert.IsTrue(Math.Round(result.Y,0) == -5); | |
// RotatePoint method | |
public static class PointRotator |
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
GDAL 3.5.0, dev-4b77cd8111ce6c6b79cb0c75101394367b9e135e, released 2022/05/03 | |
$ ogrinfo --formats | |
Supported Formats: | |
FITS -raster,vector- (rw+): Flexible Image Transport System | |
PCIDSK -raster,vector- (rw+v): PCIDSK Database File | |
netCDF -raster,multidimensional raster,vector- (rw+vs): Network Common Data Format | |
PDS4 -raster,vector- (rw+vs): NASA Planetary Data System 4 | |
VICAR -raster,vector- (rw+v): MIPL VICAR file | |
JP2OpenJPEG -raster,vector- (rwv): JPEG-2000 driver based on OpenJPEG library |
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
{ | |
"tilejson": "2.1.0", | |
"name": "i09bz13857", | |
"description": "", | |
"version": "1.1.0", | |
"format": "quantized-mesh-1.0", | |
"attribution": "", | |
"schema": "tms", | |
"tiles": [ "{z}/{x}/{y}.terrain?v={version}" ], | |
"projection": "EPSG:4326", |
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
{ | |
"buffers":[ | |
{ | |
"byteLength":16 | |
} | |
], | |
"bufferViews":[ | |
{ | |
"buffer":0, | |
"byteOffset":0, |
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
{ | |
"buffers":[ | |
{ | |
"byteLength":16 | |
} | |
], | |
"bufferViews":[ | |
{ | |
"buffer":0, | |
"byteOffset":0, |
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 pyproj | |
lon = 1231256.4091099831 | |
lat = -4800453.896456448 | |
alt = 4000024.663498499 | |
transformer = pyproj.Transformer.from_crs("EPSG:4978", "EPSG:4326") | |
print(transformer) | |
xyz = transformer.transform(lon, lat, alt) | |
print('Projected XY', xyz) | |
lonlat = transformer.transform(xyz[0], xyz[1], xyz[2], direction='INVERSE') |