Hello,
I was wondering about the reason why null properties are returned in GeoJSON and not in the default GML response.
In my case the difference in payload are significant.
Also, if there is a very good reason for this, would it be possible to add a new format option (much like the callback option) that disables the generation of null properties in the response?
The code I’m looking at is in org.geoserver.wfs.response.GeoJSONOutputFormat at row 195-198.
I’m grateful for any clarifying answer.
Regards,
Olle Markljung
On Tue, Nov 22, 2011 at 2:39 PM, Olle Markljung
<olle.markljung@anonymised.com> wrote:
Hello,
I was wondering about the reason why null properties are returned in GeoJSON
and not in the default GML response.
In my case the difference in payload are significant.
Also, if there is a very good reason for this, would it be possible to add a
new format option (much like the callback option) that disables the
generation of null properties in the response?
The code I'm looking at is in org.geoserver.wfs.response.GeoJSONOutputFormat
at row 195-198.
The code was written a long time ago, so I'm not sure what the reasoning was.
I can think of at least one good reason to have all the null values
specified, which is
the ability to determine the structure by looking at the first
feature: geojson is schemaless,
With this approach looking at the first feature you at least get to
know what the
attributes are without having to parse all the json, which is important if you
are going to transform that json into something, like a shapefile or a database,
that has a fixed structure (however one does not get the data type...).
In any case, look at line 87-88, the code accesses the format_options parameter
to determine wheter a json callback is required, or not.
You can do the same and add a new format option allowing the writer to skip
the null values. Assuming you call the option "skipnulls" the wfs call
would then look like:
&request=GetFeature&typeName=whatever&format_options=skipnulls:true
Cheers
Andrea
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------
Thanks for the clarifying response.
I'll look into providing a solution for this then.
Regards,
Olle
Den 11/22/11 9:08 PM skrev Andrea Aime <andrea.aime@anonymised.com>:
On Tue, Nov 22, 2011 at 2:39 PM, Olle Markljung
<olle.markljung@anonymised.com> wrote:
Hello,
I was wondering about the reason why null properties are returned in
GeoJSON
and not in the default GML response.
In my case the difference in payload are significant.
Also, if there is a very good reason for this, would it be possible to
add a
new format option (much like the callback option) that disables the
generation of null properties in the response?
The code I'm looking at is in
org.geoserver.wfs.response.GeoJSONOutputFormat
at row 195-198.
The code was written a long time ago, so I'm not sure what the reasoning
was.
I can think of at least one good reason to have all the null values
specified, which is
the ability to determine the structure by looking at the first
feature: geojson is schemaless,
With this approach looking at the first feature you at least get to
know what the
attributes are without having to parse all the json, which is important
if you
are going to transform that json into something, like a shapefile or a
database,
that has a fixed structure (however one does not get the data type...).
In any case, look at line 87-88, the code accesses the format_options
parameter
to determine wheter a json callback is required, or not.
You can do the same and add a new format option allowing the writer to
skip
the null values. Assuming you call the option "skipnulls" the wfs call
would then look like:
&request=GetFeature&typeName=whatever&format_options=skipnulls:true
Cheers
Andrea
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------