public void TestExplicitTransform() { const String csName1 = "EPSG:32636"; const String csName2 = "EPSG:4326"; CoordinateTransformFactory ctFactory = new CoordinateTransformFactory(); CoordinateReferenceSystemFactory csFactory = new CoordinateReferenceSystemFactory(); /* * Create {@link CoordinateReferenceSystem} & CoordinateTransformation. * Normally this would be carried out once and reused for all transformations */ CoordinateReferenceSystem crs1 = csFactory.CreateFromName(csName1); CoordinateReferenceSystem crs2 = csFactory.CreateFromName(csName2); ICoordinateTransform trans = ctFactory.CreateTransform(crs1, crs2); /* * Create input and output points. * These can be constructed once per thread and reused. */ ProjCoordinate p1 = new ProjCoordinate(); ProjCoordinate p2 = new ProjCoordinate(); p1.X = 500000; p1.Y = 4649776.22482; /* * Transform point */ trans.Transform(p1, p2); Assert.IsTrue(IsInTolerance(p2, 33, 42, 0.000001)); }
public void CRSFactoryTest() { CoordinateReferenceSystemFactory crsFactory = new CoordinateReferenceSystemFactory(); CoordinateReferenceSystem crsSource = crsFactory.CreateFromName("EPSG:4326"); Assert.IsNotNull(crsSource); Assert.AreEqual("EPSG:4326", crsSource.Name); CoordinateReferenceSystem crsTarget = crsFactory.CreateFromParameters("EPSG:3875", "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"); Assert.IsNotNull(crsTarget); Assert.AreEqual("EPSG:3875", crsTarget.Name); BasicCoordinateTransform t = new BasicCoordinateTransform(crsSource, crsTarget); ProjCoordinate prjSrc = new ProjCoordinate(0, 0); ProjCoordinate prjTgt = new ProjCoordinate(); t.Transform(prjSrc, prjTgt); BasicCoordinateTransform t2 = new BasicCoordinateTransform(crsTarget, crsSource); ProjCoordinate prjTgt2 = new ProjCoordinate(); t2.Transform(prjTgt, prjTgt2); Assert.AreEqual(0d, prjSrc.Distance(prjTgt2)); }
private static Boolean CheckTransform(String csName, double lon, double lat, double expectedX, double expectedY, double tolerance) { CoordinateTransformFactory ctFactory = new CoordinateTransformFactory(); CoordinateReferenceSystemFactory csFactory = new CoordinateReferenceSystemFactory(); /* * Create {@link CoordinateReferenceSystem} & CoordinateTransformation. * Normally this would be carried out once and reused for all transformations */ CoordinateReferenceSystem crs = csFactory.CreateFromName(csName); const String wgs84Param = "+title=long/lat:WGS84 +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"; CoordinateReferenceSystem wgs84 = csFactory.CreateFromParameters("WGS84", wgs84Param); ICoordinateTransform trans = ctFactory.CreateTransform(wgs84, crs); /* * Create input and output points. * These can be constructed once per thread and reused. */ ProjCoordinate p = new ProjCoordinate(); ProjCoordinate p2 = new ProjCoordinate(); p.X = lon; p.Y = lat; /* * Transform point */ trans.Transform(p, p2); return(IsInTolerance(p2, expectedX, expectedY, tolerance)); }
public static Vector2 CalculatePixelvalue(ProjCoordinate OrthoCoordinate) { Vector2 res = new Vector2(); res.x = (float)((((OrthoCoordinate.Longitude * PIXEL_FACTOR)) + NORTHPOLE_OFFSET)); res.y = (float)(OrthoCoordinate.Latitude * PIXEL_FACTOR); //Coordinate pco = PixelValueToCoordinate(res); return(res); }
public static Coordinate PixelValueToCoordinate(Vector2 pixvalue) { const float a = PIXEL_FACTOR; const float b = -PIXEL_FACTOR; double latOrtho = -(Math.Pow(b, -1) + Math.Pow(b, -1) * pixvalue.y); double longOrtho = -(NORTHPOLE_OFFSET)*Math.Pow(a, -1) + Math.Pow(a, -1) * pixvalue.x; var pro = new ProjCoordinate(latOrtho, longOrtho); Coordinate c = pro.FromOrthoProjectedCoordinate(); return(c); }
public void TestOrthographicProjection() { Coordinate coorOrigo = new Coordinate(89.99999999, 0.000000000001); ProjCoordinate pCoordOrigo = coorOrigo.ToOrthoProjectedCoordinate(); Coordinate coordSouthEast = new Coordinate(0, -90); Coordinate coordSouthMeredian = new Coordinate(0, 0); ProjCoordinate pCoordSouthEast = coordSouthEast.ToOrthoProjectedCoordinate(); ProjCoordinate pCoordSouthMeredian = coordSouthMeredian.ToOrthoProjectedCoordinate(); Coordinate coordBergen = new Coordinate(60, 5); Coordinate coordLondon = new Coordinate(51.508056, -0.124722); Coordinate coordReykjarvik = new Coordinate(64.133333, -21.933333); Coordinate coordBoston = new Coordinate(42.357778, -71.061667); Coordinate coordMoscow = new Coordinate(55.751667, 37.617778); Coordinate coordNorthCape = new Coordinate(71.1725, 25.794444); ProjCoordinate pCoordBergen = coordBergen.ToOrthoProjectedCoordinate(); ProjCoordinate pCoordLondon = coordLondon.ToOrthoProjectedCoordinate(); ProjCoordinate pCoordReykjarvik = coordReykjarvik.ToOrthoProjectedCoordinate(); ProjCoordinate pCoordBoston = coordBoston.ToOrthoProjectedCoordinate(); ProjCoordinate pCoordMoscow = coordMoscow.ToOrthoProjectedCoordinate(); ProjCoordinate pCoordNorthcape = coordNorthCape.ToOrthoProjectedCoordinate(); ProjCoordinate pCoordNorthOfBergen = new Coordinate(62, 5).ToOrthoProjectedCoordinate(); ProjCoordinate pCoordSouthOfBergen = new Coordinate(58, 5).ToOrthoProjectedCoordinate(); ProjCoordinate pCoordWestOfBergen = new Coordinate(60, 0).ToOrthoProjectedCoordinate(); ProjCoordinate pCoordEastOfBergen = new Coordinate(60, 10).ToOrthoProjectedCoordinate(); GameManager.Instance.Log.LogDebug("*** TestOrthographicProjection()"); GameManager.Instance.Log.LogDebug("NORTH TO SOUTH ALONG NULL-MERIDIAN, EVERY 10"); for (int i = 90; i > 0; i -= 10) { Coordinate coor = new Coordinate(i, 0); ProjCoordinate pcoor = coor.ToOrthoProjectedCoordinate(); GameManager.Instance.Log.LogDebug(string.Format("Coordinate {0} is projected as {1}", coor, pcoor)); } GameManager.Instance.Log.LogDebug("*** WEST TO EAST ALONG 60 DEG N, EVERY 10"); for (int i = -90; i < 90; i += 10) { Coordinate coor = new Coordinate(60, i); ProjCoordinate pcoor = coor.ToOrthoProjectedCoordinate(); GameManager.Instance.Log.LogDebug(string.Format("Coordinate {0} is projected as {1}", coor, pcoor)); } Coordinate coordNullNull = new ProjCoordinate(0, 0).FromOrthoProjectedCoordinate(); Coordinate coord2 = pCoordOrigo.FromOrthoProjectedCoordinate(); double DistanceM = MapHelper.CalculateDistanceM(coorOrigo, coord2); Assert.IsTrue(DistanceM < 1, "Coordinate 1 projected and back again should be the same"); }
public static Coordinate FromEquiCoordinate(this ProjCoordinate projectedCoordinate) { Coordinate result = new Coordinate(); result.LongitudeDeg = (float)(projectedCoordinate.Longitude / Math.Cos(0) / (Math.PI / 180.0)); // Calculate the geographic Y coordinate (latitude) result.LatitudeDeg = (float)(projectedCoordinate.Latitude / (Math.PI / 180.0)); //result.Latitude = projectedCoordinate.Latitude.ToRadian() * Math.Cos(0) * ONEOVERWGS84SEMIMAJOR; //result.Longitude = projectedCoordinate.Longitude.ToRadian() * ONEOVERWGS84SEMIMAJOR; return(result); }
public void TestProjCordinate() { Coordinate C1 = new Coordinate(61.0, 5.0); ProjCoordinate P1 = MapProjection.ToEquiProjectedCoordinate(C1); Coordinate C2 = MapProjection.FromEquiCoordinate(P1); double d = C1.LatitudeDeg - C2.LatitudeDeg; double d2 = C1.LongitudeDeg - C2.LongitudeDeg; Assert.IsFalse(d > 0.1 && d < -0.1, "Coordinate C1 != C2"); Assert.IsFalse(d2 > 0.1 && d2 < -0.1, "Coordinate C1 != C2"); //Assert.AreEqual(C1.Latitude, C2.Latitude, "Coordinate C1 != C2"); //Assert.AreEqual(C1.Longitude, C2.Longitude, "Coordinate C1 != C2"); }
public static ProjCoordinate ToOrthoProjectedCoordinate(this Coordinate geograpicCoordinate) { double latRad = geograpicCoordinate.LatitudeRad; double longRad = geograpicCoordinate.LongitudeRad; double latCenterRad = ORTHO_LATITUDE_CENTER_RAD; double longCenterRad = ORTHO_LONGITUDE_CENTER_RAD; double x = MapHelper.RADIUS_OF_EARTH_KM * Math.Cos(latRad) * Math.Sin(longRad - longCenterRad); double y = MapHelper.RADIUS_OF_EARTH_KM * ( (Math.Cos(latCenterRad) * Math.Sin(latRad)) - (Math.Sin(latCenterRad) * Math.Cos(latRad) * Math.Cos(longRad - longCenterRad))); ProjCoordinate result = new ProjCoordinate(y * -1, x); //note: Does not clip results that are "behind" the globe return(result); }
public Boolean CheckTransform( CoordinateReferenceSystem srcCRS, double x1, double y1, CoordinateReferenceSystem tgtCRS, double x2, double y2, double tolerance) { p.X = x1; p.Y = y1; var trans = ctFactory.CreateTransform(srcCRS, tgtCRS); trans.Transform(p, p2); var dx = Math.Abs(p2.X - x2); var dy = Math.Abs(p2.Y - y2); var delta = Math.Max(dx, dy); if (_verbose) { Console.Write("{0} => {1}", srcCRS.Name, tgtCRS.Name); } var isInTol = delta <= tolerance; if (_verbose) { if (!isInTol) { Console.WriteLine(" ... FAILED"); var source = p.ToShortString(); Console.WriteLine("\t{0} -> {1}", source, p2.ToShortString()); var result = new ProjCoordinate(x2, y2); var offset = new ProjCoordinate(p2.X - x2, p2.Y - y2); Console.WriteLine("\t{0} {1}, (tolerance={2}, max delta={3})", new string(' ', source.Length), result.ToShortString(), tolerance, delta); Console.WriteLine("\tSource CRS: " + srcCRS.GetParameterString()); Console.WriteLine("\tTarget CRS: " + tgtCRS.GetParameterString()); } else { Console.WriteLine(" ... PASSED"); } } return(isInTol); }
public static ProjCoordinate ToEquiProjectedCoordinate(this Coordinate geographicCoordinate) { // First, convert the geographic coordinate to radians double radianX = geographicCoordinate.LongitudeDeg * (Math.PI / 180); double radianY = geographicCoordinate.LatitudeDeg * (Math.PI / 180); // Make a new Point object ProjCoordinate result = new ProjCoordinate(); // Calculate the projected X coordinate result.Longitude = (float)(radianX * Math.Cos(0)); // Calculate the projected Y coordinate result.Latitude = (float)radianY; // Return the result return(result); //result.Latitude = geographicCoordinate.Latitude.ToRadian() * Math.Cos(0) * WGS84SEMIMAJOR;//Hmm... //result.Longitude = geographicCoordinate.Longitude.ToRadian()* WGS84SEMIMAJOR; // //return result; }
public static Coordinate FromOrthoProjectedCoordinate(this ProjCoordinate projectedCoordinate) { double latCenterRad = ORTHO_LATITUDE_CENTER_RAD; double longCenterRad = ORTHO_LONGITUDE_CENTER_RAD; double y = -projectedCoordinate.Latitude; double x = projectedCoordinate.Longitude; double rho = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)); double c = Math.Asin(rho / MapHelper.RADIUS_OF_EARTH_KM); double cCos = Math.Cos(c); double cSin = Math.Sin(c); double latCenterRadCos = Math.Cos(latCenterRad); double latCenterRadSin = Math.Sin(latCenterRad); double latRad = Math.Asin((cCos * latCenterRadSin) + ((y * cSin * latCenterRadCos) / rho)); double longRad = longCenterRad + Math.Atan((x * cSin) / ((rho * latCenterRadCos * cCos) - y * latCenterRadSin * cSin)); Coordinate result = new Coordinate(latRad.ToDegreeSignedLatitude(), longRad.ToDegreeSignedLongitude()); return(result); }
public Boolean RunGrid(double tolerance) { Boolean isWithinTolerance = true; _gridExtent = GridExtent(_cs.Projection); double minx = _gridExtent[0]; double miny = _gridExtent[1]; double maxx = _gridExtent[2]; double maxy = _gridExtent[3]; ProjCoordinate p = new ProjCoordinate(); double dx = (maxx - minx) / GridSize; double dy = (maxy - miny) / GridSize; Int32 tests = 0, testsPassed = 0; for (int ix = 0; ix <= GridSize; ix++) { for (int iy = 0; iy <= GridSize; iy++) { p.X = ix == GridSize ? maxx : minx + ix * dx; p.Y = iy == GridSize ? maxy : miny + iy * dy; tests++; Boolean isWithinTol = RoundTrip(p, tolerance); if (isWithinTol) { testsPassed++; } } } return(tests == testsPassed); }
public void testRepeatedTransform() { var crsFactory = new CoordinateReferenceSystemFactory(); var src = crsFactory.CreateFromName("epsg:4326"); var dest = crsFactory.CreateFromName("epsg:27700"); var ctf = new CoordinateTransformFactory(); var transform = ctf.CreateTransform(src, dest); var srcPt = new ProjCoordinate(0.899167, 51.357216); var destPt = new ProjCoordinate(); transform.Transform(srcPt, destPt); Console.WriteLine(srcPt + " ==> " + destPt); // do it again var destPt2 = new ProjCoordinate(); transform.Transform(srcPt, destPt2); Console.WriteLine(srcPt + " ==> " + destPt2); Assert.IsTrue(destPt.Equals(destPt2)); }
public ProjCoordinate projectInverse(double x, double y, ProjCoordinate lp) { if (Spherical) { double cosz = 0, rh, sinz = 0; rh = ProjectionMath.Distance(x, y); if ((lp.Y = rh * .5) > 1.0) { throw new ProjectionException(); } lp.Y = 2.0 * Math.Asin(lp.Y); if (Mode == AzimuthalMode.Oblique || Mode == AzimuthalMode.Equator) { sinz = Math.Sin(lp.Y); cosz = Math.Cos(lp.Y); } switch (Mode) { case AzimuthalMode.Equator: lp.Y = Math.Abs(rh) <= EPS10 ? 0.0 : Math.Asin(y * sinz / rh); x *= sinz; y = cosz * rh; break; case AzimuthalMode.Oblique: lp.Y = Math.Abs(rh) <= EPS10 ? ProjectionLatitude : Math.Asin(cosz * _sinphi0 + y * sinz * _cosphi0 / rh); x *= sinz * _cosphi0; y = (cosz - Math.Sin(lp.Y) * _sinphi0) * rh; break; case AzimuthalMode.NorthPole: y = -y; lp.Y = ProjectionMath.PiHalf - lp.Y; break; case AzimuthalMode.SouthPole: lp.Y -= ProjectionMath.PiHalf; break; } lp.X = (y == 0.0 && (Mode == AzimuthalMode.Equator || Mode == AzimuthalMode.Oblique)) ? 0.0 : Math.Atan2(x, y); } else { double cCe, sCe, q, rho, ab = 0; switch (Mode) { case AzimuthalMode.Equator: case AzimuthalMode.Oblique: if ((rho = ProjectionMath.Distance(x /= _dd, y *= _dd)) < EPS10) { lp.X = 0.0; lp.Y = ProjectionLatitude; return(lp); } cCe = Math.Cos(sCe = 2.0 * Math.Asin(.5 * rho / _rq)); x *= (sCe = Math.Sin(sCe)); if (Mode == AzimuthalMode.Oblique) { q = _qp * (ab = cCe * _sinb1 + y * sCe * _cosb1 / rho); y = rho * _cosb1 * cCe - y * _sinb1 * sCe; } else { q = _qp * (ab = y * sCe / rho); y = rho * cCe; } break; case AzimuthalMode.NorthPole: case AzimuthalMode.SouthPole: if (Mode == AzimuthalMode.NorthPole) { y = -y; } if ((q = (x * x + y * y)) == 0) { lp.X = 0.0; lp.Y = ProjectionLatitude; return(lp); } ab = 1.0 - q / _qp; if (Mode == AzimuthalMode.SouthPole) { ab = -ab; } break; } lp.X = Math.Atan2(x, y); lp.Y = ProjectionMath.AuthLat(Math.Asin(ab), _apa); } return(lp); }
public ProjCoordinate project(double lam, double phi, ProjCoordinate xy) { if (Spherical) { double coslam, cosphi, sinphi; sinphi = Math.Sin(phi); cosphi = Math.Cos(phi); coslam = Math.Cos(lam); switch (Mode) { case AzimuthalMode.Equator: xy.Y = 1.0 + cosphi * coslam; if (xy.Y <= EPS10) { throw new ProjectionException(); } xy.X = (xy.Y = Math.Sqrt(2.0 / xy.Y)) * cosphi * Math.Sin(lam); xy.Y *= Mode == AzimuthalMode.Equator ? sinphi : _cosphi0 * sinphi - _sinphi0 * cosphi * coslam; break; case AzimuthalMode.Oblique: xy.Y = 1.0 + _sinphi0 * sinphi + _cosphi0 * cosphi * coslam; if (xy.Y <= EPS10) { throw new ProjectionException(); } xy.X = (xy.Y = Math.Sqrt(2.0 / xy.Y)) * cosphi * Math.Sin(lam); xy.Y *= Mode == AzimuthalMode.Equator ? sinphi : _cosphi0 * sinphi - _sinphi0 * cosphi * coslam; break; case AzimuthalMode.NorthPole: case AzimuthalMode.SouthPole: if (Mode == AzimuthalMode.NorthPole) { coslam = -coslam; } if (Math.Abs(phi + ProjectionLatitude) < EPS10) { throw new ProjectionException(); } xy.Y = ProjectionMath.PiFourth - phi * .5; xy.Y = 2.0 * (Mode == AzimuthalMode.SouthPole ? Math.Cos(xy.Y) : Math.Sin(xy.Y)); xy.X = xy.Y * Math.Sin(lam); xy.Y *= coslam; break; } } else { double coslam, sinlam, sinphi, q, sinb = 0, cosb = 0, b = 0; coslam = Math.Cos(lam); sinlam = Math.Sin(lam); sinphi = Math.Sin(phi); q = ProjectionMath.Qsfn(sinphi, Eccentricity, _oneEs); if (Mode == AzimuthalMode.Oblique || Mode == AzimuthalMode.Equator) { sinb = q / _qp; cosb = Math.Sqrt(1.0 - sinb * sinb); } switch (Mode) { case AzimuthalMode.Oblique: b = 1.0 + _sinb1 * sinb + _cosb1 * cosb * coslam; break; case AzimuthalMode.Equator: b = 1.0 + cosb * coslam; break; case AzimuthalMode.NorthPole: b = ProjectionMath.PiHalf + phi; q = _qp - q; break; case AzimuthalMode.SouthPole: b = phi - ProjectionMath.PiHalf; q = _qp + q; break; } if (Math.Abs(b) < EPS10) { throw new ProjectionException(); } switch (Mode) { case AzimuthalMode.Oblique: xy.Y = _ymf * (b = Math.Sqrt(2.0 / b)) * (_cosb1 * sinb - _sinb1 * cosb * coslam); xy.X = _xmf * b * cosb * sinlam; break; case AzimuthalMode.Equator: xy.Y = (b = Math.Sqrt(2.0 / (1.0 + cosb * coslam))) * sinb * _ymf; xy.X = _xmf * b * cosb * sinlam; break; case AzimuthalMode.NorthPole: case AzimuthalMode.SouthPole: if (q >= 0.0) { xy.X = (b = Math.Sqrt(q)) * sinlam; xy.Y = coslam * (Mode == AzimuthalMode.SouthPole ? b : -b); } else { xy.X = xy.Y = 0.0; } break; } } return(xy); }
public MapVisulizer() { InitializeComponent(); _player = new Player(); CenterMarker.SetValue(Canvas.TopProperty, (backgr.Height - CenterMarker.Height) / 2); CenterMarker.SetValue(Canvas.LeftProperty, (backgr.Width - CenterMarker.Width) / 2); _game = GameManager.Instance.CreateGame(_player, "TestGame"); _game.IsNetworkEnabled = false; _game.StartGameLoop(); Group group = new Group(); GameManager.Instance.GameData.InitAllData(); Position pos = new Position(60.25, 5.25); BaseUnit unitMain = GameManager.Instance.GameData.CreateUnit(_player, group, "arleighburke", "Arleigh Burke", pos, true); unitMain.MovementOrder.AddWaypoint(new Waypoint(new Position(60.5, 5.5))); unitMain.ActualSpeedKph = 40.0; unitMain.MoveToNewCoordinate(1.0); unitMain.Position.BearingDeg = .0; //pos = new Position(61.5, 5.5); BaseUnit unitFollow = GameManager.Instance.GameData.CreateUnit(_player, group, "arleighburke", "Hood", pos, true); BaseUnit unitFollow2 = GameManager.Instance.GameData.CreateUnit(_player, group, "arleighburke", "Hood", pos, true); MovementFormationOrder order = new MovementFormationOrder(unitMain, 326000, -326000, 0); MovementFormationOrder order2 = new MovementFormationOrder(unitMain, -326000, 326000, 0); Waypoint waypoint = order.GetActiveWaypoint(); Waypoint waypoint2 = order2.GetActiveWaypoint(); unitFollow.Position = waypoint.Position.Clone(); unitFollow2.Position = waypoint2.Position.Clone(); double distanceM = MapHelper.CalculateDistanceM(unitMain.Position.Coordinate, unitFollow.Position.Coordinate); ProjCoordinate min = MapProjection.ToEquiProjectedCoordinate(new Coordinate(61.0, 6.0)); ProjCoordinate max = MapProjection.ToEquiProjectedCoordinate(new Coordinate(62.0, 5)); Coordinate CenterCoordinate = MapHelper.CalculateMidpoint(new Coordinate(62.0, 5.0), new Coordinate(62.0, 6.0)); RotateTransform rt = new RotateTransform(); rt.Angle = (double)unitMain.Position.BearingDeg; rt.CenterX = mainShip.Width / 2; rt.CenterY = mainShip.Height / 2; double testX = MapHelper.LongitudeToXvalue(unitMain.Position.Coordinate.LongitudeDeg, 1); double testY = MapHelper.LatitudeToYvalue(unitMain.Position.Coordinate.LatitudeDeg, 1); testX = ((512 - 10) / 2) + testX; testY = ((512 - 10) / 2) + testY; mainShip.SetValue(Canvas.LeftProperty, testX); mainShip.SetValue(Canvas.TopProperty, testY); mainShip.RenderTransform = rt; rt.Angle = (double)waypoint.Position.BearingDeg; folowingShip.SetValue(Canvas.LeftProperty, ((512 - 10) / 2) + MapHelper.LongitudeToXvalue(waypoint.Position.Coordinate, 1)); folowingShip.SetValue(Canvas.TopProperty, ((512 - 10) / 2) + MapHelper.LatitudeToYvalue(waypoint.Position.Coordinate, 1)); folowingShip.RenderTransform = rt; rt.Angle = (double)waypoint2.Position.BearingDeg; folowingShip2.SetValue(Canvas.LeftProperty, ((512 - 10) / 2) + MapHelper.LongitudeToXvalue(waypoint2.Position.Coordinate, 1)); folowingShip2.SetValue(Canvas.TopProperty, ((512 - 10) / 2) + MapHelper.LatitudeToYvalue(waypoint2.Position.Coordinate, 1)); folowingShip2.RenderTransform = rt; }
private object Transform2D_(object geometry, bool inverse) { if (_projectionPipeline == null) { return(geometry); } CoordinateReferenceSystem from = _fromSrs, to = _toSrs; bool fromProjective = _fromProjective, toProjektive = _toProjective; if (geometry == null) { return(null); } if (from == null || to == null) { return(geometry); } if (geometry is PointCollection) { IPointCollection pColl = (IPointCollection)geometry; int pointCount = pColl.PointCount; if (pointCount == 0) { return(geometry); } IPointCollection target = null; var basicTransformations = BasicTransformations(inverse); for (int b = 0, b_to = basicTransformations.Length; b < b_to; b++) { BasicCoordinateTransform t = basicTransformations[b]; if (pColl is IRing) { target = new Ring(); } else if (pColl is IPath) { target = new Path(); } else if (pColl is IMultiPoint) { target = new MultiPoint(); } else { target = new PointCollection(); } for (int i = 0; i < pointCount; i++) { ProjCoordinate cFrom = new ProjCoordinate(pColl[i].X, pColl[i].Y); var cTo = new ProjCoordinate(); t.Transform(cFrom, cTo); target.AddPoint(new Point(cTo.X, cTo.Y)); } pColl = target; } return(target); } if (geometry is IPoint) { IPoint target = null; var basicTransformations = BasicTransformations(inverse); for (int b = 0, b_to = basicTransformations.Length; b < b_to; b++) { BasicCoordinateTransform t = basicTransformations[b]; ProjCoordinate cFrom = new ProjCoordinate(((IPoint)geometry).X, ((IPoint)geometry).Y), cTo = new ProjCoordinate(); t.Transform(cFrom, cTo); target = new Point(cTo.X, cTo.Y); geometry = target; } return(target); } if (geometry is IEnvelope) { return(Transform2D_(((IEnvelope)geometry).ToPolygon(10), inverse)); } if (geometry is IPolyline) { int count = ((IPolyline)geometry).PathCount; IPolyline polyline = new Polyline(); for (int i = 0; i < count; i++) { polyline.AddPath((IPath)Transform2D_(((IPolyline)geometry)[i], inverse)); } return(polyline); } if (geometry is IPolygon) { int count = ((IPolygon)geometry).RingCount; IPolygon polygon = new Polygon(); for (int i = 0; i < count; i++) { polygon.AddRing((IRing)Transform2D_(((IPolygon)geometry)[i], inverse)); } return(polygon); } if (geometry is IAggregateGeometry) { int count = ((IAggregateGeometry)geometry).GeometryCount; IAggregateGeometry aGeom = new AggregateGeometry(); for (int i = 0; i < count; i++) { aGeom.AddGeometry((IGeometry)Transform2D_(((IAggregateGeometry)geometry)[i], inverse)); } return(aGeom); } return(null); }