예제 #1
0
 /// <summary>
 /// Creates a HMM map matching filter for some map, router, cost function, and spatial operator.
 /// </summary>
 /// <param name="map">map <see cref="RoadMap" /> object of the map to be matched to.</param>
 /// <param name="router">router <see cref="IGraphRouter{TEdge, TPoint}"/> object to be used for route estimation.</param>
 /// <param name="cost">Cost function to be used for routing.</param>
 /// <param name="spatial">Spatial operator for spatial calculations.</param>
 public Matcher(RoadMap map, IGraphRouter <Road, RoadPoint> router, Func <Road, double> cost, ISpatialOperation spatial)
 {
     this._map     = map;
     this._router  = router;
     this._cost    = cost;
     this._spatial = spatial;
 }
 public AbstractSpatialIndex(IEnumerable <TItem> items, ISpatialOperation spatialService,
                             Func <TItem, ILineString> geometryGetter, Func <TItem, double> lengthGetter)
 {
     this.ItemGeometryGetter = geometryGetter;
     this.ItemLengthGetter   = lengthGetter;
     this.Spatial            = spatialService;
     this.AddRange(items);
 }
예제 #3
0
        public RoadMap(IEnumerable <Road> roads, ISpatialOperation spatial) : base(roads)
        {
            _spatial = spatial;

            // The original Barefoot is using Quad Tree for spatial indexing, however, in my experiment, NTS's STRtree is
            // much faster than NTS's Quadtree.
            //this.Index = new Spatial.Index.RBush.RBushSpatialIndex<RoadInfo>(roads.Select(x => x.RoadInfo), spatial, r => r.Geometry, r => r.Length);
            this.Index = new RtreeIndex <RoadInfo>(roads.Select(x => x.RoadInfo), spatial, r => r.Geometry, r => r.Length);
        }
예제 #4
0
            public MockedRoadReader(ISpatialOperation spatial)
            {
                var wktRdr = new WKTReader();

                foreach (var e in _entries)
                {
                    var geom = wktRdr.Read("SRID=4326;" + e.Item5) as ILineString;
                    _roads.Add(new RoadInfo(e.Item1, e.Item2, e.Item3, e.Item4, (short)0, 1.0f, 100f, 100f, (float)spatial.Length(geom), geom));
                }
                _enumerator = _roads.GetEnumerator();
            }
예제 #5
0
        private static IEnumerable <RoadInfo> ReadRoads(ISpatialOperation spatial)
        {
            var json   = File.ReadAllText(Path.Combine(s_dataDir, @"road.geojson"));
            var reader = new GeoJsonReader();
            var fc     = reader.Read <FeatureCollection>(json);

            foreach (var feature in fc.Features)
            {
                var lineGeom = feature.Geometry as ILineString;
                yield return(new RoadInfo(
                                 Convert.ToInt64(feature.Attributes["Gid"]),
                                 Convert.ToInt64(feature.Attributes["Source"]),
                                 Convert.ToInt64(feature.Attributes["Target"]),
                                 (bool)feature.Attributes["Oneway"],
                                 0,
                                 Convert.ToSingle(feature.Attributes["Priority"]),
                                 Convert.ToSingle(feature.Attributes["MaxForwardSpeed"]),
                                 Convert.ToSingle(feature.Attributes["MaxBackwardSpeed"]),
                                 Convert.ToSingle(spatial.Length(lineGeom)),
                                 lineGeom));
            }
        }
예제 #6
0
        private static IEnumerable <RoadInfo> ReadRoads(ISpatialOperation spatial)
        {
            var json   = File.ReadAllText(Path.Combine(s_dataDir, @"osm-kunming-roads-network.geojson"));
            var reader = new GeoJsonReader();
            var fc     = reader.Read <FeatureCollection>(json);

            foreach (var feature in fc.Features)
            {
                var lineGeom = feature.Geometry as ILineString;
                yield return(new RoadInfo(
                                 Convert.ToInt64(feature.Attributes["gid"]),
                                 Convert.ToInt64(feature.Attributes["source"]),
                                 Convert.ToInt64(feature.Attributes["target"]),
                                 (double)feature.Attributes["reverse"] >= 0D ? false : true,
                                 (short)0,
                                 Convert.ToSingle(feature.Attributes["priority"]),
                                 120f,
                                 120f,
                                 Convert.ToSingle(spatial.Length(lineGeom)),
                                 lineGeom));
            }
        }
예제 #7
0
        private static IEnumerable <RoadInfo> ReadRoads(ISpatialOperation spatial)
        {
            var json = File.ReadAllText(Path.Combine(s_dataDir, @"osm-kunming-roads-network.geojson"));
            var fc   = JsonConvert.DeserializeObject <FeatureCollection>(json);

            foreach (var feature in fc.Features)
            {
                var geom       = feature.Geometry as LineString;
                var lineCoords = geom.Coordinates.Select(c => new GeoAPI.Geometries.Coordinate(c.Longitude, c.Latitude)).ToArray();
                var lineGeom   = new NetTopologySuite.Geometries.LineString(lineCoords);
                yield return(new RoadInfo(
                                 Convert.ToInt64(feature.Properties["gid"]),
                                 Convert.ToInt64(feature.Properties["source"]),
                                 Convert.ToInt64(feature.Properties["target"]),
                                 (double)feature.Properties["reverse"] >= 0D ? false : true,
                                 (short)0,
                                 Convert.ToSingle(feature.Properties["priority"]),
                                 120f,
                                 120f,
                                 Convert.ToSingle(spatial.Length(lineGeom)),
                                 lineGeom));
            }
        }
예제 #8
0
 public QuadtreeIndex(IEnumerable <TItem> items, ISpatialOperation spatialService,
                      Func <TItem, ILineString> geometryGetter, Func <TItem, double> lengthGetter)
     : base(items, spatialService, geometryGetter, lengthGetter)
 {
 }
예제 #9
0
 public RoadMap(IEnumerable <Road> roads, ISpatialOperation spatial) : base(roads)
 {
     _spatial   = spatial;
     this.Index = new RtreeIndex <RoadInfo>(roads.Select(x => x.RoadInfo), spatial, r => r.Geometry, r => r.Length);
 }
예제 #10
0
 public AbstractSpatialIndexTest()
 {
     this.Spatial = new GeographySpatialOperation();
     _geometries  = this.MakeGeometries();
 }
 protected AbstractNtsSpatialIndex(IEnumerable <TItem> items, ISpatialOperation spatialService,
                                   Func <TItem, ILineString> geometryGetter, Func <TItem, double> lengthGetter)
     : base(items, spatialService, geometryGetter, lengthGetter)
 {
 }
예제 #12
0
 public RoadMapBuilder(ISpatialOperation spatial)
 {
     _spatial = spatial;
 }