Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join on filtering OSM data #126

Open
bryanschoot opened this issue May 6, 2021 · 0 comments
Open

Join on filtering OSM data #126

bryanschoot opened this issue May 6, 2021 · 0 comments
Labels

Comments

@bryanschoot
Copy link

At the moment Iam doing this in seperate functions but is it possible to do something simulair to te code below?

// Constants.TagStreet => "addr:street";
// Constants.TagPostalCode => "addr:postcode";
// Constants.TagHighway => "highway";
// Constants.TagName => "name";

 OsmHelper.Download(Constants.Url, Constants.File);

  using var fileStream = File.OpenRead(Constants.File);
  var source = new PBFOsmStreamSource(fileStream);
  var results = new List<Address>();

  foreach (var address in addresses)
  {
      var final = from osmAddresses in source
                  where osmAddresses.Type == OsmGeoType.Node
                      && osmAddresses.Tags != null
                      && osmAddresses.Tags.ContainsKey(Constants.TagStreet)
                      && osmAddresses.Tags.Contains(Constants.TagPostalCode, address.Zip.NormalizeZip())
                  join osmWays in source on osmAddresses equals osmWays
                  where
                      osmWays.Type == OsmGeoType.Way
                      && osmWays.Tags != null
                      && osmWays.Tags.Contains(Constants.TagName, osmAddresses.Tags[Constants.TagStreet])
                      && osmWays.Tags.ContainsKey(Constants.TagHighway)
                  select new Address
                  {
                      Street = osmAddresses.Tags[Constants.TagStreet],
                      Zip = osmAddresses.Tags[Constants.TagPostalCode],
                      GeoLocation = new GeoLocation
                      {
                          Longitude = ((Node)osmAddresses).Longitude,
                          Latitude = ((Node)osmAddresses).Latitude
                      },
                      Nodes = ((Way)osmWays).Nodes.ToList()
                  };

      results.AddRange(final);
  }
@xivk xivk added the question label May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants