コード例 #1
0
        private async Task <List <Feature> > GetHighwaysInArea(LineString line)
        {
            var northEast = _wgs84ItmMathTransform.Transform(new Coordinate
            {
                Y = line.Coordinates.Max(c => c.Y),
                X = line.Coordinates.Max(c => c.X)
            });
            var southWest = _wgs84ItmMathTransform.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.MinimalDistanceToClosestPoint;
            northEast.X += _options.MinimalDistanceToClosestPoint;
            southWest.Y -= _options.MinimalDistanceToClosestPoint;
            southWest.X -= _options.MinimalDistanceToClosestPoint;
            var northEastLatLon = _itmWgs84MathTransform.Transform(northEast);
            var southWestLatLon = _itmWgs84MathTransform.Transform(southWest);

            var highways = await _elasticSearchGateway.GetHighways(northEastLatLon, southWestLatLon);

            return(highways.ToList());
        }
コード例 #2
0
        private async Task <List <LineString> > GetLineStringsInArea(LineString gpxItmLine, double tolerance)
        {
            var northEast = _itmWgs84MathTransform.Transform(gpxItmLine.Coordinates.Max(c => c.X) + tolerance, gpxItmLine.Coordinates.Max(c => c.Y) + tolerance);
            var southWest = _itmWgs84MathTransform.Transform(gpxItmLine.Coordinates.Min(c => c.X) - tolerance, gpxItmLine.Coordinates.Min(c => c.Y) - tolerance);
            var highways  = await _elasticSearchGateway.GetHighways(new Coordinate(northEast.x, northEast.y), new Coordinate(southWest.x, southWest.y));

            return(highways.Select(highway => ToItmLineString(highway.Geometry.Coordinates, highway.GetOsmId())).ToList());
        }
コード例 #3
0
ファイル: OsmControllerTests.cs プロジェクト: arielki/Site
        public void GetHighway_ShouldGetSome()
        {
            var list = new List<Feature> { new Feature(new LineString(new Coordinate[0]), new AttributesTable())};
            _elasticSearchGateway.GetHighways(Arg.Any<Coordinate>(), Arg.Any<Coordinate>()).Returns(list);

            var results = _controller.GetHighways("0,0", "1,1").Result;

            Assert.AreEqual(list.Count, results.Count);
        }
コード例 #4
0
ファイル: OsmController.cs プロジェクト: moshfeu/Site
        public async Task <List <Feature> > GetSnappings(string northEast, string southWest)
        {
            var northEastCooridnate = new Coordinate().FromLatLng(northEast);
            var southWestCoordinate = new Coordinate().FromLatLng(southWest);
            var highways            = await _elasticSearchGateway.GetHighways(northEastCooridnate, southWestCoordinate);

            var points = await _elasticSearchGateway.GetPointsOfInterest(northEastCooridnate, southWestCoordinate, Categories.Points);

            return(highways.Concat(points.Where(p => Sources.OSM.Equals(p.Attributes[FeatureAttributes.POI_SOURCE]))).ToList());
        }
コード例 #5
0
ファイル: OsmController.cs プロジェクト: ifle/Site
        public async Task <List <Feature> > GetSnappings(string northEast, string southWest)
        {
            var northEastCooridnate = new Coordinate().FromLatLng(northEast);
            var southWestCoordinate = new Coordinate().FromLatLng(southWest);
            var highways            = await _elasticSearchGateway.GetHighways(northEastCooridnate, southWestCoordinate);

            var points = await _elasticSearchGateway.GetPointsOfInterest(northEastCooridnate, southWestCoordinate, Categories.Points.Concat(new[] { Categories.NONE }).ToArray(), Languages.ALL);

            return(highways.Concat(points).ToList());
        }
コード例 #6
0
        private void SetupHighway(int wayId, Coordinate[] coordinates, IOsmGateway osmGateway)
        {
            var table = new AttributesTable {
                { FeatureAttributes.ID, wayId.ToString() }
            };

            _elasticSearchGateway.GetHighways(Arg.Any <Coordinate>(), Arg.Any <Coordinate>()).Returns(new List <Feature>
            {
                new Feature(new LineString(coordinates), table)
            });
            var osmCompleteWay = new CompleteWay {
                Id = wayId
            };
            var id = 1;

            osmCompleteWay.Nodes = coordinates.Select(coordinate => new Node {
                Id = id++, Latitude = coordinate.Y, Longitude = coordinate.X
            }).ToArray();
            osmGateway.GetCompleteWay(wayId.ToString()).Returns(osmCompleteWay);
        }
コード例 #7
0
        private void SetupHighways(List <LineString> lineStrings = null)
        {
            lineStrings = lineStrings ?? new List <LineString>();
            var conveter = new ItmWgs84MathTransfromFactory().Create();
            var highways = lineStrings.Select(l => new Feature(new LineString(l.Coordinates.Select(conveter.Transform).ToArray()), new AttributesTable())).ToList();

            foreach (var highway in highways)
            {
                highway.Attributes.AddAttribute(FeatureAttributes.ID, "1");
            }
            _elasticSearchGateway.GetHighways(Arg.Any <Coordinate>(), Arg.Any <Coordinate>()).Returns(highways);
        }
コード例 #8
0
        private void SetupHighway(int wayId, Coordinate[] coordinates, IAuthClient osmGateway)
        {
            var osmCompleteWay = new CompleteWay {
                Id = wayId
            };
            var id = 1;

            osmCompleteWay.Nodes = coordinates.Select(coordinate => new Node {
                Id = id++, Latitude = coordinate.Y, Longitude = coordinate.X
            }).ToArray();
            osmGateway.GetCompleteWay(wayId).Returns(osmCompleteWay);
            osmGateway.GetWay(wayId).Returns(osmCompleteWay.ToSimple() as Way);
            var table = new AttributesTable
            {
                { FeatureAttributes.ID, wayId.ToString() },
                { FeatureAttributes.POI_OSM_NODES, osmCompleteWay.Nodes.Select(n => n.Id.Value).Cast <object>().ToList() }
            };

            _elasticSearchGateway.GetHighways(Arg.Any <Coordinate>(), Arg.Any <Coordinate>()).Returns(new List <Feature>
            {
                new Feature(new LineString(coordinates), table)
            });
        }
コード例 #9
0
        private async Task <List <ILineString> > GetLineStringsInArea(ILineString gpxItmLine, double tolerance)
        {
            var northEast = _itmWgs84MathTransfrom.Transform(new Coordinate
            {
                Y = gpxItmLine.Coordinates.Max(c => c.Y) + tolerance,
                X = gpxItmLine.Coordinates.Max(c => c.X) + tolerance
            });
            var southWest = _itmWgs84MathTransfrom.Transform(new Coordinate
            {
                Y = gpxItmLine.Coordinates.Min(c => c.Y) - tolerance,
                X = gpxItmLine.Coordinates.Min(c => c.X) - tolerance
            });
            var highways = await _elasticSearchGateway.GetHighways(northEast, southWest);

            return(highways.Select(highway => ToItmLineString(highway.Geometry.Coordinates, highway.Attributes[FeatureAttributes.ID].ToString())).ToList());
        }
コード例 #10
0
 public async Task <List <Feature> > GetHighways(string northEast, string southWest)
 {
     return(await _elasticSearchGateway.GetHighways(new Coordinate().FromLatLng(northEast), new Coordinate().FromLatLng(southWest)));
 }