示例#1
0
 /// <summary>
 /// Deletes the relation with the given id.
 /// </summary>
 public static void DeleteRelation(this ISnapshotDb db, long id)
 {
     db.Delete(new OsmGeoKey()
     {
         Id   = id,
         Type = OsmGeoType.Relation
     });
 }
示例#2
0
 /// <summary>
 /// Deletes the way with the given id.
 /// </summary>
 public static void DeleteWay(this ISnapshotDb db, long id)
 {
     db.Delete(new OsmGeoKey()
     {
         Id   = id,
         Type = OsmGeoType.Way
     });
 }
        /// <summary>
        /// Creates a new osm simple complete stream.
        /// </summary>
        public OsmSimpleCompleteStreamSource(OsmStreamSource source, ISnapshotDb cache)
        {
            _dataCache    = cache;
            _simpleSource = source;

            _nodesToInclude           = new HashSet <long>();
            _nodesUsedTwiceOrMore     = new Dictionary <long, int>();
            _waysToInclude            = new HashSet <long>();
            _waysUsedTwiceOrMore      = new Dictionary <long, int>();
            _relationsToInclude       = new HashSet <long>();
            _relationsUsedTwiceOrMore = new Dictionary <long, int>();
        }
        private readonly OsmStreamSource _simpleSource; // Holds the simple source of object.

        /// <summary>
        /// Creates a new osm simple complete stream.
        /// </summary>
        public OsmSimpleCompleteStreamSource(OsmStreamSource source)
        {
            // create an in-memory cache by default.
            _dataCache    = (new MemorySnapshotDb()).CreateSnapshotDb();
            _simpleSource = source;

            _nodesToInclude           = new HashSet <long>();
            _nodesUsedTwiceOrMore     = new Dictionary <long, int>();
            _waysToInclude            = new HashSet <long>();
            _waysUsedTwiceOrMore      = new Dictionary <long, int>();
            _relationsToInclude       = new HashSet <long>();
            _relationsUsedTwiceOrMore = new Dictionary <long, int>();
        }
示例#5
0
        /// <summary>
        /// Interprets an OSM-object and returns the correctponding geometry.
        /// </summary>
        public virtual FeatureCollection Interpret(OsmGeo osmGeo, ISnapshotDb data)
        {
            switch (osmGeo.Type)
            {
            case OsmGeoType.Node:
                return(this.Interpret(osmGeo as Node));

            case OsmGeoType.Way:
                return(this.Interpret((osmGeo as Way).CreateComplete(data)));

            case OsmGeoType.Relation:
                return(this.Interpret((osmGeo as Relation).CreateComplete(data)));
            }
            throw new ArgumentOutOfRangeException();
        }
示例#6
0
        /// <summary>
        /// Gets all osm objects with the given types and the given id's.
        /// </summary>
        public static IList <OsmGeo> Get(this ISnapshotDb db, IList <OsmGeoType> type, IList <long> id)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (id.Count != type.Count)
            {
                throw new ArgumentException("Type and id lists need to have the same size.");
            }

            var result = new List <OsmGeo>();

            for (int i = 0; i < id.Count; i++)
            {
                result.Add(db.Get(type[i], id[i]));
            }
            return(result);
        }
示例#7
0
 /// <summary>
 /// Converts the given source to a complete stream.
 /// </summary>
 public static Complete.OsmCompleteStreamSource ToComplete(this IEnumerable <OsmGeo> source, ISnapshotDb cache)
 {
     return(new OsmSharp.Streams.Complete.OsmSimpleCompleteStreamSource(
                new OsmSharp.Streams.OsmEnumerableStreamSource(source), cache));
 }
示例#8
0
 /// <summary>
 /// Adds or objects the given object.
 /// </summary>
 public static void AddOrUpdate(this ISnapshotDb db, OsmGeo osmGeo)
 {
     db.AddOrUpdate(new OsmGeo[] { osmGeo });
 }
示例#9
0
 /// <summary>
 /// Deletes the relation with the given id.
 /// </summary>
 public static void DeleteRelation(this ISnapshotDb db, long id)
 {
     db.Delete(new OsmGeoKey(OsmGeoType.Relation, id));
 }
示例#10
0
 /// <summary>
 /// Deletes the way with the given id.
 /// </summary>
 public static void DeleteWay(this ISnapshotDb db, long id)
 {
     db.Delete(new OsmGeoKey(OsmGeoType.Way, id));
 }
示例#11
0
 /// <summary>
 /// Deletes the node with the given id.
 /// </summary>
 public static void DeleteNode(this ISnapshotDb db, long id)
 {
     db.Delete(new OsmGeoKey(OsmGeoType.Node, id));
 }
示例#12
0
 /// <summary>
 /// Deletes the object for the given key.
 /// </summary>
 public static void Delete(this ISnapshotDb db, OsmGeoKey key)
 {
     db.Delete(new OsmGeoKey[] { key });
 }
示例#13
0
 /// <summary>
 /// Gets all data in the form of a complete stream.
 /// </summary>
 public static OsmCompleteStreamSource GetComplete(this ISnapshotDb db)
 {
     return(new Streams.Complete.OsmCompleteEnumerableStreamSource(
                db.Get().Select(x => x.CreateComplete(db))));
 }