You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i am looking for a way to rotate a set of coordinates. The underlying coordinate system is the Web-Mercator projected coordinate system. As all length and angles are constant on the two dimensions on a PCS it should be possible to rotate coordinates.
So far i am constructing the Web Mercator PCS like this:
var params = new List<ProjectionParameter>
{
new ProjectionParameter("semi_major", 6378137.0),
new ProjectionParameter("semi_minor", 6378137.0),
new ProjectionParameter("latitude_of_origin", 0.0),
new ProjectionParameter("central_meridian", 0.0),
new ProjectionParameter("false_easting", 0.0),
new ProjectionParameter("false_northing", 0.0),
new ProjectionParameter("scale_factor", 1),
};
var proj = new CoordinateSystemFactory().CreateProjection("WebMercator", "mercator_1sp", params);
var wgs84 = new CoordinateSystemFactory().CreateGeographicCoordinateSystem("WGS84", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich,
new AxisInfo("north", AxisOrientationEnum.North), new AxisInfo("east", AxisOrientationEnum.East));
var webMercator = new CoordinateSystemFactory().CreateProjectedCoordinateSystem("WM", wgs84, proj, LinearUnit.Metre,
new AxisInfo("North", AxisOrientationEnum.North), new AxisInfo("East", AxisOrientationEnum.East));
On the Proj Wiki Page i read that it is possible doing that with an AffineTransformation but i am struggling setting it up correctly.
Rotating about the origin without offset should be done with the following matrix following wiki but when transforming the coordinate, the result is way off. (Only for an angle of 90 the resulting coordinate is correct)
var angle = 60.0;
var c1 = new Coordinate(0, 1000000);
double[,] matrix = {
{Math.Cos(angle), -Math.Sin(angle), 0.0},
{Math.Sin(angle), Math.Cos(angle), 0.0},
{0.0 , 0.0, 1}
};
var c2 = new AffineTransformation(matrix).Transform(c1); // => {(4985871.3833798366, -1972620.6026179455, NaN)}
However looking at the constructor signals that the TranslateX/Y values maybe should be used different. The Test-Method AffineTransformationTest() is also using some values, where i am not sure where they come from.
Hello,
i am looking for a way to rotate a set of coordinates. The underlying coordinate system is the Web-Mercator projected coordinate system. As all length and angles are constant on the two dimensions on a PCS it should be possible to rotate coordinates.
So far i am constructing the Web Mercator PCS like this:
On the Proj Wiki Page i read that it is possible doing that with an AffineTransformation but i am struggling setting it up correctly.
Rotating about the origin without offset should be done with the following matrix following wiki but when transforming the coordinate, the result is way off. (Only for an angle of 90 the resulting coordinate is correct)
However looking at the constructor signals that the TranslateX/Y values maybe should be used different. The Test-Method AffineTransformationTest() is also using some values, where i am not sure where they come from.
What do i have to change to rotate a coordinate about and angle within a PCS?
The text was updated successfully, but these errors were encountered: