public static WebMercatorPosition ToWebMercator(this SWEREF99Position pos) { var calc = new WebMercatorCalculator(); var wgs84 = pos.ToWGS84(); return(new WebMercatorPosition(calc.LatitudeToY(wgs84.Latitude), calc.LongitudeToX(wgs84.Longitude))); }
public static double[] GetLatLon(float x, float y) { var sweRef = new SWEREF99Position(y, x); var wgs84 = sweRef.ToWGS84(); return(new double[] { wgs84.Latitude, wgs84.Longitude }); }
public void LatitudeToStringTest2() { SWEREF99Position swePos = new SWEREF99Position(6652797.165, 658185.201); WGS84Position wgsPos = swePos.ToWGS84(); string latDegStringFromLM = "59.982008334868"; string lonDegStringFromLM = "17.8350333249246"; Assert.AreEqual(latDegStringFromLM, wgsPos.LatitudeToString(WGS84Position.WGS84Format.Degrees)); Assert.AreEqual(lonDegStringFromLM, wgsPos.LongitudeToString(WGS84Position.WGS84Format.Degrees)); }
public void SwerefToWGS84() { SWEREF99Position swePos = new SWEREF99Position(6652797.165, 658185.201); WGS84Position wgsPos = swePos.ToWGS84(); // String values from Lantmateriet.se, they convert DMS only. // Reference: http://www.lantmateriet.se/templates/LMV_Enkelkoordinattransformation.aspx?id=11500 string latDmsStringFromLM = "N 59º 58' 55.23001\""; string lonDmsStringFromLM = "E 17º 50' 6.11997\""; Assert.AreEqual(latDmsStringFromLM, wgsPos.LatitudeToString(WGS84Position.WGS84Format.DegreesMinutesSeconds)); Assert.AreEqual(lonDmsStringFromLM, wgsPos.LongitudeToString(WGS84Position.WGS84Format.DegreesMinutesSeconds)); }
public void Load(string path) { var networkPath = Path.Combine(path, "network-plain.xml"); var schedulePath = Path.Combine(path, "transitSchedule.xml"); var vehiclePath = Path.Combine(path, "vehicles.xml"); var matSimNetwork = MatSimNetwork.Load(networkPath); var matSimSchedule = MatSimSchedule.Load(schedulePath); var vehicleDefinition = VehicleDefinitions.Load(vehiclePath); var networkMinMax = matSimNetwork.GetMinMaxXY(); SWEREF99Position minSwe = new SWEREF99Position(networkMinMax[1], networkMinMax[0]); SWEREF99Position maxSwe = new SWEREF99Position(networkMinMax[3], networkMinMax[2]); WGS84Position netMinWgs = minSwe.ToWGS84(); WGS84Position netMaxWgs = maxSwe.ToWGS84(); Console.WriteLine($"Min Lat: {netMinWgs.LatitudeToString(WGS84Position.WGS84Format.Degrees)}"); Console.WriteLine($"Min Lon: {netMinWgs.LongitudeToString(WGS84Position.WGS84Format.Degrees)}"); Console.WriteLine($"Max Lat: {netMaxWgs.LatitudeToString(WGS84Position.WGS84Format.Degrees)}"); Console.WriteLine($"Max Lon: {netMaxWgs.LongitudeToString(WGS84Position.WGS84Format.Degrees)}"); var scheduleMinMax = matSimSchedule.GetMinMaxXY(); minSwe = new SWEREF99Position(scheduleMinMax[1], scheduleMinMax[0]); maxSwe = new SWEREF99Position(scheduleMinMax[3], scheduleMinMax[2]); WGS84Position schMinWgs = minSwe.ToWGS84(); WGS84Position schMaxWgs = maxSwe.ToWGS84(); Console.WriteLine($"Min Lat: {schMinWgs.LatitudeToString(WGS84Position.WGS84Format.Degrees)}, {scheduleMinMax[1]}"); Console.WriteLine($"Min Lat: {schMinWgs.Latitude}"); Console.WriteLine($"Min Lon: {schMinWgs.LongitudeToString(WGS84Position.WGS84Format.Degrees)}, {scheduleMinMax[0]}"); Console.WriteLine($"Max Lat: {schMaxWgs.LatitudeToString(WGS84Position.WGS84Format.Degrees)}, {scheduleMinMax[3]}"); Console.WriteLine($"Max Lon: {schMaxWgs.LongitudeToString(WGS84Position.WGS84Format.Degrees)}, {scheduleMinMax[2]}"); //Console.WriteLine(matSimSchedule.GetStopString("99999")); //Console.WriteLine(matSimSchedule.GetLineString("line1_r")); //Console.WriteLine(matSimSchedule.GetLineString("line10_r")); //Console.WriteLine(matSimNetwork.GetLinkString("100004_AB")); //Console.WriteLine(matSimNetwork.GetNodeString("tr_65905")); //Console.WriteLine(vehicleDefinition.GetVehicleTypeString("BUS")); //Console.WriteLine(vehicleDefinition.GetVehicleString("Veh144931")); //Console.WriteLine($"vehicle list count: {vehicleDefinition.vehicles.Count}"); }
public static WGS84Position ToWgs84(this SWEREF99Position pos) { return(pos.ToWGS84()); }
public static RT90Position ToRt90(this SWEREF99Position pos) { return(new RT90Position(pos.ToWGS84(), RT90Position.RT90Projection.rt90_2_5_gon_v)); }
public static WGS84Position WgsFromSweref(SWEREF99Position position) { return(position.ToWGS84()); }