private async Task <List <Feature> > GetHighwaysInArea(LineString line) { var northEast = _itmWgs84MathTransform.Inverse().Transform(new Coordinate { Y = line.Coordinates.Max(c => c.Y), X = line.Coordinates.Max(c => c.X) }); var southWest = _itmWgs84MathTransform.Inverse().Transform(new Coordinate { Y = line.Coordinates.Min(c => c.Y), X = line.Coordinates.Min(c => c.X) }); // adding tolerance perimiter to find ways. northEast.Y += _options.ClosestPointTolerance; northEast.X += _options.ClosestPointTolerance; southWest.Y -= _options.ClosestPointTolerance; southWest.X -= _options.ClosestPointTolerance; var northEastLatLon = _itmWgs84MathTransform.Transform(northEast); var southWestLatLon = _itmWgs84MathTransform.Transform(southWest); var highways = await _elasticSearchGateway.GetHighways(northEastLatLon, southWestLatLon); return(highways.ToList()); }
public void TestNtsIssue191() { List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_center", 45.30916666666666)); parameters.Add(new ProjectionParameter("longitude_of_center", -86)); parameters.Add(new ProjectionParameter("azimuth", 337.25556)); parameters.Add(new ProjectionParameter("rectified_grid_angle", 337.25556)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996)); parameters.Add(new ProjectionParameter("false_easting", 2546731.496)); parameters.Add(new ProjectionParameter("false_northing", -4354009.816)); CoordinateSystemFactory factory = new CoordinateSystemFactory(); IProjection projection = factory.CreateProjection("Test Oblique", "oblique_mercator", parameters); Assert.That(projection, Is.Not.Null); IGeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84; IProjectedCoordinateSystem dummy = factory.CreateProjectedCoordinateSystem("dummy pcs", wgs84, projection, LinearUnit.Metre, new AxisInfo("X", AxisOrientationEnum.East), new AxisInfo("Y", AxisOrientationEnum.North)); Assert.That(dummy, Is.Not.Null); CoordinateTransformationFactory transformationFactory = new CoordinateTransformationFactory(); ICoordinateTransformation transform = transformationFactory.CreateFromCoordinateSystems(wgs84, dummy); Assert.That(transform, Is.Not.Null); IMathTransform mathTransform = transform.MathTransform; IMathTransform inverse = mathTransform.Inverse(); Assert.That(inverse, Is.Not.Null); }
private ILineString ToItmLineString(IEnumerable <Coordinate> coordinates, string id) { var itmCoordinates = coordinates.Select(_itmWgs84MathTransfrom.Inverse().Transform).ToArray(); var line = _geometryFactory.CreateLineString(itmCoordinates); line.SetOsmId(id); return(line); }
private void Awake() { // initialize the coordinate transformation epsg900913 = CoordinateSystemWktReader.Parse(wktEPSG900913) as ICoordinateSystem; ctFactory = new CoordinateTransformationFactory(); wgs84ToEPSG900913 = ctFactory.CreateFromCoordinateSystems(GeographicCoordinateSystem.WGS84, epsg900913); wgs84ToEPSG900913Transform = wgs84ToEPSG900913.MathTransform; epsg900913ToWGS84Transform = wgs84ToEPSG900913Transform.Inverse(); }
public NorthEast GetItmCoordinates(double lat, double lon) { var coordiante = _itmWgs84MathTransform.Inverse().Transform(new Coordinate { Y = lat, X = lon }); return(new NorthEast { East = (int)coordiante.X, North = (int)coordiante.Y }); }
private ILineString ToItmLineString(IEnumerable <wptType> waypoints) { var coordinates = waypoints.Select(wptType => _itmWgs84MathTransform.Inverse().Transform(new Coordinate((double)wptType.lon, (double)wptType.lat))); var nonDuplicates = new List <Coordinate>(); foreach (var coordinate in coordinates) { if (nonDuplicates.Count <= 0 || !nonDuplicates.Last().Equals2D(coordinate)) { nonDuplicates.Add(coordinate); } } return(_geometryFactory.CreateLineString(nonDuplicates.ToArray())); }
private Coordinate[] ToWgs84Coordinates(IEnumerable <LatLng> latLngs) { return(latLngs.Select(latLng => _itmWgs84MathTransform.Inverse().Transform(new Coordinate { X = latLng.lng, Y = latLng.lat })).ToArray()); }