[OpenLayers-Dev] Empty geometries causing errors in IE

Cameron Shorter cameron.shorter at gmail.com
Tue Oct 30 01:34:35 EDT 2007


Roald de Wit wrote:
> On Fri, 2007-10-26 at 09:52 -0600, Tim Schaub wrote:
>   
>> I'm entirely in favor of this.  I don't think the renderer is the right 
>> place to bomb (or hey maybe even throw an exception!) on an empty geometry.
>>
>> I think it makes sense to have our format classes throw exceptions on 
>> empty geometries.  They could even have an option to allow empty 
>> geometry.  In any case, it should be up to the application designer to 
>> decide what to do with empty geometry.  As library developers, I don't 
>> think we should impose our beliefs about empty geometries on all others.
>>
>> Breaking in only one browser, and only when rendering, is a bit late and 
>> a bit inconsistent.
>>
>>
>>     
>>> See ticket #1111 for a simple 'fix'.
>>>       
>> See also http://trac.openlayers.org/ticket/968
>>
>> I'd like to see some tests for the renderers really.  I haven't looked 
>> closely at your patch, but it would be nice to make sure we don't slip 
>> once we decide to make a change (like make browser behavior consistent).
>>     
>
> That fix in the patch I mentioned is probably not the best solution
> (although it worked for us).
>
> A few places where I can imagine we could prevent the renderer from
> trying to render the empty geometry is:
>
> - Renderer/Elements.js: drawGeometryNode()
> - Renderer.js: drawFeature()
> - Format/*.js: parseGeometry()
>
> It would be nice if we can come up with a clean solution for this.
>
> Roald
>
>   

Chris has noted on IRC that he doesn't think VML.setNodeDimension() is 
the right place to catch this error and after digging around I agree.

The problem is that a point geometry is created which has an x,y point 
of (null, null). This eventually causes an exception in the VML renderer.

I propose we fix in Geometry/Point.initialize(x,y) where we should throw 
an exception if x or y is null.

Reason:
1. Exceptions are already raised by Format/KML.js if it needs to create 
a (null,null) point, so I believe we have a precedence for handling 
errors by raising exceptions.

2.  Our error was caused because Format/GML.js allows the creation of 
(null,null) points, probably from an empty <Point></Point> tag.

3. I don't expect to break any legacy code by forcing Geometry to have 
valid values because old code would have caused exceptions in VML.js as 
we discovered.

-- 
Cameron Shorter
Geospatial Systems Architect
Tel: +61 (0)2 8570 5050
Mob: +61 (0)419 142 254

Think Globally, Fix Locally
Commercial Support for Geospatial Open Source Software
http://www.lisasoft.com/LISAsoft/SupportedProducts.html




More information about the Dev mailing list