本文整理匯總了C#中ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory.CreateFromCoordinateSystems方法的典型用法代碼示例。如果您正苦於以下問題:C# CoordinateTransformationFactory.CreateFromCoordinateSystems方法的具體用法?C# CoordinateTransformationFactory.CreateFromCoordinateSystems怎麽用?C# CoordinateTransformationFactory.CreateFromCoordinateSystems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory
的用法示例。
在下文中一共展示了CoordinateTransformationFactory.CreateFromCoordinateSystems方法的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: 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);
}
示例4: ProjHelper
static ProjHelper()
{
CoordinateTransformationFactory factory = new CoordinateTransformationFactory();
IGeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;
IProjectedCoordinateSystem mercator = ProjectedCoordinateSystem.WebMercator;
Transformation = factory.CreateFromCoordinateSystems(wgs84, mercator);
}
示例5: 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])));
}
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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++;
}
}
示例10: 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);
}
示例11: getmapTransform
//獲取shp投影方式
public ICoordinateTransformation getmapTransform(config.ProjPara proj)
{
CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory();
CoordinateSystemFactory cFac = new CoordinateSystemFactory();
ICoordinateTransformation transform = null;
//等經緯,shp數據原始投影
var epsg4326 = cFac.CreateFromWkt("GEOGCS[\"GCS_WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_84\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]");
//目標坐標係
var epsg3857 = cFac.CreateFromWkt(getSrcCoordinate(proj));
transform = ctFac.CreateFromCoordinateSystems(epsg4326, epsg3857);
return transform;
}
示例12: ConvertDegreesToUTM
public static Coordinate ConvertDegreesToUTM(ICoordinate coordinate)
{
var ctfac = new CoordinateTransformationFactory();
ProjNet.CoordinateSystems.ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
int zone = (int)System.Math.Ceiling((coordinate.X + 180) / 6);
ProjNet.CoordinateSystems.ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(zone, coordinate.Y > 0);
var trans = ctfac.CreateFromCoordinateSystems(wgs84geo, utm);
double[] pUtm = trans.MathTransform.Transform(new[] { coordinate.X, coordinate.Y });
return new Coordinate
{
X = pUtm[0],
Y = pUtm[1],
};
}
示例13: SpatialReference
public SpatialReference(KinectReader kinectReader, PositionReader positionReader)
{
this.kinectReader = kinectReader;
this.positionReader = positionReader;
string wkt = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]";
this.wgs84 = (ICoordinateSystem)ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wkt);
//hardcoded UTM 55S - should parameterize
string toWKT = "PROJCS[\"WGS 72BE / UTM zone 55S\",GEOGCS[\"WGS 72BE\",DATUM[\"WGS_1972_Transit_Broadcast_Ephemeris\",SPHEROID[\"WGS 72\",6378135,298.26,AUTHORITY[\"EPSG\",\"7043\"]],TOWGS84[0,0,1.9,0,0,0.814,-0.38],AUTHORITY[\"EPSG\",\"6324\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4324\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",147],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",10000000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"32555\"]]";
this.toCs = (ICoordinateSystem)ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(toWKT);
CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
this.toGridtrans = ctfac.CreateFromCoordinateSystems(wgs84, toCs);
}
示例14: TestTransformListOfCoordinates
public void TestTransformListOfCoordinates()
{
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);
Coordinate[] points = new Coordinate[]
{
new Coordinate(290586.087, 6714000), new Coordinate(290586.392, 6713996.224),
new Coordinate(290590.133, 6713973.772), new Coordinate(290594.111, 6713957.416),
new Coordinate(290596.615, 6713943.567), new Coordinate(290596.701, 6713939.485)
};
Coordinate[] tpoints = trans.MathTransform.TransformList(points).ToArray();
for (int i = 0; i < points.Length; i++)
Assert.That(tpoints[i].Equals(trans.MathTransform.Transform(points[i])));
}
示例15: Main
static void Main(string[] args)
{
var wktWGS84 = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]";
var wgs84 = CoordinateSystemWktReader.Parse(wktWGS84) as ICoordinateSystem;
var wktMercator = "PROJCS[\"World_Mercator\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Mercator_1SP\"],PARAMETER[\"False_Easting\",0],PARAMETER[\"False_Northing\",0],PARAMETER[\"Central_Meridian\",0],PARAMETER[\"latitude_of_origin\",0],UNIT[\"Meter\",1]]";
var mercator = CoordinateSystemWktReader.Parse(wktMercator) as ICoordinateSystem;
var transFactory = new CoordinateTransformationFactory();
var trans = transFactory.CreateFromCoordinateSystems(wgs84, mercator);
var fromPoints = new List<double[]>();
using (var sr = new StreamReader("32332.dat"))
{
while (!sr.EndOfStream)
{
var val = sr.ReadLine().Split("".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
if (val[0].Contains("nan") || val[1].Contains("nan"))
{
continue;
}
var x = double.Parse(val[0]);
var y = double.Parse(val[1]);
fromPoints.Add(new double[] { x, y });
}
}
var toPoints = trans.MathTransform.TransformList(fromPoints);
using (var sw = new StreamWriter("result.dat"))
{
foreach (var toPoint in toPoints)
{
sw.WriteLine("{0} {1}", toPoint[0], toPoint[1]);
}
}
}