I am running this query on overpass-turbo
[out:json][timeout:25];
rel(223133);
(
rel(r);
);
rel(1250951);
out geom;
and I have received this polygon.
but when I process this data my Image is like this :
I am using dot net core and this is my query
foreach (var m in geoElement.members)
{
if (m is { type: "way", role: "outer" })
{
foreach (var g in m.geometry)
{
Coordinate coordinate = new Coordinate(g.lon, g.lat);
coordinates.Add(coordinate);
}
}
}
var shell = new LinearRing(coordinates.ToArray());
var p = new Polygon(shell);
var serializer = GeoJsonSerializer.Create();
using var stringWriter = new StringWriter();
using var jsonWriter = new JsonTextWriter(stringWriter);
serializer.Serialize(jsonWriter, p);
var geoJson = stringWriter.ToString();
return geoJson;
First I added all geometries lat and lng into a coordinate list and finally, I make a polygon and at the end I make a GeoJson.
can someone guild me on what tips exist here?
I downloaded GeoJson file from Overpass and I checked with my made GeoJson.there is so different from points. I don't know why? how can I make GeoJson like an overpass downloaded file?
asked
30 Apr '23, 19:00
alt2020
11●3●3●5
accept rate:
0%
First off, this query will return the same data as yours:
I've used a couple of osmtogeojson converters & they all output as expected. Is GeoJsonSerializer an internal command?
(following on from the conversation elsewhere)
I think that you're assuming that your "foreach" will get you the OSM ways in the "correct" order (sequentially around the relation). This isn't guaranteed. There is probably some multipolygon code out there for your language; I'd be tempted to borrow from that :)
Did u get the correct answer? @DaveF
the output of query, first geometry is
"geometry": [ { "lat": 38.2591626, "lon": 33.1844776 },
but if u download Geojson the first coordinate is[ 33.0320818, 38.1524781 ],
. as you can see there is a difference here @DaveF