NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I'm not sure I'm doing this correctly. I'm trying to get hold of the coastline of a specific little island using OsmSharp and an osm-map of Singapore (xml format).

    XmlOsmStreamSource source = new XmlOsmStreamSource(fileStream);

    var islandsIncomplete = from osmGeo in source where (osmGeo.Type == OsmSharp.OsmGeoType.Relation && osmGeo.Tags.Contains("name", "Pulau Ubin"))
    || (osmGeo.Type == OsmSharp.OsmGeoType.Way && osmGeo.Tags.Contains("natural", "coastline"))
    || (osmGeo.Type == OsmSharp.OsmGeoType.Node)
    select osmGeo;

    var completes = incompletes.ToComplete();

    var relations = from osmGeo in completes where osmGeo.Type == OsmSharp.OsmGeoType.Relation select osmGeo;
    return relations.Cast<CompleteRelation>().ToArray();

So I looked into the xml file for these specific keys and values and I think I'm only extracting the necessary objects for completion. Yet, the process takes a really long time to complete. What is it doing that is taking so long? The above example seems to never complete, but even in other examples I try to extract a small amout of specific ways from the file, and it takes many minutes. Maybe there is something I don't understand here. Maybe I should better parse the xml file myself?

Is there any OsmSharp forum?

asked 12 Nov '20, 12:31

laban77's gravatar image

accept rate: 0%

Also, try opening an issue on the OSMSharp Github at

permanent link

answered 13 Nov '20, 12:32

Mike%20N's gravatar image

Mike N
accept rate: 17%

I would if I thought that there were something wrong. I have a feeling though that I have just misunderstood the whole thing. It's not stated anywhere that the processing should take such a long time. By the way I found out why the example above never finishes. I had forgotten to check that osmGeo.Tags is not null before checking what it contains. The error is probably swallowed later by the Cast command.

The problem is really a lack of documentation. The best I have found so far is to look through the examples in the source code itself.

(13 Nov '20, 15:24) laban77

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 12 Nov '20, 12:31

question was seen: 1,533 times

last updated: 13 Nov '20, 15:24

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum