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

Support OverpassApi #76

Closed
blackboxlogic opened this issue Jul 26, 2019 · 4 comments
Closed

Support OverpassApi #76

blackboxlogic opened this issue Jul 26, 2019 · 4 comments

Comments

@blackboxlogic
Copy link
Contributor

blackboxlogic commented Jul 26, 2019

With a small change to XmlExtensions.cs, OsmSharp would be able to deserialize responses from OverpassApi and other data sources which include unexpected XML elements.

Overpass responses include a "meta" element and a "note" element, which I think would be fine to ignore while deserializing for most purposes. Your current implementation stops deserializing when it finds any unexpected element.

If I made a pull request to this effect, would you consider it?

Related: drolbr/Overpass-API#533

@xivk
Copy link
Contributor

xivk commented Jul 26, 2019

Yes, of course.

If it's backwards compatible with what is there now (but if I read correctly it will be) and if you also add some tests for it then I will thank you for submitting a pull request! 👍

Just FYI, I have also built some code in a test environment that downloads from overpass, are you saying this won't work anymore:

https://github.com/itinero/routing/blob/develop/test/Itinero.Test.Functional/Staging/Download.cs#L53

Also, if therre is anything you can reuse from there feel free to do so.

@blackboxlogic
Copy link
Contributor Author

blackboxlogic commented Jul 27, 2019

I just tested your code sample with a simple Overpass query and it works. At its heart, you're using:

IEnumerable<OsmSharp.OsmGeo> things = new OsmSharp.Streams.XmlOsmStreamSource(STREAM);

When your code gets to an XmlElement it doesn't recognize, it skips it.

The code I was using, expecting to work but having trouble with:

XmlSerializer serializer = new XmlSerializer(typeof(OsmSharp.API.Osm));
OsmSharp.API.Osm osm = serializer.Deserialize(STREAM) as OsmSharp.API.Osm;

When my code gets to an XmlElement it doesn't recognize, it stops reading and returns.

I'm not sure if I prefer having an IEnumerable<OsmSharp.OsmGeo>, or an OsmSharp.API.Osm. My next step (which I haven't gotten to yet) is trying to modify elements and submit change sets (after reading all documentation and getting community feedback).

@blackboxlogic
Copy link
Contributor Author

blackboxlogic commented Jul 28, 2019

Thank you for having tests in your project! The unit and functional tests still pass. I'm not sure the proper way to link an Issue and a PullRequest. (#77)

@xivk
Copy link
Contributor

xivk commented Jul 29, 2019

The pull-request has been merged in develop.

This should fix your issue, just use the latest nuget prerelease package until OsmSharp is ready for it's next stable release.

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