halestudio / hale

(Spatial) data harmonisation with hale»studio (formerly HUMBOLDT Alignment Editor)
143 stars 44 forks source link

[BUG]: When exporting a GeoJSON with ElementType BigDecimal, value is exported in quotation marks #1248

Open JohannaOtt opened 2 weeks ago

JohannaOtt commented 2 weeks ago

Describe the bug When exporting a GeoJSON file for a schema based on an xsd defining an element as BigDecimal, the values are exported with quotation marks.

To Reproduce Check the transformation provided in this forum thread.

Expected behavior There should be no quotation marks when exporting the data as GeoJSON.

Possible workaround: As a workaround it should be possible to use a schema that uses an actual geometry binding and let the writer encode it as geojson geometry. So defining geometry as a geometry field (using hale GeometryProperty class as binding, directly using JTS Geometry class might also work).

stempler commented 2 weeks ago

image (1)

Looking at the property definition in the screenshot I don't think the behavior is wrong for the schema definition. hale does not support multi-dimensional arrays or lists of lists as binding at the moment though.

The type is defined as list of BigDecimal but its values seem to be lists of lists of numbers. I would guess what happens is that the list can't be converted to BigDecimal so for writing to Json it resorts to the string representation as fallback.

The workaround with the explicit geometry binding that was mentioned only works in cases where the intent is to create a GeoJson geometry representation, which in the given example seems to be the case.

mgarbula commented 2 weeks ago

I was the one who raised the ticket. @stempler to understand what you meant - on the screen it can be seen coordinates (0..n) which means that coordinates is an array - is that correct? Then - that array contains lists of BigDecimal and - as you said - hale doesn't support multi-dimensional arrays. So the problem is in the multi-dimensionality of the array - right?

mgarbula commented 2 weeks ago

@JohannaOtt so how my xsd schema should look like if I wanted to use GeometryProperty class?

stempler commented 2 weeks ago

@mgarbula If you use an XML schema to define the schema, then you need to use GML types to have a geometry binding in hale.

Here is an example based on your project (zip contains project and exported Json): hale-1248.zip

In the exported Json you can see that MultiLineString is used as geometry type. Not sure if the data may have multiple line strings in the features, that this type is used is because the Shapefile reader creates this kind of geometry.