[Geoserver-devel] Complex features - Encoding XML attributes in GeoJSON

Dear all,

Currently, the complex features GeoJSON encoder [1] doesn’t encode XML (GML) attributes. For example, something like:

(…)

gsml:positionalAccuracy
gsml:CGI_NumericValue
<gsml:principalValue uom=“urn:ogc:def:uom:UCUM:m”>200.0</gsml:principalValue>
</gsml:CGI_NumericValue>
</gsml:positionalAccuracy>
(…)

Will be encoded like this in GeoJSON:

(…)

“properties”: {
“gsml:positionAccuracy”: {
“gsml:CGI_NumericValue”: {
“gsml:principalValue”: 100
}
}
}
(…)

As far as I know, there is no standard or specification that defines how the concept of complex features attributes (GML attributes) should be encoded, the GeoJSON specification is quite permissible:

*A Feature object has a member with the name "properties".* 
*The value of the properties member is an object (any JSON* 
*object or a JSON null value).*

My suggestion is to encode XML\GML attributes as an array of values, using the example above:

(…)

“properties”: {
“gsml:positionAccuracy”: {
“gsml:CGI_NumericValue”: {
“gsml:principalValue”: [
100.0,
{
“uom”: “urn:ogc:def:uom:UCUM:m”
}
]
}
}
}
(…)

So, simple values (like 100.0) represent the value of the node and objects (like {“uom”: “urn:ogc:def:uom:UCUM:m”}) represent the attributes of the node. This keeps the semantic and doesn’t add too much burden to the clients.

Any feedback \ comments on this are welcome :slight_smile:

Kind regards,

Nuno Oliveira

[1] https://github.com/geoserver/geoserver/blob/master/src/wfs/src/main/java/org/geoserver/wfs/json/ComplexGeoJsonWriter.java