0

I am writing an app using Bing API Spatial Data services to take of list of zip codes and combine them into one region. I have it mostly working but it seems to have issues with inner rings. Instead of a) deeming the inner region too small and just squashing it or b) properly drawing the inner ring, it seems to want to connect them, picture example below:

enter image description here

That interrior polygon should have been just a "hole" in the region, but instead it tries to connect them.

I currently have 2 relevent methods. One that decrypts the API response for the zip code, translates it to SqlGeography and STUnion()s any additional rings. and a second parent method which STUnions the results of the first method to a master SqlGeography object that contains all zip codes together when its done for a region.

Let me know if you need any more information.

Hershizer33
  • 1,206
  • 2
  • 23
  • 46

1 Answers1

0

I suspect the issue is with how the hole is being created in the WPF map control since polygons in that control don't support holes by default. Instead the common practice for creating holes in a polygon in the WPF control is to draw a line connecting all rings. You would choose a point on the outer ring, draw a line to the first inner ring, draw the inner ring and then draw a line back to outer ring. For this to work the rings must be closed and the lines must backtrack over themselves. The polygon's stroke is then hidden and polylines are used to draw the outline.

Looking at your image it looks like the one inner ring is trying to do the above to create a second inner ring, but isn't back tracking to the first inner ring, but instead to the outer ring.

rbrundritt
  • 16,570
  • 2
  • 21
  • 46
  • Are there any commands I can run on the `SqlGeography` object to automatically get rid of inner rings? – Hershizer33 May 12 '16 at 20:55
  • There are a couple of options to do this. One option is here: http://gis.stackexchange.com/questions/17555/calculating-the-outer-boundary-of-several-geometry-objects-in-sql-server-2008 Another option is to create a function that creates a polygon from the exterior ring of a polygon. I'll look around to see if I have some code for that somewhere. – rbrundritt May 12 '16 at 21:16
  • Haven't had a chance to put together an SQL function to remove inner rings of polygons. However I have seen your technical support email. It looks like you are only retrieving the first polygon of each zip code rather than all the polygons. Set the 0 after the 'Postcode1' value in your URL to 1. This will return several polygons for each zip code which will help fill in some of the empty areas. – rbrundritt May 13 '16 at 17:16
  • Hah, small world. Interesting, I thought the inner rings were the enemy here, should I include them to make it easier to remove them? – Hershizer33 May 13 '16 at 17:39