本文整理匯總了C#中ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory類的典型用法代碼示例。如果您正苦於以下問題:C# CoordinateTransformationFactory類的具體用法?C# CoordinateTransformationFactory怎麽用?C# CoordinateTransformationFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CoordinateTransformationFactory類屬於ProjNet.CoordinateSystems.Transformations命名空間,在下文中一共展示了CoordinateTransformationFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ActualCoordinateSystem
internal ActualCoordinateSystem(ICoordinateSystem coordinateSystem)
{
if (coordinateSystem == null)
throw new ArgumentNullException("coordinateSystem"); //NOXLATE
CoordinateTransformationFactory f = new CoordinateTransformationFactory();
CoordinateSystemFactory cf = new CoordinateSystemFactory();
m_transform = f.CreateFromCoordinateSystems(coordinateSystem, cf.CreateFromWkt(XY_M));
}
示例2: TestNAD27toWGS84
public void TestNAD27toWGS84()
{
CoordinateSystemFactory csFact = new CoordinateSystemFactory();
CoordinateTransformationFactory ctFact = new CoordinateTransformationFactory();
ICoordinateSystem ESPG32054 = csFact.CreateFromWkt(
"PROJCS[\"NAD27 / Wisconsin South\",GEOGCS[\"NAD27\",DATUM[\"North_American_Datum_1927\",SPHEROID[\"Clarke 1866\",6378206.4,294.9786982138982,AUTHORITY[\"EPSG\",\"7008\"]],AUTHORITY[\"EPSG\",\"6267\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4267\"]],PROJECTION[\"Lambert_Conformal_Conic_2SP\"],PARAMETER[\"standard_parallel_1\",42.73333333333333],PARAMETER[\"standard_parallel_2\",44.06666666666667],PARAMETER[\"latitude_of_origin\",42],PARAMETER[\"central_meridian\",-90],PARAMETER[\"false_easting\",2000000],PARAMETER[\"false_northing\",0],UNIT[\"US survey foot\",0.3048006096012192,AUTHORITY[\"EPSG\",\"9003\"]],AUTHORITY[\"EPSG\",\"32054\"]]");
GeographicCoordinateSystem WGS84 = (ProjNet.CoordinateSystems.GeographicCoordinateSystem)GeographicCoordinateSystem.WGS84;
ICoordinateTransformation trans = ctFact.CreateFromCoordinateSystems(ESPG32054, WGS84);
List<double[]> points = new List<double[]>
{
new[] { 2555658.00, 388644.00},
new[] { 2557740.000, 387024.000}
};
for (int i = 0; i < points.Count; i++)
{
double[] rst = trans.MathTransform.Transform(points[i]);
Console.WriteLine(rst[0].ToString()+" \t"+ rst[1].ToString());
}
}
示例3: LatLonToGoogle
public static ICoordinateTransformation LatLonToGoogle()
{
CoordinateSystemFactory csFac = new CoordinateSystemFactory();
CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory();
IGeographicCoordinateSystem sourceCs = csFac.CreateGeographicCoordinateSystem(
"WGS 84",
AngularUnit.Degrees,
HorizontalDatum.WGS84,
PrimeMeridian.Greenwich,
new AxisInfo("north", AxisOrientationEnum.North),
new AxisInfo("east", AxisOrientationEnum.East));
List<ProjectionParameter> parameters = 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("scale_factor", 1.0),
new ProjectionParameter("false_easting", 0.0),
new ProjectionParameter("false_northing", 0.0)
};
IProjection projection = csFac.CreateProjection("Google Mercator", "mercator_1sp", parameters);
IProjectedCoordinateSystem targetCs = csFac.CreateProjectedCoordinateSystem(
"Google Mercator",
sourceCs,
projection,
LinearUnit.Metre,
new AxisInfo("East", AxisOrientationEnum.East),
new AxisInfo("North", AxisOrientationEnum.North));
return ctFac.CreateFromCoordinateSystems(sourceCs, targetCs);
}
示例4: getOffsetFromLeader
public HIL.Vector3 getOffsetFromLeader(MAVLinkInterface leader, MAVLinkInterface mav)
{
//convert Wgs84ConversionInfo to utm
CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
GeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;
int utmzone = (int)((leader.MAV.cs.lng - -186.0) / 6.0);
IProjectedCoordinateSystem utm = ProjectedCoordinateSystem.WGS84_UTM(utmzone, leader.MAV.cs.lat < 0 ? false : true);
ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84, utm);
double[] masterpll = { leader.MAV.cs.lng, leader.MAV.cs.lat };
// get leader utm coords
double[] masterutm = trans.MathTransform.Transform(masterpll);
double[] mavpll = { mav.MAV.cs.lng, mav.MAV.cs.lat };
//getLeader follower utm coords
double[] mavutm = trans.MathTransform.Transform(mavpll);
return new HIL.Vector3(masterutm[1] - mavutm[1], masterutm[0] - mavutm[0], 0);
}
示例5: TestConversion
public void TestConversion()
{
var point = GeometryFactory.Default.CreatePoint(new Coordinate(492155.73, 6303867.82));
var transform = new CoordinateTransformationFactory().CreateFromCoordinateSystems(
ProjectedCoordinateSystem.WGS84_UTM(32, true), GeographicCoordinateSystem.WGS84);
var transformedPoint = GeometryTransform.TransformGeometry(GeometryFactory.Default, point, transform.MathTransform);
}
示例6: TestTransformListOfDoubleArray
public void TestTransformListOfDoubleArray()
{
CoordinateSystemFactory csFact = new CoordinateSystemFactory();
CoordinateTransformationFactory ctFact = new CoordinateTransformationFactory();
ICoordinateSystem utm35ETRS = csFact.CreateFromWkt(
"PROJCS[\"ETRS89 / ETRS-TM35\",GEOGCS[\"ETRS89\",DATUM[\"D_ETRS_1989\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",27],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]");
IProjectedCoordinateSystem utm33 = ProjectedCoordinateSystem.WGS84_UTM(33, true);
ICoordinateTransformation trans = ctFact.CreateFromCoordinateSystems(utm35ETRS, utm33);
List<double[]> points = new List<double[]>
{
new[] {290586.087, 6714000 }, new[] {90586.392, 6713996.224},
new[] {290590.133, 6713973.772}, new[] {290594.111, 6713957.416},
new[] {290596.615, 6713943.567}, new[] {290596.701, 6713939.485}
};
double[][] tpoints = trans.MathTransform.TransformList(points).ToArray();
for (int i = 0; i < points.Count; i++)
{
Console.WriteLine(tpoints[i]);
NUnit.Framework.Assert.IsTrue(Equal(tpoints[i], trans.MathTransform.Transform(points[i])));
}
}
示例7: TestAlbersProjectionFeet
public void TestAlbersProjectionFeet()
{
CoordinateSystemFactory cFac = new CoordinateSystemFactory();
IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot);
IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null);
IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum,
PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
new AxisInfo("Lat", AxisOrientationEnum.North));
List<ProjectionParameter> parameters = new List<ProjectionParameter>(5);
parameters.Add(new ProjectionParameter("central_meridian", -96));
parameters.Add(new ProjectionParameter("latitude_of_center", 23));
parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5));
parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5));
parameters.Add(new ProjectionParameter("false_easting", 0));
parameters.Add(new ProjectionParameter("false_northing", 0));
IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters);
IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Foot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));
ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);
double[] pGeo = new double[] { -75, 35 };
double[] pUtm = trans.MathTransform.Transform(pGeo);
double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);
double[] expected = new double[] { 1885472.7 / LinearUnit.Foot.MetersPerUnit, 1535925 / LinearUnit.Foot.MetersPerUnit };
Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.1), String.Format("Albers forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1]));
Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Albers reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1]));
}
示例8: ProjHelper
static ProjHelper()
{
CoordinateTransformationFactory factory = new CoordinateTransformationFactory();
IGeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;
IProjectedCoordinateSystem mercator = ProjectedCoordinateSystem.WebMercator;
Transformation = factory.CreateFromCoordinateSystems(wgs84, mercator);
}
示例9: EmbeddedMap_MouseMove
private void EmbeddedMap_MouseMove(object sender, MouseEventArgs e)
{
if (image.IsMouseCaptured)
{
Debug.WriteLine("Capture Move");
var tt = (TranslateTransform) ((TransformGroup) image.RenderTransform)
.Children.First(tr => tr is TranslateTransform);
Vector v = start - e.GetPosition(border);
tt.X = origin.X - v.X;
tt.Y = origin.Y - v.Y;
}
else
{
Debug.WriteLine("Normal Move");
Point p = e.GetPosition(image);
double scale = 360/image.ActualWidth;
Point pGeo = new Point(p.X*scale - 180, 90 - p.Y*scale);
locationLong.Text = string.Format("{0}", pGeo.X);
locationLat.Text = string.Format("{0}", pGeo.Y);
//Transform to UTM
CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
int zone = (int) Math.Ceiling((pGeo.X + 180)/6);
//ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(zone, pGeo.Y > 0);
//ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84geo, utm);
//Point pUtm = trans.MathTransform.Transform(pGeo);
//locationX.Text = string.Format("N{0}", pUtm.Y);
//locationY.Text = string.Format("E{0}", pUtm.X);
locationZone.Text = string.Format("Zone {0}{1}", zone, pGeo.Y > 0 ? 'N' : 'S');
}
}
示例10: TestTransform
public void TestTransform()
{
CoordinateSystemFactory csFactory = new CoordinateSystemFactory();
const string sourceCsWkt = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]";
ICoordinateSystem sourceCs = csFactory.CreateFromWkt(sourceCsWkt);
Assert.That(sourceCs, Is.Not.Null);
const string targetCsWkt = "PROJCS[\"WGS 84 / Australian Antarctic Lambert\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Lambert_Conformal_Conic_2SP\"],PARAMETER[\"standard_parallel_1\",-68.5],PARAMETER[\"standard_parallel_2\",-74.5],PARAMETER[\"latitude_of_origin\",-50],PARAMETER[\"central_meridian\",70],PARAMETER[\"false_easting\",6000000],PARAMETER[\"false_northing\",6000000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"3033\"]]";
ICoordinateSystem targetCs = csFactory.CreateFromWkt(targetCsWkt);
Assert.That(targetCs, Is.Not.Null);
CoordinateTransformationFactory ctFactory = new CoordinateTransformationFactory();
ICoordinateTransformation coordTransformation = ctFactory.CreateFromCoordinateSystems(sourceCs, targetCs);
IGeometryFactory gf = GeometryFactory.Default;
const string geomWkt = "MULTIPOINT (152.83949210500001 -42.14413555,152.83910355899999 -42.129844618)";
WKTReader reader = new WKTReader(gf);
IGeometry geom = reader.Read(geomWkt);
Assert.That(geom, Is.Not.Null);
Assert.That(geom.IsValid, Is.True);
Assert.That(geom, Is.InstanceOf<IMultiPoint>());
IMultiPoint mp = (IMultiPoint)geom;
foreach (IPoint pt in mp.Geometries)
{
IGeometry tp = GeometryTransform.TransformGeometry(gf, pt, coordTransformation.MathTransform);
Assert.That(tp, Is.Not.Null);
Assert.That(tp.IsValid, Is.True);
}
IGeometry transformed = GeometryTransform.TransformGeometry(gf, mp, coordTransformation.MathTransform);
Assert.That(transformed, Is.Not.Null);
Assert.That(transformed.IsValid, Is.True);
}
示例11: SendCommand
public override void SendCommand()
{
if (masterpos.Lat == 0 || masterpos.Lng == 0)
return;
Console.WriteLine(DateTime.Now);
Console.WriteLine("Leader {0} {1} {2}",masterpos.Lat,masterpos.Lng,masterpos.Alt);
int a = 0;
foreach (var port in MainV2.Comports)
{
if (port == Leader)
continue;
PointLatLngAlt target = new PointLatLngAlt(masterpos);
try
{
//convert Wgs84ConversionInfo to utm
CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
GeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;
int utmzone = (int)((masterpos.Lng - -186.0) / 6.0);
IProjectedCoordinateSystem utm = ProjectedCoordinateSystem.WGS84_UTM(utmzone, masterpos.Lat < 0 ? false : true);
ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84, utm);
double[] pll1 = { target.Lng, target.Lat };
double[] p1 = trans.MathTransform.Transform(pll1);
// add offsets to utm
p1[0] += ((HIL.Vector3)offsets[port]).x;
p1[1] += ((HIL.Vector3)offsets[port]).y;
// convert back to wgs84
IMathTransform inversedTransform = trans.MathTransform.Inverse();
double[] point = inversedTransform.Transform(p1);
target.Lat = point[1];
target.Lng = point[0];
target.Alt += ((HIL.Vector3)offsets[port]).z;
port.setGuidedModeWP(new Locationwp() { alt = (float)target.Alt, lat = target.Lat, lng = target.Lng, id = (byte)MAVLink.MAV_CMD.WAYPOINT });
Console.WriteLine("{0} {1} {2} {3}", port.ToString(), target.Lat, target.Lng, target.Alt);
}
catch (Exception ex) { Console.WriteLine("Failed to send command " + port.ToString() + "\n" + ex.ToString()); }
a++;
}
}
示例12: Projections
public Projections()
{
CoordinateSystemFactory c = new CoordinateSystemFactory();
ICoordinateSystem osgb = c.CreateFromWkt("PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB 1936\",DATUM[\"OSGB_1936\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646,AUTHORITY[\"EPSG\",\"7001\"]],AUTHORITY[\"EPSG\",\"6277\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4277\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",49],PARAMETER[\"central_meridian\",-2],PARAMETER[\"scale_factor\",0.9996012717],PARAMETER[\"false_easting\",400000],PARAMETER[\"false_northing\",-100000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"27700\"]]");
ICoordinateSystem wgs = c.CreateFromWkt("GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]");
CoordinateTransformationFactory trf = new CoordinateTransformationFactory();
this.OsgbToWgs = trf.CreateFromCoordinateSystems(osgb, wgs);
this.WgsToOsgb = trf.CreateFromCoordinateSystems(wgs, osgb);
}
示例13: WebMercatorCanBeTranformed
public void WebMercatorCanBeTranformed(int srid)
{
var wkt = SharpMap.Converters.WellKnownText.SpatialReference.SridToWkt(srid);
var csf = new CoordinateSystemFactory();
var cs = csf.CreateFromWkt(wkt);
var ctf = new CoordinateTransformationFactory();
Assert.DoesNotThrow(() => ctf.CreateFromCoordinateSystems(cs, GeographicCoordinateSystem.WGS84),
"Could not reproject SRID:" + srid);
}
示例14: TestMethod1
public void TestMethod1()
{
var UTMSystem = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(32, true);
ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, UTMSystem);
double[] p1 = trans.MathTransform.Transform(new double[] { 12.45693, 55.65322 });
double utmy = p1[1];
double utmx = p1[0];
var t = DateTime.Now.Subtract(new DateTime(2012, 7, 1));
}
示例15: getGeographicSRS
public override SpatialReference getGeographicSRS()
{
if (isGeographic())
{
return this;
}
else
{
ICoordinateTransformationFactory ctf = new CoordinateTransformationFactory ();
// mt = ctf.
}
throw new NotImplementedException();
}