예제 #1
0
        /// <summary>
        /// Reads an osmGeo object from disk.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        private OsmGeo Read(long id, OsmGeoType type)
        {
            switch (type)
            {
            case OsmGeoType.Node:
                string    nodeKey   = PrimitiveExtensions.BuildNodeRedisKey(id);
                RedisNode redisNode = _clientNode.GetValue(nodeKey);
                Node      node      = null;
                if (redisNode != null)
                {
                    node = PrimitiveExtensions.ConvertFrom(redisNode);
                }
                return(node);

            case OsmGeoType.Way:
                string   wayKey   = PrimitiveExtensions.BuildWayRedisKey(id);
                RedisWay redisWay = _clientWay.GetValue(wayKey);
                Way      way      = null;
                if (redisWay != null)
                {
                    way = PrimitiveExtensions.ConvertFrom(redisWay);
                }
                return(way);

            case OsmGeoType.Relation:
                string        relationKey   = PrimitiveExtensions.BuildRelationRedisKey(id);
                RedisRelation redisRelation = _clientRelation.GetValue(relationKey);
                Relation      relation      = null;
                if (redisRelation != null)
                {
                    relation = PrimitiveExtensions.ConvertFrom(redisRelation);
                }
                return(relation);
            }
            throw new ArgumentOutOfRangeException("type");
        }