webgeodatavore / osm-request

JS library for OpenStreetMap API communication
MIT License
0 stars 0 forks source link

Handle several elements at once in a collection #10

Closed PanierAvide closed 5 years ago

PanierAvide commented 5 years ago

To be able to use osmtogeojson library, we need OSM map data as raw XML string.

Solution : add a parameter for getting the result of fetchMapByBbox as a XML string.

Temporary workaround : using jsonToXml on client side

PanierAvide commented 5 years ago

Or maybe it would be better to handle several elements as a sort of collection. Because I need to both know if there are elements contained in the result of the API call, and if so get them as XML string.

Also, having a collection of elements would help in the case of /[way|relation]/:id/full calls to properly handle several objects at once.

PanierAvide commented 5 years ago

On pourrait avoir les méthodes suivantes :

ThomasG77 commented 5 years ago

Find any node, way or relation matching the osmId in a collection generated from a raw XML converted using xmlToJson

Within existing functions below,

PanierAvide commented 5 years ago
const rawxml = await this._osmApi.fetchMapByBbox(bbox.getWest(), bbox.getSouth(), bbox.getEast(), bbox.getNorth());
            rawxml.osm.node = rawxml.osm.node.map(n => {
                delete n._id;
                delete n._type;
                return n;
            });
            rawxml.osm.way = rawxml.osm.way.map((w,i) => {
                delete w._id;
                delete w._type;
                return w.osm.way[0];
            });
            this._cacheOsmXml = (new window.DOMParser()).parseFromString(jsonToXml(rawxml), "text/xml");