/// <summary> /// Adds a node to this database. /// </summary> /// <param name="node"></param> public override void AddNode(Node node) { // save the node in the current redis key. string nodeKey = node.GetRedisKey(); _nodeTypeClient.SetEntry(nodeKey, PrimitiveExtensions.ConvertTo(node)); // save the node in the correct osmhash location. var idBytes = BitConverter.GetBytes(node.Id.Value); _redisClient.SAdd(node.GetOsmHash(), idBytes); }
/// <summary> /// Adds a relation to this database. /// </summary> /// <param name="relation"></param> public override void AddRelation(Relation relation) { // save the relation in the current redis key. string relationKey = relation.GetRedisKey(); _relationTypeClient.SetEntry(relationKey, PrimitiveExtensions.ConvertTo(relation)); // save the relation-member relation. if (relation.Members != null) { foreach (var member in relation.Members) { _redisClient.AddItemToSet(PrimitiveExtensions.BuildMemberRelationListRedisKey(member), relation.Id.Value.ToString()); } } }
/// <summary> /// Adds a way to this database. /// </summary> /// <param name="way"></param> public override void AddWay(Way way) { // save the way in the current redis key. string wayKey = way.GetRedisKey(); _wayTypeClient.SetEntry(wayKey, PrimitiveExtensions.ConvertTo(way)); // save the way-node relation. if (way.Nodes != null) { foreach (long nodeId in way.Nodes) { _redisClient.AddItemToSet(PrimitiveExtensions.BuildNodeWayListRedisKey(nodeId), way.Id.Value.ToString()); } } }
/// <summary> /// Stores an osmGeo object to disk. /// </summary> /// <param name="osmGeo"></param> private void Store(OsmGeo osmGeo) { switch (osmGeo.Type) { case OsmGeoType.Node: Node node = osmGeo as Node; string nodeKey = node.GetRedisKey(); _clientNode.SetEntry(nodeKey, PrimitiveExtensions.ConvertTo(node)); break; case OsmGeoType.Way: Way way = osmGeo as Way; string wayKey = way.GetRedisKey(); _clientWay.SetEntry(wayKey, PrimitiveExtensions.ConvertTo(way)); break; case OsmGeoType.Relation: Relation relation = osmGeo as Relation; string relationKey = relation.GetRedisKey(); _clientRelation.SetEntry(relationKey, PrimitiveExtensions.ConvertTo(relation)); break; } }