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

How to fetch Latitude and Longitude co-ordinates from osmGeo object while filtering #139

Open
sivanand82 opened this issue Mar 30, 2022 · 4 comments

Comments

@sivanand82
Copy link

sivanand82 commented Mar 30, 2022

Hi Team,

I have been using the OSM library for fetching results for range of range co-ordinates. The library works well though but the unable to fetch latitude and longitude co-ordinates from the filter query.

var lastfiltered = from osmGeo in source
where osmGeo.Type == OsmSharp.OsmGeoType.Node &&

                                // where osmGeo.Type != OsmSharp.OsmGeoType.Relation &&
                                osmGeo.Tags != null
                                && osmGeo.Tags.Contains(t)
                                   select osmGeo;

var complete = filtered.ToComplete();

The osmGeo abstract class does not have a defnition of longtitudes and latitudes.How to resolve this

public abstract class OsmGeo
{
protected OsmGeo();

    public long? Id { get; set; }
    public OsmGeoType Type { get; protected set; }
    public TagsCollectionBase Tags { get; set; }
    public long? ChangeSetId { get; set; }
    public bool? Visible { get; set; }
    public DateTime? TimeStamp { get; set; }
    public int? Version { get; set; }
    public long? UserId { get; set; }
    public string UserName { get; set; }
}
@xivk
Copy link
Contributor

xivk commented Mar 31, 2022

You need to check and cast to nodes, something like this should work:

if (osmGeo is Node n) { 
   var latLon = (n.Latitude.value, n.Longitude.value)
}

@sivanand82
Copy link
Author

Sorry forgot mention that i am using the CompleteOsmGeo instead of osmGeo file.Such a cast would be valid this scenario as well right?

@xivk
Copy link
Contributor

xivk commented Mar 31, 2022

@sivanand82
Copy link
Author

Thanks Ben.It worked for me,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants