MCPcopy Create free account
hub / github.com/cartesiancs/map3d / requestBuildings

Function requestBuildings

src/ui/App.tsx:124–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

122 };
123
124 const requestBuildings = async () => {
125 setIsFetchingBuildings(true);
126
127 const south = areaData[1].lat;
128 const west = areaData[1].lng;
129 const north = areaData[0].lat;
130 const east = areaData[0].lng;
131 const query = `[out:json][timeout:25];(way["building"]( ${south},${west},${north},${east} );relation["building"]( ${south},${west},${north},${east} ););out body geom;`;
132 try {
133 const response = await fetch("https://overpass-api.de/api/interpreter", {
134 method: "POST",
135 body: query,
136 headers: { "Content-Type": "application/x-www-form-urlencoded" },
137 });
138 const data = await response.json();
139 const blds: Building[] = data.elements.map((element) => ({
140 id: element.id,
141 tags: element.tags,
142 geometry: element.geometry
143 ? element.geometry.map((pt) => ({ lat: pt.lat, lng: pt.lon }))
144 : undefined,
145 }));
146 setBuildings(blds);
147 appendAreas(blds);
148 setHasFetchedBuildings(true);
149 } catch (error) {
150 console.error("Error fetching building data:", error);
151 } finally {
152 setIsFetchingBuildings(false);
153 }
154 };
155
156 const handleClickNextStep = async () => {
157 if (step == 0 && checkIsBig()) {

Callers 1

handleClickNextStepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected