ThinkGeo.com    |     Documentation    |     Premium Support

Custom Styles

I am using several custom styles in my project primarily so that I can draw my own symbology.  I am using a custom PointStyle to render my point symbols; but, it is using either Canvas.DrawArea or Canvas.DrawLine depending on whether the symbol is a closed shape or not.  I also have a custom TextStyle to draw rotated text, and a custom line style to draw lines in specific widths and colors (by feature record not feature type or layer).  This is working fine most of the time.  I am also using almost unlimited zooming so that I can see details in my maps.  


I have noticed that when I am zoomed in very close, a point of a polygon symbol can fall outside the map window and the entire symbol disappears.  Any ideas of a cause or solution?


Although I am using four different styles, I am really running through the features on each layer in each style.  Performance is becoming a problem.  Would it help performance to merge the four style into one set of code so that I only loop through the features of each layer once per rendering? 


I should also mention that I am using a custom MsSql2008FeatureLayer.


Charles



Charles, 
  
   I hope I can help on this.  You have quite a custom setup. :-) 
  
 Well for the points disappearing the feature source returns record that are within the bounding box, it has no idea at that level what the point sytles look like, it doesn’t know they are big or small.  Having said that I think what you could do is to override the GetFeaturesForDrawing or the GetFeaturesByBoundignBox and inside of there just scale up the rectangle or add a bit on all sides and then pass it into the core.  This will make it get items a little bit outside of the original bounding box.  The other stuff that is really outside will not draw.  If you scale it up just a little bit then it shouldn’t hurt performance.  I would only do this on the point layers as it wont do much for lines or polygons unless you have them as really really thick lines.   
  
 NOTE: You know actually since you already have a custom layer you could just intercept the DrawCore there and make the rectangle bigger at that point as well maybe.  I don’t know if this would make the image returned stretched.  You may have to do it on the FeatureSource but since you have a custom layer anyway you can include any feature source you want. 
  
 Actually as I re-read your post you mention this happens with Polygons, that is really strange, can you send some screens shots of this?  I would expect points but not polygons as we determine if they are on the screen by their bounding box.  One issue could be we use single for our r-tree index and if you are zoomed in really low then maybe precision is becoming and issue. 
  
   I suggest for your four styles what you do is create a new style from scratch that has as parameters the four styles.  Then override the DrawCore in your new style and do the looping through all the features once and inside of the loop determine which of the four real styles you want to render with.  Then call the Draw on those styles but pass in a collection of just the one feature. Or you can do some variation of that.  You could also move the code for all four styles into the one and it might save a little bit more time.  Remember that a style can be a surrogate for another style and that you can chain the drawing calls. 
  
 I hope this gives you some ideas. 
  
 David