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

Overhaul import logic and stop using projected coordinates #47

Merged
merged 7 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions examples/import.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,38 @@

async function importPolygon(e) {
let polygon = e.features[0];
// Uncomment to regenerate southwark.bin
/*let polygon = {
type: "Feature",
geometry: {
type: "Polygon",
coordinates: [
[
[-0.113371, 51.474014],
[-0.113371, 51.500307],
[-0.071072, 51.500307],
[-0.071072, 51.474014],
[-0.113371, 51.474014],
],
],
},
};*/
draw.deleteAll();
let status = document.getElementById("status");

status.textContent = "Fetching from Overpass";
let resp = await fetch(overpassQueryForPolygon(polygon));
let osmXml = await resp.text();

status.textContent = `Importing OSM data (${osmXml.length} bytes) with osm2streets`;
let bytes = convert(osmXml, JSON.stringify(polygon));
status.textContent = `Graph file (${bytes.length} bytes) done, downloading`;
downloadGeneratedFile(bytes, "route-snapper-graph.bin");
try {
status.textContent = "Fetching from Overpass";
let resp = await fetch(overpassQueryForPolygon(polygon));
let osmXml = await resp.arrayBuffer();

status.textContent = `Importing OSM data (${osmXml.length} bytes)`;
let bytes = convert(new Uint8Array(osmXml), JSON.stringify(polygon));
status.textContent = `Graph file (${bytes.length} bytes) done, downloading`;
downloadGeneratedFile(bytes, "route-snapper-graph.bin");
} catch (err) {
status.textContent = `Error: ${err}`;
window.alert(`Error: ${err}`);
}
}

// Construct a query to extract all XML data in the polygon clip. See
Expand Down
2 changes: 1 addition & 1 deletion examples/osm-to-route-snapper
Binary file modified examples/southwark.bin
Binary file not shown.
Loading