[OpenLayers-Users] Geojson input: why error on 3d points?

Christopher Schmidt crschmidt at metacarta.com
Fri May 1 09:22:19 EDT 2009


On Fri, May 01, 2009 at 09:49:42AM +0100, Peter Robins wrote:
> On Thursday 30 Apr 2009, Christopher Schmidt wrote:
> > On Thu, Apr 30, 2009 at 09:34:23AM +0100, Peter Robins wrote:
> > > On Wednesday 29 Apr 2009, Christopher Schmidt wrote:
> > > > On Wed, Apr 29, 2009 at 09:03:24AM +0100, Peter Robins wrote:
> > > > > I've been having a bizarre problem where the same data (from
> > > > > featureserver) has been displayed when in kml format, but not in
> > > > > geojson. Delving into the code, I find this is because geojson.read
> > > > > throws an error if there are more than 2 coords in a point. Why is
> > > > > this? 3d points are perfectly valid in geojson, and it seems
> > > > > illogical that the 2 formats should be handled differently.
> > > >
> > > > I believe, at the time, the logic was:
> > > >  * OpenLayers can't do 3d
> > > >  * If we read 3d, when we write it, we will write it wrong
> > > >  * It is better to error at read time than fail silently at write time.
> > > >
> > > > I'd be willing to change this behavior, but it was originally
> > > > implemented by tschaub, so I'd prefer his buy-in as well.
> > >
> > > should I open a ticket and submit a patch removing this check?
> >
> > Yes, please do. It lets us keep a record, either way.
> 
> http://trac.openlayers.org/ticket/2070
> It would be nice if this could be included in 2.8, as it doesn't affect 
> anything else, so doesn't need extensive testing.

Once an RC is released, only regressions from the previous release are
fixed. This means that this change will not be included in 2.8.

However, you can probably include the fix in a reasonably safe way in
your app by doing something like the following:

OpenLayers.Format.GeoJSON.prototype.parseCoords.point = function(array) {
    return new OpenLayers.Geometry.Point(array[0], array[1]);
}    

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list