Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8300


Ignore:
Timestamp:
07/18/12 12:56:35 (11 years ago)
Author:
spimming
Message:

#1894:

  • graph data structures added
  • method to get the ways for a specific node
Location:
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/HeuristicLab.Problems.RoutePlanning.csproj

    r8293 r8300  
    5656  </ItemGroup>
    5757  <ItemGroup>
     58    <Compile Include="Graph\Edge.cs" />
     59    <Compile Include="Graph\Graph.cs" />
     60    <Compile Include="Graph\IEdge.cs" />
     61    <Compile Include="Graph\Vertex.cs" />
    5862    <Compile Include="Osm.Data\XmlDataSource.cs" />
    5963    <Compile Include="Osm\IDataSource.cs" />
     
    7478    <None Include="Properties\AssemblyInfo.cs.frame" />
    7579  </ItemGroup>
     80  <ItemGroup />
    7681  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    7782  <PropertyGroup>
  • branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Osm.Data/XmlDataSource.cs

    r8293 r8300  
    1010    private IDictionary<long, Way> ways;
    1111    private IDictionary<long, Relation> relations;
     12
     13    private IDictionary<long, List<long>> nodeWays;
    1214
    1315
     
    3840      relations = new Dictionary<long, Relation>();
    3941
     42      nodeWays = new Dictionary<long, List<long>>();
     43
    4044      ReadData();
    4145    }
     
    5559      if (ways.ContainsKey(wayId)) {
    5660        return ways[wayId];
     61      }
     62      return null;
     63    }
     64
     65    public List<Way> GetWays(Node node) {
     66      if (nodeWays.ContainsKey(node.Id)) {
     67        List<long> wayIds = nodeWays[node.Id];
     68        List<Way> result = new List<Way>(wayIds.Count);
     69        for (int i = 0; i < wayIds.Count; i++) {
     70          result.Add(GetWay(wayIds[i]));
     71        }
     72        return result;
    5773      }
    5874      return null;
     
    117133
    118134          ways.Add(way.Id, way);
     135          InsertNodeWayRelation(way);
    119136
    120137          reader.Read();
     
    170187
    171188    }
     189
     190    private void InsertNodeWayRelation(Way way) {
     191      foreach (Node node in way.Nodes) {
     192        if (!nodeWays.ContainsKey(node.Id)) {
     193          nodeWays.Add(node.Id, new List<long>());
     194        }
     195        nodeWays[node.Id].Add(way.Id);
     196      }
     197    }
    172198  }
    173199}
  • branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Osm/IDataSource.cs

    r8293 r8300  
    11
     2using System.Collections.Generic;
    23namespace HeuristicLab.Problems.RoutePlanning.Osm {
    34  public interface IDataSource {
     
    56    Node GetNode(long nodeId);
    67    Way GetWay(long wayId);
     8    List<Way> GetWays(Node node);
    79    Relation GetRelation(long relationId);
    810  }
Note: See TracChangeset for help on using the changeset viewer.