[OpenLayers-Trac] [OpenLayers] #1145: Format/GeoJSON does not parse features with null geometries
OpenLayers
trac at openlayers.org
Fri Jul 4 03:14:05 EDT 2008
#1145: Format/GeoJSON does not parse features with null geometries
-----------------------------+----------------------------------------------
Reporter: bartvde | Owner: tschaub
Type: bug | Status: new
Priority: minor | Milestone:
Component: Format.GeoJSON | Version: 2.5
Resolution: | Keywords:
State: |
-----------------------------+----------------------------------------------
Changes (by euzuro):
* state: =>
Old description:
> When there is no geometry, Geoserver outputs "geometry": null in the
> GeoJSON output. However OpenLayers cannot parse this and will end up with
> 0 features.
>
> An easy way to fix this is to add a null check for obj.geometry in
> parseFeature:
>
> if (obj.geometry) {
> try {
> geometry = this.parseGeometry(obj.geometry);
> } catch(err) {
> // deal with bad geometries
> throw err;
> }
> }
>
> But there can be more code which assumes that a geometry object exists
> (like the bounds code probably), so this needs to be discussed more.
New description:
When there is no geometry, Geoserver outputs "geometry": null in the
GeoJSON output. However OpenLayers cannot parse this and will end up with
0 features.
An easy way to fix this is to add a null check for obj.geometry in
parseFeature:
{{{
if (obj.geometry) {
try {
geometry = this.parseGeometry(obj.geometry);
} catch(err) {
// deal with bad geometries
throw err;
}
}
}}}
But there can be more code which assumes that a geometry object exists
(like the bounds code probably), so this needs to be discussed more.
--
Ticket URL: <http://trac.openlayers.org/ticket/1145#comment:2>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list