ThinkGeo.com    |     Documentation    |     Premium Support

Suggestion: IsEmpty property

Is this the right place to make suggestions?


I wanted to roll up the bounding extent of several layers.    I instantiated a new RectangleShape object, and then unioned the extent of each layer into it.   That didn't work.   The newly created RectangleShape object still had an extent, even though I had never populated it.   In other applications, the geometry objects expose an "IsEmpty" property, so you know if you have an object that has been loaded.   Then, operations like union, intersect, etc, check that property and exclude the object from participation if it is empty.   This lets you instantiate an empty object, and when you union with a populated object, the union is just that of the populated object, rather than including the 0,0 point of the empty object.


I know your underlying NTS objects do support the IsEmpty method, from the OGIS Simple Feature Spec.


As I evaluate MapSuite, should I roll up these kinds of thoughts into a single document and e-mail, or should i capture the thought/impression here as they pop up?



Ted, 
  
   This is a great idea.  I will see what we can do with this.  It would be very helpful to have this empty type of method.  Of course we will need to check for it all over the place. :)  Luckily we can put a check in our concrete method so Core overrides never need to consider this as we can strip them out before it gets to you.  See how handy the Core pattern is! 
  
   To get you going for now I have some ideas.  There is an ExplandToInclude method on a rectangle shape that can be used for this purpose.  You take the first rectangle and call this method passing in the second and the first will expand to include the second.  There is also a static method I think to this effect on the RectangleShape as well.  We also have a helper method on ExtentHelper class that I think has a method like GetBoundingBoxesOfShapes which takes an IEnumerable of shapes and the result is a RectangleShape.  Let me know if these work for you or if I am not getting the API names right.  If so I can write you a few small sample snippets. 
  
 I would suggest you keep firing off your suggestions, they are great ones by the way and we really appreciate them. 
  
 David

I was able to make it work very quickly after discovering that a new RectangleShape was not really empty.   I just passed a null value for my target geometry into the layer iterator, and on the first layer with bounds, set the RectangleShape, and then all was well.   I didn’t mean to ask what the work around was… just comment on concept. 
  
 Thanks

Ted, 
  
 I’ve added your suggestion to our tracking system, maybe you can see the IsEmpty property in the next version. :-) As David said, keep firing off your great ideas, we are really appreciate it! 
  
 Thanks, 
  
 Ben