-1

I have a geography column in database. This column holds the original polygon. Next to it I have another column that holds the simplified version of this polygon. The simplification has been done with geography.Reduce()(I use tolerance of 100) function that operates with Douglas-Peucker algorithm. When the client asks for this area I fetch it from database and do a quick convert into GeoJSON and serve it to my client.

If I query the original polygon it will take good 20 seconds before it is successfully retreived but it works. In the end only problem is the speed and that is why I introdouced the second column that holds the simplified polygon. Fetching this polygon from database happens in an instant but a curious thing happens on the client side.

enter image description here

As you can see multiple markers are shown on my map. None of them are clickable expect the top most(slightly south-west from Melbourne) but this one is actually a marker that I have added. Where do the other ones come from?

Another thing I noticed is the more I reduce simplicity the less of these fanthom markers shows. So if I serve the original polygon as GeoJSON all is fine. As soon as I start simplifying I get these fantom markers.

When I query for this simplified polygon I use geography::STAsText() function. After that I use NetTopologySuite to read this as WKT and create a NetSuiteTopology Geometry object. With this object I create a Feature and use GeoJsonWriter to create the actual GeoJSON.

var query = new SqlQuery("Location")
                .Select("LocationServicingAreaSimplified.STAsText()")
                .Where("LocationID", SqlOp.Equals, "@LocationID");
// This object query will be convertet to
// SELECT   LocationServicingAreaSimplified.STAsText() FROM Location WHERE LocationID = ?           

query.Parameters.Add("@LocationID", LocationID);
var simplifiedPolygon = await query.ExecuteScalarAsync<string>();

var wktReader = new WKTReader() { DefaultSRID = 4326 };
var geoJsonWriter = new GeoJsonWriter();

var feature = new Feature
{
    Geometry = wktReader.Read(simplifiedPolygon)
};

return geoJsonWriter.Write(feature);
Robert
  • 2,407
  • 1
  • 24
  • 35

1 Answers1

0

After an extensive research I have concluded that the proces of simplification will produce points when some polygons are oversimplified. google maps will represent the points as markers therefore, the greater the simplification the more points are produced the more markers are present.

I have found an article where it is described how to get rid of these points but haven't yet tested it.

Hope this helps some spatial noob(like me).

Robert
  • 2,407
  • 1
  • 24
  • 35