I solved it. As per Rossko suggestiong of creating holes in the
polygon while generating KML files. This answer is for anyone who is
still searching:
Check if polygons are overlapping if so get the overlapping polygons
geography or polygon data and while generating KML add them under
<innerBoundaryIs> of the container one. say for e.g Zipcode A overlaps
zipcode B then you can add zipcode B's geographic data into
<innerBoundaryIs> of Zipcode A.
To find out if two polygons intersect what I did was, I get the list
of zipcodes and its corresponding geography instance, loop through
each one and check if it overlaps:
say sourceZipcode = collection[0].zipcode, souceGeography=
collection[0].geography
for(int i=0;i<collection.count;i++)
{
if (!collection[j].Zipcode.Equals(sourceZipcode ) &&
collection[j].Geography.STDifference(souceGeography).STNumPoints() ==
0)
{
GeoData newData = new GeoData{ Zipcode = zipcode,
OverlappingZipcode = geoCollection[j].Zipcode, OverlappingGeography =
geoCollection[j].Geography };
//check if entry exists
if (!_overlappingPolygons.Exists(s => s.OverlappingZipcode ==
newData.OverlappingZipcode &&
s.OverlappingGeography.STEquals(newData.OverlappingGeography).IsTrue))
{
//there is a overlapping polygon add it to list.
_overlappingPolygons.Add(newData);
}
}
}
this way I have the overlappingpolygons for the zipcode under check
and add them to innerboundaryIs tag.