Esempio n. 1
0
        /// <summary>
        /// Returns true if the given object exists.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private bool Exist(long id, OsmGeoType type)
        {
            switch (type)
            {
            case OsmGeoType.Node:
                string nodeKey = PrimitiveExtensions.BuildNodeRedisKey(id);
                return(_clientNode.ContainsKey(nodeKey));

            case OsmGeoType.Way:
                string wayKey = PrimitiveExtensions.BuildWayRedisKey(id);
                return(_clientWay.ContainsKey(wayKey));

            case OsmGeoType.Relation:
                string relationKey = PrimitiveExtensions.BuildRelationRedisKey(id);
                return(_clientRelation.ContainsKey(relationKey));
            }
            throw new ArgumentOutOfRangeException("type");
        }
Esempio n. 2
0
        /// <summary>
        /// Deletes an osmGeo object from disk.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        private void Delete(long id, OsmGeoType type)
        {
            switch (type)
            {
            case OsmGeoType.Node:
                string nodeKey = PrimitiveExtensions.BuildNodeRedisKey(id);
                _client.Del(nodeKey);
                //_clientNode.DeleteById(nodeKey);
                break;

            case OsmGeoType.Way:
                string wayKey = PrimitiveExtensions.BuildWayRedisKey(id);
                //_clientWay.DeleteById(wayKey);
                _client.Del(wayKey);
                break;

            case OsmGeoType.Relation:
                string relationKey = PrimitiveExtensions.BuildRelationRedisKey(id);
                //_clientRelation.DeleteById(relationKey);
                _client.Del(relationKey);
                break;
            }
        }
Esempio n. 3
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");
        }