Projection conversion (WGS84 -> Mercator) question
See original GitHub issueHello,
We are new to Map Controls and Mapsui, and having issues understanding the projection conversions, the results as are follows. The Contour lines data comes from NOAA, and is calculated using the OxyPlot library, seems correct even according to the small rectangle below but when it came to the Global data, which covers 0, 360 and -90, 90 degrees. According to our tests with polygons, Mapsui seems to be limited to ±180 and ±85, as it would not draw with higher than these numbers? (unless we were doing something wrong, as converted using SphericalMercator.FromLonLat(0, 0)).
Any advice would be great, thank you!
Contour lines/LineString code (Click to expand)
Half way off-site (on the tilelayer?) renders:

Correct rectangle area conversion

converted to SM unit, LineString
{LINESTRING (14144305.9249581 222684.208505545, 14146086.8725675 231201.139468704, 14138573.2146273 333111.922170972, 14139014.8069197 334111.17140196, 14144344.7592397 340890.079699847, 14183240.9229634 399874.071311757, 14212686.062437 409349.940218685, 14248894.821539 428930.540922845, 14258248.7509737 436263.816288412, 14271048.864937 445640.109656027, 14261007.8236847 457783.504164248, 14248894.821539 461716.003920748, 14203106.0836212 511355.647743129, 14200090.7277095 557305.257274575, 14209889.6003497 596470.194430118, 14248894.821539 611612.843446787, 14303478.6697952 614280.545399771, 14306024.4545782 614676.365759493, 14360214.3123323 617921.31476913, 14390449.9107648 638746.37006298, 14410508.1672413 669141.057044245, 14422262.4453932 718704.432078043, 14471533.8031256 742533.281849441, 14507935.0596179 705754.002862049, 14565846.1494921 669141.057044245, 14573232.1093574 659467.63946003, 14582853.2939188 652213.569299688, 14592053.880248 659890.489349537, 14633874.7271989 669141.057044245, 14682257.5996945 681123.057562906, 14694172.7847121 693847.31021879, 14722737.9995752 752410.293557938, 14723698.1748647 781182.214188248, 14718155.866133 805351.04106474, 14694172.7847121 849302.943469934, 14673722.5187068 872817.124675088, 14647742.3338327 893463.751012645, 14647978.0214007 940136.662873366, 14644626.4867606 955887.494592196, 14644788.402767 1006021.06275513, 14605881.4145841 1029342.95138802, 14582853.2939188 1044725.91807055, 14527275.1610521 1062331.56399593, 14527109.9753309 1062329.57607567, 14471533.8031256 1111429.03390323, 14427933.6692314 1074643.55495423, 14459642.8575181 1118889.97485796, 14379038.9938649 1138010.06086225, 14360214.3123323 1151377.75797288, 14326549.1437456 1197828.95469926, 14314379.6402362 1232106.80189676, 14294077.8199874 1278167.5822248, 14272678.507072 1321402.9559831, 14261133.8713936 1345708.40840911, 14258615.110409 1355647.46806127, 14248894.821539 1369039.90540607, 14209349.3337382 1419175.3356418, 14193998.3426932 1459732.2718805, 14175891.2443032 1499083.58287907, 14137575.3307457 1567159.06843006, 14134966.2801803 1571527.76212701, 14134229.3727686 1574216.54816146, 14134346.4504879 1577544.48633595, 14123599.2746176 1674735.29607252, 14123977.543943 1689200.13960789, 14122326.694427 1704991.76324687, 14128247.7360501 1795021.30529091, 14126739.4441419 1804722.76625729, 14125786.2874499 1816990.15951934, 14120125.551695 1902585.5545829, 14118677.7534331 1920825.04037747, 14115937.6047228 1943463.21757854, 14126681.4003145 2026097.16013533, 14124112.9126518 2037548.5447506, 14061296.3638012 2074425.44101845, 14026255.8399525 2094125.97584981, 14003919.6564102 2131326.88859717, 13989610.5388284 2154935.91508589, 13969583.5731999 2212818.08108193, 13967454.0121544 2217225.74780375, 13943599.1581883 2273030.92698769, 13928413.5640007 2287378.60810893, 13914936.3491592 2302519.15197322, 13879886.1816197 2354374.13119094, 13844282.0602828 2391878.58794431, 13823312.7390438 2412988.27950425, 13803616.8583659 2433801.93893676, 13768019.6284135 2473175.40835845, 13721396.2124537 2511525.23484571, 13705611.6591873 2525891.23035681, 13692297.3675727 2536431.64834832, 13658088.7440156 2548460.63430405, 13629750.3480424 2564209.98059515, 13580977.8767794 2573884.33139244, 13539422.4381231 2586936.44730294, 13475247.4878438 2632018.63758642)}
Polygon code (Click to expand)
Complete fill of the tilelayer

polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(-180, 85.05));
polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(-180, -85.05));
polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(180, -85.05));
polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(180, -85.05));
polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(180, 85.05));
Results from below code

var result = new List<Polygon>();
var polygon = new Polygon();
var t = SphericalMercator.ToLonLat(0, 10000000); // 0, 66.4460277131412
// From converted values: uncomment
//polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(0, 0));
//polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(0, 66.4460277131412));
//polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(66.4460277131412, 66.4460277131412));
//polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(66.4460277131412, 0));
//polygon.ExteriorRing.Vertices.Add(SphericalMercator.FromLonLat(0, 0));
// Result: POLYGON((0 -7.08115455161362E-10, 0 10000000, 7396737.97026262 10000000, 7396737.97026262 -7.08115455161362E-10, 0 -7.08115455161362E-10))
// From Sample
polygon.ExteriorRing.Vertices.Add(new Mapsui.Geometries.Point(0, 0));
polygon.ExteriorRing.Vertices.Add(new Mapsui.Geometries.Point(0, 10000000));
polygon.ExteriorRing.Vertices.Add(new Mapsui.Geometries.Point(10000000, 10000000));
polygon.ExteriorRing.Vertices.Add(new Mapsui.Geometries.Point(10000000, 0));
polygon.ExteriorRing.Vertices.Add(new Mapsui.Geometries.Point(0, 0));
// Result: POLYGON((0 0, 0 10000000, 10000000 10000000, 10000000 0, 0 0))
result.Add(polygon);
var l = new MemoryLayer("Polygons")
{
DataSource = new MemoryProvider(result),
Style = new VectorStyle
{
Fill = new Brush(new Color(150, 150, 30, 128)),
Outline = new Pen
{
Color = new Color(150, 150, 30, 1),
Width = 0
}
}
};
MyMapControl.Map.Layers.Add(l);
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (8 by maintainers)

Top Related StackOverflow Question
Not yet, and it will not before next Friday. I have been working on projections last weeks so it is something I really should look into soon.
I saw that. Hope to have time this Friday.